Mercurial > libdvdnav.hg
annotate searching.c @ 113:ec2df154be56 src
slightly improved logic of program skipping:
previous program:
-> if PG > 1, jump to PG - 1
-> otherwise, if prev_PGC is set, jump to last PG of prev_PGC
-> otherwise fail
next program:
-> if PG < last_PG, jump to PG + 1
-> otherwise, if next_PGC is set, jump to first PG of next_PGC
-> otherwise, move to last Cell of current PG and ask the VM for the next Cell
author | mroi |
---|---|
date | Mon, 13 Jan 2003 13:33:45 +0000 |
parents | 06cba5cee071 |
children | b6834e6359cf |
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.h> | |
29 #include "dvdnav_internal.h" | |
30 | |
31 #include "vm.h" | |
32 #include <dvdread/nav_types.h> | |
33 | |
34 /* Searching API calls */ | |
35 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
36 dvdnav_status_t dvdnav_time_search(dvdnav_t *this, |
0 | 37 unsigned long int time) { |
38 /* Time search the current PGC based on the xxx table */ | |
39 return S_OK; | |
40 } | |
41 | |
24 | 42 /* Scan the ADMAP for a particular block number. */ |
43 /* Return placed in vobu. */ | |
44 /* Returns error status */ | |
45 | |
46 dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, int32_t seekto_block, int32_t *vobu) { | |
47 /* FIXME:Need to handle seeking outside current cell. */ | |
48 vobu_admap_t *admap = NULL; | |
49 *vobu = -1; | |
76 | 50 fprintf(MSG_OUT, "libdvdnav: Seeking to target %u ...\n", |
24 | 51 seekto_block); |
52 | |
53 /* Search through the VOBU_ADMAP for the nearest VOBU | |
54 * to the target block */ | |
55 switch(domain) { | |
56 case FP_DOMAIN: | |
57 case VMGM_DOMAIN: | |
58 admap = this->vm->vmgi->menu_vobu_admap; | |
59 break; | |
60 case VTSM_DOMAIN: | |
61 admap = this->vm->vtsi->menu_vobu_admap; | |
62 break; | |
63 case VTS_DOMAIN: | |
64 admap = this->vm->vtsi->vts_vobu_admap; | |
65 break; | |
66 default: | |
76 | 67 fprintf(MSG_OUT, "libdvdnav: Error: Unknown domain for seeking seek.\n"); |
24 | 68 } |
69 if(admap) { | |
70 int32_t address = 0; | |
71 int32_t vobu_start, next_vobu; | |
72 int found = 0; | |
73 | |
74 /* Search through ADMAP for best sector */ | |
75 vobu_start = 0x3fffffff; | |
76 /* FIXME: Implement a faster search algorithm */ | |
77 while((!found) && ((address<<2) < admap->last_byte)) { | |
78 next_vobu = admap->vobu_start_sectors[address]; | |
79 | |
76 | 80 /* fprintf(MSG_OUT, "libdvdnav: Found block %u\n", next_vobu); */ |
24 | 81 |
82 if(vobu_start <= seekto_block && | |
83 next_vobu > seekto_block) { | |
84 found = 1; | |
85 } else { | |
86 vobu_start = next_vobu; | |
87 } | |
88 | |
89 address ++; | |
90 } | |
91 if(found) { | |
92 *vobu = vobu_start; | |
93 return S_OK; | |
94 } else { | |
76 | 95 fprintf(MSG_OUT, "libdvdnav: Could not locate block\n"); |
24 | 96 return S_ERR; |
97 } | |
98 } | |
76 | 99 fprintf(MSG_OUT, "libdvdnav: admap not located\n"); |
24 | 100 return S_ERR; |
101 } | |
102 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
103 dvdnav_status_t dvdnav_sector_search(dvdnav_t *this, |
0 | 104 unsigned long int offset, int origin) { |
105 /* FIXME: Implement */ | |
106 | |
107 uint32_t target = 0; | |
108 uint32_t length = 0; | |
109 uint32_t first_cell_nr, last_cell_nr, cell_nr, fnd_cell_nr; | |
110 int found; | |
111 cell_playback_t *cell, *fnd_cell; | |
112 dvd_state_t *state; | |
113 dvdnav_status_t result; | |
114 | |
102
3e6970dbe8d6
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
mroi
parents:
90
diff
changeset
|
115 if((!this) || (!this->vm) || (!this->started)) |
0 | 116 return -1; |
117 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
118 state = &(this->vm->state); |
0 | 119 if((!state) || (!state->pgc) ) |
120 return -1; | |
121 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
122 if(this->position_current.still != 0) |
0 | 123 /* Cannot do seeking in a still frame. */ |
124 return -1; | |
125 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
126 pthread_mutex_lock(&this->vm_lock); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
127 result = dvdnav_get_position(this, &target, &length); |
76 | 128 fprintf(MSG_OUT, "libdvdnav: FIXME: seeking to offset=%lu pos=%u length=%u\n", offset, target, length); |
129 fprintf(MSG_OUT, "libdvdnav: FIXME: Before cellN=%u blockN=%u\n" , | |
0 | 130 state->cellN, |
131 state->blockN); | |
132 if(!result) { | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
133 pthread_mutex_unlock(&this->vm_lock); |
0 | 134 return -1; |
135 } | |
136 | |
137 switch(origin) { | |
138 case SEEK_SET: | |
139 if(offset > length) { | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
140 pthread_mutex_unlock(&this->vm_lock); |
0 | 141 return -1; |
142 } | |
143 target = offset; | |
144 break; | |
145 case SEEK_CUR: | |
146 if(target + offset > length) { | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
147 pthread_mutex_unlock(&this->vm_lock); |
0 | 148 return -1; |
149 } | |
150 target += offset; | |
151 break; | |
152 case SEEK_END: | |
153 if(length - offset < 0) { | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
154 pthread_mutex_unlock(&this->vm_lock); |
0 | 155 return -1; |
156 } | |
157 target = length - offset; | |
102
3e6970dbe8d6
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
mroi
parents:
90
diff
changeset
|
158 break; |
0 | 159 default: |
160 /* Error occured */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
161 pthread_mutex_unlock(&this->vm_lock); |
0 | 162 return -1; |
163 } | |
164 | |
165 /* First find closest cell number in program */ | |
166 first_cell_nr = state->pgc->program_map[state->pgN-1]; | |
167 if(state->pgN < state->pgc->nr_of_programs) { | |
168 last_cell_nr = state->pgc->program_map[state->pgN] - 1; | |
169 } else { | |
170 last_cell_nr = state->pgc->nr_of_cells; | |
171 } | |
172 | |
173 found = 0; target += state->pgc->cell_playback[first_cell_nr-1].first_sector; | |
174 fnd_cell_nr = last_cell_nr + 1; | |
175 for(cell_nr = first_cell_nr; (cell_nr <= last_cell_nr) && !found; cell_nr ++) { | |
176 cell = &(state->pgc->cell_playback[cell_nr-1]); | |
177 if((cell->first_sector <= target) && (cell->last_sector >= target)) { | |
178 state->cellN = cell_nr; | |
179 state->blockN = 0; | |
104 | 180 state->cell_restart++; |
0 | 181 found = 1; |
182 fnd_cell_nr = cell_nr; | |
183 fnd_cell = cell; | |
184 } | |
185 } | |
186 | |
187 if(fnd_cell_nr <= last_cell_nr) { | |
26 | 188 int32_t vobu, start; |
24 | 189 dvdnav_status_t status; |
76 | 190 fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n", |
0 | 191 fnd_cell_nr, first_cell_nr, last_cell_nr); |
24 | 192 status = dvdnav_scan_admap(this, state->domain, target, &vobu); |
0 | 193 /* |
194 * Clut does not actually change, | |
195 * but as the decoders have been closed then opened, | |
196 * A new clut has to be sent. | |
197 */ | |
24 | 198 start =(state->pgc->cell_playback[state->cellN - 1].first_sector); |
76 | 199 fprintf(MSG_OUT, "libdvdnav: FIXME: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" , |
0 | 200 state->cellN, |
24 | 201 state->blockN, |
202 target, | |
203 vobu, | |
204 start); | |
205 state->blockN = vobu - start; | |
76 | 206 fprintf(MSG_OUT, "libdvdnav: FIXME: After vobu=%x start=%x blockN=%x\n" , |
24 | 207 vobu, |
208 start, | |
0 | 209 state->blockN); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
210 pthread_mutex_unlock(&this->vm_lock); |
0 | 211 return target; |
212 } else { | |
76 | 213 fprintf(MSG_OUT, "libdvdnav: Error when seeking, asked to seek outside program\n"); |
0 | 214 } |
215 | |
76 | 216 fprintf(MSG_OUT, "libdvdnav: FIXME: Implement seeking to location %u\n", target); |
0 | 217 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
218 pthread_mutex_unlock(&this->vm_lock); |
0 | 219 return -1; |
220 } | |
221 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
222 dvdnav_status_t dvdnav_part_search(dvdnav_t *this, int part) { |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
223 |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
224 if((!this) || (!this->vm) ) |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
225 return S_ERR; |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
226 |
0 | 227 return S_OK; |
228 } | |
229 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
230 dvdnav_status_t dvdnav_prev_pg_search(dvdnav_t *this) { |
0 | 231 dvd_state_t *state; |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
232 |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
233 if((!this) || (!this->vm) ) |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
234 return S_ERR; |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
235 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
236 state = &(this->vm->state); |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
237 if((!state) || (!state->pgc) ) |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
238 return S_ERR; |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
239 |
102
3e6970dbe8d6
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
mroi
parents:
90
diff
changeset
|
240 pthread_mutex_lock(&this->vm_lock); |
113 | 241 fprintf(MSG_OUT, "libdvdnav: previous chapter\n"); |
242 if (!vm_prev_pg(this->vm)) { | |
243 fprintf(MSG_OUT, "libdvdnav: prev chapter failed.\n"); | |
102
3e6970dbe8d6
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
mroi
parents:
90
diff
changeset
|
244 pthread_mutex_unlock(&this->vm_lock); |
0 | 245 return S_ERR; |
246 } | |
102
3e6970dbe8d6
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
mroi
parents:
90
diff
changeset
|
247 this->position_current.still = 0; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
248 this->vm->hop_channel++; |
76 | 249 fprintf(MSG_OUT, "libdvdnav: previous chapter done\n"); |
102
3e6970dbe8d6
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
mroi
parents:
90
diff
changeset
|
250 pthread_mutex_unlock(&this->vm_lock); |
0 | 251 |
252 return S_OK; | |
253 } | |
254 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
255 dvdnav_status_t dvdnav_top_pg_search(dvdnav_t *this) { |
0 | 256 |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
257 if((!this) || (!this->vm) ) |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
258 return S_ERR; |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
259 |
76 | 260 fprintf(MSG_OUT, "libdvdnav: top chapter. NOP.\n"); |
0 | 261 |
262 return S_OK; | |
263 } | |
264 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
265 dvdnav_status_t dvdnav_next_pg_search(dvdnav_t *this) { |
0 | 266 dvd_state_t *state; |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
267 |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
268 if((!this) || (!this->vm) ) |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
269 return S_ERR; |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
270 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
271 state = &(this->vm->state); |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
272 if((!state) || (!state->pgc) ) |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
273 return S_ERR; |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
274 |
102
3e6970dbe8d6
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
mroi
parents:
90
diff
changeset
|
275 pthread_mutex_lock(&this->vm_lock); |
113 | 276 fprintf(MSG_OUT, "libdvdnav: next chapter\n"); |
277 if (!vm_next_pg(this->vm)) { | |
278 fprintf(MSG_OUT, "libdvdnav: next chapter failed.\n"); | |
279 pthread_mutex_unlock(&this->vm_lock); | |
280 return S_ERR; | |
0 | 281 } |
102
3e6970dbe8d6
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
mroi
parents:
90
diff
changeset
|
282 this->position_current.still = 0; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
283 this->vm->hop_channel++; |
76 | 284 fprintf(MSG_OUT, "libdvdnav: next chapter done\n"); |
102
3e6970dbe8d6
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
mroi
parents:
90
diff
changeset
|
285 pthread_mutex_unlock(&this->vm_lock); |
0 | 286 |
287 return S_OK; | |
288 } | |
289 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
290 dvdnav_status_t dvdnav_menu_call(dvdnav_t *this, DVDMenuID_t menu) { |
0 | 291 dvd_state_t *state; |
292 | |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
293 if((!this) || (!this->vm) ) |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
294 return S_ERR; |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
295 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
296 pthread_mutex_lock(&this->vm_lock); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
297 state = &(this->vm->state); |
63
a7b12d28a6ab
hop on menu calls, patch by Phil Hassey <philhassey@users.sourceforge.net>
mroi
parents:
26
diff
changeset
|
298 if (vm_menu_call(this->vm, menu, 0)) |
a7b12d28a6ab
hop on menu calls, patch by Phil Hassey <philhassey@users.sourceforge.net>
mroi
parents:
26
diff
changeset
|
299 this->vm->hop_channel++; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
300 pthread_mutex_unlock(&this->vm_lock); |
0 | 301 return S_OK; |
302 } | |
303 | |
304 static char __title_str[] = "DVDNAV"; | |
305 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
306 dvdnav_status_t dvdnav_get_title_string(dvdnav_t *this, char **title_str) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
307 if(!this) |
0 | 308 return S_ERR; |
309 | |
310 if(!title_str) { | |
311 printerr("Passed a NULL pointer"); | |
312 return S_ERR; | |
313 } | |
314 | |
315 (*title_str) = __title_str; | |
316 | |
317 return S_OK; | |
318 } | |
319 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
320 dvdnav_status_t dvdnav_get_position(dvdnav_t *this, unsigned int* pos, |
0 | 321 unsigned int *len) { |
322 uint32_t cur_sector; | |
323 uint32_t first_cell_nr; | |
324 uint32_t last_cell_nr; | |
325 cell_playback_t *first_cell; | |
326 cell_playback_t *last_cell; | |
327 dvd_state_t *state; | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
328 if((!this) || (!this->vm) ) |
0 | 329 return 0; |
330 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
331 state = &(this->vm->state); |
0 | 332 if((!state) || (!state->pgc) ) |
333 return 0; | |
334 | |
335 /* Sanity check */ | |
336 if(state->pgN > state->pgc->nr_of_programs) { | |
337 return 0; | |
338 } | |
339 | |
340 /* Get current sector */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
341 cur_sector = this->vobu.vobu_start + this->vobu.blockN; |
0 | 342 |
343 /* Find start cell of program. */ | |
344 first_cell_nr = state->pgc->program_map[state->pgN-1]; | |
345 first_cell = &(state->pgc->cell_playback[first_cell_nr-1]); | |
346 if(state->pgN < state->pgc->nr_of_programs) { | |
347 last_cell_nr = state->pgc->program_map[state->pgN] - 1; | |
348 } else { | |
349 last_cell_nr = state->pgc->nr_of_cells; | |
350 } | |
351 last_cell = &(state->pgc->cell_playback[last_cell_nr-1]); | |
352 | |
353 *pos= cur_sector - first_cell->first_sector; | |
354 *len= last_cell->last_sector - first_cell->first_sector; | |
76 | 355 /* fprintf(MSG_OUT, "libdvdnav: searching:current pos=%u length=%u\n",*pos,*len); */ |
0 | 356 |
357 | |
358 return S_OK; | |
359 } | |
360 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
361 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
|
362 unsigned int *pos, |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
363 unsigned int *len) { |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
364 uint32_t cur_sector; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
365 uint32_t first_cell_nr; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
366 uint32_t last_cell_nr; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
367 cell_playback_t *first_cell; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
368 cell_playback_t *last_cell; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
369 dvd_state_t *state; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
370 if((!this) || (!this->vm) ) |
8
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
371 return S_ERR; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
372 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
373 state = &(this->vm->state); |
8
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
374 if((!state) || (!state->pgc) ) |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
375 return S_ERR; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
376 |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
377 /* Sanity check */ |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
378 if(state->pgN > state->pgc->nr_of_programs) { |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
379 return S_ERR; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
380 } |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
381 |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
382 /* Get current sector */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
383 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
|
384 |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
385 /* 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
|
386 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
|
387 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
|
388 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
|
389 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
|
390 |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
391 *pos = cur_sector - first_cell->first_sector; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
392 *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
|
393 |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
394 return S_OK; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
395 } |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
396 |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
397 |