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