Mercurial > libdvdnav.hg
annotate dvdnav.c @ 115:b527b7cbfb19 src
fix seek detection
author | mroi |
---|---|
date | Mon, 24 Feb 2003 18:19:27 +0000 |
parents | b6834e6359cf |
children | 4d711d0518e9 |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright (C) 2000 Rich Wareham <richwareham@users.sourceforge.net> | |
3 * | |
4 * This file is part of libdvdnav, a DVD navigation library. | |
5 * | |
6 * libdvdnav is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * libdvdnav is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
19 * | |
20 * $Id$ | |
21 * | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include "config.h" | |
26 #endif | |
27 | |
31 | 28 /* |
29 #define LOG_DEBUG | |
30 */ | |
31 | |
0 | 32 #include <pthread.h> |
33 #include "dvdnav_internal.h" | |
34 #include "read_cache.h" | |
35 | |
36 #include <dvdread/nav_read.h> | |
37 | |
38 #include <stdlib.h> | |
39 #include <stdio.h> | |
84 | 40 #include <sys/time.h> |
0 | 41 |
97
c1dff1899bda
First patch for personalized dvd viewing. I have not tested it yet.
jcdutton
parents:
92
diff
changeset
|
42 #include "remap.h" |
c1dff1899bda
First patch for personalized dvd viewing. I have not tested it yet.
jcdutton
parents:
92
diff
changeset
|
43 |
114 | 44 static dvdnav_status_t dvdnav_clear(dvdnav_t * this) { |
45 /* clear everything except file, vm, mutex, readahead */ | |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
46 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
47 if (this->file) DVDCloseFile(this->file); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
48 this->file = NULL; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
49 this->open_vtsN = -1; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
50 this->open_domain = -1; |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
51 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
52 memset(&this->pci,0,sizeof(this->pci)); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
53 memset(&this->dsi,0,sizeof(this->dsi)); |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
54 |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
55 /* Set initial values of flags */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
56 this->position_current.still = 0; |
23 | 57 this->skip_still = 0; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
58 this->spu_clut_changed = 0; |
114 | 59 this->started = 0; |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
60 |
34
1f29402ef2ef
'Objectified' the read-ahead cache in preparation to implement a 'proper' threaded cache a-la that recommended in the DVD Demystified book.
richwareham
parents:
33
diff
changeset
|
61 dvdnav_read_cache_clear(this->cache); |
1f29402ef2ef
'Objectified' the read-ahead cache in preparation to implement a 'proper' threaded cache a-la that recommended in the DVD Demystified book.
richwareham
parents:
33
diff
changeset
|
62 |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
63 return S_OK; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
64 } |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
65 |
114 | 66 dvdnav_status_t dvdnav_open(dvdnav_t** dest, const char *path) { |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
67 dvdnav_t *this; |
84 | 68 struct timeval time; |
0 | 69 |
70 /* Create a new structure */ | |
100 | 71 fprintf(MSG_OUT, "libdvdnav: Using dvdnav version %s from http://dvd.sf.net\n", VERSION); |
82 | 72 |
0 | 73 (*dest) = NULL; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
74 this = (dvdnav_t*)malloc(sizeof(dvdnav_t)); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
75 if(!this) |
114 | 76 return S_ERR; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
77 memset(this, 0, (sizeof(dvdnav_t) ) ); /* Make sure this structure is clean */ |
114 | 78 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
79 pthread_mutex_init(&this->vm_lock, NULL); |
0 | 80 /* Initialise the error string */ |
81 printerr(""); | |
82 | |
83 /* Initialise the VM */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
84 this->vm = vm_new_vm(); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
85 if(!this->vm) { |
114 | 86 printerr("Error initialising the DVD VM."); |
92 | 87 pthread_mutex_destroy(&this->vm_lock); |
88 free(this); | |
0 | 89 return S_ERR; |
90 } | |
114 | 91 if(!vm_reset(this->vm, path)) { |
92 printerr("Error starting the VM / opening the DVD device."); | |
92 | 93 pthread_mutex_destroy(&this->vm_lock); |
94 vm_free_vm(this->vm); | |
95 free(this); | |
0 | 96 return S_ERR; |
97 } | |
98 | |
99 /* Set the path. FIXME: Is a deep copy 'right' */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
100 strncpy(this->path, path, MAX_PATH_LEN); |
0 | 101 |
102 /* Pre-open and close a file so that the CSS-keys are cached. */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
103 this->file = DVDOpenFile(vm_get_dvd_reader(this->vm), 0, DVD_READ_MENU_VOBS); |
0 | 104 |
34
1f29402ef2ef
'Objectified' the read-ahead cache in preparation to implement a 'proper' threaded cache a-la that recommended in the DVD Demystified book.
richwareham
parents:
33
diff
changeset
|
105 /* Start the read-ahead cache. */ |
1f29402ef2ef
'Objectified' the read-ahead cache in preparation to implement a 'proper' threaded cache a-la that recommended in the DVD Demystified book.
richwareham
parents:
33
diff
changeset
|
106 this->cache = dvdnav_read_cache_new(this); |
84 | 107 |
114 | 108 /* Seed the random numbers. So that the DVD VM Command rand() |
109 * gives a different start value each time a DVD is played. */ | |
110 gettimeofday(&time, NULL); | |
84 | 111 srand(time.tv_usec); |
112 | |
114 | 113 dvdnav_clear(this); |
114 | |
115 (*dest) = this; | |
0 | 116 return S_OK; |
117 } | |
118 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
119 dvdnav_status_t dvdnav_close(dvdnav_t *this) { |
114 | 120 |
31 | 121 #ifdef LOG_DEBUG |
76 | 122 fprintf(MSG_OUT, "libdvdnav: close:called\n"); |
31 | 123 #endif |
34
1f29402ef2ef
'Objectified' the read-ahead cache in preparation to implement a 'proper' threaded cache a-la that recommended in the DVD Demystified book.
richwareham
parents:
33
diff
changeset
|
124 |
114 | 125 if(!this) { |
126 printerr("Passed a NULL pointer."); | |
127 return S_ERR; | |
128 } | |
129 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
130 if (this->file) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
131 DVDCloseFile(this->file); |
31 | 132 #ifdef LOG_DEBUG |
76 | 133 fprintf(MSG_OUT, "libdvdnav: close:file closing\n"); |
31 | 134 #endif |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
135 this->file = NULL; |
0 | 136 } |
137 | |
138 /* Free the VM */ | |
114 | 139 if(this->vm) |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
140 vm_free_vm(this->vm); |
114 | 141 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
142 pthread_mutex_destroy(&this->vm_lock); |
60 | 143 |
144 /* We leave the final freeing of the entire structure to the cache, | |
145 * because we don't know, if there are still buffers out in the wild, | |
146 * that must return first. */ | |
114 | 147 if(this->cache) |
60 | 148 dvdnav_read_cache_free(this->cache); |
114 | 149 else |
150 free(this); | |
0 | 151 |
152 return S_OK; | |
153 } | |
154 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
155 dvdnav_status_t dvdnav_reset(dvdnav_t *this) { |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
156 dvdnav_status_t result; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
157 |
31 | 158 #ifdef LOG_DEBUG |
76 | 159 fprintf(MSG_OUT, "libdvdnav: reset:called\n"); |
31 | 160 #endif |
114 | 161 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
162 if(!this) { |
114 | 163 printerr("Passed a NULL pointer."); |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
164 return S_ERR; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
165 } |
114 | 166 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
167 pthread_mutex_lock(&this->vm_lock); |
114 | 168 |
31 | 169 #ifdef LOG_DEBUG |
76 | 170 fprintf(MSG_OUT, "libdvdnav: reseting vm\n"); |
31 | 171 #endif |
114 | 172 if(!vm_reset(this->vm, NULL)) { |
173 printerr("Error restarting the VM."); | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
174 pthread_mutex_unlock(&this->vm_lock); |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
175 return S_ERR; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
176 } |
31 | 177 #ifdef LOG_DEBUG |
76 | 178 fprintf(MSG_OUT, "libdvdnav: clearing dvdnav\n"); |
31 | 179 #endif |
114 | 180 result = dvdnav_clear(this); |
181 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
182 pthread_mutex_unlock(&this->vm_lock); |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
183 return result; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
184 } |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
185 |
114 | 186 dvdnav_status_t dvdnav_path(dvdnav_t *this, const char** path) { |
187 | |
188 if(!this || !path) { | |
189 printerr("Passed a NULL pointer."); | |
0 | 190 return S_ERR; |
191 } | |
192 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
193 (*path) = this->path; |
0 | 194 |
195 return S_OK; | |
196 } | |
197 | |
114 | 198 const char* dvdnav_err_to_string(dvdnav_t *this) { |
199 | |
200 if(!this) | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
201 return "Hey! You gave me a NULL pointer you naughty person!"; |
0 | 202 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
203 return this->err_str; |
0 | 204 } |
205 | |
114 | 206 /* |
0 | 207 * Returns 1 if block contains NAV packet, 0 otherwise. |
208 * Precesses said NAV packet if present. | |
209 * | |
210 * Most of the code in here is copied from xine's MPEG demuxer | |
211 * so any bugs which are found in that should be corrected here also. | |
212 */ | |
114 | 213 static int dvdnav_decode_packet(dvdnav_t *this, uint8_t *p, dsi_t *nav_dsi, pci_t *nav_pci) { |
214 int bMpeg1 = 0; | |
0 | 215 uint32_t nHeaderLen; |
216 uint32_t nPacketLen; | |
217 uint32_t nStreamID; | |
218 | |
219 if (p[3] == 0xBA) { /* program stream pack header */ | |
220 int nStuffingBytes; | |
221 | |
222 bMpeg1 = (p[4] & 0x40) == 0; | |
223 | |
224 if (bMpeg1) { | |
114 | 225 p += 12; |
0 | 226 } else { /* mpeg2 */ |
227 nStuffingBytes = p[0xD] & 0x07; | |
228 p += 14 + nStuffingBytes; | |
229 } | |
230 } | |
231 | |
232 if (p[3] == 0xbb) { /* program stream system header */ | |
233 nHeaderLen = (p[4] << 8) | p[5]; | |
234 p += 6 + nHeaderLen; | |
235 } | |
236 | |
237 /* we should now have a PES packet here */ | |
238 if (p[0] || p[1] || (p[2] != 1)) { | |
76 | 239 fprintf(MSG_OUT, "libdvdnav: demux error! %02x %02x %02x (should be 0x000001) \n",p[0],p[1],p[2]); |
0 | 240 return 0; |
241 } | |
242 | |
243 nPacketLen = p[4] << 8 | p[5]; | |
244 nStreamID = p[3]; | |
245 | |
246 nHeaderLen = 6; | |
247 p += nHeaderLen; | |
248 | |
249 if (nStreamID == 0xbf) { /* Private stream 2 */ | |
114 | 250 #if 0 |
251 int i; | |
252 fprintf(MSG_OUT, "libdvdnav: nav packet=%u\n",p-p_start-6); | |
253 for(i=0;i<80;i++) | |
254 fprintf(MSG_OUT, "%02x ",p[i-6]); | |
255 fprintf(MSG_OUT, "\n"); | |
256 #endif | |
257 | |
0 | 258 if(p[0] == 0x00) { |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
259 navRead_PCI(nav_pci, p+1); |
0 | 260 } |
261 | |
262 p += nPacketLen; | |
263 | |
264 /* We should now have a DSI packet. */ | |
265 if(p[6] == 0x01) { | |
266 nPacketLen = p[4] << 8 | p[5]; | |
267 p += 6; | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
268 navRead_DSI(nav_dsi, p+1); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
269 } |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
270 return 1; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
271 } |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
272 return 0; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
273 } |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
274 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
275 /* DSI is used for most angle stuff. |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
276 * PCI is used for only non-seemless angle stuff |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
277 */ |
114 | 278 static int dvdnav_get_vobu(dvdnav_t *this, dsi_t *nav_dsi, pci_t *nav_pci, dvdnav_vobu_t *vobu) { |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
279 uint32_t next; |
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
280 int angle, num_angle; |
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
281 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
282 vobu->vobu_start = nav_dsi->dsi_gi.nv_pck_lbn; /* Absolute offset from start of disk */ |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
283 vobu->vobu_length = nav_dsi->dsi_gi.vobu_ea; /* Relative offset from vobu_start */ |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
284 |
43
0ba15bf3dc25
Biiiiiiig change to let doxygen generate some docs for the library. Note that I'm in no way sure that the autoconf stuff plays nice.
richwareham
parents:
42
diff
changeset
|
285 /* |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
286 * If we're not at the end of this cell, we can determine the next |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
287 * VOBU to display using the VOBU_SRI information section of the |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
288 * DSI. Using this value correctly follows the current angle, |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
289 * avoiding the doubled scenes in The Matrix, and makes our life |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
290 * really happy. |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
291 * |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
292 * vobu_next is an offset value, 0x3fffffff = SRI_END_OF_CELL |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
293 * DVDs are about 6 Gigs, which is only up to 0x300000 blocks |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
294 * Should really assert if bit 31 != 1 |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
295 */ |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
296 |
114 | 297 #if 0 |
298 /* Old code -- may still be useful one day */ | |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
299 if(nav_dsi->vobu_sri.next_vobu != SRI_END_OF_CELL ) { |
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
300 vobu->vobu_next = ( nav_dsi->vobu_sri.next_vobu & 0x3fffffff ); |
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
301 } else { |
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
302 vobu->vobu_next = vobu->vobu_length; |
114 | 303 } |
304 #else | |
305 /* Relative offset from vobu_start */ | |
306 vobu->vobu_next = ( nav_dsi->vobu_sri.next_vobu & 0x3fffffff ); | |
307 #endif | |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
308 |
114 | 309 vm_get_angle_info(this->vm, &angle, &num_angle); |
310 | |
311 /* FIMXE: The angle reset doesn't work for some reason for the moment */ | |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
312 #if 0 |
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
313 if((num_angle < angle) && (angle != 1)) { |
114 | 314 fprintf(MSG_OUT, "libdvdnav: angle ends!\n"); |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
315 |
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
316 /* This is to switch back to angle one when we |
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
317 * finish with angles. */ |
114 | 318 dvdnav_angle_change(this, 1); |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
319 } |
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
320 #endif |
0 | 321 |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
322 if(num_angle != 0) { |
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
323 |
114 | 324 if((next = nav_pci->nsml_agli.nsml_agl_dsta[angle-1]) != 0) { |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
325 if((next & 0x3fffffff) != 0) { |
114 | 326 if(next & 0x80000000) |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
327 vobu->vobu_next = - (int32_t)(next & 0x3fffffff); |
114 | 328 else |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
329 vobu->vobu_next = + (int32_t)(next & 0x3fffffff); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
330 } |
114 | 331 } else if((next = nav_dsi->sml_agli.data[angle-1].address) != 0) { |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
332 vobu->vobu_length = nav_dsi->sml_pbi.ilvu_ea; |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
333 |
114 | 334 if((next & 0x80000000) && (next != 0x7fffffff)) |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
335 vobu->vobu_next = - (int32_t)(next & 0x3fffffff); |
114 | 336 else |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
337 vobu->vobu_next = + (int32_t)(next & 0x3fffffff); |
0 | 338 } |
339 } | |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
340 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
341 return 1; |
0 | 342 } |
60 | 343 |
114 | 344 /* |
345 * These are the main get_next_block function which actually get the media stream video and audio etc. | |
346 * | |
347 * There are two versions: The second one is using the zero-copy read ahead cache and therefore | |
348 * hands out pointers targetting directly into the cache. | |
349 * The first one uses a memcopy to fill this cache block into the application provided memory. | |
350 * The benefit of this first one is that no special memory management is needed. The application is | |
351 * the only one responsible of allocating and freeing the memory associated with the pointer. | |
352 * The drawback is the additional memcopy. | |
28 | 353 */ |
60 | 354 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
355 dvdnav_status_t dvdnav_get_next_block(dvdnav_t *this, unsigned char *buf, |
114 | 356 int *event, int *len) { |
60 | 357 unsigned char *block; |
358 dvdnav_status_t status; | |
359 | |
360 block = buf; | |
361 status = dvdnav_get_next_cache_block(this, &block, event, len); | |
114 | 362 if (status == S_OK && block != buf) { |
60 | 363 /* we received a block from the cache, copy it, so we can give it back */ |
364 memcpy(buf, block, DVD_VIDEO_LB_LEN); | |
365 dvdnav_free_cache_block(this, block); | |
366 } | |
367 return status; | |
368 } | |
369 | |
370 dvdnav_status_t dvdnav_get_next_cache_block(dvdnav_t *this, unsigned char **buf, | |
114 | 371 int *event, int *len) { |
0 | 372 dvd_state_t *state; |
373 int result; | |
114 | 374 |
60 | 375 if(!this || !event || !len || !buf || !*buf) { |
114 | 376 printerr("Passed a NULL pointer."); |
0 | 377 return S_ERR; |
378 } | |
114 | 379 |
380 pthread_mutex_lock(&this->vm_lock); | |
0 | 381 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
382 if(!this->started) { |
0 | 383 /* Start the VM */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
384 vm_start(this->vm); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
385 this->started = 1; |
0 | 386 } |
387 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
388 state = &(this->vm->state); |
0 | 389 (*event) = DVDNAV_NOP; |
390 (*len) = 0; | |
391 | |
392 /* Check the STOP flag */ | |
114 | 393 if(this->vm->stopped) { |
0 | 394 (*event) = DVDNAV_STOP; |
114 | 395 this->started = 0; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
396 pthread_mutex_unlock(&this->vm_lock); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
397 return S_OK; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
398 } |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
399 |
114 | 400 vm_position_get(this->vm, &this->position_next); |
0 | 401 |
114 | 402 #ifdef TRACE |
403 fprintf(MSG_OUT, "libdvdnav: POS-NEXT "); | |
404 vm_position_print(this->vm, &this->position_next); | |
405 fprintf(MSG_OUT, "libdvdnav: POS-CUR "); | |
406 vm_position_print(this->vm, &this->position_current); | |
31 | 407 #endif |
114 | 408 |
409 /* did we hop? */ | |
410 if(this->position_current.hop_channel != this->position_next.hop_channel) { | |
411 (*event) = DVDNAV_HOP_CHANNEL; | |
58 | 412 #ifdef LOG_DEBUG |
114 | 413 fprintf(MSG_OUT, "libdvdnav: HOP_CHANNEL\n"); |
31 | 414 #endif |
115 | 415 if (this->position_next.hop_channel - this->position_current.hop_channel >= HOP_SEEK) { |
114 | 416 int num_angles = 0, current; |
417 | |
418 /* we seeked -> check for multiple angles */ | |
419 vm_get_angle_info(this->vm, ¤t, &num_angles); | |
420 if (num_angles > 1) { | |
421 int result, block; | |
422 /* we have to skip the first VOBU when seeking in a multiangle feature, | |
423 * because it might belong to the wrong angle */ | |
424 block = this->position_next.cell_start + this->position_next.block; | |
425 result = dvdnav_read_cache_block(this->cache, block, 1, buf); | |
426 if(result <= 0) { | |
427 printerr("Error reading NAV packet."); | |
428 pthread_mutex_unlock(&this->vm_lock); | |
429 return S_ERR; | |
430 } | |
431 /* Decode nav into pci and dsi. Then get next VOBU info. */ | |
432 if(!dvdnav_decode_packet(this, *buf, &this->dsi, &this->pci)) { | |
433 printerr("Expected NAV packet but none found."); | |
434 pthread_mutex_unlock(&this->vm_lock); | |
435 return S_ERR; | |
436 } | |
437 dvdnav_get_vobu(this, &this->dsi, &this->pci, &this->vobu); | |
438 /* skip to next, if there is a next */ | |
439 if (this->vobu.vobu_next != SRI_END_OF_CELL) { | |
440 this->vobu.vobu_start += this->vobu.vobu_next; | |
441 this->vobu.vobu_next = 0; | |
442 } | |
443 /* update VM state */ | |
444 this->vm->state.blockN = this->vobu.vobu_start - this->position_next.cell_start; | |
445 } | |
446 } | |
447 this->position_current.hop_channel = this->position_next.hop_channel; | |
448 /* Make blockN > vobu_length to do expected_nav */ | |
449 this->vobu.vobu_length = 0; | |
450 this->vobu.blockN = 1; | |
30 | 451 pthread_mutex_unlock(&this->vm_lock); |
452 return S_OK; | |
0 | 453 } |
454 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
455 /* Check to see if we need to change the currently opened VOB */ |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
456 if((this->position_current.vts != this->position_next.vts) || |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
457 (this->position_current.domain != this->position_next.domain)) { |
0 | 458 dvd_read_domain_t domain; |
459 int vtsN; | |
460 dvdnav_vts_change_event_t vts_event; | |
461 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
462 if(this->file) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
463 DVDCloseFile(this->file); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
464 this->file = NULL; |
0 | 465 } |
466 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
467 vts_event.old_vtsN = this->open_vtsN; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
468 vts_event.old_domain = this->open_domain; |
0 | 469 |
114 | 470 /* Use the DOMAIN to find whether to open menu or title VOBs */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
471 switch(this->position_next.domain) { |
114 | 472 case FP_DOMAIN: |
473 case VMGM_DOMAIN: | |
0 | 474 domain = DVD_READ_MENU_VOBS; |
475 vtsN = 0; | |
476 break; | |
114 | 477 case VTSM_DOMAIN: |
0 | 478 domain = DVD_READ_MENU_VOBS; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
479 vtsN = this->position_next.vts; |
0 | 480 break; |
114 | 481 case VTS_DOMAIN: |
0 | 482 domain = DVD_READ_TITLE_VOBS; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
483 vtsN = this->position_next.vts; |
0 | 484 break; |
114 | 485 default: |
0 | 486 printerr("Unknown domain when changing VTS."); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
487 pthread_mutex_unlock(&this->vm_lock); |
0 | 488 return S_ERR; |
489 } | |
490 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
491 this->position_current.vts = this->position_next.vts; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
492 this->position_current.domain = this->position_next.domain; |
34
1f29402ef2ef
'Objectified' the read-ahead cache in preparation to implement a 'proper' threaded cache a-la that recommended in the DVD Demystified book.
richwareham
parents:
33
diff
changeset
|
493 dvdnav_read_cache_clear(this->cache); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
494 this->file = DVDOpenFile(vm_get_dvd_reader(this->vm), vtsN, domain); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
495 vts_event.new_vtsN = this->position_next.vts; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
496 vts_event.new_domain = this->position_next.domain; |
0 | 497 |
498 /* If couldn't open the file for some reason, moan */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
499 if(this->file == NULL) { |
0 | 500 printerrf("Error opening vtsN=%i, domain=%i.", vtsN, domain); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
501 pthread_mutex_unlock(&this->vm_lock); |
0 | 502 return S_ERR; |
503 } | |
504 | |
505 /* File opened successfully so return a VTS change event */ | |
506 (*event) = DVDNAV_VTS_CHANGE; | |
114 | 507 #ifdef LOG_DEBUG |
508 fprintf(MSG_OUT, "libdvdnav: VTS_CHANGE\n"); | |
509 #endif | |
510 (*len) = sizeof(vts_event); | |
60 | 511 memcpy(*buf, &(vts_event), sizeof(vts_event)); |
0 | 512 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
513 this->spu_clut_changed = 1; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
514 this->position_current.cell = -1; /* Force an update */ |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
515 this->position_current.spu_channel = -1; /* Force an update */ |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
516 this->position_current.audio_channel = -1; /* Force an update */; |
0 | 517 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
518 pthread_mutex_unlock(&this->vm_lock); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
519 return S_OK; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
520 } |
114 | 521 |
522 /* Check if the cell changed */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
523 if( (this->position_current.cell != this->position_next.cell) || |
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
45
diff
changeset
|
524 (this->position_current.cell_restart != this->position_next.cell_restart) || |
114 | 525 (this->position_current.cell_start != this->position_next.cell_start) ) { |
526 | |
527 (*event) = DVDNAV_CELL_CHANGE; | |
528 #ifdef LOG_DEBUG | |
529 fprintf(MSG_OUT, "libdvdnav: CELL_CHANGE\n"); | |
530 #endif | |
531 (*len) = 0; | |
532 | |
533 this->position_current.cell = this->position_next.cell; | |
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
45
diff
changeset
|
534 this->position_current.cell_restart = this->position_next.cell_restart; |
114 | 535 this->position_current.cell_start = this->position_next.cell_start; |
536 this->position_current.block = this->position_next.block; | |
537 | |
538 /* vobu info is used for mid cell resumes */ | |
539 this->vobu.vobu_start = this->position_next.cell_start + this->position_next.block; | |
540 this->vobu.vobu_next = 0; | |
541 /* Make blockN > vobu_length to do expected_nav */ | |
542 this->vobu.vobu_length = 0; | |
543 this->vobu.blockN = 1; | |
544 | |
545 /* update the spu palette at least on PGC changes */ | |
546 this->spu_clut_changed = 1; | |
547 this->position_current.spu_channel = -1; /* Force an update */ | |
548 this->position_current.audio_channel = -1; /* Force an update */ | |
549 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
550 pthread_mutex_unlock(&this->vm_lock); |
0 | 551 return S_OK; |
552 } | |
553 | |
114 | 554 /* has the CLUT changed? */ |
555 if(this->spu_clut_changed) { | |
556 (*event) = DVDNAV_SPU_CLUT_CHANGE; | |
557 #ifdef LOG_DEBUG | |
558 fprintf(MSG_OUT, "libdvdnav: SPU_CLUT_CHANGE\n"); | |
559 #endif | |
560 (*len) = 16 * sizeof(uint32_t); | |
561 memcpy(*buf, &(state->pgc->palette), 16 * sizeof(uint32_t)); | |
562 this->spu_clut_changed = 0; | |
563 pthread_mutex_unlock(&this->vm_lock); | |
564 return S_OK; | |
565 } | |
566 | |
567 /* has the SPU channel changed? */ | |
568 if(this->position_current.spu_channel != this->position_next.spu_channel) { | |
569 dvdnav_spu_stream_change_event_t stream_change; | |
570 | |
571 (*event) = DVDNAV_SPU_STREAM_CHANGE; | |
572 #ifdef LOG_DEBUG | |
573 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE\n"); | |
574 #endif | |
575 (*len) = sizeof(dvdnav_spu_stream_change_event_t); | |
576 stream_change.physical_wide = vm_get_subp_active_stream(this->vm, 0); | |
577 stream_change.physical_letterbox = vm_get_subp_active_stream(this->vm, 1); | |
578 stream_change.physical_pan_scan = vm_get_subp_active_stream(this->vm, 2); | |
579 memcpy(*buf, &(stream_change), sizeof(dvdnav_spu_stream_change_event_t)); | |
580 this->position_current.spu_channel = this->position_next.spu_channel; | |
581 #ifdef LOG_DEBUG | |
582 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_wide=%d\n",stream_change.physical_wide); | |
583 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_letterbox=%d\n",stream_change.physical_letterbox); | |
584 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_pan_scan=%d\n",stream_change.physical_pan_scan); | |
585 #endif | |
586 if (stream_change.physical_wide != -1 && | |
587 stream_change.physical_letterbox != -1 && | |
588 stream_change.physical_pan_scan != -1) { | |
589 #ifdef LOG_DEBUG | |
590 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE returning S_OK\n"); | |
591 #endif | |
592 pthread_mutex_unlock(&this->vm_lock); | |
593 return S_OK; | |
594 } | |
595 } | |
0 | 596 |
114 | 597 /* has the audio channel changed? */ |
598 if(this->position_current.audio_channel != this->position_next.audio_channel) { | |
599 dvdnav_audio_stream_change_event_t stream_change; | |
600 | |
601 (*event) = DVDNAV_AUDIO_STREAM_CHANGE; | |
602 #ifdef LOG_DEBUG | |
603 fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE\n"); | |
604 #endif | |
605 (*len) = sizeof(dvdnav_audio_stream_change_event_t); | |
606 stream_change.physical = vm_get_audio_active_stream( this->vm ); | |
607 memcpy(*buf, &(stream_change), sizeof( dvdnav_audio_stream_change_event_t)); | |
608 this->position_current.audio_channel = this->position_next.audio_channel; | |
609 #ifdef LOG_DEBUG | |
610 fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE stream_id=%d returning S_OK\n",stream_change.physical); | |
611 #endif | |
612 pthread_mutex_unlock(&this->vm_lock); | |
613 return S_OK; | |
614 } | |
615 | |
616 /* Check the HIGHLIGHT flag */ | |
617 if(this->position_current.button != this->position_next.button) { | |
618 dvdnav_highlight_event_t hevent; | |
619 | |
620 (*event) = DVDNAV_HIGHLIGHT; | |
621 #ifdef LOG_DEBUG | |
622 fprintf(MSG_OUT, "libdvdnav: HIGHLIGHT\n"); | |
623 #endif | |
624 (*len) = sizeof(hevent); | |
625 hevent.display = 1; | |
626 hevent.buttonN = this->position_next.button; | |
627 memcpy(*buf, &(hevent), sizeof(hevent)); | |
628 this->position_current.button = this->position_next.button; | |
629 pthread_mutex_unlock(&this->vm_lock); | |
630 return S_OK; | |
631 } | |
632 | |
633 /* Check the STILLFRAME flag */ | |
634 if(this->position_current.still != 0) { | |
635 dvdnav_still_event_t still_event; | |
636 | |
637 (*event) = DVDNAV_STILL_FRAME; | |
638 #ifdef LOG_DEBUG | |
639 fprintf(MSG_OUT, "libdvdnav: STILL_FRAME\n"); | |
640 #endif | |
641 (*len) = sizeof(dvdnav_still_event_t); | |
642 still_event.length = this->position_current.still; | |
643 memcpy(*buf, &(still_event), sizeof(dvdnav_still_event_t)); | |
644 pthread_mutex_unlock(&this->vm_lock); | |
645 return S_OK; | |
646 } | |
647 | |
648 /* Have we reached the end of a VOBU? */ | |
649 if (this->vobu.blockN >= this->vobu.vobu_length) { | |
650 | |
651 /* Have we reached the end of a cell? */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
652 if(this->vobu.vobu_next == SRI_END_OF_CELL) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
653 /* End of Cell from NAV DSI info */ |
31 | 654 #ifdef LOG_DEBUG |
76 | 655 fprintf(MSG_OUT, "libdvdnav: Still set to %x\n", this->position_next.still); |
31 | 656 #endif |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
657 this->position_current.still = this->position_next.still; |
0 | 658 |
23 | 659 if( this->position_current.still == 0 || this->skip_still ) { |
114 | 660 /* no active cell still -> get us to the next cell */ |
661 vm_get_next_cell(this->vm); | |
662 this->position_current.still = 0; /* still gets activated at end of cell */ | |
663 this->skip_still = 0; | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
664 } |
114 | 665 /* handle related state changes in next iteration */ |
666 (*event) = DVDNAV_NOP; | |
667 (*len) = 0; | |
668 pthread_mutex_unlock(&this->vm_lock); | |
669 return S_OK; | |
670 } | |
0 | 671 |
114 | 672 /* Perform remapping jump if necessary (this is always a |
0 | 673 * VOBU boundary). */ |
114 | 674 if (this->vm->map) { |
675 this->vobu.vobu_next = remap_block( this->vm->map, | |
676 this->vm->state.domain, this->vm->state.TTN_REG, | |
677 this->vm->state.pgN, | |
678 this->vobu.vobu_start, this->vobu.vobu_next); | |
679 } | |
0 | 680 |
114 | 681 /* at the start of the next VOBU -> expecting NAV packet */ |
45 | 682 result = dvdnav_read_cache_block(this->cache, this->vobu.vobu_start + this->vobu.vobu_next, 1, buf); |
0 | 683 |
684 if(result <= 0) { | |
685 printerr("Error reading NAV packet."); | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
686 pthread_mutex_unlock(&this->vm_lock); |
0 | 687 return S_ERR; |
688 } | |
114 | 689 /* Decode nav into pci and dsi. Then get next VOBU info. */ |
690 if(!dvdnav_decode_packet(this, *buf, &this->dsi, &this->pci)) { | |
0 | 691 printerr("Expected NAV packet but none found."); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
692 pthread_mutex_unlock(&this->vm_lock); |
0 | 693 return S_ERR; |
694 } | |
114 | 695 /* We need to update the vm state->blockN with which VOBU we are in. |
696 * This is so RSM resumes to the VOBU level and not just the CELL level. | |
28 | 697 */ |
114 | 698 this->vm->state.blockN = this->vobu.vobu_start - this->position_current.cell_start; |
699 | |
700 dvdnav_get_vobu(this, &this->dsi, &this->pci, &this->vobu); | |
701 this->vobu.blockN = 0; | |
702 /* Give the cache a hint about the size of next VOBU. | |
703 * This improves pre-caching, because the VOBU will almost certainly be read entirely. | |
45 | 704 */ |
705 dvdnav_pre_cache_blocks(this->cache, this->vobu.vobu_start+1, this->vobu.vobu_length+1); | |
0 | 706 |
707 /* Successfully got a NAV packet */ | |
708 (*event) = DVDNAV_NAV_PACKET; | |
114 | 709 #ifdef LOG_DEBUG |
710 fprintf(MSG_OUT, "libdvdnav: NAV_PACKET\n"); | |
711 #endif | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
712 (*len) = 2048; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
713 pthread_mutex_unlock(&this->vm_lock); |
0 | 714 return S_OK; |
715 } | |
716 | |
717 /* If we've got here, it must just be a normal block. */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
718 if(!this->file) { |
114 | 719 printerr("Attempting to read without opening file."); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
720 pthread_mutex_unlock(&this->vm_lock); |
0 | 721 return S_ERR; |
722 } | |
723 | |
114 | 724 this->vobu.blockN++; |
34
1f29402ef2ef
'Objectified' the read-ahead cache in preparation to implement a 'proper' threaded cache a-la that recommended in the DVD Demystified book.
richwareham
parents:
33
diff
changeset
|
725 result = dvdnav_read_cache_block(this->cache, this->vobu.vobu_start + this->vobu.blockN, 1, buf); |
0 | 726 if(result <= 0) { |
727 printerr("Error reading from DVD."); | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
728 pthread_mutex_unlock(&this->vm_lock); |
0 | 729 return S_ERR; |
730 } | |
114 | 731 (*event) = DVDNAV_BLOCK_OK; |
0 | 732 (*len) = 2048; |
733 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
734 pthread_mutex_unlock(&this->vm_lock); |
0 | 735 return S_OK; |
736 } | |
737 | |
114 | 738 dvdnav_status_t dvdnav_get_title_string(dvdnav_t *this, const char **title_str) { |
739 | |
740 if(!this || !title_str) { | |
741 printerr("Passed a NULL pointer."); | |
742 return S_ERR; | |
743 } | |
744 | |
745 (*title_str) = this->vm->dvd_name; | |
746 return S_OK; | |
747 } | |
748 | |
749 uint8_t dvdnav_get_video_aspect(dvdnav_t *this) { | |
750 uint8_t retval; | |
751 | |
752 if(!this) | |
753 return -1; | |
754 | |
755 pthread_mutex_lock(&this->vm_lock); | |
756 retval = (uint8_t)vm_get_video_aspect(this->vm); | |
757 pthread_mutex_unlock(&this->vm_lock); | |
758 | |
759 return retval; | |
760 } | |
761 | |
762 uint8_t dvdnav_get_video_scale_permission(dvdnav_t *this) { | |
763 uint8_t retval; | |
764 | |
765 if(!this) | |
766 return -1; | |
767 | |
768 pthread_mutex_lock(&this->vm_lock); | |
769 retval = (uint8_t)vm_get_video_scale_permission(this->vm); | |
770 pthread_mutex_unlock(&this->vm_lock); | |
771 | |
772 return retval; | |
773 } | |
774 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
775 uint16_t dvdnav_audio_stream_to_lang(dvdnav_t *this, uint8_t stream) { |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
776 audio_attr_t attr; |
0 | 777 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
778 if(!this) |
0 | 779 return -1; |
780 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
781 pthread_mutex_lock(&this->vm_lock); |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
782 attr = vm_get_audio_attr(this->vm, stream); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
783 pthread_mutex_unlock(&this->vm_lock); |
0 | 784 |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
785 if(attr.lang_type != 1) |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
786 return 0xffff; |
0 | 787 |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
788 return attr.lang_code; |
0 | 789 } |
790 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
791 uint16_t dvdnav_spu_stream_to_lang(dvdnav_t *this, uint8_t stream) { |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
792 subp_attr_t attr; |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
793 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
794 if(!this) |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
795 return -1; |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
796 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
797 pthread_mutex_lock(&this->vm_lock); |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
798 attr = vm_get_subp_attr(this->vm, stream); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
799 pthread_mutex_unlock(&this->vm_lock); |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
800 |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
801 if(attr.type != 1) |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
802 return 0xffff; |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
803 |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
804 return attr.lang_code; |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
805 } |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
806 |
114 | 807 int8_t dvdnav_get_audio_logical_stream(dvdnav_t *this, uint8_t audio_num) { |
808 int8_t retval; | |
809 | |
810 if(!this) | |
811 return -1; | |
812 | |
813 pthread_mutex_lock(&this->vm_lock); | |
814 if (!this->vm->state.pgc) { | |
815 pthread_mutex_unlock(&this->vm_lock); | |
816 return -1; | |
817 } | |
818 retval = vm_get_audio_stream(this->vm, audio_num); | |
819 pthread_mutex_unlock(&this->vm_lock); | |
820 | |
821 return retval; | |
822 } | |
823 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
824 int8_t dvdnav_get_spu_logical_stream(dvdnav_t *this, uint8_t subp_num) { |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
825 int8_t retval; |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
826 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
827 if(!this) |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
828 return -1; |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
829 |
114 | 830 pthread_mutex_lock(&this->vm_lock); |
831 if (!this->vm->state.pgc) { | |
832 pthread_mutex_unlock(&this->vm_lock); | |
833 return -1; | |
834 } | |
835 retval = vm_get_subp_stream(this->vm, subp_num, 0); | |
836 pthread_mutex_unlock(&this->vm_lock); | |
837 | |
838 return retval; | |
839 } | |
840 | |
841 int8_t dvdnav_get_active_audio_stream(dvdnav_t *this) { | |
842 int8_t retval; | |
843 | |
844 if(!this) | |
845 return -1; | |
846 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
847 pthread_mutex_lock(&this->vm_lock); |
114 | 848 if (!this->vm->state.pgc) { |
849 pthread_mutex_unlock(&this->vm_lock); | |
850 return -1; | |
851 } | |
852 retval = vm_get_audio_active_stream(this->vm); | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
853 pthread_mutex_unlock(&this->vm_lock); |
114 | 854 |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
855 return retval; |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
856 } |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
857 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
858 int8_t dvdnav_get_active_spu_stream(dvdnav_t *this) { |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
859 int8_t retval; |
0 | 860 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
861 if(!this) |
0 | 862 return -1; |
863 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
864 pthread_mutex_lock(&this->vm_lock); |
114 | 865 if (!this->vm->state.pgc) { |
866 pthread_mutex_unlock(&this->vm_lock); | |
867 return -1; | |
868 } | |
869 retval = vm_get_subp_active_stream(this->vm, 0); | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
870 pthread_mutex_unlock(&this->vm_lock); |
0 | 871 |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
872 return retval; |
0 | 873 } |
874 | |
114 | 875 static int8_t dvdnav_is_domain(dvdnav_t *this, domain_t domain) { |
876 int8_t retval; | |
877 | |
878 if (!this || !this->started) | |
879 return -1; | |
880 | |
881 pthread_mutex_lock(&this->vm_lock); | |
882 retval = (this->vm->state.domain == domain); | |
883 pthread_mutex_unlock(&this->vm_lock); | |
884 | |
885 return retval; | |
886 } | |
887 | |
0 | 888 /* First Play domain. (Menu) */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
889 int8_t dvdnav_is_domain_fp(dvdnav_t *this) { |
114 | 890 return dvdnav_is_domain(this, FP_DOMAIN); |
0 | 891 } |
892 /* Video management Menu domain. (Menu) */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
893 int8_t dvdnav_is_domain_vmgm(dvdnav_t *this) { |
114 | 894 return dvdnav_is_domain(this, VMGM_DOMAIN); |
0 | 895 } |
896 /* Video Title Menu domain (Menu) */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
897 int8_t dvdnav_is_domain_vtsm(dvdnav_t *this) { |
114 | 898 return dvdnav_is_domain(this, VTSM_DOMAIN); |
0 | 899 } |
900 /* Video Title domain (playing movie). */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
901 int8_t dvdnav_is_domain_vts(dvdnav_t *this) { |
114 | 902 return dvdnav_is_domain(this, VTS_DOMAIN); |
0 | 903 } |
904 | |
114 | 905 /* Generally delegate angle information handling to VM */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
906 dvdnav_status_t dvdnav_angle_change(dvdnav_t *this, int angle) { |
0 | 907 int num, current; |
908 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
909 if(!this) { |
114 | 910 printerr("Passed a NULL pointer."); |
0 | 911 return S_ERR; |
912 } | |
913 | |
114 | 914 pthread_mutex_lock(&this->vm_lock); |
915 vm_get_angle_info(this->vm, ¤t, &num); | |
0 | 916 /* Set angle SPRM if valid */ |
917 if((angle > 0) && (angle <= num)) { | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
918 this->vm->state.AGL_REG = angle; |
0 | 919 } else { |
114 | 920 printerr("Passed an invalid angle number."); |
921 pthread_mutex_unlock(&this->vm_lock); | |
0 | 922 return S_ERR; |
923 } | |
114 | 924 pthread_mutex_unlock(&this->vm_lock); |
0 | 925 |
926 return S_OK; | |
927 } | |
928 | |
114 | 929 dvdnav_status_t dvdnav_get_angle_info(dvdnav_t *this, int *current_angle, |
930 int *number_of_angles) { | |
931 if(!this || !current_angle || !number_of_angles) { | |
932 printerr("Passed a NULL pointer."); | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
933 return S_ERR; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
934 } |
114 | 935 |
936 pthread_mutex_lock(&this->vm_lock); | |
937 vm_get_angle_info(this->vm, current_angle, number_of_angles); | |
938 pthread_mutex_unlock(&this->vm_lock); | |
939 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
940 return S_OK; |
114 | 941 } |
0 | 942 |
67
61c0ee1bbb7a
Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents:
66
diff
changeset
|
943 pci_t* dvdnav_get_current_nav_pci(dvdnav_t *this) { |
114 | 944 if(!this) return 0; |
67
61c0ee1bbb7a
Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents:
66
diff
changeset
|
945 return &this->pci; |
61c0ee1bbb7a
Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents:
66
diff
changeset
|
946 } |
61c0ee1bbb7a
Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents:
66
diff
changeset
|
947 |
66
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
948 dsi_t* dvdnav_get_current_nav_dsi(dvdnav_t *this) { |
114 | 949 if(!this) return 0; |
66
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
950 return &this->dsi; |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
951 } |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
952 |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
953 uint32_t dvdnav_get_next_still_flag(dvdnav_t *this) { |
114 | 954 if(!this) return -1; |
66
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
955 return this->position_next.still; |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
956 } |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
957 |
0 | 958 /* |
959 * $Log$ | |
115 | 960 * Revision 1.41 2003/02/24 18:19:27 mroi |
961 * fix seek detection | |
962 * | |
114 | 963 * Revision 1.40 2003/02/20 15:32:15 mroi |
964 * big libdvdnav cleanup, quoting the ChangeLog: | |
965 * * some bugfixes | |
966 * * code cleanup | |
967 * * build process polishing | |
968 * * more sensible event order in get_next_block to ensure useful event delivery | |
969 * * VOBU level resume | |
970 * * fixed: seeking in a multiangle feature briefly showed the wrong angle | |
971 * | |
106
e984044bbe7b
port Stephen's comment fixing to avoid problems when syncing xine-lib's copy of
mroi
parents:
100
diff
changeset
|
972 * Revision 1.39 2002/10/23 11:38:09 mroi |
e984044bbe7b
port Stephen's comment fixing to avoid problems when syncing xine-lib's copy of
mroi
parents:
100
diff
changeset
|
973 * port Stephen's comment fixing to avoid problems when syncing xine-lib's copy of |
e984044bbe7b
port Stephen's comment fixing to avoid problems when syncing xine-lib's copy of
mroi
parents:
100
diff
changeset
|
974 * libdvdnav |
e984044bbe7b
port Stephen's comment fixing to avoid problems when syncing xine-lib's copy of
mroi
parents:
100
diff
changeset
|
975 * |
100 | 976 * Revision 1.38 2002/09/19 04:48:28 jcdutton |
977 * Update version info. | |
978 * The "note2" bit if to help developers know which version of libdvdnav the user is using. | |
979 * | |
99 | 980 * Revision 1.37 2002/09/18 14:26:42 mroi |
981 * fix possible unlock on not locked mutex | |
982 * | |
97
c1dff1899bda
First patch for personalized dvd viewing. I have not tested it yet.
jcdutton
parents:
92
diff
changeset
|
983 * Revision 1.36 2002/09/17 11:00:21 jcdutton |
c1dff1899bda
First patch for personalized dvd viewing. I have not tested it yet.
jcdutton
parents:
92
diff
changeset
|
984 * First patch for personalized dvd viewing. I have not tested it yet. |
c1dff1899bda
First patch for personalized dvd viewing. I have not tested it yet.
jcdutton
parents:
92
diff
changeset
|
985 * |
92 | 986 * Revision 1.35 2002/09/05 12:55:05 mroi |
987 * fix memleaks in dvdnav_open | |
988 * | |
89
0fbef4901e2c
Add a comment so I can tell which version of the CVS a user is using.
jcdutton
parents:
84
diff
changeset
|
989 * Revision 1.34 2002/09/03 00:41:48 jcdutton |
0fbef4901e2c
Add a comment so I can tell which version of the CVS a user is using.
jcdutton
parents:
84
diff
changeset
|
990 * Add a comment so I can tell which version of the CVS a user is using. |
0fbef4901e2c
Add a comment so I can tell which version of the CVS a user is using.
jcdutton
parents:
84
diff
changeset
|
991 * Also add a FIXME to remind me to fix the Chapter number display. |
0fbef4901e2c
Add a comment so I can tell which version of the CVS a user is using.
jcdutton
parents:
84
diff
changeset
|
992 * |
84 | 993 * Revision 1.33 2002/08/31 11:05:27 jcdutton |
994 * Properly seed the DVD VM Instruction rand(). | |
995 * | |
82 | 996 * Revision 1.32 2002/08/31 02:50:27 jcdutton |
997 * Improve some debug messages. | |
998 * Add some comments about dvdnav_open memory leaks. | |
999 * | |
76 | 1000 * Revision 1.31 2002/08/27 19:15:08 mroi |
1001 * more consistent console output | |
1002 * | |
73
a23d50ba81d3
update spu clut, spu channel and audio channel more often
mroi
parents:
67
diff
changeset
|
1003 * Revision 1.30 2002/08/09 21:34:27 mroi |
a23d50ba81d3
update spu clut, spu channel and audio channel more often
mroi
parents:
67
diff
changeset
|
1004 * update spu clut, spu channel and audio channel more often |
a23d50ba81d3
update spu clut, spu channel and audio channel more often
mroi
parents:
67
diff
changeset
|
1005 * |
67
61c0ee1bbb7a
Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents:
66
diff
changeset
|
1006 * Revision 1.29 2002/07/25 14:51:40 richwareham |
61c0ee1bbb7a
Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents:
66
diff
changeset
|
1007 * Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled' |
61c0ee1bbb7a
Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents:
66
diff
changeset
|
1008 * check_packet. |
61c0ee1bbb7a
Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents:
66
diff
changeset
|
1009 * |
66
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1010 * Revision 1.28 2002/07/25 14:42:33 richwareham |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1011 * Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead' |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1012 * |
60 | 1013 * Revision 1.27 2002/07/12 15:46:44 mroi |
1014 * use new memcopy'less read ahead cache | |
1015 * | |
58 | 1016 * Revision 1.26 2002/07/06 16:24:54 mroi |
1017 * * fix debug messages | |
1018 * * send spu stream change event only, when there are new streams | |
1019 * (should fix problems with Terminator disk 2) | |
1020 * | |
55
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1021 * Revision 1.25 2002/07/05 14:18:54 mroi |
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1022 * report all spu types (widescreen, letterbox and pan&scan), not widescreen |
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1023 * only and report the stream's scale permissions to detect pan&scan material |
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1024 * |
54 | 1025 * Revision 1.24 2002/07/05 01:42:30 jcdutton |
1026 * Add more debug info for Menu language selection. | |
1027 * Only do vm_start when we have to. | |
1028 * | |
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
45
diff
changeset
|
1029 * Revision 1.23 2002/07/02 22:57:09 jcdutton |
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
45
diff
changeset
|
1030 * Rename some of the functions in vm.c to help readability. |
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
45
diff
changeset
|
1031 * Hopefully fix __FUNCTION__ problem. Use __func_ as recommended in C99. |
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
45
diff
changeset
|
1032 * Fix bug where libdvdnav would not immeadiately replay the same cell due to menu buttons. |
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
45
diff
changeset
|
1033 * |
45 | 1034 * Revision 1.22 2002/06/25 13:37:11 jcdutton |
1035 * Revert back to old read_cache method. | |
1036 * Some new optimizations added to the old read_cache method, thus reducing the amount of calls to read blocks from the DVD device. | |
1037 * | |
43
0ba15bf3dc25
Biiiiiiig change to let doxygen generate some docs for the library. Note that I'm in no way sure that the autoconf stuff plays nice.
richwareham
parents:
42
diff
changeset
|
1038 * Revision 1.21 2002/06/06 15:03:09 richwareham |
0ba15bf3dc25
Biiiiiiig change to let doxygen generate some docs for the library. Note that I'm in no way sure that the autoconf stuff plays nice.
richwareham
parents:
42
diff
changeset
|
1039 * Biiiiiiig change to let doxygen generate some docs for the library. Note that I'm in no way sure that the autoconf stuff plays nice. |
0ba15bf3dc25
Biiiiiiig change to let doxygen generate some docs for the library. Note that I'm in no way sure that the autoconf stuff plays nice.
richwareham
parents:
42
diff
changeset
|
1040 * |
42 | 1041 * Revision 1.20 2002/06/04 13:35:16 richwareham |
1042 * Removed more C++ style comments | |
1043 * | |
39 | 1044 * Revision 1.19 2002/05/30 23:15:14 richwareham |
1045 * First draft of removing HAVE_DVDREAD9 | |
1046 * | |
34
1f29402ef2ef
'Objectified' the read-ahead cache in preparation to implement a 'proper' threaded cache a-la that recommended in the DVD Demystified book.
richwareham
parents:
33
diff
changeset
|
1047 * Revision 1.18 2002/05/30 09:52:29 richwareham |
1f29402ef2ef
'Objectified' the read-ahead cache in preparation to implement a 'proper' threaded cache a-la that recommended in the DVD Demystified book.
richwareham
parents:
33
diff
changeset
|
1048 * 'Objectified' the read-ahead cache in preparation to implement a 'proper' threaded cache a-la that recommended in the DVD Demystified book. |
1f29402ef2ef
'Objectified' the read-ahead cache in preparation to implement a 'proper' threaded cache a-la that recommended in the DVD Demystified book.
richwareham
parents:
33
diff
changeset
|
1049 * |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
1050 * Revision 1.17 2002/05/09 11:57:24 richwareham |
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
1051 * Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus) |
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
1052 * |
31 | 1053 * Revision 1.16 2002/04/24 21:15:25 jcdutton |
1054 * Quiet please!!! | |
1055 * | |
30 | 1056 * Revision 1.15 2002/04/24 00:47:46 jcdutton |
1057 * Some more cleanups. | |
1058 * Improve button passing. | |
1059 * | |
28 | 1060 * Revision 1.14 2002/04/23 13:26:08 jcdutton |
1061 * Add some comments, FIXMEs. | |
1062 * The main point being that dvdnav_get_next_block is almost in a state where it can be optional whether the application programmer uses it, or implements their own version of the function. That is been the main reason for the re-write of this function recently. | |
1063 * | |
26 | 1064 * Revision 1.13 2002/04/23 12:55:40 jcdutton |
1065 * Removed un-needed variables. | |
1066 * General Clean up. | |
1067 * | |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
1068 * Revision 1.12 2002/04/23 12:34:39 f1rmb |
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
1069 * Why rewrite vm function, use it instead (this remark is for me, of course ;-) ). |
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
1070 * Comment unused var, shut compiler warnings. |
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
1071 * |
24 | 1072 * Revision 1.11 2002/04/23 02:12:27 jcdutton |
1073 * Re-implemented seeking. | |
1074 * | |
23 | 1075 * Revision 1.10 2002/04/23 00:07:16 jcdutton |
1076 * Name stills work better. | |
1077 * | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1078 * Revision 1.9 2002/04/22 22:00:48 jcdutton |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1079 * Start of rewrite of libdvdnav. Still need to re-implement seeking. |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1080 * |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1081 * Revision 1.8 2002/04/22 20:57:14 f1rmb |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1082 * Change/fix SPU active stream id. Same for audio. Few new functions, largely |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1083 * inspired from libogle ;-). |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1084 * |
17 | 1085 * Revision 1.7 2002/04/10 16:45:57 jcdutton |
1086 * Actually fix the const this time! | |
1087 * | |
8
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
7
diff
changeset
|
1088 * Revision 1.6 2002/04/07 14:10:11 richwareham |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
7
diff
changeset
|
1089 * Stop C++ bitching about some things and extend the menus example |
66708b4a1b5e
Stop C++ bitching about some things and extend the menus example
richwareham
parents:
7
diff
changeset
|
1090 * |
7
7fdefafa624f
Slight correction to handle quicker menu transitions.
jcdutton
parents:
6
diff
changeset
|
1091 * Revision 1.5 2002/04/06 18:42:05 jcdutton |
7fdefafa624f
Slight correction to handle quicker menu transitions.
jcdutton
parents:
6
diff
changeset
|
1092 * Slight correction to handle quicker menu transitions. |
7fdefafa624f
Slight correction to handle quicker menu transitions.
jcdutton
parents:
6
diff
changeset
|
1093 * |
6 | 1094 * Revision 1.4 2002/04/06 18:31:50 jcdutton |
1095 * Some cleaning up. | |
1096 * changed exit(1) to assert(0) so they actually get seen by the user so that it helps developers more. | |
1097 * | |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
1098 * Revision 1.3 2002/04/02 18:22:27 richwareham |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
1099 * Added reset patch from Kees Cook <kees@outflux.net> |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
1100 * |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
1101 * Revision 1.2 2002/04/01 18:56:28 richwareham |
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
1102 * Added initial example programs directory and make sure all debug/error output goes to stderr. |
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
1103 * |
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
1104 * Revision 1.1.1.1 2002/03/12 19:45:57 richwareham |
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
1105 * Initial import |
0 | 1106 * |
1107 * Revision 1.28 2002/02/02 23:26:20 richwareham | |
1108 * Restored title selection | |
1109 * | |
1110 * Revision 1.27 2002/02/01 15:48:10 richwareham | |
1111 * Re-implemented angle selection and title/chapter display | |
1112 * | |
1113 * Revision 1.26 2002/01/31 16:53:49 richwareham | |
1114 * Big patch from Daniel Caujolle-Bert to (re)implement SPU/Audio language display | |
1115 * | |
1116 * Revision 1.25 2002/01/24 20:53:50 richwareham | |
1117 * Added option to _not_ use DVD read-ahead to options | |
1118 * | |
1119 * Revision 1.24 2002/01/20 15:54:59 jcdutton | |
1120 * Implement seeking. | |
1121 * It is still a bit buggy, but works sometimes. | |
1122 * I need to find out how to make the jump clean. | |
1123 * At the moment, some corruption of the mpeg2 stream occurs, | |
1124 * which causes libmpeg2 to crash. | |
1125 * | |
1126 * Revision 1.23 2002/01/18 00:23:52 jcdutton | |
1127 * Support Ejecting of DVD. | |
1128 * It will first un-mount the DVD, then eject it. | |
1129 * | |
1130 * Revision 1.22 2002/01/17 14:50:32 jcdutton | |
1131 * Fix corruption of stream during menu transitions. | |
1132 * Menu transitions are now clean. | |
1133 * | |
1134 * Revision 1.21 2002/01/15 00:37:03 jcdutton | |
1135 * Just a few cleanups, and a assert fix. (memset fixed it) | |
1136 * | |
1137 * Revision 1.20 2002/01/13 22:17:57 jcdutton | |
1138 * Change logging. | |
1139 * | |
1140 * | |
1141 */ |