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