Mercurial > libdvdread4.hg
annotate searching.c @ 0:427b7da5cbdb src
first split of dvdread; it's just a copy of dvdnav still to be cleaned
author | nicodvb |
---|---|
date | Sun, 01 Jun 2008 08:39:07 +0000 |
parents | |
children |
rev | line source |
---|---|
0
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
1 /* |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
2 * Copyright (C) 2000 Rich Wareham <richwareham@users.sourceforge.net> |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
3 * |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
4 * This file is part of libdvdnav, a DVD navigation library. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
5 * |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
6 * libdvdnav is free software; you can redistribute it and/or modify |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
9 * (at your option) any later version. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
10 * |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
11 * libdvdnav is distributed in the hope that it will be useful, |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
15 * |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
19 * |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
20 * $Id$ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
21 * |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
22 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
23 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
24 #ifdef HAVE_CONFIG_H |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
25 #include "config.h" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
26 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
27 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
28 #include <assert.h> |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
29 #include <inttypes.h> |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
30 #include <limits.h> |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
31 #include <stdio.h> |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
32 #include <string.h> |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
33 #include <stdlib.h> |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
34 #include <sys/time.h> |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
35 #include "dvd_types.h" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
36 #include "nav_types.h" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
37 #include "ifo_types.h" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
38 #include "remap.h" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
39 #include "vm/decoder.h" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
40 #include "vm/vm.h" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
41 #include "dvdnav.h" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
42 #include "dvdnav_internal.h" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
43 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
44 /* |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
45 #define LOG_DEBUG |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
46 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
47 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
48 /* Searching API calls */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
49 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
50 /* Scan the ADMAP for a particular block number. */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
51 /* Return placed in vobu. */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
52 /* Returns error status */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
53 /* FIXME: Maybe need to handle seeking outside current cell. */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
54 static dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, uint32_t seekto_block, uint32_t *vobu) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
55 vobu_admap_t *admap = NULL; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
56 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
57 #ifdef LOG_DEBUG |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
58 fprintf(MSG_OUT, "libdvdnav: Seeking to target %u ...\n", seekto_block); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
59 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
60 *vobu = -1; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
61 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
62 /* Search through the VOBU_ADMAP for the nearest VOBU |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
63 * to the target block */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
64 switch(domain) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
65 case FP_DOMAIN: |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
66 case VMGM_DOMAIN: |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
67 admap = this->vm->vmgi->menu_vobu_admap; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
68 break; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
69 case VTSM_DOMAIN: |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
70 admap = this->vm->vtsi->menu_vobu_admap; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
71 break; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
72 case VTS_DOMAIN: |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
73 admap = this->vm->vtsi->vts_vobu_admap; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
74 break; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
75 default: |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
76 fprintf(MSG_OUT, "libdvdnav: Error: Unknown domain for seeking.\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
77 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
78 if(admap) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
79 uint32_t address = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
80 uint32_t vobu_start, next_vobu; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
81 int admap_entries = (admap->last_byte + 1 - VOBU_ADMAP_SIZE)/VOBU_ADMAP_SIZE; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
82 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
83 /* Search through ADMAP for best sector */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
84 vobu_start = SRI_END_OF_CELL; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
85 /* FIXME: Implement a faster search algorithm */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
86 while(address < admap_entries) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
87 next_vobu = admap->vobu_start_sectors[address]; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
88 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
89 /* fprintf(MSG_OUT, "libdvdnav: Found block %u\n", next_vobu); */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
90 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
91 if(vobu_start <= seekto_block && next_vobu > seekto_block) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
92 break; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
93 vobu_start = next_vobu; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
94 address++; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
95 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
96 *vobu = vobu_start; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
97 return DVDNAV_STATUS_OK; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
98 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
99 fprintf(MSG_OUT, "libdvdnav: admap not located\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
100 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
101 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
102 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
103 /* FIXME: right now, this function does not use the time tables but interpolates |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
104 only the cell times */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
105 dvdnav_status_t dvdnav_time_search(dvdnav_t *this, |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
106 uint64_t time) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
107 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
108 uint64_t target = time; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
109 uint64_t length = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
110 uint32_t first_cell_nr, last_cell_nr, cell_nr; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
111 int32_t found; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
112 cell_playback_t *cell; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
113 dvd_state_t *state; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
114 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
115 if(this->position_current.still != 0) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
116 printerr("Cannot seek in a still frame."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
117 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
118 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
119 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
120 pthread_mutex_lock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
121 state = &(this->vm->state); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
122 if(!state->pgc) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
123 printerr("No current PGC."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
124 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
125 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
126 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
127 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
128 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
129 this->cur_cell_time = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
130 if (this->pgc_based) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
131 first_cell_nr = 1; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
132 last_cell_nr = state->pgc->nr_of_cells; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
133 } else { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
134 /* Find start cell of program. */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
135 first_cell_nr = state->pgc->program_map[state->pgN-1]; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
136 /* Find end cell of program */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
137 if(state->pgN < state->pgc->nr_of_programs) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
138 last_cell_nr = state->pgc->program_map[state->pgN] - 1; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
139 else |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
140 last_cell_nr = state->pgc->nr_of_cells; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
141 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
142 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
143 found = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
144 for(cell_nr = first_cell_nr; (cell_nr <= last_cell_nr) && !found; cell_nr ++) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
145 cell = &(state->pgc->cell_playback[cell_nr-1]); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
146 if(cell->block_type == BLOCK_TYPE_ANGLE_BLOCK && cell->block_mode != BLOCK_MODE_FIRST_CELL) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
147 continue; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
148 length = dvdnav_convert_time(&cell->playback_time); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
149 if (target >= length) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
150 target -= length; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
151 } else { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
152 /* FIXME: there must be a better way than interpolation */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
153 target = target * (cell->last_sector - cell->first_sector + 1) / length; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
154 target += cell->first_sector; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
155 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
156 found = 1; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
157 break; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
158 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
159 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
160 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
161 if(found) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
162 uint32_t vobu; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
163 #ifdef LOG_DEBUG |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
164 fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n", |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
165 cell_nr, first_cell_nr, last_cell_nr); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
166 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
167 if (dvdnav_scan_admap(this, state->domain, target, &vobu) == DVDNAV_STATUS_OK) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
168 uint32_t start = state->pgc->cell_playback[cell_nr-1].first_sector; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
169 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
170 if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
171 #ifdef LOG_DEBUG |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
172 fprintf(MSG_OUT, "libdvdnav: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" , |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
173 state->cellN, state->blockN, target, vobu, start); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
174 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
175 this->vm->hop_channel += HOP_SEEK; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
176 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
177 return DVDNAV_STATUS_OK; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
178 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
179 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
180 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
181 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
182 fprintf(MSG_OUT, "libdvdnav: Error when seeking\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
183 printerr("Error when seeking."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
184 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
185 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
186 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
187 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
188 dvdnav_status_t dvdnav_sector_search(dvdnav_t *this, |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
189 uint64_t offset, int32_t origin) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
190 uint32_t target = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
191 uint32_t length = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
192 uint32_t first_cell_nr, last_cell_nr, cell_nr; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
193 int32_t found; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
194 cell_playback_t *cell; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
195 dvd_state_t *state; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
196 dvdnav_status_t result; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
197 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
198 if(this->position_current.still != 0) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
199 printerr("Cannot seek in a still frame."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
200 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
201 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
202 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
203 result = dvdnav_get_position(this, &target, &length); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
204 if(!result) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
205 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
206 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
207 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
208 pthread_mutex_lock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
209 state = &(this->vm->state); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
210 if(!state->pgc) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
211 printerr("No current PGC."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
212 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
213 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
214 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
215 #ifdef LOG_DEBUG |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
216 fprintf(MSG_OUT, "libdvdnav: seeking to offset=%lu pos=%u length=%u\n", offset, target, length); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
217 fprintf(MSG_OUT, "libdvdnav: Before cellN=%u blockN=%u\n", state->cellN, state->blockN); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
218 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
219 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
220 switch(origin) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
221 case SEEK_SET: |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
222 if(offset >= length) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
223 printerr("Request to seek behind end."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
224 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
225 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
226 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
227 target = offset; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
228 break; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
229 case SEEK_CUR: |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
230 if(target + offset >= length) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
231 printerr("Request to seek behind end."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
232 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
233 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
234 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
235 target += offset; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
236 break; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
237 case SEEK_END: |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
238 if(length < offset) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
239 printerr("Request to seek before start."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
240 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
241 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
242 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
243 target = length - offset; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
244 break; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
245 default: |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
246 /* Error occured */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
247 printerr("Illegal seek mode."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
248 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
249 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
250 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
251 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
252 this->cur_cell_time = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
253 if (this->pgc_based) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
254 first_cell_nr = 1; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
255 last_cell_nr = state->pgc->nr_of_cells; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
256 } else { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
257 /* Find start cell of program. */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
258 first_cell_nr = state->pgc->program_map[state->pgN-1]; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
259 /* Find end cell of program */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
260 if(state->pgN < state->pgc->nr_of_programs) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
261 last_cell_nr = state->pgc->program_map[state->pgN] - 1; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
262 else |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
263 last_cell_nr = state->pgc->nr_of_cells; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
264 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
265 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
266 found = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
267 for(cell_nr = first_cell_nr; (cell_nr <= last_cell_nr) && !found; cell_nr ++) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
268 cell = &(state->pgc->cell_playback[cell_nr-1]); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
269 if(cell->block_type == BLOCK_TYPE_ANGLE_BLOCK && cell->block_mode != BLOCK_MODE_FIRST_CELL) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
270 continue; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
271 length = cell->last_sector - cell->first_sector + 1; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
272 if (target >= length) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
273 target -= length; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
274 } else { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
275 /* convert the target sector from Cell-relative to absolute physical sector */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
276 target += cell->first_sector; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
277 found = 1; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
278 break; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
279 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
280 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
281 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
282 if(found) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
283 int32_t vobu; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
284 #ifdef LOG_DEBUG |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
285 fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n", |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
286 cell_nr, first_cell_nr, last_cell_nr); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
287 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
288 if (dvdnav_scan_admap(this, state->domain, target, &vobu) == DVDNAV_STATUS_OK) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
289 int32_t start = state->pgc->cell_playback[cell_nr-1].first_sector; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
290 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
291 if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
292 #ifdef LOG_DEBUG |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
293 fprintf(MSG_OUT, "libdvdnav: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" , |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
294 state->cellN, state->blockN, target, vobu, start); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
295 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
296 this->vm->hop_channel += HOP_SEEK; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
297 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
298 return DVDNAV_STATUS_OK; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
299 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
300 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
301 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
302 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
303 fprintf(MSG_OUT, "libdvdnav: Error when seeking\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
304 fprintf(MSG_OUT, "libdvdnav: FIXME: Implement seeking to location %u\n", target); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
305 printerr("Error when seeking."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
306 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
307 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
308 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
309 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
310 dvdnav_status_t dvdnav_part_search(dvdnav_t *this, int32_t part) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
311 int32_t title, old_part; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
312 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
313 if (dvdnav_current_title_info(this, &title, &old_part) == DVDNAV_STATUS_OK) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
314 return dvdnav_part_play(this, title, part); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
315 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
316 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
317 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
318 dvdnav_status_t dvdnav_prev_pg_search(dvdnav_t *this) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
319 pthread_mutex_lock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
320 if(!this->vm->state.pgc) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
321 printerr("No current PGC."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
322 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
323 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
324 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
325 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
326 #ifdef LOG_DEBUG |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
327 fprintf(MSG_OUT, "libdvdnav: previous chapter\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
328 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
329 if (!vm_jump_prev_pg(this->vm)) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
330 fprintf(MSG_OUT, "libdvdnav: previous chapter failed.\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
331 printerr("Skip to previous chapter failed."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
332 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
333 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
334 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
335 this->cur_cell_time = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
336 this->position_current.still = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
337 this->vm->hop_channel++; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
338 #ifdef LOG_DEBUG |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
339 fprintf(MSG_OUT, "libdvdnav: previous chapter done\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
340 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
341 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
342 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
343 return DVDNAV_STATUS_OK; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
344 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
345 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
346 dvdnav_status_t dvdnav_top_pg_search(dvdnav_t *this) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
347 pthread_mutex_lock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
348 if(!this->vm->state.pgc) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
349 printerr("No current PGC."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
350 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
351 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
352 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
353 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
354 #ifdef LOG_DEBUG |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
355 fprintf(MSG_OUT, "libdvdnav: top chapter\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
356 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
357 if (!vm_jump_top_pg(this->vm)) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
358 fprintf(MSG_OUT, "libdvdnav: top chapter failed.\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
359 printerr("Skip to top chapter failed."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
360 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
361 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
362 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
363 this->cur_cell_time = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
364 this->position_current.still = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
365 this->vm->hop_channel++; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
366 #ifdef LOG_DEBUG |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
367 fprintf(MSG_OUT, "libdvdnav: top chapter done\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
368 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
369 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
370 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
371 return DVDNAV_STATUS_OK; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
372 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
373 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
374 dvdnav_status_t dvdnav_next_pg_search(dvdnav_t *this) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
375 vm_t *try_vm; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
376 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
377 pthread_mutex_lock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
378 if(!this->vm->state.pgc) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
379 printerr("No current PGC."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
380 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
381 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
382 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
383 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
384 #ifdef LOG_DEBUG |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
385 fprintf(MSG_OUT, "libdvdnav: next chapter\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
386 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
387 /* make a copy of current VM and try to navigate the copy to the next PG */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
388 try_vm = vm_new_copy(this->vm); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
389 if (!vm_jump_next_pg(try_vm) || try_vm->stopped) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
390 vm_free_copy(try_vm); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
391 /* next_pg failed, try to jump at least to the next cell */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
392 try_vm = vm_new_copy(this->vm); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
393 vm_get_next_cell(try_vm); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
394 if (try_vm->stopped) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
395 vm_free_copy(try_vm); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
396 fprintf(MSG_OUT, "libdvdnav: next chapter failed.\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
397 printerr("Skip to next chapter failed."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
398 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
399 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
400 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
401 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
402 this->cur_cell_time = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
403 /* merge changes on success */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
404 vm_merge(this->vm, try_vm); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
405 vm_free_copy(try_vm); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
406 this->position_current.still = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
407 this->vm->hop_channel++; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
408 #ifdef LOG_DEBUG |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
409 fprintf(MSG_OUT, "libdvdnav: next chapter done\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
410 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
411 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
412 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
413 return DVDNAV_STATUS_OK; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
414 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
415 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
416 dvdnav_status_t dvdnav_menu_call(dvdnav_t *this, DVDMenuID_t menu) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
417 vm_t *try_vm; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
418 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
419 pthread_mutex_lock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
420 if(!this->vm->state.pgc) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
421 printerr("No current PGC."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
422 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
423 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
424 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
425 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
426 this->cur_cell_time = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
427 /* make a copy of current VM and try to navigate the copy to the menu */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
428 try_vm = vm_new_copy(this->vm); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
429 if ( (menu == DVD_MENU_Escape) && (this->vm->state.domain != VTS_DOMAIN)) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
430 /* Try resume */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
431 if (vm_jump_resume(try_vm) && !try_vm->stopped) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
432 /* merge changes on success */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
433 vm_merge(this->vm, try_vm); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
434 vm_free_copy(try_vm); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
435 this->position_current.still = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
436 this->vm->hop_channel++; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
437 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
438 return DVDNAV_STATUS_OK; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
439 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
440 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
441 if (menu == DVD_MENU_Escape) menu = DVD_MENU_Root; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
442 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
443 if (vm_jump_menu(try_vm, menu) && !try_vm->stopped) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
444 /* merge changes on success */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
445 vm_merge(this->vm, try_vm); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
446 vm_free_copy(try_vm); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
447 this->position_current.still = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
448 this->vm->hop_channel++; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
449 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
450 return DVDNAV_STATUS_OK; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
451 } else { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
452 vm_free_copy(try_vm); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
453 printerr("No such menu or menu not reachable."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
454 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
455 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
456 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
457 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
458 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
459 dvdnav_status_t dvdnav_get_position(dvdnav_t *this, uint32_t *pos, |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
460 uint32_t *len) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
461 uint32_t cur_sector; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
462 int32_t cell_nr, first_cell_nr, last_cell_nr; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
463 cell_playback_t *cell; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
464 dvd_state_t *state; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
465 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
466 if(!this->started) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
467 printerr("Virtual DVD machine not started."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
468 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
469 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
470 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
471 pthread_mutex_lock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
472 state = &(this->vm->state); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
473 if(!state->pgc || this->vm->stopped) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
474 printerr("No current PGC."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
475 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
476 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
477 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
478 if (this->position_current.hop_channel != this->vm->hop_channel || |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
479 this->position_current.domain != state->domain || |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
480 this->position_current.vts != state->vtsN || |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
481 this->position_current.cell_restart != state->cell_restart) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
482 printerr("New position not yet determined."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
483 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
484 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
485 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
486 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
487 /* Get current sector */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
488 cur_sector = this->vobu.vobu_start + this->vobu.blockN; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
489 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
490 if (this->pgc_based) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
491 first_cell_nr = 1; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
492 last_cell_nr = state->pgc->nr_of_cells; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
493 } else { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
494 /* Find start cell of program. */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
495 first_cell_nr = state->pgc->program_map[state->pgN-1]; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
496 /* Find end cell of program */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
497 if(state->pgN < state->pgc->nr_of_programs) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
498 last_cell_nr = state->pgc->program_map[state->pgN] - 1; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
499 else |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
500 last_cell_nr = state->pgc->nr_of_cells; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
501 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
502 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
503 *pos = -1; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
504 *len = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
505 for (cell_nr = first_cell_nr; cell_nr <= last_cell_nr; cell_nr++) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
506 cell = &(state->pgc->cell_playback[cell_nr-1]); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
507 if (cell_nr == state->cellN) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
508 /* the current sector is in this cell, |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
509 * pos is length of PG up to here + sector's offset in this cell */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
510 *pos = *len + cur_sector - cell->first_sector; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
511 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
512 *len += cell->last_sector - cell->first_sector + 1; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
513 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
514 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
515 assert((signed)*pos != -1); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
516 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
517 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
518 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
519 return DVDNAV_STATUS_OK; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
520 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
521 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
522 dvdnav_status_t dvdnav_get_position_in_title(dvdnav_t *this, |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
523 uint32_t *pos, |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
524 uint32_t *len) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
525 uint32_t cur_sector; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
526 uint32_t first_cell_nr; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
527 uint32_t last_cell_nr; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
528 cell_playback_t *first_cell; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
529 cell_playback_t *last_cell; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
530 dvd_state_t *state; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
531 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
532 state = &(this->vm->state); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
533 if(!state->pgc) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
534 printerr("No current PGC."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
535 return DVDNAV_STATUS_ERR; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
536 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
537 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
538 /* Get current sector */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
539 cur_sector = this->vobu.vobu_start + this->vobu.blockN; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
540 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
541 /* Now find first and last cells in title. */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
542 first_cell_nr = state->pgc->program_map[0]; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
543 first_cell = &(state->pgc->cell_playback[first_cell_nr-1]); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
544 last_cell_nr = state->pgc->nr_of_cells; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
545 last_cell = &(state->pgc->cell_playback[last_cell_nr-1]); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
546 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
547 *pos = cur_sector - first_cell->first_sector; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
548 *len = last_cell->last_sector - first_cell->first_sector; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
549 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
550 return DVDNAV_STATUS_OK; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
551 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
552 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
553 uint32_t dvdnav_describe_title_chapters(dvdnav_t *this, int32_t title, uint64_t **times, uint64_t *duration) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
554 int32_t retval=0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
555 uint16_t parts, i; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
556 title_info_t *ptitle = NULL; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
557 ptt_info_t *ptt = NULL; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
558 ifo_handle_t *ifo; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
559 pgc_t *pgc; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
560 cell_playback_t *cell; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
561 uint64_t length, *tmp=NULL; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
562 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
563 *times = NULL; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
564 *duration = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
565 pthread_mutex_lock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
566 if(!this->vm->vmgi) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
567 printerr("Bad VM state or missing VTSI."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
568 goto fail; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
569 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
570 if(!this->started) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
571 /* don't report an error but be nice */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
572 vm_start(this->vm); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
573 this->started = 1; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
574 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
575 ifo = vm_get_title_ifo(this->vm, title); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
576 if(!ifo || !ifo->vts_pgcit) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
577 printerr("Couldn't open IFO for chosen title, exit."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
578 goto fail; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
579 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
580 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
581 ptitle = &this->vm->vmgi->tt_srpt->title[title-1]; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
582 parts = ptitle->nr_of_ptts; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
583 ptt = ifo->vts_ptt_srpt->title[ptitle->vts_ttn-1].ptt; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
584 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
585 tmp = calloc(1, sizeof(uint64_t)*parts); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
586 if(!tmp) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
587 goto fail; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
588 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
589 length = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
590 for(i=0; i<parts; i++) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
591 uint32_t cellnr, endcellnr; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
592 pgc = ifo->vts_pgcit->pgci_srp[ptt[i].pgcn-1].pgc; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
593 if(ptt[i].pgn > pgc->nr_of_programs) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
594 printerr("WRONG part number."); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
595 goto fail; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
596 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
597 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
598 cellnr = pgc->program_map[ptt[i].pgn-1]; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
599 if(ptt[i].pgn < pgc->nr_of_programs) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
600 endcellnr = pgc->program_map[ptt[i].pgn]; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
601 else |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
602 endcellnr = 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
603 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
604 do { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
605 cell = &pgc->cell_playback[cellnr-1]; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
606 if(!(cell->block_type == BLOCK_TYPE_ANGLE_BLOCK && |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
607 cell->block_mode != BLOCK_MODE_FIRST_CELL |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
608 )) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
609 { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
610 tmp[i] = length + dvdnav_convert_time(&cell->playback_time); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
611 length = tmp[i]; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
612 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
613 cellnr++; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
614 } while(cellnr < endcellnr); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
615 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
616 *duration = length; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
617 vm_ifo_close(ifo); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
618 retval = parts; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
619 *times = tmp; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
620 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
621 fail: |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
622 pthread_mutex_unlock(&this->vm_lock); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
623 if(!retval && tmp) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
624 free(tmp); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
625 return retval; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
626 } |