Mercurial > libdvdnav.hg
annotate dvdnav.c @ 4:99bed5d6db2f src
Added reset patch from Kees Cook <kees@outflux.net>
author | richwareham |
---|---|
date | Tue, 02 Apr 2002 18:22:27 +0000 |
parents | 328eadb3f37e |
children | 5f319e02e333 |
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 <pthread.h> | |
29 #include <dvdnav.h> | |
30 #include "dvdnav_internal.h" | |
31 #include "read_cache.h" | |
32 | |
33 #include <dvdread/nav_read.h> | |
34 | |
35 #include <stdlib.h> | |
36 #include <stdio.h> | |
37 | |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
38 dvdnav_status_t dvdnav_clear(dvdnav_t * self) { |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
39 if (!self) { |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
40 printerr("Passed a NULL pointer"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
41 return S_ERR; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
42 } |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
43 /* clear everything except path, file, vm, mutex, readahead */ |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
44 |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
45 // path |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
46 if (self->file) DVDCloseFile(self->file); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
47 self->file = NULL; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
48 self->open_vtsN = -1; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
49 self->open_domain = -1; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
50 self->vobu_start=0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
51 self->vobu_length=0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
52 self->blockN=0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
53 self->next_vobu=0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
54 self->cell = NULL; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
55 self->jmp_blockN=0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
56 self->jmp_vobu_start=0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
57 self->seekto_block=0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
58 |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
59 memset(&self->pci,0,sizeof(self->pci)); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
60 memset(&self->dsi,0,sizeof(self->dsi)); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
61 |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
62 /* Set initial values of flags */ |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
63 self->expecting_nav_packet = 1; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
64 self->at_soc = 1; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
65 self->still_frame = -1; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
66 self->jumping = 0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
67 self->seeking = 0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
68 self->stop = 0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
69 self->highlight_changed = 0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
70 self->spu_clut_changed = 0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
71 self->spu_stream_changed = 0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
72 self->audio_stream_changed = 0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
73 self->started=0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
74 // self->use_read_ahead |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
75 |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
76 self->hli_state=0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
77 |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
78 self->cache_start_sector = -1; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
79 self->cache_block_count = 0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
80 self->cache_valid = 0; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
81 |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
82 return S_OK; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
83 } |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
84 |
0 | 85 dvdnav_status_t dvdnav_open(dvdnav_t** dest, char *path) { |
86 dvdnav_t *self; | |
87 | |
88 /* Create a new structure */ | |
89 (*dest) = NULL; | |
90 self = (dvdnav_t*)malloc(sizeof(dvdnav_t)); | |
91 if(!self) | |
92 return S_ERR; | |
93 memset(self, 0, (sizeof(dvdnav_t) ) ); /* Make sure self structure is clean */ | |
94 | |
95 pthread_mutex_init(&self->vm_lock, NULL); | |
96 /* Initialise the error string */ | |
97 printerr(""); | |
98 | |
99 /* Initialise the VM */ | |
100 self->vm = vm_new_vm(); | |
101 if(!self->vm) { | |
102 printerr("Error initialising the DVD VM"); | |
103 return S_ERR; | |
104 } | |
105 if(vm_reset(self->vm, path) == -1) { | |
106 printerr("Error starting the VM / opening the DVD device"); | |
107 return S_ERR; | |
108 } | |
109 | |
110 /* Set the path. FIXME: Is a deep copy 'right' */ | |
111 strncpy(self->path, path, MAX_PATH_LEN); | |
112 | |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
113 dvdnav_clear(self); |
0 | 114 |
115 /* Pre-open and close a file so that the CSS-keys are cached. */ | |
116 self->file = DVDOpenFile(vm_get_dvd_reader(self->vm), 0, DVD_READ_MENU_VOBS); | |
117 if (self->file) DVDCloseFile(self->file); | |
118 self->file = NULL; | |
119 | |
120 if(!self->started) { | |
121 /* Start the VM */ | |
122 vm_start(self->vm); | |
123 self->started = 1; | |
124 } | |
125 | |
126 (*dest) = self; | |
127 return S_OK; | |
128 } | |
129 | |
130 dvdnav_status_t dvdnav_close(dvdnav_t *self) { | |
131 if(!self) { | |
132 printerr("Passed a NULL pointer"); | |
133 return S_ERR; | |
134 } | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
135 fprintf(stderr,"dvdnav:close:called\n"); |
0 | 136 if (self->file) { |
137 DVDCloseFile(self->file); | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
138 fprintf(stderr,"dvdnav:close:file closing\n"); |
0 | 139 self->file = NULL; |
140 } | |
141 | |
142 /* Free the VM */ | |
143 if(self->vm) { | |
144 vm_free_vm(self->vm); | |
145 } | |
146 if (self->file) { | |
147 DVDCloseFile(self->file); | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
148 fprintf(stderr,"dvdnav:close2:file closing\n"); |
0 | 149 self->file = NULL; |
150 } | |
151 pthread_mutex_destroy(&self->vm_lock); | |
152 /* Finally free the entire structure */ | |
153 free(self); | |
154 | |
155 return S_OK; | |
156 } | |
157 | |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
158 dvdnav_status_t dvdnav_reset(dvdnav_t *self) { |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
159 dvdnav_status_t result; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
160 |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
161 printf("dvdnav:reset:called\n"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
162 if(!self) { |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
163 printerr("Passed a NULL pointer"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
164 return S_ERR; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
165 } |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
166 printf("getting lock\n"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
167 pthread_mutex_lock(&self->vm_lock); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
168 printf("reseting vm\n"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
169 if(vm_reset(self->vm, NULL) == -1) { |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
170 printerr("Error restarting the VM"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
171 pthread_mutex_unlock(&self->vm_lock); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
172 return S_ERR; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
173 } |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
174 printf("clearing dvdnav\n"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
175 result=dvdnav_clear(self); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
176 printf("starting vm\n"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
177 if(!self->started) { |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
178 /* Start the VM */ |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
179 vm_start(self->vm); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
180 self->started = 1; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
181 } |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
182 printf("unlocking\n"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
183 pthread_mutex_unlock(&self->vm_lock); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
184 return result; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
185 } |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
186 |
0 | 187 dvdnav_status_t dvdnav_path(dvdnav_t *self, char** path) { |
188 if(!self || !path || !(*path)) { | |
189 return S_ERR; | |
190 } | |
191 | |
192 /* FIXME: Is shallow copy 'right'? */ | |
193 (*path) = self->path; | |
194 | |
195 return S_OK; | |
196 } | |
197 | |
198 char* dvdnav_err_to_string(dvdnav_t *self) { | |
199 if(!self) { | |
200 /* Shold this be "passed a NULL pointer?" */ | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
201 return "Hey! You gave me a NULL pointer you naughty person!"; |
0 | 202 } |
203 | |
204 return self->err_str; | |
205 } | |
206 | |
207 /** | |
208 * Returns 1 if block contains NAV packet, 0 otherwise. | |
209 * Precesses said NAV packet if present. | |
210 * | |
211 * Most of the code in here is copied from xine's MPEG demuxer | |
212 * so any bugs which are found in that should be corrected here also. | |
213 */ | |
214 int dvdnav_check_packet(dvdnav_t *self, uint8_t *p) { | |
215 int bMpeg1=0; | |
216 uint32_t nHeaderLen; | |
217 uint32_t nPacketLen; | |
218 uint32_t nStreamID; | |
219 /* uint8_t *p_start=p; */ | |
220 | |
221 | |
222 if (p==NULL) { | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
223 fprintf(stderr,"Passed a NULL pointer.\n"); |
0 | 224 return 0; |
225 } | |
226 | |
227 /* dprint("Checking packet...\n"); */ | |
228 | |
229 if (p[3] == 0xBA) { /* program stream pack header */ | |
230 | |
231 int nStuffingBytes; | |
232 | |
233 /* xprintf (VERBOSE|DEMUX, "program stream pack header\n"); */ | |
234 | |
235 bMpeg1 = (p[4] & 0x40) == 0; | |
236 | |
237 if (bMpeg1) { | |
238 p += 12; | |
239 } else { /* mpeg2 */ | |
240 nStuffingBytes = p[0xD] & 0x07; | |
241 p += 14 + nStuffingBytes; | |
242 } | |
243 } | |
244 | |
245 | |
246 if (p[3] == 0xbb) { /* program stream system header */ | |
247 int nHeaderLen; | |
248 | |
249 nHeaderLen = (p[4] << 8) | p[5]; | |
250 p += 6 + nHeaderLen; | |
251 } | |
252 | |
253 /* we should now have a PES packet here */ | |
254 | |
255 if (p[0] || p[1] || (p[2] != 1)) { | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
256 fprintf(stderr,"demux error! %02x %02x %02x (should be 0x000001) \n",p[0],p[1],p[2]); |
0 | 257 return 0; |
258 } | |
259 | |
260 nPacketLen = p[4] << 8 | p[5]; | |
261 nStreamID = p[3]; | |
262 | |
263 nHeaderLen = 6; | |
264 p += nHeaderLen; | |
265 | |
266 if (nStreamID == 0xbf) { /* Private stream 2 */ | |
267 /* | |
268 * int i; | |
269 * printf("dvdnav:nav packet=%u\n",p-p_start-6); | |
270 * for(i=0;i<80;i++) { | |
271 * printf("%02x ",p[i-6]); | |
272 * } | |
273 * printf("\n"); | |
274 */ | |
275 if(p[0] == 0x00) { | |
276 #ifdef HAVE_DVDREAD9 | |
277 navRead_PCI(&(self->pci), p+1); | |
278 #else | |
279 navRead_PCI(&(self->pci), p+1, nPacketLen - 1); | |
280 #endif | |
281 } | |
282 | |
283 p += nPacketLen; | |
284 | |
285 /* We should now have a DSI packet. */ | |
286 if(p[6] == 0x01) { | |
287 int num=0, current=0; | |
288 | |
289 nPacketLen = p[4] << 8 | p[5]; | |
290 p += 6; | |
291 /* dprint("NAV DSI packet\n"); */ | |
292 #ifdef HAVE_DVDREAD9 | |
293 navRead_DSI(&(self->dsi), p+1); | |
294 #else | |
295 navRead_DSI(&(self->dsi), p+1, sizeof(dsi_t)); | |
296 #endif | |
297 | |
298 self->vobu_start = self->dsi.dsi_gi.nv_pck_lbn; | |
299 self->vobu_length = self->dsi.dsi_gi.vobu_ea; | |
300 | |
301 /** | |
302 * If we're not at the end of this cell, we can determine the next | |
303 * VOBU to display using the VOBU_SRI information section of the | |
304 * DSI. Using this value correctly follows the current angle, | |
305 * avoiding the doubled scenes in The Matrix, and makes our life | |
306 * really happy. | |
307 * | |
308 * Otherwise, we set our next address past the end of this cell to | |
309 * force the code above to go to the next cell in the program. | |
310 */ | |
311 if( self->dsi.vobu_sri.next_vobu != SRI_END_OF_CELL ) { | |
312 self->next_vobu = self->dsi.dsi_gi.nv_pck_lbn | |
313 + ( self->dsi.vobu_sri.next_vobu & 0x7fffffff ); | |
314 } else { | |
315 self->next_vobu = self->vobu_start + self->vobu_length; | |
316 } | |
317 | |
318 dvdnav_get_angle_info(self, ¤t, &num); | |
319 if(num == 1) { | |
320 /* This is to switch back to angle one when we | |
321 * finish */ | |
322 dvdnav_angle_change(self, 1); | |
323 } | |
324 | |
325 if(num != 0) { | |
326 uint32_t next = self->pci.nsml_agli.nsml_agl_dsta[current-1]; | |
327 | |
328 if(next != 0) { | |
329 int dir = 0; | |
330 if(next & 0x80000000) { | |
331 dir = -1; | |
332 next = next & 0x3fffffff; | |
333 } else { | |
334 dir = 1; | |
335 } | |
336 | |
337 if(next != 0) { | |
338 self->next_vobu = self->vobu_start + dir * next; | |
339 } | |
340 } else if( self->dsi.sml_agli.data[current-1].address != 0 ) { | |
341 next = self->dsi.sml_agli.data[current-1].address; | |
342 self->vobu_length = self->dsi.sml_pbi.ilvu_ea; | |
343 | |
344 if((next & 0x80000000) && (next != 0x7fffffff)) { | |
345 self->next_vobu = self->dsi.dsi_gi.nv_pck_lbn - (next & 0x7fffffff); | |
346 } else { | |
347 self->next_vobu = self->dsi.dsi_gi.nv_pck_lbn + next; | |
348 } | |
349 } | |
350 } | |
351 } | |
352 return 1; | |
353 } | |
354 | |
355 return 0; | |
356 } | |
357 | |
358 dvdnav_status_t dvdnav_get_next_block(dvdnav_t *self, unsigned char *buf, | |
359 int *event, int *len) { | |
360 dvd_state_t *state; | |
361 int result; | |
362 if(!self || !event || !len || !buf) { | |
363 printerr("Passed a NULL pointer"); | |
364 return S_ERR; | |
365 } | |
366 pthread_mutex_lock(&self->vm_lock); | |
367 | |
368 if(!self->started) { | |
369 /* Start the VM */ | |
370 vm_start(self->vm); | |
371 self->started = 1; | |
372 } | |
373 | |
374 state = &(self->vm->state); | |
375 (*event) = DVDNAV_NOP; | |
376 (*len) = 0; | |
377 | |
378 /* Check the STOP flag */ | |
379 if(self->stop) { | |
380 (*event) = DVDNAV_STOP; | |
381 pthread_mutex_unlock(&self->vm_lock); | |
382 return S_OK; | |
383 } | |
384 | |
385 if(self->spu_clut_changed) { | |
386 (*event) = DVDNAV_SPU_CLUT_CHANGE; | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
387 fprintf(stderr,"libdvdnav:SPU_CLUT_CHANGE\n"); |
0 | 388 (*len) = sizeof(dvdnav_still_event_t); |
389 memcpy(buf, &(state->pgc->palette), 16 * sizeof(uint32_t)); | |
390 self->spu_clut_changed = 0; | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
391 fprintf(stderr,"libdvdnav:SPU_CLUT_CHANGE returning S_OK\n"); |
0 | 392 pthread_mutex_unlock(&self->vm_lock); |
393 return S_OK; | |
394 } | |
395 | |
396 if(self->spu_stream_changed) { | |
397 dvdnav_stream_change_event_t stream_change; | |
398 (*event) = DVDNAV_SPU_STREAM_CHANGE; | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
399 fprintf(stderr,"libdvdnav:SPU_STREAM_CHANGE\n"); |
0 | 400 (*len) = sizeof(dvdnav_stream_change_event_t); |
401 stream_change.physical= vm_get_subp_active_stream( self->vm ); | |
402 memcpy(buf, &(stream_change), sizeof( dvdnav_stream_change_event_t)); | |
403 self->spu_stream_changed = 0; | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
404 fprintf(stderr,"libdvdnav:SPU_STREAM_CHANGE stream_id=%d returning S_OK\n",stream_change.physical); |
0 | 405 pthread_mutex_unlock(&self->vm_lock); |
406 return S_OK; | |
407 } | |
408 | |
409 if(self->audio_stream_changed) { | |
410 dvdnav_stream_change_event_t stream_change; | |
411 (*event) = DVDNAV_AUDIO_STREAM_CHANGE; | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
412 fprintf(stderr,"libdvdnav:AUDIO_STREAM_CHANGE\n"); |
0 | 413 (*len) = sizeof(dvdnav_stream_change_event_t); |
414 stream_change.physical= vm_get_audio_active_stream( self->vm ); | |
415 memcpy(buf, &(stream_change), sizeof( dvdnav_stream_change_event_t)); | |
416 self->audio_stream_changed = 0; | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
417 fprintf(stderr,"libdvdnav:AUDIO_STREAM_CHANGE stream_id=%d returning S_OK\n",stream_change.physical); |
0 | 418 pthread_mutex_unlock(&self->vm_lock); |
419 return S_OK; | |
420 } | |
421 | |
422 /* Check the HIGHLIGHT flag */ | |
423 if(self->highlight_changed) { | |
424 dvdnav_highlight_event_t hevent; | |
425 | |
426 /* Fill in highlight struct with appropriate values */ | |
427 if(self->hli_state != 0) { | |
428 hevent.display = 1; | |
429 | |
430 /* Copy current button bounding box. */ | |
431 hevent.sx = self->hli_bbox[0]; | |
432 hevent.sy = self->hli_bbox[1]; | |
433 hevent.ex = self->hli_bbox[2]; | |
434 hevent.ey = self->hli_bbox[3]; | |
435 | |
436 hevent.palette = self->hli_clut; | |
437 hevent.pts = self->hli_pts; | |
438 hevent.buttonN = self->hli_buttonN; | |
439 | |
440 } else { | |
441 hevent.display = 0; | |
442 } | |
443 | |
444 (*event) = DVDNAV_HIGHLIGHT; | |
445 memcpy(buf, &(hevent), sizeof(hevent)); | |
446 (*len) = sizeof(hevent); | |
447 | |
448 self->highlight_changed = 0; | |
449 | |
450 pthread_mutex_unlock(&self->vm_lock); | |
451 return S_OK; | |
452 } | |
453 | |
454 /* Check to see if we need to change the curently opened VOB */ | |
455 if((self->open_vtsN != state->vtsN) || | |
456 (self->open_domain != state->domain)) { | |
457 dvd_read_domain_t domain; | |
458 int vtsN; | |
459 dvdnav_vts_change_event_t vts_event; | |
460 | |
461 if(self->file) { | |
462 dvdnav_read_cache_clear(self); | |
463 DVDCloseFile(self->file); | |
464 self->file = NULL; | |
465 } | |
466 | |
467 vts_event.old_vtsN = self->open_vtsN; | |
468 vts_event.old_domain = self->open_domain; | |
469 | |
470 /* Use the current DOMAIN to find whether to open menu or title VOBs */ | |
471 switch(state->domain) { | |
472 case FP_DOMAIN: | |
473 case VMGM_DOMAIN: | |
474 domain = DVD_READ_MENU_VOBS; | |
475 vtsN = 0; | |
476 break; | |
477 case VTSM_DOMAIN: | |
478 domain = DVD_READ_MENU_VOBS; | |
479 vtsN = state->vtsN; | |
480 break; | |
481 case VTS_DOMAIN: | |
482 domain = DVD_READ_TITLE_VOBS; | |
483 vtsN = state->vtsN; | |
484 break; | |
485 default: | |
486 printerr("Unknown domain when changing VTS."); | |
487 pthread_mutex_unlock(&self->vm_lock); | |
488 return S_ERR; | |
489 } | |
490 | |
491 self->open_domain = state->domain; | |
492 self->open_vtsN = state->vtsN; | |
493 dvdnav_read_cache_clear(self); | |
494 self->file = DVDOpenFile(vm_get_dvd_reader(self->vm), vtsN, domain); | |
495 vts_event.new_vtsN = self->open_vtsN; | |
496 vts_event.new_domain = self->open_domain; | |
497 | |
498 /* If couldn't open the file for some reason, moan */ | |
499 if(self->file == NULL) { | |
500 printerrf("Error opening vtsN=%i, domain=%i.", vtsN, domain); | |
501 pthread_mutex_unlock(&self->vm_lock); | |
502 return S_ERR; | |
503 } | |
504 | |
505 /* File opened successfully so return a VTS change event */ | |
506 (*event) = DVDNAV_VTS_CHANGE; | |
507 memcpy(buf, &(vts_event), sizeof(vts_event)); | |
508 (*len) = sizeof(vts_event); | |
509 | |
510 /* On a VTS change, we want to disable any highlights which | |
511 * may have been shown (FIXME: is this valid?) */ | |
512 self->highlight_changed = 1; | |
513 self->spu_clut_changed = 1; | |
514 self->spu_stream_changed = 1; | |
515 self->audio_stream_changed = 1; | |
516 self->hli_state = 0; /* Hide */ | |
517 self->expecting_nav_packet = 1; | |
518 | |
519 pthread_mutex_unlock(&self->vm_lock); | |
520 return S_OK; | |
521 } | |
522 | |
523 /* Check the STILLFRAME flag */ | |
524 if(self->still_frame != -1) { | |
525 dvdnav_still_event_t still_event; | |
526 | |
527 still_event.length = self->still_frame; | |
528 | |
529 (*event) = DVDNAV_STILL_FRAME; | |
530 (*len) = sizeof(dvdnav_still_event_t); | |
531 memcpy(buf, &(still_event), sizeof(dvdnav_still_event_t)); | |
532 | |
533 pthread_mutex_unlock(&self->vm_lock); | |
534 return S_OK; | |
535 } | |
536 | |
537 if(self->at_soc) { | |
538 dvdnav_cell_change_event_t cell_event; | |
539 cell_playback_t *cell = &(state->pgc->cell_playback[state->cellN - 1]); | |
540 | |
541 cell_event.old_cell = self->cell; | |
542 self->vobu_start = cell->first_sector; | |
543 self->cell = cell; | |
544 cell_event.new_cell = self->cell; | |
545 | |
546 self->at_soc = 0; | |
547 | |
548 (*event) = DVDNAV_CELL_CHANGE; | |
549 (*len) = sizeof(dvdnav_cell_change_event_t); | |
550 memcpy(buf, &(cell_event), sizeof(dvdnav_cell_change_event_t)); | |
551 | |
552 pthread_mutex_unlock(&self->vm_lock); | |
553 return S_OK; | |
554 } | |
555 | |
556 if(self->expecting_nav_packet) { | |
557 dvdnav_nav_packet_event_t nav_event; | |
558 | |
559 /* Perform the jump if necessary (this is always a | |
560 * VOBU boundary). */ | |
561 | |
562 if(self->seeking) { | |
563 /* FIXME:Need to handle seeking outside current cell. */ | |
564 vobu_admap_t *admap = NULL; | |
565 | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
566 fprintf(stderr,"Seeking to target %u ...\n", |
0 | 567 self->seekto_block); |
568 | |
569 /* Search through the VOBU_ADMAP for the nearest VOBU | |
570 * to the target block */ | |
571 switch(state->domain) { | |
572 case FP_DOMAIN: | |
573 case VMGM_DOMAIN: | |
574 //ifo = vm_get_vmgi(); | |
575 //ifoRead_VOBU_ADMAP(ifo); | |
576 admap = self->vm->vmgi->menu_vobu_admap; | |
577 break; | |
578 case VTSM_DOMAIN: | |
579 //ifo = vm_get_vtsi(); | |
580 //ifoRead_VOBU_ADMAP(ifo); | |
581 admap = self->vm->vtsi->menu_vobu_admap; | |
582 break; | |
583 case VTS_DOMAIN: | |
584 //ifo = vm_get_vtsi(); | |
585 //ifoRead_TITLE_VOBU_ADMAP(ifo); | |
586 admap = self->vm->vtsi->vts_vobu_admap; | |
587 break; | |
588 default: | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
589 fprintf(stderr,"Error: Unknown domain for seeking seek.\n"); |
0 | 590 } |
591 | |
592 if(admap) { | |
593 uint32_t address = 0; | |
594 uint32_t vobu_start, next_vobu; | |
595 int found = 0; | |
596 | |
597 /* Search through ADMAP for best sector */ | |
598 vobu_start = 0x3fffffff; | |
599 | |
600 while((!found) && ((address<<2) < admap->last_byte)) { | |
601 next_vobu = admap->vobu_start_sectors[address]; | |
602 | |
603 /* printf("Found block %u\n", next_vobu); */ | |
604 | |
605 if(vobu_start <= self->seekto_block && | |
606 next_vobu > self->seekto_block) { | |
607 found = 1; | |
608 } else { | |
609 vobu_start = next_vobu; | |
610 } | |
611 | |
612 address ++; | |
613 } | |
614 if(found) { | |
615 self->vobu_start = vobu_start; | |
616 self->blockN = 0; | |
617 self->seeking = 0; | |
618 //self->at_soc = 1; | |
619 (*event) = DVDNAV_SEEK_DONE; | |
620 (*len) = 0; | |
621 pthread_mutex_unlock(&self->vm_lock); | |
622 return S_OK; | |
623 } else { | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
624 fprintf(stderr,"Could not locate block\n"); |
0 | 625 return -1; |
626 } | |
627 } | |
628 } | |
629 if(self->jumping) { | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
630 fprintf(stderr,"doing jumping\n"); |
0 | 631 self->vobu_start = self->jmp_vobu_start; |
632 self->blockN = self->jmp_blockN; | |
633 self->jumping = 0; | |
634 self->at_soc = 1; | |
635 } | |
636 | |
637 result = DVDReadBlocks(self->file, self->vobu_start + self->blockN, 1, buf); | |
638 | |
639 if(result <= 0) { | |
640 printerr("Error reading NAV packet."); | |
641 pthread_mutex_unlock(&self->vm_lock); | |
642 return S_ERR; | |
643 } | |
644 | |
645 if(dvdnav_check_packet(self, buf) == 0) { | |
646 printerr("Expected NAV packet but none found."); | |
647 pthread_mutex_unlock(&self->vm_lock); | |
648 return S_ERR; | |
649 } | |
650 | |
651 self->blockN++; | |
652 self->expecting_nav_packet = 0; | |
653 | |
654 dvdnav_pre_cache_blocks(self, self->vobu_start, self->vobu_length+1); | |
655 | |
656 /* Successfully got a NAV packet */ | |
657 nav_event.pci = &(self->pci); | |
658 nav_event.dsi = &(self->dsi); | |
659 | |
660 (*event) = DVDNAV_NAV_PACKET; | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
661 /* memcpy(buf, &(nav_event), sizeof(dvdnav_nav_packet_event_t)); |
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
662 (*len) = sizeof(dvdnav_nav_packet_event_t); */ |
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
663 (*len) = 2048; |
0 | 664 pthread_mutex_unlock(&self->vm_lock); |
665 return S_OK; | |
666 } | |
667 | |
668 /* If we've got here, it must just be a normal block. */ | |
669 if(!self->file) { | |
670 printerr("Attempting to read without opening file"); | |
671 pthread_mutex_unlock(&self->vm_lock); | |
672 return S_ERR; | |
673 } | |
674 | |
675 result = dvdnav_read_cache_block(self, self->vobu_start + self->blockN, 1, buf); | |
676 if(result <= 0) { | |
677 printerr("Error reading from DVD."); | |
678 pthread_mutex_unlock(&self->vm_lock); | |
679 return S_ERR; | |
680 } | |
681 self->blockN++; | |
682 (*len) = 2048; | |
683 (*event) = DVDNAV_BLOCK_OK; | |
684 | |
685 if(self->blockN > self->vobu_length) { | |
686 self->vobu_start = self->next_vobu; | |
687 self->blockN = 0; | |
688 self->expecting_nav_packet = 1; | |
689 | |
690 if(self->dsi.vobu_sri.next_vobu == SRI_END_OF_CELL) { | |
691 cell_playback_t *cell = &(state->pgc->cell_playback[state->cellN - 1]); | |
692 | |
693 if(cell->still_time != 0xff) { | |
694 vm_get_next_cell(self->vm); | |
695 } | |
696 | |
697 if(cell->still_time != 0) { | |
698 self->still_frame = cell->still_time; | |
699 } | |
700 | |
701 self->at_soc = 1; | |
702 } | |
703 } | |
704 | |
705 pthread_mutex_unlock(&self->vm_lock); | |
706 return S_OK; | |
707 } | |
708 | |
709 uint16_t dvdnav_audio_stream_to_lang(dvdnav_t *self, uint8_t stream) { | |
710 ifo_handle_t *vtsi; | |
711 dvd_state_t *state; | |
712 | |
713 if(!self) | |
714 return -1; | |
715 | |
716 pthread_mutex_lock(&self->vm_lock); | |
717 | |
718 vtsi = self->vm->vtsi; | |
719 state = &(self->vm->state); | |
720 | |
721 if((vtsi == NULL) || (state == NULL) || (state->domain != VTS_DOMAIN)) | |
722 goto __failed; | |
723 | |
724 if(stream >= vtsi->vtsi_mat->nr_of_vts_audio_streams) | |
725 goto __failed; | |
726 | |
727 if(vtsi->vtsi_mat->vts_audio_attr[stream].lang_type != 1) | |
728 goto __failed; | |
729 | |
730 pthread_mutex_unlock(&self->vm_lock); | |
731 return vtsi->vtsi_mat->vts_audio_attr[stream].lang_code; | |
732 | |
733 __failed: | |
734 pthread_mutex_unlock(&self->vm_lock); | |
735 return 0xffff; | |
736 } | |
737 | |
738 int8_t dvdnav_audio_logical_to_physical(dvdnav_t *self, uint8_t logical) { | |
739 audio_status_t *audio_status; | |
740 dvd_state_t *state; | |
741 int i = 0; | |
742 | |
743 if(!self) | |
744 return -1; | |
745 | |
746 pthread_mutex_lock(&self->vm_lock); | |
747 | |
748 state = &(self->vm->state); | |
749 | |
750 if((!state) || (!state->pgc) || (!state->pgc->audio_control)) | |
751 goto __failed; | |
752 | |
753 if(logical > 7) { | |
754 fprintf(stderr, "Invalid logical audio channel: %i\n", logical); | |
755 goto __failed; | |
756 } | |
757 | |
758 while (i < 8) { | |
759 audio_status = (audio_status_t*) &(state->pgc->audio_control[i]); | |
760 | |
761 if(!audio_status) | |
762 goto __failed; | |
763 | |
764 if(audio_status->available) | |
765 break; | |
766 | |
767 i++; | |
768 } | |
769 | |
770 if (i > 7) | |
771 goto __failed; | |
772 | |
773 if ((logical+i) > 7) | |
774 goto __failed; | |
775 | |
776 audio_status = (audio_status_t*) &(state->pgc->audio_control[logical+i]); | |
777 | |
778 if(!audio_status) | |
779 goto __failed; | |
780 | |
781 if(audio_status->available) { | |
782 /* Stream is available */ | |
783 pthread_mutex_unlock(&self->vm_lock); | |
784 return audio_status->stream_number; | |
785 } | |
786 | |
787 __failed: | |
788 pthread_mutex_unlock(&self->vm_lock); | |
789 return -1; | |
790 } | |
791 | |
792 int8_t dvdnav_audio_physical_to_logical(dvdnav_t *self, uint8_t physical) { | |
793 int8_t logical = -1; | |
794 int i = 0; | |
795 | |
796 if((!self) || (physical > 7)) | |
797 return -1; | |
798 | |
799 do { | |
800 if(dvdnav_audio_logical_to_physical(self, i) == physical) | |
801 logical = i; | |
802 | |
803 i++; | |
804 } while((i<8) && (logical == -1)); | |
805 | |
806 return logical; | |
807 } | |
808 | |
809 uint16_t dvdnav_spu_stream_to_lang(dvdnav_t *self, uint8_t stream) { | |
810 ifo_handle_t *vtsi; | |
811 dvd_state_t *state; | |
812 | |
813 if(!self) | |
814 return -1; | |
815 | |
816 pthread_mutex_lock(&self->vm_lock); | |
817 | |
818 vtsi = self->vm->vtsi; | |
819 state = &(self->vm->state); | |
820 | |
821 if((vtsi == NULL) || (state == NULL) || (state->domain != VTS_DOMAIN)) { | |
822 goto __failed; | |
823 } | |
824 | |
825 if(stream >= vtsi->vtsi_mat->nr_of_vts_subp_streams) { | |
826 goto __failed; | |
827 } | |
828 | |
829 if(vtsi->vtsi_mat->vts_subp_attr[stream].type != 1) { | |
830 goto __failed; | |
831 } | |
832 | |
833 pthread_mutex_unlock(&self->vm_lock); | |
834 return vtsi->vtsi_mat->vts_subp_attr[stream].lang_code; | |
835 | |
836 __failed: | |
837 pthread_mutex_unlock(&self->vm_lock); | |
838 return 0xffff; | |
839 } | |
840 | |
841 int8_t dvdnav_spu_logical_to_physical(dvdnav_t *self, uint8_t logical) { | |
842 spu_status_t *spu_status; | |
843 dvd_state_t *state; | |
844 ifo_handle_t *vtsi; | |
845 | |
846 if(!self) | |
847 return -1; | |
848 | |
849 pthread_mutex_lock(&self->vm_lock); | |
850 | |
851 vtsi = self->vm->vtsi; | |
852 state = &(self->vm->state); | |
853 | |
854 if((!state) || (!vtsi)) | |
855 goto __failed; | |
856 | |
857 if(logical > 31) { | |
858 fprintf(stderr, "Invalid logical spu channel: %i\n", logical); | |
859 goto __failed; | |
860 } | |
861 | |
862 spu_status = (spu_status_t*) &(state->pgc->subp_control[logical]); | |
863 | |
864 if(!spu_status) | |
865 goto __failed; | |
866 | |
867 if(spu_status->available) { | |
868 int8_t logical = -1; | |
869 video_attr_t *attr; | |
870 | |
871 attr = &(vtsi->vtsi_mat->vtsm_video_attr); | |
872 | |
873 if(!attr) | |
874 goto __failed; | |
875 | |
876 /* Stream is available */ | |
877 switch(attr->display_aspect_ratio) { | |
878 case 0: /* 4:3 */ | |
879 logical = spu_status->stream_number_4_3; | |
880 break; | |
881 case 3: /* 16:9 */ | |
882 logical = spu_status->stream_number_letterbox; | |
883 break; | |
884 } | |
885 pthread_mutex_unlock(&self->vm_lock); | |
886 return logical; | |
887 } | |
888 | |
889 __failed: | |
890 pthread_mutex_unlock(&self->vm_lock); | |
891 return -1; | |
892 } | |
893 | |
894 int8_t dvdnav_spu_physical_to_logical(dvdnav_t *self, uint8_t physical) { | |
895 int8_t logical = -1; | |
896 int i = 0; | |
897 | |
898 if(physical > 31) | |
899 return -1; | |
900 | |
901 do { | |
902 if(dvdnav_spu_logical_to_physical(self, i) == physical) | |
903 logical = i; | |
904 | |
905 i++; | |
906 } while((i<32) && (logical == -1)); | |
907 | |
908 return logical; | |
909 } | |
910 | |
911 /* Current domain (backend to dvdnav_is_domain_() funcs) */ | |
912 static int8_t _dvdnav_is_domain(dvdnav_t *self, domain_t domain) { | |
913 dvd_state_t *state; | |
914 | |
915 if((!self) || (!self->started) || (!self->vm)) | |
916 return -1; | |
917 | |
918 pthread_mutex_lock(&self->vm_lock); | |
919 state = &(self->vm->state); | |
920 pthread_mutex_unlock(&self->vm_lock); | |
921 | |
922 if(!state) | |
923 return -1; | |
924 | |
925 return (state->domain == domain) ? 1 : 0; | |
926 } | |
927 | |
928 /* First Play domain. (Menu) */ | |
929 int8_t dvdnav_is_domain_fp(dvdnav_t *self) { | |
930 return _dvdnav_is_domain(self, FP_DOMAIN); | |
931 } | |
932 /* Video management Menu domain. (Menu) */ | |
933 int8_t dvdnav_is_domain_vmgm(dvdnav_t *self) { | |
934 return _dvdnav_is_domain(self, VMGM_DOMAIN); | |
935 } | |
936 /* Video Title Menu domain (Menu) */ | |
937 int8_t dvdnav_is_domain_vtsm(dvdnav_t *self) { | |
938 return _dvdnav_is_domain(self, VTSM_DOMAIN); | |
939 } | |
940 /* Video Title domain (playing movie). */ | |
941 int8_t dvdnav_is_domain_vts(dvdnav_t *self) { | |
942 return _dvdnav_is_domain(self, VTS_DOMAIN); | |
943 } | |
944 | |
945 /* Generally delegate angle information handling to | |
946 * VM */ | |
947 dvdnav_status_t dvdnav_angle_change(dvdnav_t *self, int angle) { | |
948 int num, current; | |
949 | |
950 if(!self) { | |
951 return S_ERR; | |
952 } | |
953 | |
954 if(dvdnav_get_angle_info(self, ¤t, &num) != S_OK) { | |
955 printerr("Error getting angle info"); | |
956 return S_ERR; | |
957 } | |
958 | |
959 /* Set angle SPRM if valid */ | |
960 if((angle > 0) && (angle <= num)) { | |
961 self->vm->state.AGL_REG = angle; | |
962 } else { | |
963 printerr("Passed an invalid angle number"); | |
964 return S_ERR; | |
965 } | |
966 | |
967 return S_OK; | |
968 } | |
969 | |
970 dvdnav_status_t dvdnav_get_angle_info(dvdnav_t *self, int* current_angle, | |
971 int *number_of_angles) { | |
972 if(!self || !self->vm) { | |
973 return S_ERR; | |
974 } | |
975 | |
976 if(!current_angle || !number_of_angles) { | |
977 printerr("Passed a NULL pointer"); | |
978 return S_ERR; | |
979 } | |
980 | |
981 vm_get_angle_info(self->vm, number_of_angles, current_angle); | |
982 | |
983 return S_OK; | |
984 } | |
985 | |
986 | |
987 /* | |
988 * $Log$ | |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
989 * Revision 1.3 2002/04/02 18:22:27 richwareham |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
990 * Added reset patch from Kees Cook <kees@outflux.net> |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
991 * |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
992 * Revision 1.2 2002/04/01 18:56:28 richwareham |
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
993 * Added initial example programs directory and make sure all debug/error output goes to stderr. |
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
994 * |
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
995 * Revision 1.1.1.1 2002/03/12 19:45:57 richwareham |
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
996 * Initial import |
0 | 997 * |
998 * Revision 1.28 2002/02/02 23:26:20 richwareham | |
999 * Restored title selection | |
1000 * | |
1001 * Revision 1.27 2002/02/01 15:48:10 richwareham | |
1002 * Re-implemented angle selection and title/chapter display | |
1003 * | |
1004 * Revision 1.26 2002/01/31 16:53:49 richwareham | |
1005 * Big patch from Daniel Caujolle-Bert to (re)implement SPU/Audio language display | |
1006 * | |
1007 * Revision 1.25 2002/01/24 20:53:50 richwareham | |
1008 * Added option to _not_ use DVD read-ahead to options | |
1009 * | |
1010 * Revision 1.24 2002/01/20 15:54:59 jcdutton | |
1011 * Implement seeking. | |
1012 * It is still a bit buggy, but works sometimes. | |
1013 * I need to find out how to make the jump clean. | |
1014 * At the moment, some corruption of the mpeg2 stream occurs, | |
1015 * which causes libmpeg2 to crash. | |
1016 * | |
1017 * Revision 1.23 2002/01/18 00:23:52 jcdutton | |
1018 * Support Ejecting of DVD. | |
1019 * It will first un-mount the DVD, then eject it. | |
1020 * | |
1021 * Revision 1.22 2002/01/17 14:50:32 jcdutton | |
1022 * Fix corruption of stream during menu transitions. | |
1023 * Menu transitions are now clean. | |
1024 * | |
1025 * Revision 1.21 2002/01/15 00:37:03 jcdutton | |
1026 * Just a few cleanups, and a assert fix. (memset fixed it) | |
1027 * | |
1028 * Revision 1.20 2002/01/13 22:17:57 jcdutton | |
1029 * Change logging. | |
1030 * | |
1031 * | |
1032 */ |