Mercurial > libdvdnav.hg
annotate dvdnav.c @ 409:9b8bfc56a7fe src
Add dvdnav_program_play & dvdnav_current_title_program
Using title parts w/ dvdnav_part_play and dvdnav_current_title_info
is not reliable for use as chapter marks in files made from
transcoding. The start of a part does not necessarily fall strictly
inside the main title. Parts can have an intro sequence before
getting into the title. So we use program boundaries instead of
part markers to test when we have reached a chapter point during
encoding of the title. The same would apply to displaying the
current chapter during playback. The program boundaries
should be checked instead of looking for a part.
Patch from John Stebbins. Thanks!
author | erik |
---|---|
date | Fri, 30 Jul 2010 23:34:16 +0000 |
parents | 51be513f1a1d |
children | 8c87207b73ac |
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 |
135 | 206 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
|
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 |
0 | 339 |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
340 if(num_angle != 0) { |
388 | 341 |
114 | 342 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
|
343 if((next & 0x3fffffff) != 0) { |
114 | 344 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
|
345 vobu->vobu_next = - (int32_t)(next & 0x3fffffff); |
114 | 346 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
|
347 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
|
348 } |
114 | 349 } 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
|
350 vobu->vobu_length = nav_dsi->sml_pbi.ilvu_ea; |
388 | 351 |
114 | 352 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
|
353 vobu->vobu_next = - (int32_t)(next & 0x3fffffff); |
114 | 354 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
|
355 vobu->vobu_next = + (int32_t)(next & 0x3fffffff); |
0 | 356 } |
357 } | |
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
|
358 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
359 return 1; |
0 | 360 } |
60 | 361 |
114 | 362 /* |
363 * These are the main get_next_block function which actually get the media stream video and audio etc. | |
364 * | |
365 * There are two versions: The second one is using the zero-copy read ahead cache and therefore | |
366 * hands out pointers targetting directly into the cache. | |
367 * The first one uses a memcopy to fill this cache block into the application provided memory. | |
368 * The benefit of this first one is that no special memory management is needed. The application is | |
369 * the only one responsible of allocating and freeing the memory associated with the pointer. | |
370 * The drawback is the additional memcopy. | |
28 | 371 */ |
60 | 372 |
195 | 373 dvdnav_status_t dvdnav_get_next_block(dvdnav_t *this, uint8_t *buf, |
374 int32_t *event, int32_t *len) { | |
60 | 375 unsigned char *block; |
376 dvdnav_status_t status; | |
388 | 377 |
60 | 378 block = buf; |
379 status = dvdnav_get_next_cache_block(this, &block, event, len); | |
193 | 380 if (status == DVDNAV_STATUS_OK && block != buf) { |
60 | 381 /* we received a block from the cache, copy it, so we can give it back */ |
382 memcpy(buf, block, DVD_VIDEO_LB_LEN); | |
383 dvdnav_free_cache_block(this, block); | |
384 } | |
385 return status; | |
386 } | |
269
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
387 |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
388 int64_t dvdnav_get_current_time(dvdnav_t *this) { |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
389 int i; |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
390 int64_t tm=0; |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
391 dvd_state_t *state = &this->vm->state; |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
392 |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
393 for(i=0; i<state->cellN-1; i++) { |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
394 if(! |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
395 (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
|
396 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
|
397 ) |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
398 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
|
399 } |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
400 tm += this->cur_cell_time; |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
401 |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
402 return tm; |
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
403 } |
388 | 404 |
195 | 405 dvdnav_status_t dvdnav_get_next_cache_block(dvdnav_t *this, uint8_t **buf, |
406 int32_t *event, int32_t *len) { | |
0 | 407 dvd_state_t *state; |
195 | 408 int32_t result; |
114 | 409 |
410 pthread_mutex_lock(&this->vm_lock); | |
388 | 411 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
412 if(!this->started) { |
0 | 413 /* Start the VM */ |
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
249
diff
changeset
|
414 if (!vm_start(this->vm)) { |
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
249
diff
changeset
|
415 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
|
416 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
|
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; | |
388 | 425 |
0 | 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; |
388 | 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); |
388 | 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; |
388 | 452 |
114 | 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."); | |
388 | 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."); | |
388 | 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; |
388 | 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; |
388 | 506 pthread_mutex_unlock(&this->vm_lock); |
193 | 507 return DVDNAV_STATUS_OK; |
116 | 508 } |
388 | 509 |
116 | 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 */ |
388 | 522 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
|
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; |
388 | 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; | |
388 | 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; |
388 | 545 vtsN = this->position_next.vts; |
0 | 546 break; |
114 | 547 case VTS_DOMAIN: |
0 | 548 domain = DVD_READ_TITLE_VOBS; |
388 | 549 vtsN = this->position_next.vts; |
0 | 550 break; |
114 | 551 default: |
0 | 552 printerr("Unknown domain when changing VTS."); |
388 | 553 pthread_mutex_unlock(&this->vm_lock); |
193 | 554 return DVDNAV_STATUS_ERR; |
0 | 555 } |
388 | 556 |
557 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
|
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); |
388 | 561 vts_event->new_vtsN = this->position_next.vts; |
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); |
388 | 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 */; |
388 | 582 |
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 |
388 | 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; |
388 | 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); |
388 | 601 |
134
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; | |
388 | 634 |
114 | 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; |
388 | 641 |
114 | 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 | |
388 | 647 pthread_mutex_unlock(&this->vm_lock); |
193 | 648 return DVDNAV_STATUS_OK; |
0 | 649 } |
388 | 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; | |
388 | 660 pthread_mutex_unlock(&this->vm_lock); |
193 | 661 return DVDNAV_STATUS_OK; |
114 | 662 } |
663 | |
388 | 664 /* has the SPU channel changed? */ |
114 | 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 |
388 | 683 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
|
684 return DVDNAV_STATUS_OK; |
114 | 685 } |
0 | 686 |
388 | 687 /* has the audio channel changed? */ |
114 | 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; |
388 | 690 |
114 | 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 ); |
383
275f15342ea3
after an AUDIO change event assign the logical stream to the returned event,
nicodvb
parents:
380
diff
changeset
|
697 stream_change->logical = this->position_next.audio_channel; |
114 | 698 this->position_current.audio_channel = this->position_next.audio_channel; |
699 #ifdef LOG_DEBUG | |
193 | 700 fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE stream_id=%d returning DVDNAV_STATUS_OK\n",stream_change->physical); |
114 | 701 #endif |
388 | 702 pthread_mutex_unlock(&this->vm_lock); |
193 | 703 return DVDNAV_STATUS_OK; |
114 | 704 } |
388 | 705 |
114 | 706 /* Check the STILLFRAME flag */ |
707 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
|
708 dvdnav_still_event_t *still_event = (dvdnav_still_event_t *)*buf; |
114 | 709 |
710 (*event) = DVDNAV_STILL_FRAME; | |
711 #ifdef LOG_DEBUG | |
712 fprintf(MSG_OUT, "libdvdnav: STILL_FRAME\n"); | |
713 #endif | |
714 (*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
|
715 still_event->length = this->position_current.still; |
388 | 716 pthread_mutex_unlock(&this->vm_lock); |
194 | 717 return DVDNAV_STATUS_OK; |
114 | 718 } |
719 | |
720 /* Have we reached the end of a VOBU? */ | |
721 if (this->vobu.blockN >= this->vobu.vobu_length) { | |
722 | |
723 /* 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
|
724 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
|
725 /* End of Cell from NAV DSI info */ |
31 | 726 #ifdef LOG_DEBUG |
76 | 727 fprintf(MSG_OUT, "libdvdnav: Still set to %x\n", this->position_next.still); |
31 | 728 #endif |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
729 this->position_current.still = this->position_next.still; |
0 | 730 |
116 | 731 /* we are about to leave a cell, so a lot of state changes could occur; |
732 * under certain conditions, the application should get in sync with us before this, | |
733 * otherwise it might show stills or menus too shortly */ | |
734 if ((this->position_current.still || this->pci.hli.hl_gi.hli_ss) && !this->sync_wait_skip) { | |
735 this->sync_wait = 1; | |
736 } else { | |
737 if( this->position_current.still == 0 || this->skip_still ) { | |
738 /* no active cell still -> get us to the next cell */ | |
739 vm_get_next_cell(this->vm); | |
740 this->position_current.still = 0; /* still gets activated at end of cell */ | |
741 this->skip_still = 0; | |
742 this->sync_wait_skip = 0; | |
743 } | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
744 } |
114 | 745 /* handle related state changes in next iteration */ |
746 (*event) = DVDNAV_NOP; | |
747 (*len) = 0; | |
388 | 748 pthread_mutex_unlock(&this->vm_lock); |
193 | 749 return DVDNAV_STATUS_OK; |
114 | 750 } |
0 | 751 |
388 | 752 /* Perform remapping jump if necessary (this is always a |
0 | 753 * VOBU boundary). */ |
114 | 754 if (this->vm->map) { |
755 this->vobu.vobu_next = remap_block( this->vm->map, | |
756 this->vm->state.domain, this->vm->state.TTN_REG, | |
757 this->vm->state.pgN, | |
758 this->vobu.vobu_start, this->vobu.vobu_next); | |
759 } | |
0 | 760 |
114 | 761 /* at the start of the next VOBU -> expecting NAV packet */ |
45 | 762 result = dvdnav_read_cache_block(this->cache, this->vobu.vobu_start + this->vobu.vobu_next, 1, buf); |
0 | 763 |
764 if(result <= 0) { | |
765 printerr("Error reading NAV packet."); | |
388 | 766 pthread_mutex_unlock(&this->vm_lock); |
193 | 767 return DVDNAV_STATUS_ERR; |
0 | 768 } |
114 | 769 /* Decode nav into pci and dsi. Then get next VOBU info. */ |
770 if(!dvdnav_decode_packet(this, *buf, &this->dsi, &this->pci)) { | |
0 | 771 printerr("Expected NAV packet but none found."); |
388 | 772 pthread_mutex_unlock(&this->vm_lock); |
193 | 773 return DVDNAV_STATUS_ERR; |
0 | 774 } |
114 | 775 /* We need to update the vm state->blockN with which VOBU we are in. |
776 * This is so RSM resumes to the VOBU level and not just the CELL level. | |
28 | 777 */ |
114 | 778 this->vm->state.blockN = this->vobu.vobu_start - this->position_current.cell_start; |
779 | |
388 | 780 dvdnav_get_vobu(this, &this->dsi, &this->pci, &this->vobu); |
114 | 781 this->vobu.blockN = 0; |
782 /* Give the cache a hint about the size of next VOBU. | |
783 * This improves pre-caching, because the VOBU will almost certainly be read entirely. | |
45 | 784 */ |
785 dvdnav_pre_cache_blocks(this->cache, this->vobu.vobu_start+1, this->vobu.vobu_length+1); | |
388 | 786 |
191
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
179
diff
changeset
|
787 /* 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
|
788 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
|
789 this->last_cmd_nav_lbn = SRI_END_OF_CELL; |
388 | 790 |
0 | 791 /* Successfully got a NAV packet */ |
792 (*event) = DVDNAV_NAV_PACKET; | |
114 | 793 #ifdef LOG_DEBUG |
794 fprintf(MSG_OUT, "libdvdnav: NAV_PACKET\n"); | |
795 #endif | |
388 | 796 (*len) = 2048; |
269
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
797 this->cur_cell_time = dvdnav_convert_time(&this->dsi.dsi_gi.c_eltm); |
388 | 798 pthread_mutex_unlock(&this->vm_lock); |
193 | 799 return DVDNAV_STATUS_OK; |
0 | 800 } |
388 | 801 |
0 | 802 /* 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
|
803 if(!this->file) { |
114 | 804 printerr("Attempting to read without opening file."); |
388 | 805 pthread_mutex_unlock(&this->vm_lock); |
193 | 806 return DVDNAV_STATUS_ERR; |
0 | 807 } |
808 | |
114 | 809 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
|
810 result = dvdnav_read_cache_block(this->cache, this->vobu.vobu_start + this->vobu.blockN, 1, buf); |
0 | 811 if(result <= 0) { |
812 printerr("Error reading from DVD."); | |
388 | 813 pthread_mutex_unlock(&this->vm_lock); |
193 | 814 return DVDNAV_STATUS_ERR; |
0 | 815 } |
114 | 816 (*event) = DVDNAV_BLOCK_OK; |
0 | 817 (*len) = 2048; |
818 | |
388 | 819 pthread_mutex_unlock(&this->vm_lock); |
193 | 820 return DVDNAV_STATUS_OK; |
0 | 821 } |
822 | |
114 | 823 dvdnav_status_t dvdnav_get_title_string(dvdnav_t *this, const char **title_str) { |
824 (*title_str) = this->vm->dvd_name; | |
193 | 825 return DVDNAV_STATUS_OK; |
114 | 826 } |
827 | |
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
|
828 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
|
829 (*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
|
830 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
|
831 } |
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 |
114 | 833 uint8_t dvdnav_get_video_aspect(dvdnav_t *this) { |
834 uint8_t retval; | |
273
bd734ab914d0
removed nonsensical checks on the sanity of dvdnav_t *this
nicodvb
parents:
272
diff
changeset
|
835 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
836 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
837 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
838 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
839 } |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
840 |
114 | 841 pthread_mutex_lock(&this->vm_lock); |
842 retval = (uint8_t)vm_get_video_aspect(this->vm); | |
843 pthread_mutex_unlock(&this->vm_lock); | |
388 | 844 |
114 | 845 return retval; |
846 } | |
401 | 847 int dvdnav_get_video_resolution(dvdnav_t *this, uint32_t *width, uint32_t *height) { |
848 int w, h; | |
849 | |
850 if(!this->started) { | |
851 printerr("Virtual DVD machine not started."); | |
852 return -1; | |
853 } | |
854 | |
855 pthread_mutex_lock(&this->vm_lock); | |
856 vm_get_video_res(this->vm, &w, &h); | |
857 pthread_mutex_unlock(&this->vm_lock); | |
858 | |
859 *width = w; | |
860 *height = h; | |
861 return 0; | |
862 } | |
114 | 863 |
864 uint8_t dvdnav_get_video_scale_permission(dvdnav_t *this) { | |
865 uint8_t retval; | |
388 | 866 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
867 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
868 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
869 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
870 } |
388 | 871 |
114 | 872 pthread_mutex_lock(&this->vm_lock); |
873 retval = (uint8_t)vm_get_video_scale_permission(this->vm); | |
874 pthread_mutex_unlock(&this->vm_lock); | |
388 | 875 |
114 | 876 return retval; |
877 } | |
878 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
879 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
|
880 audio_attr_t attr; |
388 | 881 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
882 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
883 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
884 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
885 } |
388 | 886 |
887 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
|
888 attr = vm_get_audio_attr(this->vm, stream); |
388 | 889 pthread_mutex_unlock(&this->vm_lock); |
890 | |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
891 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
|
892 return 0xffff; |
388 | 893 |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
894 return attr.lang_code; |
0 | 895 } |
896 | |
266 | 897 uint16_t dvdnav_audio_stream_format(dvdnav_t *this, uint8_t stream) { |
898 audio_attr_t attr; | |
899 uint16_t format; | |
388 | 900 |
266 | 901 if(!this->started) { |
902 printerr("Virtual DVD machine not started."); | |
903 return -1; /* 0xffff */ | |
904 } | |
388 | 905 |
906 pthread_mutex_lock(&this->vm_lock); | |
266 | 907 attr = vm_get_audio_attr(this->vm, stream); |
388 | 908 pthread_mutex_unlock(&this->vm_lock); |
909 | |
266 | 910 switch(attr.audio_format) { |
911 case 0: | |
912 format = DVDNAV_FORMAT_AC3; | |
913 break; | |
914 case 2: /* MPEG-1 or MPEG-2 without extension bitstream. */ | |
915 case 3: /* MPEG-2 with extension bitstream. */ | |
916 format = DVDNAV_FORMAT_MPEGAUDIO; | |
917 break; | |
918 case 4: | |
919 format = DVDNAV_FORMAT_LPCM; | |
920 break; | |
921 case 6: | |
922 format = DVDNAV_FORMAT_DTS; | |
923 break; | |
924 case 7: | |
925 format = DVDNAV_FORMAT_SDDS; | |
926 break; | |
388 | 927 default: |
266 | 928 format = 0xffff; |
929 break; | |
930 } | |
388 | 931 |
266 | 932 return format; |
933 } | |
934 | |
272
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
935 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
|
936 audio_attr_t attr; |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
937 |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
938 if(!this->started) { |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
939 printerr("Virtual DVD machine not started."); |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
940 return -1; /* 0xffff */ |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
941 } |
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 pthread_mutex_lock(&this->vm_lock); |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
944 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
|
945 pthread_mutex_unlock(&this->vm_lock); |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
946 |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
947 return attr.channels + 1; |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
948 } |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
949 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
950 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
|
951 subp_attr_t attr; |
388 | 952 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
953 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
954 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
955 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
956 } |
388 | 957 |
958 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
|
959 attr = vm_get_subp_attr(this->vm, stream); |
388 | 960 pthread_mutex_unlock(&this->vm_lock); |
961 | |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
962 if(attr.type != 1) |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
963 return 0xffff; |
388 | 964 |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
965 return attr.lang_code; |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
966 } |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
967 |
114 | 968 int8_t dvdnav_get_audio_logical_stream(dvdnav_t *this, uint8_t audio_num) { |
969 int8_t retval; | |
388 | 970 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
971 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
972 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
973 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
974 } |
388 | 975 |
114 | 976 pthread_mutex_lock(&this->vm_lock); |
977 if (!this->vm->state.pgc) { | |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
978 printerr("No current PGC."); |
388 | 979 pthread_mutex_unlock(&this->vm_lock); |
114 | 980 return -1; |
981 } | |
982 retval = vm_get_audio_stream(this->vm, audio_num); | |
388 | 983 pthread_mutex_unlock(&this->vm_lock); |
114 | 984 |
985 return retval; | |
986 } | |
987 | |
300
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
988 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
|
989 if(!this->started) { |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
990 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
|
991 return -1; |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
992 } |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
993 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
|
994 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
|
995 printerr("No current PGC."); |
388 | 996 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
|
997 return -1; |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
998 } |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
999 *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
|
1000 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
|
1001 |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1002 return DVDNAV_STATUS_OK; |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1003 } |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1004 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1005 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
|
1006 int8_t retval; |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1007 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1008 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1009 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1010 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1011 } |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1012 |
114 | 1013 pthread_mutex_lock(&this->vm_lock); |
1014 if (!this->vm->state.pgc) { | |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1015 printerr("No current PGC."); |
388 | 1016 pthread_mutex_unlock(&this->vm_lock); |
114 | 1017 return -1; |
1018 } | |
1019 retval = vm_get_subp_stream(this->vm, subp_num, 0); | |
1020 pthread_mutex_unlock(&this->vm_lock); | |
1021 | |
1022 return retval; | |
1023 } | |
1024 | |
300
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1025 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
|
1026 if(!this->started) { |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1027 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
|
1028 return -1; |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1029 } |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1030 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
|
1031 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
|
1032 printerr("No current PGC."); |
388 | 1033 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
|
1034 return -1; |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1035 } |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1036 *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
|
1037 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
|
1038 return DVDNAV_STATUS_OK; |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1039 } |
cbd2b606f343
implemented dvdnav_get_audio_attr and dvdnav_get_spu_attr; patch by Attila Otvos
nicodvb
parents:
291
diff
changeset
|
1040 |
114 | 1041 int8_t dvdnav_get_active_audio_stream(dvdnav_t *this) { |
1042 int8_t retval; | |
1043 | |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1044 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1045 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1046 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1047 } |
388 | 1048 |
1049 pthread_mutex_lock(&this->vm_lock); | |
114 | 1050 if (!this->vm->state.pgc) { |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1051 printerr("No current PGC."); |
388 | 1052 pthread_mutex_unlock(&this->vm_lock); |
114 | 1053 return -1; |
1054 } | |
1055 retval = vm_get_audio_active_stream(this->vm); | |
388 | 1056 pthread_mutex_unlock(&this->vm_lock); |
1057 | |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1058 return retval; |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1059 } |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1060 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1061 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
|
1062 int8_t retval; |
0 | 1063 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1064 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1065 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1066 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1067 } |
388 | 1068 |
1069 pthread_mutex_lock(&this->vm_lock); | |
114 | 1070 if (!this->vm->state.pgc) { |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1071 printerr("No current PGC."); |
388 | 1072 pthread_mutex_unlock(&this->vm_lock); |
114 | 1073 return -1; |
1074 } | |
1075 retval = vm_get_subp_active_stream(this->vm, 0); | |
388 | 1076 pthread_mutex_unlock(&this->vm_lock); |
1077 | |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1078 return retval; |
0 | 1079 } |
1080 | |
114 | 1081 static int8_t dvdnav_is_domain(dvdnav_t *this, domain_t domain) { |
1082 int8_t retval; | |
388 | 1083 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1084 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1085 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1086 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1087 } |
388 | 1088 |
114 | 1089 pthread_mutex_lock(&this->vm_lock); |
1090 retval = (this->vm->state.domain == domain); | |
1091 pthread_mutex_unlock(&this->vm_lock); | |
388 | 1092 |
114 | 1093 return retval; |
1094 } | |
1095 | |
0 | 1096 /* First Play domain. (Menu) */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1097 int8_t dvdnav_is_domain_fp(dvdnav_t *this) { |
114 | 1098 return dvdnav_is_domain(this, FP_DOMAIN); |
0 | 1099 } |
1100 /* Video management Menu domain. (Menu) */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1101 int8_t dvdnav_is_domain_vmgm(dvdnav_t *this) { |
114 | 1102 return dvdnav_is_domain(this, VMGM_DOMAIN); |
0 | 1103 } |
1104 /* Video Title Menu domain (Menu) */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1105 int8_t dvdnav_is_domain_vtsm(dvdnav_t *this) { |
114 | 1106 return dvdnav_is_domain(this, VTSM_DOMAIN); |
0 | 1107 } |
1108 /* Video Title domain (playing movie). */ | |
388 | 1109 int8_t dvdnav_is_domain_vts(dvdnav_t *this) { |
114 | 1110 return dvdnav_is_domain(this, VTS_DOMAIN); |
0 | 1111 } |
1112 | |
114 | 1113 /* Generally delegate angle information handling to VM */ |
195 | 1114 dvdnav_status_t dvdnav_angle_change(dvdnav_t *this, int32_t angle) { |
1115 int32_t num, current; | |
388 | 1116 |
114 | 1117 pthread_mutex_lock(&this->vm_lock); |
1118 vm_get_angle_info(this->vm, ¤t, &num); | |
0 | 1119 /* Set angle SPRM if valid */ |
1120 if((angle > 0) && (angle <= num)) { | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1121 this->vm->state.AGL_REG = angle; |
0 | 1122 } else { |
114 | 1123 printerr("Passed an invalid angle number."); |
1124 pthread_mutex_unlock(&this->vm_lock); | |
193 | 1125 return DVDNAV_STATUS_ERR; |
0 | 1126 } |
114 | 1127 pthread_mutex_unlock(&this->vm_lock); |
0 | 1128 |
193 | 1129 return DVDNAV_STATUS_OK; |
0 | 1130 } |
1131 | |
195 | 1132 dvdnav_status_t dvdnav_get_angle_info(dvdnav_t *this, int32_t *current_angle, |
1133 int32_t *number_of_angles) { | |
114 | 1134 pthread_mutex_lock(&this->vm_lock); |
1135 vm_get_angle_info(this->vm, current_angle, number_of_angles); | |
1136 pthread_mutex_unlock(&this->vm_lock); | |
1137 | |
193 | 1138 return DVDNAV_STATUS_OK; |
114 | 1139 } |
0 | 1140 |
67
61c0ee1bbb7a
Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents:
66
diff
changeset
|
1141 pci_t* dvdnav_get_current_nav_pci(dvdnav_t *this) { |
114 | 1142 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
|
1143 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
|
1144 } |
61c0ee1bbb7a
Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents:
66
diff
changeset
|
1145 |
66
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1146 dsi_t* dvdnav_get_current_nav_dsi(dvdnav_t *this) { |
114 | 1147 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
|
1148 return &this->dsi; |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1149 } |
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 uint32_t dvdnav_get_next_still_flag(dvdnav_t *this) { |
114 | 1152 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
|
1153 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
|
1154 } |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1155 |
262 | 1156 user_ops_t dvdnav_get_restrictions(dvdnav_t* this) { |
388 | 1157 /* |
1158 * user_ops_t is a structure of 32 bits. We want to compute | |
1159 * the union of two of those bitfields so to make this quicker | |
262 | 1160 * than performing 32 ORs, we will access them as 32bits words. |
1161 */ | |
264 | 1162 union { |
1163 user_ops_t ops_struct; | |
1164 uint32_t ops_int; | |
1165 } ops; | |
388 | 1166 |
264 | 1167 ops.ops_int = 0; |
388 | 1168 |
263 | 1169 if(!this->started) { |
1170 printerr("Virtual DVD machine not started."); | |
264 | 1171 return ops.ops_struct; |
263 | 1172 } |
388 | 1173 |
1174 pthread_mutex_lock(&this->vm_lock); | |
264 | 1175 ops.ops_int |= *(uint32_t*)&this->pci.pci_gi.vobu_uop_ctl; |
388 | 1176 |
262 | 1177 if(this->vm && this->vm->state.pgc) |
264 | 1178 ops.ops_int |= *(uint32_t*)&this->vm->state.pgc->prohibited_ops; |
388 | 1179 pthread_mutex_unlock(&this->vm_lock); |
1180 | |
264 | 1181 return ops.ops_struct; |
262 | 1182 } |