annotate navigation.c @ 411:ce9b314b6e43 src

If there is no VMGI or PGCI return instead of try to get them If there is no menu there isn't much point in trying to jump to them.
author erik
date Fri, 30 Jul 2010 23:34:24 +0000
parents 9b8bfc56a7fe
children 264c5b900bfb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
388
90ca650854e0 Remove all trailing whitespace,
rathann
parents: 387
diff changeset
1 /*
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
2 * Copyright (C) 2000 Rich Wareham <richwareham@users.sourceforge.net>
388
90ca650854e0 Remove all trailing whitespace,
rathann
parents: 387
diff changeset
3 *
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
4 * This file is part of libdvdnav, a DVD navigation library.
388
90ca650854e0 Remove all trailing whitespace,
rathann
parents: 387
diff changeset
5 *
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
6 * libdvdnav is free software; you can redistribute it and/or modify
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
9 * (at your option) any later version.
388
90ca650854e0 Remove all trailing whitespace,
rathann
parents: 387
diff changeset
10 *
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
11 * libdvdnav is distributed in the hope that it will be useful,
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
14 * GNU General Public License for more details.
388
90ca650854e0 Remove all trailing whitespace,
rathann
parents: 387
diff changeset
15 *
389
d3c273ced49c Use consistent license headers everywhere: Fix wrong FSF address.
diego
parents: 388
diff changeset
16 * You should have received a copy of the GNU General Public License along
d3c273ced49c Use consistent license headers everywhere: Fix wrong FSF address.
diego
parents: 388
diff changeset
17 * with libdvdnav; if not, write to the Free Software Foundation, Inc.,
d3c273ced49c Use consistent license headers everywhere: Fix wrong FSF address.
diego
parents: 388
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
19 */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
20
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
21 #ifdef HAVE_CONFIG_H
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
22 #include "config.h"
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
23 #endif
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
24
278
ef3b33441db5 include inttypes.h wherever necessary
nicodvb
parents: 273
diff changeset
25 #include <inttypes.h>
294
2146ff691bcd include limits.h; it was included in the previous dvdnav_internal.h and without it players segfault
nicodvb
parents: 290
diff changeset
26 #include <limits.h>
288
ce4230602517 moved away from dvdnav_internal.h inclusion of various system headers
nicodvb
parents: 285
diff changeset
27 #include <string.h>
290
54b6a000f6da decoder.h needs inclusion of sys/time.h
nicodvb
parents: 288
diff changeset
28 #include <sys/time.h>
395
9c5aef10d165 Move dvd_types.h, dvdnav_events.h and dvdnav.h into a dvdnav directory.
reimar
parents: 392
diff changeset
29 #include "dvdnav/dvdnav.h"
386
579a3538d284 Sync with current libdvdread header location.
rathann
parents: 378
diff changeset
30 #include <dvdread/nav_types.h>
579a3538d284 Sync with current libdvdread header location.
rathann
parents: 378
diff changeset
31 #include <dvdread/ifo_types.h>
285
52877d182e96 moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents: 278
diff changeset
32 #include "remap.h"
52877d182e96 moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents: 278
diff changeset
33 #include "vm/decoder.h"
52877d182e96 moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents: 278
diff changeset
34 #include "vm/vm.h"
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
35 #include "dvdnav_internal.h"
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
36
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
37 /* Navigation API calls */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
38
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 5
diff changeset
39 dvdnav_status_t dvdnav_still_skip(dvdnav_t *this) {
387
4e28052eb201 A variable assignment is missing a lock around it.
rathann
parents: 386
diff changeset
40 pthread_mutex_lock(&this->vm_lock);
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 5
diff changeset
41 this->position_current.still = 0;
387
4e28052eb201 A variable assignment is missing a lock around it.
rathann
parents: 386
diff changeset
42 pthread_mutex_unlock(&this->vm_lock);
23
c2d40c38e12f Name stills work better.
jcdutton
parents: 22
diff changeset
43 this->skip_still = 1;
116
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 114
diff changeset
44 this->sync_wait = 0;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 114
diff changeset
45 this->sync_wait_skip = 1;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 114
diff changeset
46
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
47 return DVDNAV_STATUS_OK;
116
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 114
diff changeset
48 }
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 114
diff changeset
49
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 114
diff changeset
50 dvdnav_status_t dvdnav_wait_skip(dvdnav_t *this) {
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 114
diff changeset
51 this->sync_wait = 0;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 114
diff changeset
52 this->sync_wait_skip = 1;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
53
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
54 return DVDNAV_STATUS_OK;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
55 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
56
195
6b1bfe8f5283 Start some cleanups.
jcdutton
parents: 193
diff changeset
57 dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int32_t *titles) {
248
5124cfd4725d fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents: 223
diff changeset
58 if (!this->vm->vmgi) {
5124cfd4725d fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents: 223
diff changeset
59 printerr("Bad VM state.");
223
2d79ef3f3956 we should not start the VM on dvdnav_get_number_of_titles,
mroi
parents: 195
diff changeset
60 return DVDNAV_STATUS_ERR;
94
e29110f67f3a Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents: 90
diff changeset
61 }
e29110f67f3a Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents: 90
diff changeset
62
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 5
diff changeset
63 (*titles) = vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
64
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
65 return DVDNAV_STATUS_OK;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
66 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
67
195
6b1bfe8f5283 Start some cleanups.
jcdutton
parents: 193
diff changeset
68 dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int32_t title, int32_t *parts) {
248
5124cfd4725d fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents: 223
diff changeset
69 if (!this->vm->vmgi) {
5124cfd4725d fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents: 223
diff changeset
70 printerr("Bad VM state.");
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
71 return DVDNAV_STATUS_ERR;
95
e7ebabe059b9 Start to get dvd mrl working in xine.
jcdutton
parents: 94
diff changeset
72 }
e7ebabe059b9 Start to get dvd mrl working in xine.
jcdutton
parents: 94
diff changeset
73 if ((title < 1) || (title > vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts) ) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
74 printerr("Passed a title number out of range.");
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
75 return DVDNAV_STATUS_ERR;
95
e7ebabe059b9 Start to get dvd mrl working in xine.
jcdutton
parents: 94
diff changeset
76 }
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
77
95
e7ebabe059b9 Start to get dvd mrl working in xine.
jcdutton
parents: 94
diff changeset
78 (*parts) = vm_get_vmgi(this->vm)->tt_srpt->title[title-1].nr_of_ptts;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
79
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
80 return DVDNAV_STATUS_OK;
5
c1b55dc1bfed Add API call to get number of programmes in current title.
richwareham
parents: 0
diff changeset
81 }
c1b55dc1bfed Add API call to get number of programmes in current title.
richwareham
parents: 0
diff changeset
82
195
6b1bfe8f5283 Start some cleanups.
jcdutton
parents: 193
diff changeset
83 dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int32_t *title, int32_t *part) {
6b1bfe8f5283 Start some cleanups.
jcdutton
parents: 193
diff changeset
84 int32_t retval;
388
90ca650854e0 Remove all trailing whitespace,
rathann
parents: 387
diff changeset
85
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
86 pthread_mutex_lock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
87 if (!this->vm->vtsi || !this->vm->vmgi) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
88 printerr("Bad VM state.");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
89 pthread_mutex_unlock(&this->vm_lock);
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
90 return DVDNAV_STATUS_ERR;
90
eeabf5a51b2b Improve chapter selection functions.
jcdutton
parents: 26
diff changeset
91 }
248
5124cfd4725d fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents: 223
diff changeset
92 if (!this->started) {
5124cfd4725d fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents: 223
diff changeset
93 printerr("Virtual DVD machine not started.");
5124cfd4725d fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents: 223
diff changeset
94 pthread_mutex_unlock(&this->vm_lock);
5124cfd4725d fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents: 223
diff changeset
95 return DVDNAV_STATUS_ERR;
5124cfd4725d fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents: 223
diff changeset
96 }
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
97 if (!this->vm->state.pgc) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
98 printerr("No current PGC.");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
99 pthread_mutex_unlock(&this->vm_lock);
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
100 return DVDNAV_STATUS_ERR;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
101 }
158
66a615581b3f Tidy up a bit.
jcdutton
parents: 157
diff changeset
102 if ( (this->vm->state.domain == VTSM_DOMAIN)
66a615581b3f Tidy up a bit.
jcdutton
parents: 157
diff changeset
103 || (this->vm->state.domain == VMGM_DOMAIN) ) {
66a615581b3f Tidy up a bit.
jcdutton
parents: 157
diff changeset
104 /* Get current Menu ID: into *part. */
344
fb2fbd4cfbf6 in get_PGCIT() check the validity of vm->vtsi before risking to dereference NULL;
nicodvb
parents: 332
diff changeset
105 if(! vm_get_current_menu(this->vm, part)) {
fb2fbd4cfbf6 in get_PGCIT() check the validity of vm->vtsi before risking to dereference NULL;
nicodvb
parents: 332
diff changeset
106 pthread_mutex_unlock(&this->vm_lock);
fb2fbd4cfbf6 in get_PGCIT() check the validity of vm->vtsi before risking to dereference NULL;
nicodvb
parents: 332
diff changeset
107 return DVDNAV_STATUS_ERR;
fb2fbd4cfbf6 in get_PGCIT() check the validity of vm->vtsi before risking to dereference NULL;
nicodvb
parents: 332
diff changeset
108 }
159
25b0c4f881c3 Fix Menu type display.
jcdutton
parents: 158
diff changeset
109 if (*part > -1) {
25b0c4f881c3 Fix Menu type display.
jcdutton
parents: 158
diff changeset
110 *title = 0;
157
7094c8661c05 Return details about menu number in dvdnav_current_title_info()
jcdutton
parents: 146
diff changeset
111 pthread_mutex_unlock(&this->vm_lock);
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
112 return DVDNAV_STATUS_OK;
157
7094c8661c05 Return details about menu number in dvdnav_current_title_info()
jcdutton
parents: 146
diff changeset
113 }
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
114 }
158
66a615581b3f Tidy up a bit.
jcdutton
parents: 157
diff changeset
115 if (this->vm->state.domain == VTS_DOMAIN) {
66a615581b3f Tidy up a bit.
jcdutton
parents: 157
diff changeset
116 retval = vm_get_current_title_part(this->vm, title, part);
66a615581b3f Tidy up a bit.
jcdutton
parents: 157
diff changeset
117 pthread_mutex_unlock(&this->vm_lock);
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
118 return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR;
158
66a615581b3f Tidy up a bit.
jcdutton
parents: 157
diff changeset
119 }
66a615581b3f Tidy up a bit.
jcdutton
parents: 157
diff changeset
120 printerr("Not in a title or menu.");
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
121 pthread_mutex_unlock(&this->vm_lock);
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
122 return DVDNAV_STATUS_ERR;
90
eeabf5a51b2b Improve chapter selection functions.
jcdutton
parents: 26
diff changeset
123 }
eeabf5a51b2b Improve chapter selection functions.
jcdutton
parents: 26
diff changeset
124
409
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
125 dvdnav_status_t dvdnav_current_title_program(dvdnav_t *this, int32_t *title, int32_t *pgcn, int32_t *pgn) {
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
126 int32_t retval;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
127 int32_t part;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
128
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
129 pthread_mutex_lock(&this->vm_lock);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
130 if (!this->vm->vtsi || !this->vm->vmgi) {
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
131 printerr("Bad VM state.");
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
132 pthread_mutex_unlock(&this->vm_lock);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
133 return DVDNAV_STATUS_ERR;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
134 }
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
135 if (!this->started) {
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
136 printerr("Virtual DVD machine not started.");
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
137 pthread_mutex_unlock(&this->vm_lock);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
138 return DVDNAV_STATUS_ERR;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
139 }
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
140 if (!this->vm->state.pgc) {
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
141 printerr("No current PGC.");
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
142 pthread_mutex_unlock(&this->vm_lock);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
143 return DVDNAV_STATUS_ERR;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
144 }
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
145 if ( (this->vm->state.domain == VTSM_DOMAIN)
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
146 || (this->vm->state.domain == VMGM_DOMAIN) ) {
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
147 /* Get current Menu ID: into *part. */
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
148 if(! vm_get_current_menu(this->vm, &part)) {
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
149 pthread_mutex_unlock(&this->vm_lock);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
150 return DVDNAV_STATUS_ERR;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
151 }
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
152 if (part > -1) {
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
153 *title = 0;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
154 *pgcn = this->vm->state.pgcN;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
155 *pgn = this->vm->state.pgN;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
156 pthread_mutex_unlock(&this->vm_lock);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
157 return DVDNAV_STATUS_OK;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
158 }
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
159 }
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
160 if (this->vm->state.domain == VTS_DOMAIN) {
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
161 retval = vm_get_current_title_part(this->vm, title, &part);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
162 *pgcn = this->vm->state.pgcN;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
163 *pgn = this->vm->state.pgN;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
164 pthread_mutex_unlock(&this->vm_lock);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
165 return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
166 }
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
167 printerr("Not in a title or menu.");
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
168 pthread_mutex_unlock(&this->vm_lock);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
169 return DVDNAV_STATUS_ERR;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
170 }
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
171
195
6b1bfe8f5283 Start some cleanups.
jcdutton
parents: 193
diff changeset
172 dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int32_t title) {
90
eeabf5a51b2b Improve chapter selection functions.
jcdutton
parents: 26
diff changeset
173 return dvdnav_part_play(this, title, 1);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
174 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
175
409
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
176 dvdnav_status_t dvdnav_program_play(dvdnav_t *this, int32_t title, int32_t pgcn, int32_t pgn) {
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
177 int32_t retval;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
178
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
179 pthread_mutex_lock(&this->vm_lock);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
180 if (!this->vm->vmgi) {
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
181 printerr("Bad VM state.");
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
182 pthread_mutex_unlock(&this->vm_lock);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
183 return DVDNAV_STATUS_ERR;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
184 }
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
185 if (!this->started) {
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
186 /* don't report an error but be nice */
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
187 vm_start(this->vm);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
188 this->started = 1;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
189 }
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
190 if (!this->vm->state.pgc) {
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
191 printerr("No current PGC.");
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
192 pthread_mutex_unlock(&this->vm_lock);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
193 return DVDNAV_STATUS_ERR;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
194 }
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
195 if((title < 1) || (title > this->vm->vmgi->tt_srpt->nr_of_srpts)) {
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
196 printerr("Title out of range.");
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
197 pthread_mutex_unlock(&this->vm_lock);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
198 return DVDNAV_STATUS_ERR;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
199 }
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
200
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
201 retval = vm_jump_title_program(this->vm, title, pgcn, pgn);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
202 if (retval)
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
203 this->vm->hop_channel++;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
204 pthread_mutex_unlock(&this->vm_lock);
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
205
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
206 return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR;
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
207 }
9b8bfc56a7fe Add dvdnav_program_play & dvdnav_current_title_program
erik
parents: 395
diff changeset
208
195
6b1bfe8f5283 Start some cleanups.
jcdutton
parents: 193
diff changeset
209 dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int32_t title, int32_t part) {
6b1bfe8f5283 Start some cleanups.
jcdutton
parents: 193
diff changeset
210 int32_t retval;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
211
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
212 pthread_mutex_lock(&this->vm_lock);
137
15e239caef8f title/part jumping does not need a valid vtsi
mroi
parents: 136
diff changeset
213 if (!this->vm->vmgi) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
214 printerr("Bad VM state.");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
215 pthread_mutex_unlock(&this->vm_lock);
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
216 return DVDNAV_STATUS_ERR;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
217 }
248
5124cfd4725d fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents: 223
diff changeset
218 if (!this->started) {
5124cfd4725d fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents: 223
diff changeset
219 /* don't report an error but be nice */
5124cfd4725d fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents: 223
diff changeset
220 vm_start(this->vm);
5124cfd4725d fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents: 223
diff changeset
221 this->started = 1;
5124cfd4725d fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents: 223
diff changeset
222 }
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
223 if (!this->vm->state.pgc) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
224 printerr("No current PGC.");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
225 pthread_mutex_unlock(&this->vm_lock);
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
226 return DVDNAV_STATUS_ERR;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
227 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
228 if((title < 1) || (title > this->vm->vmgi->tt_srpt->nr_of_srpts)) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
229 printerr("Title out of range.");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
230 pthread_mutex_unlock(&this->vm_lock);
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
231 return DVDNAV_STATUS_ERR;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
232 }
140
33d6bb570dcb one additional sanity check on the part number
mroi
parents: 137
diff changeset
233 if((part < 1) || (part > this->vm->vmgi->tt_srpt->title[title-1].nr_of_ptts)) {
33d6bb570dcb one additional sanity check on the part number
mroi
parents: 137
diff changeset
234 printerr("Part out of range.");
33d6bb570dcb one additional sanity check on the part number
mroi
parents: 137
diff changeset
235 pthread_mutex_unlock(&this->vm_lock);
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
236 return DVDNAV_STATUS_ERR;
140
33d6bb570dcb one additional sanity check on the part number
mroi
parents: 137
diff changeset
237 }
33d6bb570dcb one additional sanity check on the part number
mroi
parents: 137
diff changeset
238
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
239 retval = vm_jump_title_part(this->vm, title, part);
133
d09a81cf65ce determine correct PG and PTT numbers when seeking across PG boundaries
mroi
parents: 116
diff changeset
240 if (retval)
d09a81cf65ce determine correct PG and PTT numbers when seeking across PG boundaries
mroi
parents: 116
diff changeset
241 this->vm->hop_channel++;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
242 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
243
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
244 return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
245 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
246
195
6b1bfe8f5283 Start some cleanups.
jcdutton
parents: 193
diff changeset
247 dvdnav_status_t dvdnav_part_play_auto_stop(dvdnav_t *this, int32_t title,
6b1bfe8f5283 Start some cleanups.
jcdutton
parents: 193
diff changeset
248 int32_t part, int32_t parts_to_play) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
249 /* FIXME: Implement auto-stop */
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
250 if (dvdnav_part_play(this, title, part) == DVDNAV_STATUS_OK)
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
251 printerr("Not implemented yet.");
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
252 return DVDNAV_STATUS_ERR;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
253 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
254
195
6b1bfe8f5283 Start some cleanups.
jcdutton
parents: 193
diff changeset
255 dvdnav_status_t dvdnav_time_play(dvdnav_t *this, int32_t title,
6b1bfe8f5283 Start some cleanups.
jcdutton
parents: 193
diff changeset
256 uint64_t time) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
257 /* FIXME: Implement */
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
258 printerr("Not implemented yet.");
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
259 return DVDNAV_STATUS_ERR;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
260 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
261
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 5
diff changeset
262 dvdnav_status_t dvdnav_stop(dvdnav_t *this) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
263 pthread_mutex_lock(&this->vm_lock);
146
7f242ec838fd do not stop the VM here, get_next_block will do that without races
mroi
parents: 140
diff changeset
264 this->vm->stopped = 1;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
265 pthread_mutex_unlock(&this->vm_lock);
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
266 return DVDNAV_STATUS_OK;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
267 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
268
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 5
diff changeset
269 dvdnav_status_t dvdnav_go_up(dvdnav_t *this) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
270 /* A nice easy function... delegate to the VM */
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
271 pthread_mutex_lock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
272 vm_jump_up(this->vm);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 95
diff changeset
273 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
274
193
b80dff4bef76 Remove all references to S_OK and S_ERR.
jcdutton
parents: 159
diff changeset
275 return DVDNAV_STATUS_OK;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
276 }