Mercurial > libdvdnav.hg
annotate dvdnav.c @ 337:f08dbb15ece1 src
in dvdnav_open() make sure to NULL-terminate this->path and to not overrun its length; patch by Erik Hovland - erik hovland org
author | nicodvb |
---|---|
date | Sat, 19 Apr 2008 09:44:15 +0000 |
parents | cbd2b606f343 |
children | 0dc09442ff9c |
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 | |
278 | 32 #include <inttypes.h> |
288
ce4230602517
moved away from dvdnav_internal.h inclusion of various system headers
nicodvb
parents:
285
diff
changeset
|
33 #include <stdlib.h> |
ce4230602517
moved away from dvdnav_internal.h inclusion of various system headers
nicodvb
parents:
285
diff
changeset
|
34 #include <stdio.h> |
ce4230602517
moved away from dvdnav_internal.h inclusion of various system headers
nicodvb
parents:
285
diff
changeset
|
35 #include <unistd.h> |
ce4230602517
moved away from dvdnav_internal.h inclusion of various system headers
nicodvb
parents:
285
diff
changeset
|
36 #include <limits.h> |
ce4230602517
moved away from dvdnav_internal.h inclusion of various system headers
nicodvb
parents:
285
diff
changeset
|
37 #include <string.h> |
291 | 38 #include <sys/time.h> |
285
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
39 #include "dvd_types.h" |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
40 #include "dvd_reader.h" |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
41 #include "nav_types.h" |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
42 #include "ifo_types.h" /* For vm_cmd_t */ |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
43 #include "remap.h" |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
44 #include "vm/decoder.h" |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
45 #include "vm/vm.h" |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
46 #include "dvdnav.h" |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
47 #include "dvdnav_events.h" |
0 | 48 #include "dvdnav_internal.h" |
49 #include "read_cache.h" | |
231 | 50 #include "nav_read.h" |
97
c1dff1899bda
First patch for personalized dvd viewing. I have not tested it yet.
jcdutton
parents:
92
diff
changeset
|
51 #include "remap.h" |
c1dff1899bda
First patch for personalized dvd viewing. I have not tested it yet.
jcdutton
parents:
92
diff
changeset
|
52 |
114 | 53 static dvdnav_status_t dvdnav_clear(dvdnav_t * this) { |
54 /* 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
|
55 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
56 if (this->file) DVDCloseFile(this->file); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
57 this->file = NULL; |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
58 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
59 memset(&this->pci,0,sizeof(this->pci)); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
60 memset(&this->dsi,0,sizeof(this->dsi)); |
197
a20a5976a207
last_cmd_nav_lbn has to be initialized with an invalid value, so that the first
mroi
parents:
195
diff
changeset
|
61 this->last_cmd_nav_lbn = SRI_END_OF_CELL; |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
62 |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
63 /* Set initial values of flags */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
64 this->position_current.still = 0; |
23 | 65 this->skip_still = 0; |
116 | 66 this->sync_wait = 0; |
67 this->sync_wait_skip = 0; | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
68 this->spu_clut_changed = 0; |
114 | 69 this->started = 0; |
269
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
70 this->cur_cell_time = 0; |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
71 |
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
|
72 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
|
73 |
193 | 74 return DVDNAV_STATUS_OK; |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
75 } |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
76 |
114 | 77 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
|
78 dvdnav_t *this; |
84 | 79 struct timeval time; |
0 | 80 |
81 /* Create a new structure */ | |
100 | 82 fprintf(MSG_OUT, "libdvdnav: Using dvdnav version %s from http://dvd.sf.net\n", VERSION); |
82 | 83 |
0 | 84 (*dest) = NULL; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
85 this = (dvdnav_t*)malloc(sizeof(dvdnav_t)); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
86 if(!this) |
193 | 87 return DVDNAV_STATUS_ERR; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
88 memset(this, 0, (sizeof(dvdnav_t) ) ); /* Make sure this structure is clean */ |
114 | 89 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
90 pthread_mutex_init(&this->vm_lock, NULL); |
0 | 91 /* Initialise the error string */ |
92 printerr(""); | |
93 | |
94 /* Initialise the VM */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
95 this->vm = vm_new_vm(); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
96 if(!this->vm) { |
114 | 97 printerr("Error initialising the DVD VM."); |
92 | 98 pthread_mutex_destroy(&this->vm_lock); |
99 free(this); | |
193 | 100 return DVDNAV_STATUS_ERR; |
0 | 101 } |
114 | 102 if(!vm_reset(this->vm, path)) { |
103 printerr("Error starting the VM / opening the DVD device."); | |
92 | 104 pthread_mutex_destroy(&this->vm_lock); |
105 vm_free_vm(this->vm); | |
106 free(this); | |
193 | 107 return DVDNAV_STATUS_ERR; |
0 | 108 } |
109 | |
110 /* Set the path. FIXME: Is a deep copy 'right' */ | |
337
f08dbb15ece1
in dvdnav_open() make sure to NULL-terminate this->path and to not overrun its length; patch by Erik Hovland - erik hovland org
nicodvb
parents:
300
diff
changeset
|
111 strncpy(this->path, path, MAX_PATH_LEN - 1); |
f08dbb15ece1
in dvdnav_open() make sure to NULL-terminate this->path and to not overrun its length; patch by Erik Hovland - erik hovland org
nicodvb
parents:
300
diff
changeset
|
112 this->path[MAX_PATH_LEN - 1] = '\0'; |
0 | 113 |
114 /* 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
|
115 this->file = DVDOpenFile(vm_get_dvd_reader(this->vm), 0, DVD_READ_MENU_VOBS); |
0 | 116 |
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
|
117 /* 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
|
118 this->cache = dvdnav_read_cache_new(this); |
84 | 119 |
114 | 120 /* Seed the random numbers. So that the DVD VM Command rand() |
121 * gives a different start value each time a DVD is played. */ | |
122 gettimeofday(&time, NULL); | |
84 | 123 srand(time.tv_usec); |
124 | |
114 | 125 dvdnav_clear(this); |
126 | |
127 (*dest) = this; | |
193 | 128 return DVDNAV_STATUS_OK; |
0 | 129 } |
130 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
131 dvdnav_status_t dvdnav_close(dvdnav_t *this) { |
114 | 132 |
31 | 133 #ifdef LOG_DEBUG |
76 | 134 fprintf(MSG_OUT, "libdvdnav: close:called\n"); |
31 | 135 #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
|
136 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
137 if (this->file) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
138 DVDCloseFile(this->file); |
31 | 139 #ifdef LOG_DEBUG |
76 | 140 fprintf(MSG_OUT, "libdvdnav: close:file closing\n"); |
31 | 141 #endif |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
142 this->file = NULL; |
0 | 143 } |
144 | |
145 /* Free the VM */ | |
114 | 146 if(this->vm) |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
147 vm_free_vm(this->vm); |
114 | 148 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
149 pthread_mutex_destroy(&this->vm_lock); |
60 | 150 |
151 /* We leave the final freeing of the entire structure to the cache, | |
152 * because we don't know, if there are still buffers out in the wild, | |
153 * that must return first. */ | |
114 | 154 if(this->cache) |
60 | 155 dvdnav_read_cache_free(this->cache); |
114 | 156 else |
157 free(this); | |
0 | 158 |
193 | 159 return DVDNAV_STATUS_OK; |
0 | 160 } |
161 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
162 dvdnav_status_t dvdnav_reset(dvdnav_t *this) { |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
163 dvdnav_status_t result; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
164 |
31 | 165 #ifdef LOG_DEBUG |
76 | 166 fprintf(MSG_OUT, "libdvdnav: reset:called\n"); |
31 | 167 #endif |
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); |
193 | 177 return DVDNAV_STATUS_ERR; |
4
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) { |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
189 (*path) = this->path; |
0 | 190 |
193 | 191 return DVDNAV_STATUS_OK; |
0 | 192 } |
193 | |
114 | 194 const char* dvdnav_err_to_string(dvdnav_t *this) { |
195 | |
196 if(!this) | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
197 return "Hey! You gave me a NULL pointer you naughty person!"; |
0 | 198 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
199 return this->err_str; |
0 | 200 } |
201 | |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
202 /* converts a dvd_time_t to PTS ticks */ |
265 | 203 int64_t dvdnav_convert_time(dvd_time_t *time) { |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
204 int64_t result; |
195 | 205 int64_t frames; |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
206 |
135 | 207 result = (time->hour >> 4 ) * 10 * 60 * 60 * 90000; |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
208 result += (time->hour & 0x0f) * 60 * 60 * 90000; |
135 | 209 result += (time->minute >> 4 ) * 10 * 60 * 90000; |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
210 result += (time->minute & 0x0f) * 60 * 90000; |
135 | 211 result += (time->second >> 4 ) * 10 * 90000; |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
212 result += (time->second & 0x0f) * 90000; |
135 | 213 |
214 frames = ((time->frame_u & 0x30) >> 4) * 10; | |
215 frames += ((time->frame_u & 0x0f) ) ; | |
216 | |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
217 if (time->frame_u & 0x80) |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
218 result += frames * 3000; |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
219 else |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
220 result += frames * 3600; |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
221 |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
222 return result; |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
223 } |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
224 |
114 | 225 /* |
0 | 226 * Returns 1 if block contains NAV packet, 0 otherwise. |
217 | 227 * Processes said NAV packet if present. |
0 | 228 * |
229 * Most of the code in here is copied from xine's MPEG demuxer | |
230 * so any bugs which are found in that should be corrected here also. | |
231 */ | |
195 | 232 static int32_t dvdnav_decode_packet(dvdnav_t *this, uint8_t *p, dsi_t *nav_dsi, pci_t *nav_pci) { |
233 int32_t bMpeg1 = 0; | |
0 | 234 uint32_t nHeaderLen; |
235 uint32_t nPacketLen; | |
236 uint32_t nStreamID; | |
237 | |
238 if (p[3] == 0xBA) { /* program stream pack header */ | |
195 | 239 int32_t nStuffingBytes; |
0 | 240 |
241 bMpeg1 = (p[4] & 0x40) == 0; | |
242 | |
243 if (bMpeg1) { | |
114 | 244 p += 12; |
0 | 245 } else { /* mpeg2 */ |
246 nStuffingBytes = p[0xD] & 0x07; | |
247 p += 14 + nStuffingBytes; | |
248 } | |
249 } | |
250 | |
251 if (p[3] == 0xbb) { /* program stream system header */ | |
252 nHeaderLen = (p[4] << 8) | p[5]; | |
253 p += 6 + nHeaderLen; | |
254 } | |
255 | |
256 /* we should now have a PES packet here */ | |
257 if (p[0] || p[1] || (p[2] != 1)) { | |
76 | 258 fprintf(MSG_OUT, "libdvdnav: demux error! %02x %02x %02x (should be 0x000001) \n",p[0],p[1],p[2]); |
0 | 259 return 0; |
260 } | |
261 | |
262 nPacketLen = p[4] << 8 | p[5]; | |
263 nStreamID = p[3]; | |
264 | |
265 nHeaderLen = 6; | |
266 p += nHeaderLen; | |
267 | |
268 if (nStreamID == 0xbf) { /* Private stream 2 */ | |
114 | 269 #if 0 |
195 | 270 int32_t i; |
114 | 271 fprintf(MSG_OUT, "libdvdnav: nav packet=%u\n",p-p_start-6); |
272 for(i=0;i<80;i++) | |
273 fprintf(MSG_OUT, "%02x ",p[i-6]); | |
274 fprintf(MSG_OUT, "\n"); | |
275 #endif | |
276 | |
0 | 277 if(p[0] == 0x00) { |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
278 navRead_PCI(nav_pci, p+1); |
0 | 279 } |
280 | |
281 p += nPacketLen; | |
282 | |
283 /* We should now have a DSI packet. */ | |
284 if(p[6] == 0x01) { | |
285 nPacketLen = p[4] << 8 | p[5]; | |
286 p += 6; | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
287 navRead_DSI(nav_dsi, p+1); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
288 } |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
289 return 1; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
290 } |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
291 return 0; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
292 } |
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
|
293 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
294 /* DSI is used for most angle stuff. |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
295 * 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
|
296 */ |
195 | 297 static int32_t 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
|
298 uint32_t next; |
195 | 299 int32_t angle, num_angle; |
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
|
300 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
301 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
|
302 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
|
303 |
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
|
304 /* |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
305 * 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
|
306 * 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
|
307 * 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
|
308 * 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
|
309 * really happy. |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
310 * |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
311 * 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
|
312 * 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
|
313 * Should really assert if bit 31 != 1 |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
314 */ |
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 |
114 | 316 #if 0 |
317 /* 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
|
318 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
|
319 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
|
320 } 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
|
321 vobu->vobu_next = vobu->vobu_length; |
114 | 322 } |
323 #else | |
324 /* Relative offset from vobu_start */ | |
325 vobu->vobu_next = ( nav_dsi->vobu_sri.next_vobu & 0x3fffffff ); | |
326 #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
|
327 |
114 | 328 vm_get_angle_info(this->vm, &angle, &num_angle); |
329 | |
330 /* 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
|
331 #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
|
332 if((num_angle < angle) && (angle != 1)) { |
114 | 333 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
|
334 |
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 /* 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
|
336 * finish with angles. */ |
114 | 337 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
|
338 } |
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 #endif |
0 | 340 |
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
|
341 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
|
342 |
114 | 343 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
|
344 if((next & 0x3fffffff) != 0) { |
114 | 345 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
|
346 vobu->vobu_next = - (int32_t)(next & 0x3fffffff); |
114 | 347 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
|
348 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
|
349 } |
114 | 350 } 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
|
351 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
|
352 |
114 | 353 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
|
354 vobu->vobu_next = - (int32_t)(next & 0x3fffffff); |
114 | 355 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
|
356 vobu->vobu_next = + (int32_t)(next & 0x3fffffff); |
0 | 357 } |
358 } | |
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
|
359 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
360 return 1; |
0 | 361 } |
60 | 362 |
114 | 363 /* |
364 * These are the main get_next_block function which actually get the media stream video and audio etc. | |
365 * | |
366 * There are two versions: The second one is using the zero-copy read ahead cache and therefore | |
367 * hands out pointers targetting directly into the cache. | |
368 * The first one uses a memcopy to fill this cache block into the application provided memory. | |
369 * The benefit of this first one is that no special memory management is needed. The application is | |
370 * the only one responsible of allocating and freeing the memory associated with the pointer. | |
371 * The drawback is the additional memcopy. | |
28 | 372 */ |
60 | 373 |
195 | 374 dvdnav_status_t dvdnav_get_next_block(dvdnav_t *this, uint8_t *buf, |
375 int32_t *event, int32_t *len) { | |
60 | 376 unsigned char *block; |
377 dvdnav_status_t status; | |
378 | |
379 block = buf; | |
380 status = dvdnav_get_next_cache_block(this, &block, event, len); | |
193 | 381 if (status == DVDNAV_STATUS_OK && block != buf) { |
60 | 382 /* we received a block from the cache, copy it, so we can give it back */ |
383 memcpy(buf, block, DVD_VIDEO_LB_LEN); | |
384 dvdnav_free_cache_block(this, block); | |
385 } | |
386 return status; | |
387 } | |
269
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
388 |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
389 int64_t dvdnav_get_current_time(dvdnav_t *this) { |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
390 int i; |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
391 int64_t tm=0; |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
392 dvd_state_t *state = &this->vm->state; |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
393 |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
394 for(i=0; i<state->cellN-1; i++) { |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
395 if(! |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
396 (state->pgc->cell_playback[i].block_type == BLOCK_TYPE_ANGLE_BLOCK && |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
397 state->pgc->cell_playback[i].block_mode != BLOCK_MODE_FIRST_CELL) |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
398 ) |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
399 tm += dvdnav_convert_time(&state->pgc->cell_playback[i].playback_time); |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
400 } |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
401 tm += this->cur_cell_time; |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
402 |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
403 return tm; |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
404 } |
60 | 405 |
195 | 406 dvdnav_status_t dvdnav_get_next_cache_block(dvdnav_t *this, uint8_t **buf, |
407 int32_t *event, int32_t *len) { | |
0 | 408 dvd_state_t *state; |
195 | 409 int32_t result; |
114 | 410 |
411 pthread_mutex_lock(&this->vm_lock); | |
0 | 412 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
413 if(!this->started) { |
0 | 414 /* Start the VM */ |
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
249
diff
changeset
|
415 if (!vm_start(this->vm)) { |
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
249
diff
changeset
|
416 printerr("Encrypted or faulty DVD"); |
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
249
diff
changeset
|
417 return DVDNAV_STATUS_ERR; |
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
249
diff
changeset
|
418 } |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
419 this->started = 1; |
0 | 420 } |
421 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
422 state = &(this->vm->state); |
0 | 423 (*event) = DVDNAV_NOP; |
424 (*len) = 0; | |
425 | |
426 /* Check the STOP flag */ | |
114 | 427 if(this->vm->stopped) { |
121 | 428 vm_stop(this->vm); |
0 | 429 (*event) = DVDNAV_STOP; |
114 | 430 this->started = 0; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
431 pthread_mutex_unlock(&this->vm_lock); |
193 | 432 return DVDNAV_STATUS_OK; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
433 } |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
434 |
114 | 435 vm_position_get(this->vm, &this->position_next); |
0 | 436 |
126 | 437 #ifdef LOG_DEBUG |
114 | 438 fprintf(MSG_OUT, "libdvdnav: POS-NEXT "); |
439 vm_position_print(this->vm, &this->position_next); | |
116 | 440 fprintf(MSG_OUT, "libdvdnav: POS-CUR "); |
114 | 441 vm_position_print(this->vm, &this->position_current); |
31 | 442 #endif |
114 | 443 |
444 /* did we hop? */ | |
445 if(this->position_current.hop_channel != this->position_next.hop_channel) { | |
446 (*event) = DVDNAV_HOP_CHANNEL; | |
58 | 447 #ifdef LOG_DEBUG |
114 | 448 fprintf(MSG_OUT, "libdvdnav: HOP_CHANNEL\n"); |
31 | 449 #endif |
115 | 450 if (this->position_next.hop_channel - this->position_current.hop_channel >= HOP_SEEK) { |
195 | 451 int32_t num_angles = 0, current; |
114 | 452 |
453 /* we seeked -> check for multiple angles */ | |
454 vm_get_angle_info(this->vm, ¤t, &num_angles); | |
455 if (num_angles > 1) { | |
195 | 456 int32_t result, block; |
114 | 457 /* we have to skip the first VOBU when seeking in a multiangle feature, |
458 * because it might belong to the wrong angle */ | |
459 block = this->position_next.cell_start + this->position_next.block; | |
460 result = dvdnav_read_cache_block(this->cache, block, 1, buf); | |
461 if(result <= 0) { | |
462 printerr("Error reading NAV packet."); | |
463 pthread_mutex_unlock(&this->vm_lock); | |
193 | 464 return DVDNAV_STATUS_ERR; |
114 | 465 } |
466 /* Decode nav into pci and dsi. Then get next VOBU info. */ | |
467 if(!dvdnav_decode_packet(this, *buf, &this->dsi, &this->pci)) { | |
468 printerr("Expected NAV packet but none found."); | |
469 pthread_mutex_unlock(&this->vm_lock); | |
193 | 470 return DVDNAV_STATUS_ERR; |
114 | 471 } |
472 dvdnav_get_vobu(this, &this->dsi, &this->pci, &this->vobu); | |
473 /* skip to next, if there is a next */ | |
474 if (this->vobu.vobu_next != SRI_END_OF_CELL) { | |
475 this->vobu.vobu_start += this->vobu.vobu_next; | |
476 this->vobu.vobu_next = 0; | |
477 } | |
478 /* update VM state */ | |
479 this->vm->state.blockN = this->vobu.vobu_start - this->position_next.cell_start; | |
480 } | |
481 } | |
482 this->position_current.hop_channel = this->position_next.hop_channel; | |
141
8f63f4c25f2f
update position on HOP_CHANNEL, do not rely on a following CELL_CHANGE
mroi
parents:
135
diff
changeset
|
483 /* update VOBU info */ |
8f63f4c25f2f
update position on HOP_CHANNEL, do not rely on a following CELL_CHANGE
mroi
parents:
135
diff
changeset
|
484 this->vobu.vobu_start = this->position_next.cell_start + this->position_next.block; |
8f63f4c25f2f
update position on HOP_CHANNEL, do not rely on a following CELL_CHANGE
mroi
parents:
135
diff
changeset
|
485 this->vobu.vobu_next = 0; |
127 | 486 /* Make blockN == vobu_length to do expected_nav */ |
114 | 487 this->vobu.vobu_length = 0; |
127 | 488 this->vobu.blockN = 0; |
116 | 489 this->sync_wait = 0; |
30 | 490 pthread_mutex_unlock(&this->vm_lock); |
193 | 491 return DVDNAV_STATUS_OK; |
0 | 492 } |
493 | |
116 | 494 /* Check the HIGHLIGHT flag */ |
495 if(this->position_current.button != this->position_next.button) { | |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
496 dvdnav_highlight_event_t *hevent = (dvdnav_highlight_event_t *)*buf; |
116 | 497 |
498 (*event) = DVDNAV_HIGHLIGHT; | |
499 #ifdef LOG_DEBUG | |
500 fprintf(MSG_OUT, "libdvdnav: HIGHLIGHT\n"); | |
501 #endif | |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
502 (*len) = sizeof(dvdnav_highlight_event_t); |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
503 hevent->display = 1; |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
504 hevent->buttonN = this->position_next.button; |
116 | 505 this->position_current.button = this->position_next.button; |
506 pthread_mutex_unlock(&this->vm_lock); | |
193 | 507 return DVDNAV_STATUS_OK; |
116 | 508 } |
509 | |
510 /* Check the WAIT flag */ | |
511 if(this->sync_wait) { | |
512 (*event) = DVDNAV_WAIT; | |
513 #ifdef LOG_DEBUG | |
514 fprintf(MSG_OUT, "libdvdnav: WAIT\n"); | |
515 #endif | |
516 (*len) = 0; | |
517 pthread_mutex_unlock(&this->vm_lock); | |
193 | 518 return DVDNAV_STATUS_OK; |
116 | 519 } |
520 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
521 /* 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
|
522 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
|
523 (this->position_current.domain != this->position_next.domain)) { |
0 | 524 dvd_read_domain_t domain; |
195 | 525 int32_t vtsN; |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
526 dvdnav_vts_change_event_t *vts_event = (dvdnav_vts_change_event_t *)*buf; |
0 | 527 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
528 if(this->file) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
529 DVDCloseFile(this->file); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
530 this->file = NULL; |
0 | 531 } |
532 | |
217 | 533 vts_event->old_vtsN = this->position_current.vts; |
534 vts_event->old_domain = this->position_current.domain; | |
0 | 535 |
114 | 536 /* 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
|
537 switch(this->position_next.domain) { |
114 | 538 case FP_DOMAIN: |
539 case VMGM_DOMAIN: | |
0 | 540 domain = DVD_READ_MENU_VOBS; |
541 vtsN = 0; | |
542 break; | |
114 | 543 case VTSM_DOMAIN: |
0 | 544 domain = DVD_READ_MENU_VOBS; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
545 vtsN = this->position_next.vts; |
0 | 546 break; |
114 | 547 case VTS_DOMAIN: |
0 | 548 domain = DVD_READ_TITLE_VOBS; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
549 vtsN = this->position_next.vts; |
0 | 550 break; |
114 | 551 default: |
0 | 552 printerr("Unknown domain when changing VTS."); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
553 pthread_mutex_unlock(&this->vm_lock); |
193 | 554 return DVDNAV_STATUS_ERR; |
0 | 555 } |
556 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
557 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
|
558 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
|
559 dvdnav_read_cache_clear(this->cache); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
560 this->file = DVDOpenFile(vm_get_dvd_reader(this->vm), vtsN, domain); |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
561 vts_event->new_vtsN = this->position_next.vts; |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
562 vts_event->new_domain = this->position_next.domain; |
0 | 563 |
564 /* 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
|
565 if(this->file == NULL) { |
0 | 566 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
|
567 pthread_mutex_unlock(&this->vm_lock); |
193 | 568 return DVDNAV_STATUS_ERR; |
0 | 569 } |
570 | |
571 /* File opened successfully so return a VTS change event */ | |
572 (*event) = DVDNAV_VTS_CHANGE; | |
114 | 573 #ifdef LOG_DEBUG |
574 fprintf(MSG_OUT, "libdvdnav: VTS_CHANGE\n"); | |
575 #endif | |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
576 (*len) = sizeof(dvdnav_vts_change_event_t); |
0 | 577 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
578 this->spu_clut_changed = 1; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
579 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
|
580 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
|
581 this->position_current.audio_channel = -1; /* Force an update */; |
0 | 582 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
583 pthread_mutex_unlock(&this->vm_lock); |
193 | 584 return DVDNAV_STATUS_OK; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
585 } |
114 | 586 |
587 /* Check if the cell changed */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
588 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
|
589 (this->position_current.cell_restart != this->position_next.cell_restart) || |
114 | 590 (this->position_current.cell_start != this->position_next.cell_start) ) { |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
591 dvdnav_cell_change_event_t *cell_event = (dvdnav_cell_change_event_t *)*buf; |
195 | 592 int32_t first_cell_nr, last_cell_nr, i; |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
593 dvd_state_t *state = &this->vm->state; |
114 | 594 |
269
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
595 this->cur_cell_time = 0; |
114 | 596 (*event) = DVDNAV_CELL_CHANGE; |
597 #ifdef LOG_DEBUG | |
598 fprintf(MSG_OUT, "libdvdnav: CELL_CHANGE\n"); | |
599 #endif | |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
600 (*len) = sizeof(dvdnav_cell_change_event_t); |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
601 |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
602 cell_event->cellN = state->cellN; |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
603 cell_event->pgN = state->pgN; |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
604 cell_event->cell_length = |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
605 dvdnav_convert_time(&state->pgc->cell_playback[state->cellN-1].playback_time); |
161 | 606 |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
607 cell_event->pg_length = 0; |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
608 /* Find start cell of program. */ |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
609 first_cell_nr = state->pgc->program_map[state->pgN-1]; |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
610 /* Find end cell of program */ |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
611 if(state->pgN < state->pgc->nr_of_programs) |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
612 last_cell_nr = state->pgc->program_map[state->pgN] - 1; |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
613 else |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
614 last_cell_nr = state->pgc->nr_of_cells; |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
615 for (i = first_cell_nr; i <= last_cell_nr; i++) |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
616 cell_event->pg_length += |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
617 dvdnav_convert_time(&state->pgc->cell_playback[i - 1].playback_time); |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
618 cell_event->pgc_length = dvdnav_convert_time(&state->pgc->playback_time); |
151 | 619 |
620 cell_event->cell_start = 0; | |
621 for (i = 1; i < state->cellN; i++) | |
622 cell_event->cell_start += | |
623 dvdnav_convert_time(&state->pgc->cell_playback[i - 1].playback_time); | |
161 | 624 |
625 cell_event->pg_start = 0; | |
626 for (i = 1; i < state->pgc->program_map[state->pgN-1]; i++) | |
627 cell_event->pg_start += | |
628 dvdnav_convert_time(&state->pgc->cell_playback[i - 1].playback_time); | |
629 | |
114 | 630 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
|
631 this->position_current.cell_restart = this->position_next.cell_restart; |
114 | 632 this->position_current.cell_start = this->position_next.cell_start; |
633 this->position_current.block = this->position_next.block; | |
634 | |
635 /* vobu info is used for mid cell resumes */ | |
636 this->vobu.vobu_start = this->position_next.cell_start + this->position_next.block; | |
637 this->vobu.vobu_next = 0; | |
127 | 638 /* Make blockN == vobu_length to do expected_nav */ |
114 | 639 this->vobu.vobu_length = 0; |
127 | 640 this->vobu.blockN = 0; |
114 | 641 |
642 /* update the spu palette at least on PGC changes */ | |
643 this->spu_clut_changed = 1; | |
644 this->position_current.spu_channel = -1; /* Force an update */ | |
645 this->position_current.audio_channel = -1; /* Force an update */ | |
646 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
647 pthread_mutex_unlock(&this->vm_lock); |
193 | 648 return DVDNAV_STATUS_OK; |
0 | 649 } |
650 | |
114 | 651 /* has the CLUT changed? */ |
652 if(this->spu_clut_changed) { | |
653 (*event) = DVDNAV_SPU_CLUT_CHANGE; | |
654 #ifdef LOG_DEBUG | |
655 fprintf(MSG_OUT, "libdvdnav: SPU_CLUT_CHANGE\n"); | |
656 #endif | |
657 (*len) = 16 * sizeof(uint32_t); | |
658 memcpy(*buf, &(state->pgc->palette), 16 * sizeof(uint32_t)); | |
659 this->spu_clut_changed = 0; | |
660 pthread_mutex_unlock(&this->vm_lock); | |
193 | 661 return DVDNAV_STATUS_OK; |
114 | 662 } |
663 | |
664 /* has the SPU channel changed? */ | |
665 if(this->position_current.spu_channel != this->position_next.spu_channel) { | |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
666 dvdnav_spu_stream_change_event_t *stream_change = (dvdnav_spu_stream_change_event_t *)*buf; |
114 | 667 |
668 (*event) = DVDNAV_SPU_STREAM_CHANGE; | |
669 #ifdef LOG_DEBUG | |
670 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE\n"); | |
671 #endif | |
672 (*len) = sizeof(dvdnav_spu_stream_change_event_t); | |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
673 stream_change->physical_wide = vm_get_subp_active_stream(this->vm, 0); |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
674 stream_change->physical_letterbox = vm_get_subp_active_stream(this->vm, 1); |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
675 stream_change->physical_pan_scan = vm_get_subp_active_stream(this->vm, 2); |
114 | 676 this->position_current.spu_channel = this->position_next.spu_channel; |
677 #ifdef LOG_DEBUG | |
143
0b302ca31859
merge James fixes from xine-lib cvs back into libdvdnav cvs so they will not be lost
mroi
parents:
142
diff
changeset
|
678 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_wide=%d\n",stream_change->physical_wide); |
0b302ca31859
merge James fixes from xine-lib cvs back into libdvdnav cvs so they will not be lost
mroi
parents:
142
diff
changeset
|
679 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_letterbox=%d\n",stream_change->physical_letterbox); |
0b302ca31859
merge James fixes from xine-lib cvs back into libdvdnav cvs so they will not be lost
mroi
parents:
142
diff
changeset
|
680 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_pan_scan=%d\n",stream_change->physical_pan_scan); |
249
5d643668f1e3
I added this code myself a long time ago, but now I am quite convinced that
mroi
parents:
231
diff
changeset
|
681 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE returning DVDNAV_STATUS_OK\n"); |
114 | 682 #endif |
249
5d643668f1e3
I added this code myself a long time ago, but now I am quite convinced that
mroi
parents:
231
diff
changeset
|
683 pthread_mutex_unlock(&this->vm_lock); |
5d643668f1e3
I added this code myself a long time ago, but now I am quite convinced that
mroi
parents:
231
diff
changeset
|
684 return DVDNAV_STATUS_OK; |
114 | 685 } |
0 | 686 |
114 | 687 /* has the audio channel changed? */ |
688 if(this->position_current.audio_channel != this->position_next.audio_channel) { | |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
689 dvdnav_audio_stream_change_event_t *stream_change = (dvdnav_audio_stream_change_event_t *)*buf; |
114 | 690 |
691 (*event) = DVDNAV_AUDIO_STREAM_CHANGE; | |
692 #ifdef LOG_DEBUG | |
693 fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE\n"); | |
694 #endif | |
695 (*len) = sizeof(dvdnav_audio_stream_change_event_t); | |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
696 stream_change->physical = vm_get_audio_active_stream( this->vm ); |
114 | 697 this->position_current.audio_channel = this->position_next.audio_channel; |
698 #ifdef LOG_DEBUG | |
193 | 699 fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE stream_id=%d returning DVDNAV_STATUS_OK\n",stream_change->physical); |
114 | 700 #endif |
701 pthread_mutex_unlock(&this->vm_lock); | |
193 | 702 return DVDNAV_STATUS_OK; |
114 | 703 } |
704 | |
705 /* Check the STILLFRAME flag */ | |
706 if(this->position_current.still != 0) { | |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
707 dvdnav_still_event_t *still_event = (dvdnav_still_event_t *)*buf; |
114 | 708 |
709 (*event) = DVDNAV_STILL_FRAME; | |
710 #ifdef LOG_DEBUG | |
711 fprintf(MSG_OUT, "libdvdnav: STILL_FRAME\n"); | |
712 #endif | |
713 (*len) = sizeof(dvdnav_still_event_t); | |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
714 still_event->length = this->position_current.still; |
114 | 715 pthread_mutex_unlock(&this->vm_lock); |
194 | 716 return DVDNAV_STATUS_OK; |
114 | 717 } |
718 | |
719 /* Have we reached the end of a VOBU? */ | |
720 if (this->vobu.blockN >= this->vobu.vobu_length) { | |
721 | |
722 /* 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
|
723 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
|
724 /* End of Cell from NAV DSI info */ |
31 | 725 #ifdef LOG_DEBUG |
76 | 726 fprintf(MSG_OUT, "libdvdnav: Still set to %x\n", this->position_next.still); |
31 | 727 #endif |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
728 this->position_current.still = this->position_next.still; |
0 | 729 |
116 | 730 /* we are about to leave a cell, so a lot of state changes could occur; |
731 * under certain conditions, the application should get in sync with us before this, | |
732 * otherwise it might show stills or menus too shortly */ | |
733 if ((this->position_current.still || this->pci.hli.hl_gi.hli_ss) && !this->sync_wait_skip) { | |
734 this->sync_wait = 1; | |
735 } else { | |
736 if( this->position_current.still == 0 || this->skip_still ) { | |
737 /* no active cell still -> get us to the next cell */ | |
738 vm_get_next_cell(this->vm); | |
739 this->position_current.still = 0; /* still gets activated at end of cell */ | |
740 this->skip_still = 0; | |
741 this->sync_wait_skip = 0; | |
742 } | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
743 } |
114 | 744 /* handle related state changes in next iteration */ |
745 (*event) = DVDNAV_NOP; | |
746 (*len) = 0; | |
747 pthread_mutex_unlock(&this->vm_lock); | |
193 | 748 return DVDNAV_STATUS_OK; |
114 | 749 } |
0 | 750 |
114 | 751 /* Perform remapping jump if necessary (this is always a |
0 | 752 * VOBU boundary). */ |
114 | 753 if (this->vm->map) { |
754 this->vobu.vobu_next = remap_block( this->vm->map, | |
755 this->vm->state.domain, this->vm->state.TTN_REG, | |
756 this->vm->state.pgN, | |
757 this->vobu.vobu_start, this->vobu.vobu_next); | |
758 } | |
0 | 759 |
114 | 760 /* at the start of the next VOBU -> expecting NAV packet */ |
45 | 761 result = dvdnav_read_cache_block(this->cache, this->vobu.vobu_start + this->vobu.vobu_next, 1, buf); |
0 | 762 |
763 if(result <= 0) { | |
764 printerr("Error reading NAV packet."); | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
765 pthread_mutex_unlock(&this->vm_lock); |
193 | 766 return DVDNAV_STATUS_ERR; |
0 | 767 } |
114 | 768 /* Decode nav into pci and dsi. Then get next VOBU info. */ |
769 if(!dvdnav_decode_packet(this, *buf, &this->dsi, &this->pci)) { | |
0 | 770 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
|
771 pthread_mutex_unlock(&this->vm_lock); |
193 | 772 return DVDNAV_STATUS_ERR; |
0 | 773 } |
114 | 774 /* We need to update the vm state->blockN with which VOBU we are in. |
775 * This is so RSM resumes to the VOBU level and not just the CELL level. | |
28 | 776 */ |
114 | 777 this->vm->state.blockN = this->vobu.vobu_start - this->position_current.cell_start; |
778 | |
779 dvdnav_get_vobu(this, &this->dsi, &this->pci, &this->vobu); | |
780 this->vobu.blockN = 0; | |
781 /* Give the cache a hint about the size of next VOBU. | |
782 * This improves pre-caching, because the VOBU will almost certainly be read entirely. | |
45 | 783 */ |
784 dvdnav_pre_cache_blocks(this->cache, this->vobu.vobu_start+1, this->vobu.vobu_length+1); | |
0 | 785 |
191
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
179
diff
changeset
|
786 /* release NAV menu filter, when we reach the same NAV packet again */ |
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
179
diff
changeset
|
787 if (this->last_cmd_nav_lbn == this->pci.pci_gi.nv_pck_lbn) |
198
373f27da196b
This one should also be reset to an invalid value, but 0 is not invalid.
mroi
parents:
197
diff
changeset
|
788 this->last_cmd_nav_lbn = SRI_END_OF_CELL; |
191
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
179
diff
changeset
|
789 |
0 | 790 /* Successfully got a NAV packet */ |
791 (*event) = DVDNAV_NAV_PACKET; | |
114 | 792 #ifdef LOG_DEBUG |
793 fprintf(MSG_OUT, "libdvdnav: NAV_PACKET\n"); | |
794 #endif | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
795 (*len) = 2048; |
269
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
796 this->cur_cell_time = dvdnav_convert_time(&this->dsi.dsi_gi.c_eltm); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
797 pthread_mutex_unlock(&this->vm_lock); |
193 | 798 return DVDNAV_STATUS_OK; |
0 | 799 } |
800 | |
801 /* 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
|
802 if(!this->file) { |
114 | 803 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
|
804 pthread_mutex_unlock(&this->vm_lock); |
193 | 805 return DVDNAV_STATUS_ERR; |
0 | 806 } |
807 | |
114 | 808 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
|
809 result = dvdnav_read_cache_block(this->cache, this->vobu.vobu_start + this->vobu.blockN, 1, buf); |
0 | 810 if(result <= 0) { |
811 printerr("Error reading from DVD."); | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
812 pthread_mutex_unlock(&this->vm_lock); |
193 | 813 return DVDNAV_STATUS_ERR; |
0 | 814 } |
114 | 815 (*event) = DVDNAV_BLOCK_OK; |
0 | 816 (*len) = 2048; |
817 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
818 pthread_mutex_unlock(&this->vm_lock); |
193 | 819 return DVDNAV_STATUS_OK; |
0 | 820 } |
821 | |
114 | 822 dvdnav_status_t dvdnav_get_title_string(dvdnav_t *this, const char **title_str) { |
823 (*title_str) = this->vm->dvd_name; | |
193 | 824 return DVDNAV_STATUS_OK; |
114 | 825 } |
826 | |
827 uint8_t dvdnav_get_video_aspect(dvdnav_t *this) { | |
828 uint8_t retval; | |
273
bd734ab914d0
removed nonsensical checks on the sanity of dvdnav_t *this
nicodvb
parents:
272
diff
changeset
|
829 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
830 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
831 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
832 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
833 } |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
834 |
114 | 835 pthread_mutex_lock(&this->vm_lock); |
836 retval = (uint8_t)vm_get_video_aspect(this->vm); | |
837 pthread_mutex_unlock(&this->vm_lock); | |
838 | |
839 return retval; | |
840 } | |
841 | |
842 uint8_t dvdnav_get_video_scale_permission(dvdnav_t *this) { | |
843 uint8_t retval; | |
844 | |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
845 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
846 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
847 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
848 } |
114 | 849 |
850 pthread_mutex_lock(&this->vm_lock); | |
851 retval = (uint8_t)vm_get_video_scale_permission(this->vm); | |
852 pthread_mutex_unlock(&this->vm_lock); | |
853 | |
854 return retval; | |
855 } | |
856 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
857 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
|
858 audio_attr_t attr; |
0 | 859 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
860 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
861 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
862 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
863 } |
0 | 864 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
865 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
|
866 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
|
867 pthread_mutex_unlock(&this->vm_lock); |
0 | 868 |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
869 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
|
870 return 0xffff; |
0 | 871 |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
872 return attr.lang_code; |
0 | 873 } |
874 | |
266 | 875 uint16_t dvdnav_audio_stream_format(dvdnav_t *this, uint8_t stream) { |
876 audio_attr_t attr; | |
877 uint16_t format; | |
878 | |
879 if(!this->started) { | |
880 printerr("Virtual DVD machine not started."); | |
881 return -1; /* 0xffff */ | |
882 } | |
883 | |
884 pthread_mutex_lock(&this->vm_lock); | |
885 attr = vm_get_audio_attr(this->vm, stream); | |
886 pthread_mutex_unlock(&this->vm_lock); | |
887 | |
888 switch(attr.audio_format) { | |
889 case 0: | |
890 format = DVDNAV_FORMAT_AC3; | |
891 break; | |
892 case 2: /* MPEG-1 or MPEG-2 without extension bitstream. */ | |
893 case 3: /* MPEG-2 with extension bitstream. */ | |
894 format = DVDNAV_FORMAT_MPEGAUDIO; | |
895 break; | |
896 case 4: | |
897 format = DVDNAV_FORMAT_LPCM; | |
898 break; | |
899 case 6: | |
900 format = DVDNAV_FORMAT_DTS; | |
901 break; | |
902 case 7: | |
903 format = DVDNAV_FORMAT_SDDS; | |
904 break; | |
905 default: | |
906 format = 0xffff; | |
907 break; | |
908 } | |
909 | |
910 return format; | |
911 } | |
912 | |
272
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
913 uint16_t dvdnav_audio_stream_channels(dvdnav_t *this, uint8_t stream) { |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
914 audio_attr_t attr; |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
915 |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
916 if(!this->started) { |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
917 printerr("Virtual DVD machine not started."); |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
918 return -1; /* 0xffff */ |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
919 } |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
920 |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
921 pthread_mutex_lock(&this->vm_lock); |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
922 attr = vm_get_audio_attr(this->vm, stream); |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
923 pthread_mutex_unlock(&this->vm_lock); |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
924 |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
925 return attr.channels + 1; |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
926 } |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
927 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
928 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
|
929 subp_attr_t attr; |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
930 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
931 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
932 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
933 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
934 } |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
935 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
936 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
|
937 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
|
938 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
|
939 |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
940 if(attr.type != 1) |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
941 return 0xffff; |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
942 |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
943 return attr.lang_code; |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
944 } |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
945 |
114 | 946 int8_t dvdnav_get_audio_logical_stream(dvdnav_t *this, uint8_t audio_num) { |
947 int8_t retval; | |
948 | |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
949 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
950 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
951 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
952 } |
114 | 953 |
954 pthread_mutex_lock(&this->vm_lock); | |
955 if (!this->vm->state.pgc) { | |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
956 printerr("No current PGC."); |
114 | 957 pthread_mutex_unlock(&this->vm_lock); |
958 return -1; | |
959 } | |
960 retval = vm_get_audio_stream(this->vm, audio_num); | |
961 pthread_mutex_unlock(&this->vm_lock); | |
962 | |
963 return retval; | |
964 } | |
965 | |
300
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
966 dvdnav_status_t dvdnav_get_audio_attr(dvdnav_t *this, uint8_t audio_num, audio_attr_t *audio_attr) { |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
967 if(!this->started) { |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
968 printerr("Virtual DVD machine not started."); |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
969 return -1; |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
970 } |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
971 pthread_mutex_lock(&this->vm_lock); |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
972 if (!this->vm->state.pgc) { |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
973 printerr("No current PGC."); |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
974 pthread_mutex_unlock(&this->vm_lock); |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
975 return -1; |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
976 } |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
977 *audio_attr=vm_get_audio_attr(this->vm, audio_num); |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
978 pthread_mutex_unlock(&this->vm_lock); |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
979 |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
980 return DVDNAV_STATUS_OK; |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
981 } |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
982 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
983 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
|
984 int8_t retval; |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
985 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
986 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
987 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
988 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
989 } |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
990 |
114 | 991 pthread_mutex_lock(&this->vm_lock); |
992 if (!this->vm->state.pgc) { | |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
993 printerr("No current PGC."); |
114 | 994 pthread_mutex_unlock(&this->vm_lock); |
995 return -1; | |
996 } | |
997 retval = vm_get_subp_stream(this->vm, subp_num, 0); | |
998 pthread_mutex_unlock(&this->vm_lock); | |
999 | |
1000 return retval; | |
1001 } | |
1002 | |
300
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1003 dvdnav_status_t dvdnav_get_spu_attr(dvdnav_t *this, uint8_t audio_num, subp_attr_t *subp_attr) { |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1004 if(!this->started) { |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1005 printerr("Virtual DVD machine not started."); |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1006 return -1; |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1007 } |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1008 pthread_mutex_lock(&this->vm_lock); |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1009 if (!this->vm->state.pgc) { |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1010 printerr("No current PGC."); |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1011 pthread_mutex_unlock(&this->vm_lock); |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1012 return -1; |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1013 } |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1014 *subp_attr=vm_get_subp_attr(this->vm, audio_num); |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1015 pthread_mutex_unlock(&this->vm_lock); |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1016 return DVDNAV_STATUS_OK; |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1017 } |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1018 |
114 | 1019 int8_t dvdnav_get_active_audio_stream(dvdnav_t *this) { |
1020 int8_t retval; | |
1021 | |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1022 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1023 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1024 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1025 } |
114 | 1026 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1027 pthread_mutex_lock(&this->vm_lock); |
114 | 1028 if (!this->vm->state.pgc) { |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1029 printerr("No current PGC."); |
114 | 1030 pthread_mutex_unlock(&this->vm_lock); |
1031 return -1; | |
1032 } | |
1033 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
|
1034 pthread_mutex_unlock(&this->vm_lock); |
114 | 1035 |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1036 return retval; |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1037 } |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1038 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1039 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
|
1040 int8_t retval; |
0 | 1041 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1042 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1043 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1044 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1045 } |
0 | 1046 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1047 pthread_mutex_lock(&this->vm_lock); |
114 | 1048 if (!this->vm->state.pgc) { |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1049 printerr("No current PGC."); |
114 | 1050 pthread_mutex_unlock(&this->vm_lock); |
1051 return -1; | |
1052 } | |
1053 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
|
1054 pthread_mutex_unlock(&this->vm_lock); |
0 | 1055 |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1056 return retval; |
0 | 1057 } |
1058 | |
114 | 1059 static int8_t dvdnav_is_domain(dvdnav_t *this, domain_t domain) { |
1060 int8_t retval; | |
1061 | |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1062 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1063 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1064 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1065 } |
114 | 1066 |
1067 pthread_mutex_lock(&this->vm_lock); | |
1068 retval = (this->vm->state.domain == domain); | |
1069 pthread_mutex_unlock(&this->vm_lock); | |
1070 | |
1071 return retval; | |
1072 } | |
1073 | |
0 | 1074 /* First Play domain. (Menu) */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1075 int8_t dvdnav_is_domain_fp(dvdnav_t *this) { |
114 | 1076 return dvdnav_is_domain(this, FP_DOMAIN); |
0 | 1077 } |
1078 /* Video management Menu domain. (Menu) */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1079 int8_t dvdnav_is_domain_vmgm(dvdnav_t *this) { |
114 | 1080 return dvdnav_is_domain(this, VMGM_DOMAIN); |
0 | 1081 } |
1082 /* Video Title Menu domain (Menu) */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1083 int8_t dvdnav_is_domain_vtsm(dvdnav_t *this) { |
114 | 1084 return dvdnav_is_domain(this, VTSM_DOMAIN); |
0 | 1085 } |
1086 /* Video Title domain (playing movie). */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1087 int8_t dvdnav_is_domain_vts(dvdnav_t *this) { |
114 | 1088 return dvdnav_is_domain(this, VTS_DOMAIN); |
0 | 1089 } |
1090 | |
114 | 1091 /* Generally delegate angle information handling to VM */ |
195 | 1092 dvdnav_status_t dvdnav_angle_change(dvdnav_t *this, int32_t angle) { |
1093 int32_t num, current; | |
0 | 1094 |
114 | 1095 pthread_mutex_lock(&this->vm_lock); |
1096 vm_get_angle_info(this->vm, ¤t, &num); | |
0 | 1097 /* Set angle SPRM if valid */ |
1098 if((angle > 0) && (angle <= num)) { | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1099 this->vm->state.AGL_REG = angle; |
0 | 1100 } else { |
114 | 1101 printerr("Passed an invalid angle number."); |
1102 pthread_mutex_unlock(&this->vm_lock); | |
193 | 1103 return DVDNAV_STATUS_ERR; |
0 | 1104 } |
114 | 1105 pthread_mutex_unlock(&this->vm_lock); |
0 | 1106 |
193 | 1107 return DVDNAV_STATUS_OK; |
0 | 1108 } |
1109 | |
195 | 1110 dvdnav_status_t dvdnav_get_angle_info(dvdnav_t *this, int32_t *current_angle, |
1111 int32_t *number_of_angles) { | |
114 | 1112 pthread_mutex_lock(&this->vm_lock); |
1113 vm_get_angle_info(this->vm, current_angle, number_of_angles); | |
1114 pthread_mutex_unlock(&this->vm_lock); | |
1115 | |
193 | 1116 return DVDNAV_STATUS_OK; |
114 | 1117 } |
0 | 1118 |
67
61c0ee1bbb7a
Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents:
66
diff
changeset
|
1119 pci_t* dvdnav_get_current_nav_pci(dvdnav_t *this) { |
114 | 1120 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
|
1121 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
|
1122 } |
61c0ee1bbb7a
Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents:
66
diff
changeset
|
1123 |
66
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1124 dsi_t* dvdnav_get_current_nav_dsi(dvdnav_t *this) { |
114 | 1125 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
|
1126 return &this->dsi; |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1127 } |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1128 |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1129 uint32_t dvdnav_get_next_still_flag(dvdnav_t *this) { |
114 | 1130 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
|
1131 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
|
1132 } |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1133 |
262 | 1134 user_ops_t dvdnav_get_restrictions(dvdnav_t* this) { |
1135 /* | |
1136 * user_ops_t is a structure of 32 bits. We want to compute | |
1137 * the union of two of those bitfields so to make this quicker | |
1138 * than performing 32 ORs, we will access them as 32bits words. | |
1139 */ | |
264 | 1140 union { |
1141 user_ops_t ops_struct; | |
1142 uint32_t ops_int; | |
1143 } ops; | |
1144 | |
1145 ops.ops_int = 0; | |
262 | 1146 |
263 | 1147 if(!this->started) { |
1148 printerr("Virtual DVD machine not started."); | |
264 | 1149 return ops.ops_struct; |
263 | 1150 } |
1151 | |
1152 pthread_mutex_lock(&this->vm_lock); | |
264 | 1153 ops.ops_int |= *(uint32_t*)&this->pci.pci_gi.vobu_uop_ctl; |
262 | 1154 |
1155 if(this->vm && this->vm->state.pgc) | |
264 | 1156 ops.ops_int |= *(uint32_t*)&this->vm->state.pgc->prohibited_ops; |
263 | 1157 pthread_mutex_unlock(&this->vm_lock); |
262 | 1158 |
264 | 1159 return ops.ops_struct; |
262 | 1160 } |