annotate searching.c @ 68:3b45c78f061e src

Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
author richwareham
date Fri, 26 Jul 2002 07:27:52 +0000
parents a7b12d28a6ab
children 0e2abe7083de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1 /*
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
2 * Copyright (C) 2000 Rich Wareham <richwareham@users.sourceforge.net>
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
3 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
4 * This file is part of libdvdnav, a DVD navigation library.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
5 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
6 * libdvdnav is free software; you can redistribute it and/or modify
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
9 * (at your option) any later version.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
10 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
11 * libdvdnav is distributed in the hope that it will be useful,
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
14 * GNU General Public License for more details.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
15 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
19 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
20 * $Id$
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
21 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
22 */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
23
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
25 #include "config.h"
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
26 #endif
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
27
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
28 #include <dvdnav.h>
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
29 #include "dvdnav_internal.h"
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
30
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
31 #include "vm.h"
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
32 #include <dvdread/nav_types.h>
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
33
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
34 /* Searching API calls */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
37 unsigned long int time) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
38 /* Time search the current PGC based on the xxx table */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
39 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
40 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
41
24
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
42 /* Scan the ADMAP for a particular block number. */
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
43 /* Return placed in vobu. */
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
44 /* Returns error status */
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
45
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
46 dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, int32_t seekto_block, int32_t *vobu) {
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
47 /* FIXME:Need to handle seeking outside current cell. */
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
48 vobu_admap_t *admap = NULL;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
49 *vobu = -1;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
50 fprintf(stderr,"Seeking to target %u ...\n",
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
51 seekto_block);
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
52
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
53 /* Search through the VOBU_ADMAP for the nearest VOBU
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
54 * to the target block */
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
55 switch(domain) {
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
56 case FP_DOMAIN:
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
57 case VMGM_DOMAIN:
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
58 admap = this->vm->vmgi->menu_vobu_admap;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
59 break;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
60 case VTSM_DOMAIN:
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
61 admap = this->vm->vtsi->menu_vobu_admap;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
62 break;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
63 case VTS_DOMAIN:
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
64 admap = this->vm->vtsi->vts_vobu_admap;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
65 break;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
66 default:
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
67 fprintf(stderr,"Error: Unknown domain for seeking seek.\n");
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
68 }
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
69 if(admap) {
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
70 int32_t address = 0;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
71 int32_t vobu_start, next_vobu;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
72 int found = 0;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
73
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
74 /* Search through ADMAP for best sector */
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
75 vobu_start = 0x3fffffff;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
76 /* FIXME: Implement a faster search algorithm */
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
77 while((!found) && ((address<<2) < admap->last_byte)) {
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
78 next_vobu = admap->vobu_start_sectors[address];
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
79
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
80 /* printf("Found block %u\n", next_vobu); */
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
81
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
82 if(vobu_start <= seekto_block &&
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
83 next_vobu > seekto_block) {
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
84 found = 1;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
85 } else {
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
86 vobu_start = next_vobu;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
87 }
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
88
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
89 address ++;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
90 }
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
91 if(found) {
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
92 *vobu = vobu_start;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
93 return S_OK;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
94 } else {
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
95 fprintf(stderr,"Could not locate block\n");
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
96 return S_ERR;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
97 }
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
98 }
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
99 fprintf(stderr,"admap not located\n");
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
100 return S_ERR;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
101 }
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
104 unsigned long int offset, int origin) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
105 /* FIXME: Implement */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
106
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
107 uint32_t target = 0;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
108 uint32_t length = 0;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
109 uint32_t first_cell_nr, last_cell_nr, cell_nr, fnd_cell_nr;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
110 int found;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
111 cell_playback_t *cell, *fnd_cell;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
112 dvd_state_t *state;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
113 dvdnav_status_t result;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
116 return -1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
119 if((!state) || (!state->pgc) )
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
120 return -1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
121
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
122 if(offset == 0)
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
123 return -1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
126 /* Cannot do seeking in a still frame. */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
127 return -1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
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);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
131 fprintf(stderr,"FIXME: seeking to offset=%lu pos=%u length=%u\n", offset, target, length);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
132 fprintf(stderr,"FIXME: Before cellN=%u blockN=%u\n" ,
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
133 state->cellN,
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
134 state->blockN);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
137 return -1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
138 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
139
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
140 switch(origin) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
141 case SEEK_SET:
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
144 return -1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
145 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
146 target = offset;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
147 break;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
148 case SEEK_CUR:
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
151 return -1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
152 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
153 target += offset;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
154 break;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
155 case SEEK_END:
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
158 return -1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
159 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
160 target = length - offset;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
161 default:
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
164 return -1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
165 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
166
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
167 /* First find closest cell number in program */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
168 first_cell_nr = state->pgc->program_map[state->pgN-1];
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
169 if(state->pgN < state->pgc->nr_of_programs) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
170 last_cell_nr = state->pgc->program_map[state->pgN] - 1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
171 } else {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
172 last_cell_nr = state->pgc->nr_of_cells;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
173 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
174
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
175 found = 0; target += state->pgc->cell_playback[first_cell_nr-1].first_sector;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
176 fnd_cell_nr = last_cell_nr + 1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
177 for(cell_nr = first_cell_nr; (cell_nr <= last_cell_nr) && !found; cell_nr ++) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
178 cell = &(state->pgc->cell_playback[cell_nr-1]);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
179 if((cell->first_sector <= target) && (cell->last_sector >= target)) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
180 state->cellN = cell_nr;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
181 state->blockN = 0;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
182 found = 1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
183 fnd_cell_nr = cell_nr;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
184 fnd_cell = cell;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
185 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
186 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
187
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
188 if(fnd_cell_nr <= last_cell_nr) {
26
794d2e16a4d4 Removed un-needed variables.
jcdutton
parents: 25
diff changeset
189 int32_t vobu, start;
24
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
190 dvdnav_status_t status;
3
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
191 fprintf(stderr,"Seeking to cell %i from choice of %i to %i\n",
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
192 fnd_cell_nr, first_cell_nr, last_cell_nr);
24
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
193 status = dvdnav_scan_admap(this, state->domain, target, &vobu);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
194 /*
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
195 * Clut does not actually change,
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
196 * but as the decoders have been closed then opened,
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
197 * A new clut has to be sent.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
198 */
24
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
199 start =(state->pgc->cell_playback[state->cellN - 1].first_sector);
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
200 fprintf(stderr,"FIXME: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" ,
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
201 state->cellN,
24
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
202 state->blockN,
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
203 target,
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
204 vobu,
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
205 start);
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
206 state->blockN = vobu - start;
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
207 fprintf(stderr,"FIXME: After vobu=%x start=%x blockN=%x\n" ,
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
208 vobu,
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 22
diff changeset
209 start,
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
212 return target;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
213 } else {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
214 fprintf(stderr, "Error when seeking, asked to seek outside program\n");
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
215 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
216
3
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
217 fprintf(stderr,"FIXME: Implement seeking to location %u\n", target);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
220 return -1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
221 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
228 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
229 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
230
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
231 dvdnav_status_t dvdnav_prev_pg_search(dvdnav_t *this) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
232 dvd_state_t *state;
68
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
233
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
234 if((!this) || (!this->vm) )
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
235 return S_ERR;
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
236
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
237 state = &(this->vm->state);
68
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
238 if((!state) || (!state->pgc) )
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
239 return S_ERR;
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
240
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
241 /* Make sure this is not the first chapter */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
242 if(state->pgN <= 1 ) {
3
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
243 fprintf(stderr,"dvdnav: at first chapter. prev chapter failed.\n");
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
244 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
245 }
3
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
246 fprintf(stderr,"dvdnav: previous chapter\n");
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
247 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
248 this->vm->hop_channel++;
3
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
249 fprintf(stderr,"dvdnav: previous chapter done\n");
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
250
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
251 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
252 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
253
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
254 dvdnav_status_t dvdnav_top_pg_search(dvdnav_t *this) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
255
68
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
256 if((!this) || (!this->vm) )
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
257 return S_ERR;
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
258
3
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
259 fprintf(stderr,"dvdnav: top chapter. NOP.\n");
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
260
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
261 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
262 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
263
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
264 dvdnav_status_t dvdnav_next_pg_search(dvdnav_t *this) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
265 dvd_state_t *state;
68
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
266
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
267 if((!this) || (!this->vm) )
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
268 return S_ERR;
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
269
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
270 state = &(this->vm->state);
68
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
271 if((!state) || (!state->pgc) )
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
272 return S_ERR;
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
273
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
274 /* Make sure this is not the last chapter */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
275 if(state->pgN >= state->pgc->nr_of_programs) {
3
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
276 fprintf(stderr,"dvdnav: at last chapter. next chapter failed.\n");
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
277 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
278 }
3
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
279 fprintf(stderr,"dvdnav: next chapter\n");
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
280 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
281 this->vm->hop_channel++;
3
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
282 fprintf(stderr,"dvdnav: next chapter done\n");
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
283
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
284 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
285 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
286
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
287 dvdnav_status_t dvdnav_menu_call(dvdnav_t *this, DVDMenuID_t menu) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
288 dvd_state_t *state;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
289
68
3b45c78f061e Some NULL-pointer check from aschultz@cs.uni-magdeburg.de
richwareham
parents: 63
diff changeset
290 if((!this) || (!this->vm) )
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
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
293 pthread_mutex_lock(&this->vm_lock);
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
294 state = &(this->vm->state);
63
a7b12d28a6ab hop on menu calls, patch by Phil Hassey <philhassey@users.sourceforge.net>
mroi
parents: 26
diff changeset
295 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
296 this->vm->hop_channel++;
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
297 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
298 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
299 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
300
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
301 dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int *tt, int *pr) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
302 int vts_ttn = 0;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
303 int vts, i;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
304 domain_t domain;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
305 tt_srpt_t* srpt;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
306
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
307 if(!this)
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
308 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
309
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
310 if(!tt || !pr) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
311 printerr("Passed a NULL pointer");
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
312 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
313
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
314 if(tt)
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
315 *tt = -1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
316 if(*pr)
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
317 *pr = -1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
318
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
319 domain = this->vm->state.domain;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
320 if((domain == FP_DOMAIN) || (domain == VMGM_DOMAIN)) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
321 /* Not in a title */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
322 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
323 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
324
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
325 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
326 vts = this->vm->state.vtsN;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
327
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
328 if(pr) {
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
329 *pr = this->vm->state.pgN;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
330 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
331
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
332 /* Search TT_SRPT for title */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
333 if(!(vm_get_vmgi(this->vm))) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
334 printerr("Oh poo, no SRPT");
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
335 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
336 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
337
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
338 srpt = vm_get_vmgi(this->vm)->tt_srpt;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
339 for(i=0; i<srpt->nr_of_srpts; i++) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
340 title_info_t* info = &(srpt->title[i]);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
341 if((info->title_set_nr == vts) && (info->vts_ttn == vts_ttn)) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
342 if(tt)
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
343 *tt = i+1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
344 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
345 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
346
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
347 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
348 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
349
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
350 static char __title_str[] = "DVDNAV";
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
351
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
352 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
353 if(!this)
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
354 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
355
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
356 if(!title_str) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
357 printerr("Passed a NULL pointer");
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
358 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
359 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
360
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
361 (*title_str) = __title_str;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
362
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
363 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
364 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
365
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
366 dvdnav_status_t dvdnav_get_position(dvdnav_t *this, unsigned int* pos,
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
367 unsigned int *len) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
368 uint32_t cur_sector;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
369 uint32_t first_cell_nr;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
370 uint32_t last_cell_nr;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
371 cell_playback_t *first_cell;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
372 cell_playback_t *last_cell;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
373 dvd_state_t *state;
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
374 if((!this) || (!this->vm) )
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
375 return 0;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
376
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
377 state = &(this->vm->state);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
378 if((!state) || (!state->pgc) )
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
379 return 0;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
380
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
381 /* Sanity check */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
382 if(state->pgN > state->pgc->nr_of_programs) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
383 return 0;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
384 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
385
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
386 /* Get current sector */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
387 cur_sector = this->vobu.vobu_start + this->vobu.blockN;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
388
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
389 /* Find start cell of program. */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
390 first_cell_nr = state->pgc->program_map[state->pgN-1];
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
391 first_cell = &(state->pgc->cell_playback[first_cell_nr-1]);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
392 if(state->pgN < state->pgc->nr_of_programs) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
393 last_cell_nr = state->pgc->program_map[state->pgN] - 1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
394 } else {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
395 last_cell_nr = state->pgc->nr_of_cells;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
396 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
397 last_cell = &(state->pgc->cell_playback[last_cell_nr-1]);
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
398
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
399 *pos= cur_sector - first_cell->first_sector;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
400 *len= last_cell->last_sector - first_cell->first_sector;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
401 /* printf("dvdnav:searching:current pos=%u length=%u\n",*pos,*len); */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
402
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
403
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
404 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
405 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
406
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
407 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
408 unsigned int *pos,
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
409 unsigned int *len) {
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
410 uint32_t cur_sector;
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
411 uint32_t first_cell_nr;
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
412 uint32_t last_cell_nr;
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
413 cell_playback_t *first_cell;
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
414 cell_playback_t *last_cell;
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
415 dvd_state_t *state;
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
416 if((!this) || (!this->vm) )
8
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
417 return S_ERR;
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
418
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
419 state = &(this->vm->state);
8
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
420 if((!state) || (!state->pgc) )
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
421 return S_ERR;
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
422
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
423 /* Sanity check */
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
424 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
425 return S_ERR;
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
426 }
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
427
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
428 /* Get current sector */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 8
diff changeset
429 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
430
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
431 /* 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
432 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
433 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
434 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
435 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
436
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
437 *pos = cur_sector - first_cell->first_sector;
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
438 *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
439
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
440 return S_OK;
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 3
diff changeset
441 }
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