Mercurial > libdvdnav.hg
annotate searching.c @ 89:0fbef4901e2c src
Add a comment so I can tell which version of the CVS a user is using.
Also add a FIXME to remind me to fix the Chapter number display.
author | jcdutton |
---|---|
date | Tue, 03 Sep 2002 00:41:48 +0000 |
parents | 929f732a0135 |
children | eeabf5a51b2b |
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 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
115 if((!this) || (!this->vm) ) |
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 | |
122 if(offset == 0) | |
123 return -1; | |
124 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
125 if(this->position_current.still != 0) |
0 | 126 /* Cannot do seeking in a still frame. */ |
127 return -1; | |
128 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
129 pthread_mutex_lock(&this->vm_lock); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
130 result = dvdnav_get_position(this, &target, &length); |
76 | 131 fprintf(MSG_OUT, "libdvdnav: FIXME: seeking to offset=%lu pos=%u length=%u\n", offset, target, length); |
132 fprintf(MSG_OUT, "libdvdnav: FIXME: Before cellN=%u blockN=%u\n" , | |
0 | 133 state->cellN, |
134 state->blockN); | |
135 if(!result) { | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
136 pthread_mutex_unlock(&this->vm_lock); |
0 | 137 return -1; |
138 } | |
139 | |
140 switch(origin) { | |
141 case SEEK_SET: | |
142 if(offset > length) { | |
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); |
0 | 144 return -1; |
145 } | |
146 target = offset; | |
147 break; | |
148 case SEEK_CUR: | |
149 if(target + offset > length) { | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
150 pthread_mutex_unlock(&this->vm_lock); |
0 | 151 return -1; |
152 } | |
153 target += offset; | |
154 break; | |
155 case SEEK_END: | |
156 if(length - offset < 0) { | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
157 pthread_mutex_unlock(&this->vm_lock); |
0 | 158 return -1; |
159 } | |
160 target = length - offset; | |
161 default: | |
162 /* Error occured */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
163 pthread_mutex_unlock(&this->vm_lock); |
0 | 164 return -1; |
165 } | |
166 | |
167 /* First find closest cell number in program */ | |
168 first_cell_nr = state->pgc->program_map[state->pgN-1]; | |
169 if(state->pgN < state->pgc->nr_of_programs) { | |
170 last_cell_nr = state->pgc->program_map[state->pgN] - 1; | |
171 } else { | |
172 last_cell_nr = state->pgc->nr_of_cells; | |
173 } | |
174 | |
175 found = 0; target += state->pgc->cell_playback[first_cell_nr-1].first_sector; | |
176 fnd_cell_nr = last_cell_nr + 1; | |
177 for(cell_nr = first_cell_nr; (cell_nr <= last_cell_nr) && !found; cell_nr ++) { | |
178 cell = &(state->pgc->cell_playback[cell_nr-1]); | |
179 if((cell->first_sector <= target) && (cell->last_sector >= target)) { | |
180 state->cellN = cell_nr; | |
181 state->blockN = 0; | |
182 found = 1; | |
183 fnd_cell_nr = cell_nr; | |
184 fnd_cell = cell; | |
185 } | |
186 } | |
187 | |
188 if(fnd_cell_nr <= last_cell_nr) { | |
26 | 189 int32_t vobu, start; |
24 | 190 dvdnav_status_t status; |
76 | 191 fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n", |
0 | 192 fnd_cell_nr, first_cell_nr, last_cell_nr); |
24 | 193 status = dvdnav_scan_admap(this, state->domain, target, &vobu); |
0 | 194 /* |
195 * Clut does not actually change, | |
196 * but as the decoders have been closed then opened, | |
197 * A new clut has to be sent. | |
198 */ | |
24 | 199 start =(state->pgc->cell_playback[state->cellN - 1].first_sector); |
76 | 200 fprintf(MSG_OUT, "libdvdnav: FIXME: 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); | |
206 state->blockN = vobu - start; | |
76 | 207 fprintf(MSG_OUT, "libdvdnav: FIXME: After vobu=%x start=%x blockN=%x\n" , |
24 | 208 vobu, |
209 start, | |
0 | 210 state->blockN); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
211 pthread_mutex_unlock(&this->vm_lock); |
0 | 212 return target; |
213 } else { | |
76 | 214 fprintf(MSG_OUT, "libdvdnav: Error when seeking, asked to seek outside program\n"); |
0 | 215 } |
216 | |
76 | 217 fprintf(MSG_OUT, "libdvdnav: FIXME: Implement seeking to location %u\n", target); |
0 | 218 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
219 pthread_mutex_unlock(&this->vm_lock); |
0 | 220 return -1; |
221 } | |
222 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
223 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
|
224 |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
225 if((!this) || (!this->vm) ) |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
226 return S_ERR; |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
227 |
0 | 228 return S_OK; |
229 } | |
230 | |
88 | 231 dvdnav_status_t dvdnav_prev_part_search(dvdnav_t *this) { |
232 | |
233 if((!this) || (!this->vm) ) | |
234 return S_ERR; | |
235 | |
236 vm_prev_part(this->vm); | |
237 /* FIXME: handle errors */ | |
238 return S_OK; | |
239 } | |
240 | |
241 dvdnav_status_t dvdnav_next_part_search(dvdnav_t *this) { | |
242 if((!this) || (!this->vm) ) | |
243 return S_ERR; | |
244 | |
245 vm_next_part(this->vm); | |
246 /* FIXME: handle errors */ | |
247 return S_OK; | |
248 } | |
249 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
250 dvdnav_status_t dvdnav_prev_pg_search(dvdnav_t *this) { |
0 | 251 dvd_state_t *state; |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
252 |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
253 if((!this) || (!this->vm) ) |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
254 return S_ERR; |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
255 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
256 state = &(this->vm->state); |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
257 if((!state) || (!state->pgc) ) |
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 |
0 | 260 /* Make sure this is not the first chapter */ |
261 if(state->pgN <= 1 ) { | |
76 | 262 fprintf(MSG_OUT, "libdvdnav: at first chapter. prev chapter failed.\n"); |
0 | 263 return S_ERR; |
264 } | |
76 | 265 fprintf(MSG_OUT, "libdvdnav: previous chapter\n"); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
266 vm_jump_prog(this->vm, state->pgN - 1); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
267 this->vm->hop_channel++; |
76 | 268 fprintf(MSG_OUT, "libdvdnav: previous chapter done\n"); |
0 | 269 |
270 return S_OK; | |
271 } | |
272 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
273 dvdnav_status_t dvdnav_top_pg_search(dvdnav_t *this) { |
0 | 274 |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
275 if((!this) || (!this->vm) ) |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
276 return S_ERR; |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
277 |
76 | 278 fprintf(MSG_OUT, "libdvdnav: top chapter. NOP.\n"); |
0 | 279 |
280 return S_OK; | |
281 } | |
282 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
283 dvdnav_status_t dvdnav_next_pg_search(dvdnav_t *this) { |
0 | 284 dvd_state_t *state; |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
285 |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
286 if((!this) || (!this->vm) ) |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
287 return S_ERR; |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
288 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
289 state = &(this->vm->state); |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
290 if((!state) || (!state->pgc) ) |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
291 return S_ERR; |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
292 |
0 | 293 /* Make sure this is not the last chapter */ |
294 if(state->pgN >= state->pgc->nr_of_programs) { | |
76 | 295 fprintf(MSG_OUT, "libdvdnav: at last chapter. next chapter failed.\n"); |
0 | 296 return S_ERR; |
297 } | |
76 | 298 fprintf(MSG_OUT, "libdvdnav: next chapter\n"); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
299 vm_jump_prog(this->vm, state->pgN + 1); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
300 this->vm->hop_channel++; |
76 | 301 fprintf(MSG_OUT, "libdvdnav: next chapter done\n"); |
0 | 302 |
303 return S_OK; | |
304 } | |
305 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
306 dvdnav_status_t dvdnav_menu_call(dvdnav_t *this, DVDMenuID_t menu) { |
0 | 307 dvd_state_t *state; |
308 | |
68
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
309 if((!this) || (!this->vm) ) |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
310 return S_ERR; |
3b45c78f061e
Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents:
63
diff
changeset
|
311 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
312 pthread_mutex_lock(&this->vm_lock); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
313 state = &(this->vm->state); |
63
a7b12d28a6ab
hop on menu calls, patch by Phil Hassey <philhassey@users.sourceforge.net>
mroi
parents:
26
diff
changeset
|
314 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
|
315 this->vm->hop_channel++; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
316 pthread_mutex_unlock(&this->vm_lock); |
0 | 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_current_title_info(dvdnav_t *this, int *tt, int *pr) { |
0 | 321 int vts_ttn = 0; |
322 int vts, i; | |
323 domain_t domain; | |
324 tt_srpt_t* srpt; | |
325 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
326 if(!this) |
0 | 327 return S_ERR; |
328 | |
329 if(!tt || !pr) { | |
330 printerr("Passed a NULL pointer"); | |
331 } | |
332 | |
333 if(tt) | |
334 *tt = -1; | |
335 if(*pr) | |
336 *pr = -1; | |
337 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
338 domain = this->vm->state.domain; |
0 | 339 if((domain == FP_DOMAIN) || (domain == VMGM_DOMAIN)) { |
340 /* Not in a title */ | |
341 return S_OK; | |
342 } | |
343 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
344 vts_ttn = this->vm->state.VTS_TTN_REG; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
345 vts = this->vm->state.vtsN; |
0 | 346 |
89
0fbef4901e2c
Add a comment so I can tell which version of the CVS a user is using.
jcdutton
parents:
88
diff
changeset
|
347 /* FIXME: pr should be found by searching the VTS_SRPT table. Not just the pgN */ |
0 | 348 if(pr) { |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
349 *pr = this->vm->state.pgN; |
0 | 350 } |
351 | |
352 /* Search TT_SRPT for title */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
353 if(!(vm_get_vmgi(this->vm))) { |
0 | 354 printerr("Oh poo, no SRPT"); |
355 return S_ERR; | |
356 } | |
357 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
358 srpt = vm_get_vmgi(this->vm)->tt_srpt; |
0 | 359 for(i=0; i<srpt->nr_of_srpts; i++) { |
360 title_info_t* info = &(srpt->title[i]); | |
361 if((info->title_set_nr == vts) && (info->vts_ttn == vts_ttn)) { | |
362 if(tt) | |
363 *tt = i+1; | |
364 } | |
365 } | |
366 | |
367 return S_OK; | |
368 } | |
369 | |
370 static char __title_str[] = "DVDNAV"; | |
371 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
372 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
|
373 if(!this) |
0 | 374 return S_ERR; |
375 | |
376 if(!title_str) { | |
377 printerr("Passed a NULL pointer"); | |
378 return S_ERR; | |
379 } | |
380 | |
381 (*title_str) = __title_str; | |
382 | |
383 return S_OK; | |
384 } | |
385 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
386 dvdnav_status_t dvdnav_get_position(dvdnav_t *this, unsigned int* pos, |
0 | 387 unsigned int *len) { |
388 uint32_t cur_sector; | |
389 uint32_t first_cell_nr; | |
390 uint32_t last_cell_nr; | |
391 cell_playback_t *first_cell; | |
392 cell_playback_t *last_cell; | |
393 dvd_state_t *state; | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
394 if((!this) || (!this->vm) ) |
0 | 395 return 0; |
396 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
397 state = &(this->vm->state); |
0 | 398 if((!state) || (!state->pgc) ) |
399 return 0; | |
400 | |
401 /* Sanity check */ | |
402 if(state->pgN > state->pgc->nr_of_programs) { | |
403 return 0; | |
404 } | |
405 | |
406 /* Get current sector */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
407 cur_sector = this->vobu.vobu_start + this->vobu.blockN; |
0 | 408 |
409 /* Find start cell of program. */ | |
410 first_cell_nr = state->pgc->program_map[state->pgN-1]; | |
411 first_cell = &(state->pgc->cell_playback[first_cell_nr-1]); | |
412 if(state->pgN < state->pgc->nr_of_programs) { | |
413 last_cell_nr = state->pgc->program_map[state->pgN] - 1; | |
414 } else { | |
415 last_cell_nr = state->pgc->nr_of_cells; | |
416 } | |
417 last_cell = &(state->pgc->cell_playback[last_cell_nr-1]); | |
418 | |
419 *pos= cur_sector - first_cell->first_sector; | |
420 *len= last_cell->last_sector - first_cell->first_sector; | |
76 | 421 /* fprintf(MSG_OUT, "libdvdnav: searching:current pos=%u length=%u\n",*pos,*len); */ |
0 | 422 |
423 | |
424 return S_OK; | |
425 } | |
426 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
427 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
|
428 unsigned int *pos, |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
429 unsigned int *len) { |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
430 uint32_t cur_sector; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
431 uint32_t first_cell_nr; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
432 uint32_t last_cell_nr; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
433 cell_playback_t *first_cell; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
434 cell_playback_t *last_cell; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
435 dvd_state_t *state; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
436 if((!this) || (!this->vm) ) |
8
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
437 return S_ERR; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
438 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
439 state = &(this->vm->state); |
8
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
440 if((!state) || (!state->pgc) ) |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
441 return S_ERR; |
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 /* Sanity check */ |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
444 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
|
445 return S_ERR; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
446 } |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
447 |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
448 /* Get current sector */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
8
diff
changeset
|
449 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
|
450 |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
451 /* 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
|
452 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
|
453 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
|
454 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
|
455 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
|
456 |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
457 *pos = cur_sector - first_cell->first_sector; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
458 *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
|
459 |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
460 return S_OK; |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
461 } |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
462 |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
3
diff
changeset
|
463 |