Mercurial > libdvdnav.hg
annotate navigation.c @ 157:7094c8661c05 src
Return details about menu number in dvdnav_current_title_info()
If title = 0, we are in menu, and part gives us what menu number.
If title > 0, we are in a title.
author | jcdutton |
---|---|
date | Sun, 06 Apr 2003 10:59:28 +0000 |
parents | 7f242ec838fd |
children | 66a615581b3f |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright (C) 2000 Rich Wareham <richwareham@users.sourceforge.net> | |
3 * | |
4 * This file is part of libdvdnav, a DVD navigation library. | |
5 * | |
6 * libdvdnav is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * libdvdnav is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
19 * | |
20 * $Id$ | |
21 * | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include "config.h" | |
26 #endif | |
27 | |
28 #include "dvdnav_internal.h" | |
29 | |
30 /* Navigation API calls */ | |
31 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
32 dvdnav_status_t dvdnav_still_skip(dvdnav_t *this) { |
114 | 33 if(!this) { |
34 printerr("Passed a NULL pointer."); | |
35 return S_ERR; | |
36 } | |
0 | 37 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
38 this->position_current.still = 0; |
23 | 39 this->skip_still = 1; |
116 | 40 this->sync_wait = 0; |
41 this->sync_wait_skip = 1; | |
42 | |
43 return S_OK; | |
44 } | |
45 | |
46 dvdnav_status_t dvdnav_wait_skip(dvdnav_t *this) { | |
47 if(!this) { | |
48 printerr("Passed a NULL pointer."); | |
49 return S_ERR; | |
50 } | |
51 | |
52 this->sync_wait = 0; | |
53 this->sync_wait_skip = 1; | |
0 | 54 |
55 return S_OK; | |
56 } | |
57 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
58 dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int *titles) { |
114 | 59 if(!this || !titles) { |
60 printerr("Passed a NULL pointer."); | |
0 | 61 return S_ERR; |
62 } | |
63 | |
94
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
64 if(!this->started) { |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
65 /* Start the VM */ |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
66 vm_start(this->vm); |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
67 this->started = 1; |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
68 } |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
69 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
70 (*titles) = vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts; |
0 | 71 |
72 return S_OK; | |
73 } | |
74 | |
95 | 75 dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int title, int *parts) { |
114 | 76 if(!this || !parts) { |
77 printerr("Passed a NULL pointer."); | |
5
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
78 return S_ERR; |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
79 } |
95 | 80 if(!this->started) { |
81 printerr("Virtual DVD machine not started."); | |
82 return S_ERR; | |
83 } | |
84 if ((title < 1) || (title > vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts) ) { | |
114 | 85 printerr("Passed a title number out of range."); |
95 | 86 return S_ERR; |
87 } | |
114 | 88 |
95 | 89 (*parts) = vm_get_vmgi(this->vm)->tt_srpt->title[title-1].nr_of_ptts; |
114 | 90 |
5
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
91 return S_OK; |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
92 } |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
93 |
90 | 94 dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int *title, int *part) { |
114 | 95 int retval; |
96 | |
97 if(!this || !title || !part) { | |
98 printerr("Passed a NULL pointer."); | |
99 return S_ERR; | |
100 } | |
101 | |
102 pthread_mutex_lock(&this->vm_lock); | |
103 if (!this->vm->vtsi || !this->vm->vmgi) { | |
104 printerr("Bad VM state."); | |
105 pthread_mutex_unlock(&this->vm_lock); | |
90 | 106 return S_ERR; |
107 } | |
114 | 108 if (!this->vm->state.pgc) { |
109 printerr("No current PGC."); | |
110 pthread_mutex_unlock(&this->vm_lock); | |
111 return S_ERR; | |
112 } | |
113 if (this->vm->state.domain != VTS_DOMAIN) { | |
157
7094c8661c05
Return details about menu number in dvdnav_current_title_info()
jcdutton
parents:
146
diff
changeset
|
114 if ( (this->vm->state.domain == VTSM_DOMAIN) |
7094c8661c05
Return details about menu number in dvdnav_current_title_info()
jcdutton
parents:
146
diff
changeset
|
115 || (this->vm->state.domain == VMGM_DOMAIN) ) { |
7094c8661c05
Return details about menu number in dvdnav_current_title_info()
jcdutton
parents:
146
diff
changeset
|
116 /* Get current Menu ID: into *part. */ |
7094c8661c05
Return details about menu number in dvdnav_current_title_info()
jcdutton
parents:
146
diff
changeset
|
117 vm_get_current_menu(this->vm, part); |
7094c8661c05
Return details about menu number in dvdnav_current_title_info()
jcdutton
parents:
146
diff
changeset
|
118 pthread_mutex_unlock(&this->vm_lock); |
7094c8661c05
Return details about menu number in dvdnav_current_title_info()
jcdutton
parents:
146
diff
changeset
|
119 return S_OK; |
7094c8661c05
Return details about menu number in dvdnav_current_title_info()
jcdutton
parents:
146
diff
changeset
|
120 } |
114 | 121 printerr("Not in VTS domain."); |
122 pthread_mutex_unlock(&this->vm_lock); | |
123 return S_ERR; | |
124 } | |
125 retval = vm_get_current_title_part(this->vm, title, part); | |
126 pthread_mutex_unlock(&this->vm_lock); | |
127 | |
128 return retval ? S_OK : S_ERR; | |
90 | 129 } |
130 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
131 dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int title) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
132 if(!this) { |
114 | 133 printerr("Passed a NULL pointer."); |
0 | 134 return S_ERR; |
135 } | |
90 | 136 return dvdnav_part_play(this, title, 1); |
0 | 137 } |
138 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
139 dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int title, int part) { |
114 | 140 int retval; |
0 | 141 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
142 if(!this) { |
114 | 143 printerr("Passed a NULL pointer."); |
144 return S_ERR; | |
145 } | |
146 | |
147 pthread_mutex_lock(&this->vm_lock); | |
137 | 148 if (!this->vm->vmgi) { |
114 | 149 printerr("Bad VM state."); |
150 pthread_mutex_unlock(&this->vm_lock); | |
0 | 151 return S_ERR; |
152 } | |
114 | 153 if (!this->vm->state.pgc) { |
154 printerr("No current PGC."); | |
155 pthread_mutex_unlock(&this->vm_lock); | |
156 return S_ERR; | |
157 } | |
158 if((title < 1) || (title > this->vm->vmgi->tt_srpt->nr_of_srpts)) { | |
159 printerr("Title out of range."); | |
160 pthread_mutex_unlock(&this->vm_lock); | |
161 return S_ERR; | |
162 } | |
140 | 163 if((part < 1) || (part > this->vm->vmgi->tt_srpt->title[title-1].nr_of_ptts)) { |
164 printerr("Part out of range."); | |
165 pthread_mutex_unlock(&this->vm_lock); | |
166 return S_ERR; | |
167 } | |
168 | |
114 | 169 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
|
170 if (retval) |
d09a81cf65ce
determine correct PG and PTT numbers when seeking across PG boundaries
mroi
parents:
116
diff
changeset
|
171 this->vm->hop_channel++; |
114 | 172 pthread_mutex_unlock(&this->vm_lock); |
0 | 173 |
114 | 174 return retval ? S_OK : S_ERR; |
0 | 175 } |
176 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
177 dvdnav_status_t dvdnav_part_play_auto_stop(dvdnav_t *this, int title, |
114 | 178 int part, int parts_to_play) { |
179 /* FIXME: Implement auto-stop */ | |
180 if (dvdnav_part_play(this, title, part) == S_OK) | |
181 printerr("Not implemented yet."); | |
182 return S_ERR; | |
0 | 183 } |
184 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
185 dvdnav_status_t dvdnav_time_play(dvdnav_t *this, int title, |
114 | 186 unsigned long int time) { |
187 if(!this) { | |
188 printerr("Passed a NULL pointer."); | |
189 return S_ERR; | |
190 } | |
191 | |
0 | 192 /* FIXME: Implement */ |
114 | 193 printerr("Not implemented yet."); |
194 return S_ERR; | |
0 | 195 } |
196 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
197 dvdnav_status_t dvdnav_stop(dvdnav_t *this) { |
114 | 198 if(!this) { |
199 printerr("Passed a NULL pointer."); | |
200 return S_ERR; | |
201 } | |
0 | 202 |
114 | 203 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
|
204 this->vm->stopped = 1; |
114 | 205 pthread_mutex_unlock(&this->vm_lock); |
0 | 206 return S_OK; |
207 } | |
208 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
209 dvdnav_status_t dvdnav_go_up(dvdnav_t *this) { |
114 | 210 if(!this) { |
211 printerr("Passed a NULL pointer."); | |
212 return S_ERR; | |
213 } | |
0 | 214 |
215 /* A nice easy function... delegate to the VM */ | |
114 | 216 pthread_mutex_lock(&this->vm_lock); |
217 vm_jump_up(this->vm); | |
218 pthread_mutex_unlock(&this->vm_lock); | |
0 | 219 |
220 return S_OK; | |
221 } |