Mercurial > libdvdnav.hg
annotate searching.c @ 122:29b046894eac src
use the new VM copy mechanism to try-run program skipping and report failure in case
we end with a stopped VM
author | mroi |
---|---|
date | Wed, 12 Mar 2003 11:39:49 +0000 |
parents | bd8601b74c3d |
children | 87400040e4a4 |
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 | |
114 | 28 #include <assert.h> |
29 | |
0 | 30 #include "dvdnav_internal.h" |
31 | |
32 #include "vm.h" | |
33 | |
114 | 34 /* |
35 #define LOG_DEBUG | |
36 */ | |
37 | |
0 | 38 /* Searching API calls */ |
39 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
40 dvdnav_status_t dvdnav_time_search(dvdnav_t *this, |
0 | 41 unsigned long int time) { |
114 | 42 /* FIXME: Time search the current PGC based on the xxx table */ |
0 | 43 return S_OK; |
44 } | |
45 | |
24 | 46 /* Scan the ADMAP for a particular block number. */ |
47 /* Return placed in vobu. */ | |
48 /* Returns error status */ | |
114 | 49 /* FIXME: Maybe need to handle seeking outside current cell. */ |
50 static dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, int32_t seekto_block, int32_t *vobu) { | |
24 | 51 vobu_admap_t *admap = NULL; |
114 | 52 |
53 #ifdef LOG_DEBUG | |
54 fprintf(MSG_OUT, "libdvdnav: Seeking to target %u ...\n", seekto_block); | |
55 #endif | |
24 | 56 *vobu = -1; |
57 | |
58 /* Search through the VOBU_ADMAP for the nearest VOBU | |
59 * to the target block */ | |
60 switch(domain) { | |
114 | 61 case FP_DOMAIN: |
62 case VMGM_DOMAIN: | |
63 admap = this->vm->vmgi->menu_vobu_admap; | |
64 break; | |
65 case VTSM_DOMAIN: | |
66 admap = this->vm->vtsi->menu_vobu_admap; | |
67 break; | |
68 case VTS_DOMAIN: | |
69 admap = this->vm->vtsi->vts_vobu_admap; | |
70 break; | |
71 default: | |
72 fprintf(MSG_OUT, "libdvdnav: Error: Unknown domain for seeking.\n"); | |
24 | 73 } |
74 if(admap) { | |
75 int32_t address = 0; | |
76 int32_t vobu_start, next_vobu; | |
77 int found = 0; | |
78 | |
79 /* Search through ADMAP for best sector */ | |
80 vobu_start = 0x3fffffff; | |
81 /* FIXME: Implement a faster search algorithm */ | |
82 while((!found) && ((address<<2) < admap->last_byte)) { | |
83 next_vobu = admap->vobu_start_sectors[address]; | |
84 | |
76 | 85 /* fprintf(MSG_OUT, "libdvdnav: Found block %u\n", next_vobu); */ |
24 | 86 |
87 if(vobu_start <= seekto_block && | |
88 next_vobu > seekto_block) { | |
89 found = 1; | |
90 } else { | |
91 vobu_start = next_vobu; | |
92 } | |
93 address ++; | |
94 } | |
95 if(found) { | |
96 *vobu = vobu_start; | |
97 return S_OK; | |
98 } else { | |
76 | 99 fprintf(MSG_OUT, "libdvdnav: Could not locate block\n"); |
24 | 100 return S_ERR; |
101 } | |
102 } | |
76 | 103 fprintf(MSG_OUT, "libdvdnav: admap not located\n"); |
24 | 104 return S_ERR; |
105 } | |
106 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
107 dvdnav_status_t dvdnav_sector_search(dvdnav_t *this, |
114 | 108 unsigned long int offset, int origin) { |
0 | 109 uint32_t target = 0; |
110 uint32_t length = 0; | |
114 | 111 uint32_t first_cell_nr, last_cell_nr, cell_nr; |
0 | 112 int found; |
114 | 113 cell_playback_t *cell; |
0 | 114 dvd_state_t *state; |
115 dvdnav_status_t result; | |
116 | |
114 | 117 if(this->position_current.still != 0) { |
118 printerr("Cannot seek in a still frame."); | |
119 return S_ERR; | |
120 } | |
0 | 121 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
122 result = dvdnav_get_position(this, &target, &length); |
114 | 123 #ifdef LOG_DEBUG |
124 fprintf(MSG_OUT, "libdvdnav: seeking to offset=%lu pos=%u length=%u\n", offset, target, length); | |
125 fprintf(MSG_OUT, "libdvdnav: Before cellN=%u blockN=%u\n", state->cellN, state->blockN); | |
126 #endif | |
0 | 127 if(!result) { |
114 | 128 return S_ERR; |
0 | 129 } |
130 | |
114 | 131 pthread_mutex_lock(&this->vm_lock); |
132 state = &(this->vm->state); | |
133 if(!state->pgc) { | |
134 printerr("No current PGC."); | |
135 pthread_mutex_unlock(&this->vm_lock); | |
136 return S_ERR; | |
137 } | |
138 | |
0 | 139 switch(origin) { |
140 case SEEK_SET: | |
141 if(offset > length) { | |
114 | 142 printerr("Request to seek behind end."); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
143 pthread_mutex_unlock(&this->vm_lock); |
114 | 144 return S_ERR; |
0 | 145 } |
146 target = offset; | |
147 break; | |
148 case SEEK_CUR: | |
149 if(target + offset > length) { | |
114 | 150 printerr("Request to seek behind end."); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
151 pthread_mutex_unlock(&this->vm_lock); |
114 | 152 return S_ERR; |
0 | 153 } |
154 target += offset; | |
155 break; | |
156 case SEEK_END: | |
157 if(length - offset < 0) { | |
114 | 158 printerr("Request to seek before start."); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
159 pthread_mutex_unlock(&this->vm_lock); |
114 | 160 return S_ERR; |
0 | 161 } |
162 target = length - offset; | |
102
3e6970dbe8d6
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
mroi
parents:
90
diff
changeset
|
163 break; |
0 | 164 default: |
165 /* Error occured */ | |
114 | 166 printerr("Illegal seek mode."); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
167 pthread_mutex_unlock(&this->vm_lock); |
114 | 168 return S_ERR; |
0 | 169 } |
170 | |
171 /* First find closest cell number in program */ | |
172 first_cell_nr = state->pgc->program_map[state->pgN-1]; | |
173 if(state->pgN < state->pgc->nr_of_programs) { | |
174 last_cell_nr = state->pgc->program_map[state->pgN] - 1; | |
175 } else { | |
176 last_cell_nr = state->pgc->nr_of_cells; | |
177 } | |
178 | |
114 | 179 found = 0; |
180 target += state->pgc->cell_playback[first_cell_nr-1].first_sector; | |
0 | 181 for(cell_nr = first_cell_nr; (cell_nr <= last_cell_nr) && !found; cell_nr ++) { |
182 cell = &(state->pgc->cell_playback[cell_nr-1]); | |
183 if((cell->first_sector <= target) && (cell->last_sector >= target)) { | |
114 | 184 found = 1; |
0 | 185 state->cellN = cell_nr; |
186 state->blockN = 0; | |
114 | 187 state->cell_restart++; |
0 | 188 } |
189 } | |
190 | |
114 | 191 if(found) { |
26 | 192 int32_t vobu, start; |
114 | 193 #ifdef LOG_DEBUG |
76 | 194 fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n", |
114 | 195 state->cellN, first_cell_nr, last_cell_nr); |
196 #endif | |
197 dvdnav_scan_admap(this, state->domain, target, &vobu); | |
198 start = state->pgc->cell_playback[state->cellN - 1].first_sector; | |
199 #ifdef LOG_DEBUG | |
200 fprintf(MSG_OUT, "libdvdnav: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" , | |
0 | 201 state->cellN, |
24 | 202 state->blockN, |
203 target, | |
204 vobu, | |
205 start); | |
114 | 206 #endif |
207 state->blockN = vobu - start; | |
208 #ifdef LOG_DEBUG | |
209 fprintf(MSG_OUT, "libdvdnav: After vobu=%x start=%x blockN=%x\n" , | |
24 | 210 vobu, |
211 start, | |
0 | 212 state->blockN); |
114 | 213 #endif |
214 this->vm->hop_channel += HOP_SEEK; | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
215 pthread_mutex_unlock(&this->vm_lock); |
114 | 216 return S_OK; |
0 | 217 } |
114 | 218 |
219 fprintf(MSG_OUT, "libdvdnav: Error when seeking, asked to seek outside program\n"); | |
76 | 220 fprintf(MSG_OUT, "libdvdnav: FIXME: Implement seeking to location %u\n", target); |
114 | 221 printerr("Error when seeking."); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
222 pthread_mutex_unlock(&this->vm_lock); |
114 | 223 return S_ERR; |
0 | 224 } |
225 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
226 dvdnav_status_t dvdnav_part_search(dvdnav_t *this, int part) { |
114 | 227 int title, old_part; |
228 | |
229 if (dvdnav_current_title_info(this, &title, &old_part) == S_OK) | |
230 return dvdnav_part_play(this, title, part); | |
231 return S_ERR; | |
0 | 232 } |
233 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
234 dvdnav_status_t dvdnav_prev_pg_search(dvdnav_t *this) { |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
235 |
114 | 236 if(!this) { |
237 printerr("Passed a NULL pointer."); | |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
238 return S_ERR; |
114 | 239 } |
240 | |
241 pthread_mutex_lock(&this->vm_lock); | |
242 if(!this->vm->state.pgc) { | |
243 printerr("No current PGC."); | |
244 pthread_mutex_unlock(&this->vm_lock); | |
245 return S_ERR; | |
246 } | |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
247 |
114 | 248 #ifdef LOG_DEBUG |
113 | 249 fprintf(MSG_OUT, "libdvdnav: previous chapter\n"); |
114 | 250 #endif |
251 if (!vm_jump_prev_pg(this->vm)) { | |
252 fprintf(MSG_OUT, "libdvdnav: previous chapter failed.\n"); | |
253 printerr("Skip to previous chapter failed."); | |
102
3e6970dbe8d6
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
mroi
parents:
90
diff
changeset
|
254 pthread_mutex_unlock(&this->vm_lock); |
0 | 255 return S_ERR; |
256 } | |
102
3e6970dbe8d6
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
mroi
parents:
90
diff
changeset
|
257 this->position_current.still = 0; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
258 this->vm->hop_channel++; |
114 | 259 #ifdef LOG_DEBUG |
76 | 260 fprintf(MSG_OUT, "libdvdnav: previous chapter done\n"); |
114 | 261 #endif |
102
3e6970dbe8d6
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
mroi
parents:
90
diff
changeset
|
262 pthread_mutex_unlock(&this->vm_lock); |
0 | 263 |
264 return S_OK; | |
265 } | |
266 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
267 dvdnav_status_t dvdnav_top_pg_search(dvdnav_t *this) { |
0 | 268 |
114 | 269 if(!this) { |
270 printerr("Passed a NULL pointer."); | |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
271 return S_ERR; |
114 | 272 } |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
273 |
114 | 274 pthread_mutex_lock(&this->vm_lock); |
275 if(!this->vm->state.pgc) { | |
276 printerr("No current PGC."); | |
277 pthread_mutex_unlock(&this->vm_lock); | |
278 return S_ERR; | |
279 } | |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
280 |
114 | 281 #ifdef LOG_DEBUG |
282 fprintf(MSG_OUT, "libdvdnav: top chapter\n"); | |
283 #endif | |
284 if (!vm_jump_top_pg(this->vm)) { | |
285 fprintf(MSG_OUT, "libdvdnav: top chapter failed.\n"); | |
286 printerr("Skip to top chapter failed."); | |
113 | 287 pthread_mutex_unlock(&this->vm_lock); |
288 return S_ERR; | |
0 | 289 } |
102
3e6970dbe8d6
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
mroi
parents:
90
diff
changeset
|
290 this->position_current.still = 0; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
291 this->vm->hop_channel++; |
114 | 292 #ifdef LOG_DEBUG |
293 fprintf(MSG_OUT, "libdvdnav: top chapter done\n"); | |
294 #endif | |
295 pthread_mutex_unlock(&this->vm_lock); | |
296 | |
297 return S_OK; | |
298 } | |
299 | |
300 dvdnav_status_t dvdnav_next_pg_search(dvdnav_t *this) { | |
122
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
301 vm_t *try_vm; |
114 | 302 |
303 if(!this) { | |
304 printerr("Passed a NULL pointer."); | |
305 return S_ERR; | |
306 } | |
307 | |
308 pthread_mutex_lock(&this->vm_lock); | |
309 if(!this->vm->state.pgc) { | |
310 printerr("No current PGC."); | |
311 pthread_mutex_unlock(&this->vm_lock); | |
312 return S_ERR; | |
313 } | |
314 | |
315 #ifdef LOG_DEBUG | |
316 fprintf(MSG_OUT, "libdvdnav: next chapter\n"); | |
317 #endif | |
122
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
318 /* make a copy of current VM and try to navigate the copy to the next PG */ |
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
319 try_vm = vm_new_copy(this->vm); |
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
320 if (!vm_jump_next_pg(try_vm) || try_vm->stopped) { |
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
321 vm_free_copy(try_vm); |
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
322 /* next_pg failed, try to jump at least to the next cell */ |
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
323 try_vm = vm_new_copy(this->vm); |
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
324 vm_get_next_cell(try_vm); |
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
325 if (try_vm->stopped) { |
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
326 vm_free_copy(try_vm); |
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
327 fprintf(MSG_OUT, "libdvdnav: next chapter failed.\n"); |
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
328 printerr("Skip to next chapter failed."); |
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
329 pthread_mutex_unlock(&this->vm_lock); |
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
330 return S_ERR; |
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
331 } |
114 | 332 } |
122
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
333 /* merge changes on success */ |
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
334 vm_merge(this->vm, try_vm); |
29b046894eac
use the new VM copy mechanism to try-run program skipping and report failure in case
mroi
parents:
119
diff
changeset
|
335 vm_free_copy(try_vm); |
114 | 336 this->position_current.still = 0; |
337 this->vm->hop_channel++; | |
338 #ifdef LOG_DEBUG | |
76 | 339 fprintf(MSG_OUT, "libdvdnav: next chapter done\n"); |
114 | 340 #endif |
102
3e6970dbe8d6
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
mroi
parents:
90
diff
changeset
|
341 pthread_mutex_unlock(&this->vm_lock); |
0 | 342 |
343 return S_OK; | |
344 } | |
345 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
346 dvdnav_status_t dvdnav_menu_call(dvdnav_t *this, DVDMenuID_t menu) { |
114 | 347 |
348 if(!this) { | |
349 printerr("Passed a NULL pointer."); | |
0 | 350 return S_ERR; |
351 } | |
352 | |
114 | 353 pthread_mutex_lock(&this->vm_lock); |
354 if(!this->vm->state.pgc) { | |
355 printerr("No current PGC."); | |
356 pthread_mutex_unlock(&this->vm_lock); | |
357 return S_ERR; | |
358 } | |
359 | |
360 if (vm_jump_menu(this->vm, menu)) { | |
361 this->vm->hop_channel++; | |
362 pthread_mutex_unlock(&this->vm_lock); | |
363 return S_OK; | |
364 } else { | |
365 printerr("No such menu."); | |
366 pthread_mutex_unlock(&this->vm_lock); | |
367 return S_ERR; | |
368 } | |
0 | 369 } |
370 | |
114 | 371 dvdnav_status_t dvdnav_get_position(dvdnav_t *this, unsigned int *pos, |
0 | 372 unsigned int *len) { |
373 uint32_t cur_sector; | |
374 uint32_t first_cell_nr; | |
375 uint32_t last_cell_nr; | |
376 cell_playback_t *first_cell; | |
377 cell_playback_t *last_cell; | |
378 dvd_state_t *state; | |
114 | 379 |
380 if(!this || !pos || !len) { | |
381 printerr("Passed a NULL pointer."); | |
382 return S_ERR; | |
383 } | |
384 if(!this->started) { | |
385 printerr("Virtual DVD machine not started."); | |
386 return S_ERR; | |
387 } | |
388 | |
389 pthread_mutex_lock(&this->vm_lock); | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
390 state = &(this->vm->state); |
114 | 391 if(!state->pgc) { |
392 printerr("No current PGC."); | |
393 pthread_mutex_unlock(&this->vm_lock); | |
394 return S_ERR; | |
0 | 395 } |
114 | 396 |
0 | 397 /* Get current sector */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
398 cur_sector = this->vobu.vobu_start + this->vobu.blockN; |
0 | 399 |
400 /* Find start cell of program. */ | |
401 first_cell_nr = state->pgc->program_map[state->pgN-1]; | |
402 first_cell = &(state->pgc->cell_playback[first_cell_nr-1]); | |
114 | 403 |
404 /* Find end cell of program */ | |
0 | 405 if(state->pgN < state->pgc->nr_of_programs) { |
406 last_cell_nr = state->pgc->program_map[state->pgN] - 1; | |
407 } else { | |
408 last_cell_nr = state->pgc->nr_of_cells; | |
409 } | |
410 last_cell = &(state->pgc->cell_playback[last_cell_nr-1]); | |
411 | |
412 *pos= cur_sector - first_cell->first_sector; | |
413 *len= last_cell->last_sector - first_cell->first_sector; | |
114 | 414 pthread_mutex_unlock(&this->vm_lock); |
0 | 415 |
416 return S_OK; | |
417 } | |
418 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
419 dvdnav_status_t dvdnav_get_position_in_title(dvdnav_t *this, |
8
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
420 unsigned int *pos, |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
421 unsigned int *len) { |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
422 uint32_t cur_sector; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
423 uint32_t first_cell_nr; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
424 uint32_t last_cell_nr; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
425 cell_playback_t *first_cell; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
426 cell_playback_t *last_cell; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
427 dvd_state_t *state; |
114 | 428 |
429 if(!this || !pos || !len) { | |
430 printerr("Passed a NULL pointer."); | |
8
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
431 return S_ERR; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
432 } |
114 | 433 |
434 state = &(this->vm->state); | |
435 if(!state->pgc) { | |
436 printerr("No current PGC."); | |
437 return S_ERR; | |
438 } | |
439 | |
8
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
440 /* Get current sector */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
441 cur_sector = this->vobu.vobu_start + this->vobu.blockN; |
8
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
442 |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
443 /* Now find first and last cells in title. */ |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
444 first_cell_nr = state->pgc->program_map[0]; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
445 first_cell = &(state->pgc->cell_playback[first_cell_nr-1]); |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
446 last_cell_nr = state->pgc->nr_of_cells; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
447 last_cell = &(state->pgc->cell_playback[last_cell_nr-1]); |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
448 |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
449 *pos = cur_sector - first_cell->first_sector; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
450 *len = last_cell->last_sector - first_cell->first_sector; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
451 |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
452 return S_OK; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
453 } |