annotate searching.c @ 118:48ba92648842 src

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