Mercurial > libdvdnav.hg
annotate dvdnav.c @ 291:b9783221fb6e src
include sys/time.h for gettimeofday() prototype
author | nicodvb |
---|---|
date | Sat, 21 Apr 2007 22:27:26 +0000 |
parents | ce4230602517 |
children | cbd2b606f343 |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright (C) 2000 Rich Wareham <richwareham@users.sourceforge.net> | |
3 * | |
4 * This file is part of libdvdnav, a DVD navigation library. | |
5 * | |
6 * libdvdnav is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * libdvdnav is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
19 * | |
20 * $Id$ | |
21 * | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include "config.h" | |
26 #endif | |
27 | |
31 | 28 /* |
29 #define LOG_DEBUG | |
30 */ | |
31 | |
278 | 32 #include <inttypes.h> |
288
ce4230602517
moved away from dvdnav_internal.h inclusion of various system headers
nicodvb
parents:
285
diff
changeset
|
33 #include <stdlib.h> |
ce4230602517
moved away from dvdnav_internal.h inclusion of various system headers
nicodvb
parents:
285
diff
changeset
|
34 #include <stdio.h> |
ce4230602517
moved away from dvdnav_internal.h inclusion of various system headers
nicodvb
parents:
285
diff
changeset
|
35 #include <unistd.h> |
ce4230602517
moved away from dvdnav_internal.h inclusion of various system headers
nicodvb
parents:
285
diff
changeset
|
36 #include <limits.h> |
ce4230602517
moved away from dvdnav_internal.h inclusion of various system headers
nicodvb
parents:
285
diff
changeset
|
37 #include <string.h> |
291 | 38 #include <sys/time.h> |
285
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
39 #include "dvd_types.h" |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
40 #include "dvd_reader.h" |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
41 #include "nav_types.h" |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
42 #include "ifo_types.h" /* For vm_cmd_t */ |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
43 #include "remap.h" |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
44 #include "vm/decoder.h" |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
45 #include "vm/vm.h" |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
46 #include "dvdnav.h" |
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
278
diff
changeset
|
47 #include "dvdnav_events.h" |
0 | 48 #include "dvdnav_internal.h" |
49 #include "read_cache.h" | |
231 | 50 #include "nav_read.h" |
97
c1dff1899bda
First patch for personalized dvd viewing. I have not tested it yet.
jcdutton
parents:
92
diff
changeset
|
51 #include "remap.h" |
c1dff1899bda
First patch for personalized dvd viewing. I have not tested it yet.
jcdutton
parents:
92
diff
changeset
|
52 |
114 | 53 static dvdnav_status_t dvdnav_clear(dvdnav_t * this) { |
54 /* clear everything except file, vm, mutex, readahead */ | |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
55 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
56 if (this->file) DVDCloseFile(this->file); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
57 this->file = NULL; |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
58 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
59 memset(&this->pci,0,sizeof(this->pci)); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
60 memset(&this->dsi,0,sizeof(this->dsi)); |
197
a20a5976a207
last_cmd_nav_lbn has to be initialized with an invalid value, so that the first
mroi
parents:
195
diff
changeset
|
61 this->last_cmd_nav_lbn = SRI_END_OF_CELL; |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
62 |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
63 /* Set initial values of flags */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
64 this->position_current.still = 0; |
23 | 65 this->skip_still = 0; |
116 | 66 this->sync_wait = 0; |
67 this->sync_wait_skip = 0; | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
68 this->spu_clut_changed = 0; |
114 | 69 this->started = 0; |
269
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
70 this->cur_cell_time = 0; |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
71 |
34
1f29402ef2ef
'Objectified' the read-ahead cache in preparation to implement a 'proper' threaded cache a-la that recommended in the DVD Demystified book.
richwareham
parents:
33
diff
changeset
|
72 dvdnav_read_cache_clear(this->cache); |
1f29402ef2ef
'Objectified' the read-ahead cache in preparation to implement a 'proper' threaded cache a-la that recommended in the DVD Demystified book.
richwareham
parents:
33
diff
changeset
|
73 |
193 | 74 return DVDNAV_STATUS_OK; |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
75 } |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
76 |
114 | 77 dvdnav_status_t dvdnav_open(dvdnav_t** dest, const char *path) { |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
78 dvdnav_t *this; |
84 | 79 struct timeval time; |
0 | 80 |
81 /* Create a new structure */ | |
100 | 82 fprintf(MSG_OUT, "libdvdnav: Using dvdnav version %s from http://dvd.sf.net\n", VERSION); |
82 | 83 |
0 | 84 (*dest) = NULL; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
85 this = (dvdnav_t*)malloc(sizeof(dvdnav_t)); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
86 if(!this) |
193 | 87 return DVDNAV_STATUS_ERR; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
88 memset(this, 0, (sizeof(dvdnav_t) ) ); /* Make sure this structure is clean */ |
114 | 89 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
90 pthread_mutex_init(&this->vm_lock, NULL); |
0 | 91 /* Initialise the error string */ |
92 printerr(""); | |
93 | |
94 /* Initialise the VM */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
95 this->vm = vm_new_vm(); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
96 if(!this->vm) { |
114 | 97 printerr("Error initialising the DVD VM."); |
92 | 98 pthread_mutex_destroy(&this->vm_lock); |
99 free(this); | |
193 | 100 return DVDNAV_STATUS_ERR; |
0 | 101 } |
114 | 102 if(!vm_reset(this->vm, path)) { |
103 printerr("Error starting the VM / opening the DVD device."); | |
92 | 104 pthread_mutex_destroy(&this->vm_lock); |
105 vm_free_vm(this->vm); | |
106 free(this); | |
193 | 107 return DVDNAV_STATUS_ERR; |
0 | 108 } |
109 | |
110 /* Set the path. FIXME: Is a deep copy 'right' */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
111 strncpy(this->path, path, MAX_PATH_LEN); |
0 | 112 |
113 /* 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
|
114 this->file = DVDOpenFile(vm_get_dvd_reader(this->vm), 0, DVD_READ_MENU_VOBS); |
0 | 115 |
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
|
116 /* 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
|
117 this->cache = dvdnav_read_cache_new(this); |
84 | 118 |
114 | 119 /* Seed the random numbers. So that the DVD VM Command rand() |
120 * gives a different start value each time a DVD is played. */ | |
121 gettimeofday(&time, NULL); | |
84 | 122 srand(time.tv_usec); |
123 | |
114 | 124 dvdnav_clear(this); |
125 | |
126 (*dest) = this; | |
193 | 127 return DVDNAV_STATUS_OK; |
0 | 128 } |
129 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
130 dvdnav_status_t dvdnav_close(dvdnav_t *this) { |
114 | 131 |
31 | 132 #ifdef LOG_DEBUG |
76 | 133 fprintf(MSG_OUT, "libdvdnav: close:called\n"); |
31 | 134 #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
|
135 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
136 if (this->file) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
137 DVDCloseFile(this->file); |
31 | 138 #ifdef LOG_DEBUG |
76 | 139 fprintf(MSG_OUT, "libdvdnav: close:file closing\n"); |
31 | 140 #endif |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
141 this->file = NULL; |
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); | |
0 | 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 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
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."); | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
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 |
114 | 181 result = dvdnav_clear(this); |
182 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
183 pthread_mutex_unlock(&this->vm_lock); |
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) { |
194 | |
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!"; |
0 | 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; |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
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; |
135 | 212 |
213 frames = ((time->frame_u & 0x30) >> 4) * 10; | |
214 frames += ((time->frame_u & 0x0f) ) ; | |
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; |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
220 |
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); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
287 } |
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 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
293 /* DSI is used for most angle stuff. |
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 |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
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 */ |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
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 */ |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
314 |
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 | |
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
|
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"); |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
333 |
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); |
33
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
337 } |
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) { |
ef2136c4e7b2
Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents:
31
diff
changeset
|
341 |
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; |
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
|
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; | |
377 | |
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 } |
60 | 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); | |
0 | 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"); |
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
249
diff
changeset
|
416 return DVDNAV_STATUS_ERR; |
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
249
diff
changeset
|
417 } |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
418 this->started = 1; |
0 | 419 } |
420 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
421 state = &(this->vm->state); |
0 | 422 (*event) = DVDNAV_NOP; |
423 (*len) = 0; | |
424 | |
425 /* Check the STOP flag */ | |
114 | 426 if(this->vm->stopped) { |
121 | 427 vm_stop(this->vm); |
0 | 428 (*event) = DVDNAV_STOP; |
114 | 429 this->started = 0; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
430 pthread_mutex_unlock(&this->vm_lock); |
193 | 431 return DVDNAV_STATUS_OK; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
432 } |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
433 |
114 | 434 vm_position_get(this->vm, &this->position_next); |
0 | 435 |
126 | 436 #ifdef LOG_DEBUG |
114 | 437 fprintf(MSG_OUT, "libdvdnav: POS-NEXT "); |
438 vm_position_print(this->vm, &this->position_next); | |
116 | 439 fprintf(MSG_OUT, "libdvdnav: POS-CUR "); |
114 | 440 vm_position_print(this->vm, &this->position_current); |
31 | 441 #endif |
114 | 442 |
443 /* did we hop? */ | |
444 if(this->position_current.hop_channel != this->position_next.hop_channel) { | |
445 (*event) = DVDNAV_HOP_CHANNEL; | |
58 | 446 #ifdef LOG_DEBUG |
114 | 447 fprintf(MSG_OUT, "libdvdnav: HOP_CHANNEL\n"); |
31 | 448 #endif |
115 | 449 if (this->position_next.hop_channel - this->position_current.hop_channel >= HOP_SEEK) { |
195 | 450 int32_t num_angles = 0, current; |
114 | 451 |
452 /* we seeked -> check for multiple angles */ | |
453 vm_get_angle_info(this->vm, ¤t, &num_angles); | |
454 if (num_angles > 1) { | |
195 | 455 int32_t result, block; |
114 | 456 /* we have to skip the first VOBU when seeking in a multiangle feature, |
457 * because it might belong to the wrong angle */ | |
458 block = this->position_next.cell_start + this->position_next.block; | |
459 result = dvdnav_read_cache_block(this->cache, block, 1, buf); | |
460 if(result <= 0) { | |
461 printerr("Error reading NAV packet."); | |
462 pthread_mutex_unlock(&this->vm_lock); | |
193 | 463 return DVDNAV_STATUS_ERR; |
114 | 464 } |
465 /* Decode nav into pci and dsi. Then get next VOBU info. */ | |
466 if(!dvdnav_decode_packet(this, *buf, &this->dsi, &this->pci)) { | |
467 printerr("Expected NAV packet but none found."); | |
468 pthread_mutex_unlock(&this->vm_lock); | |
193 | 469 return DVDNAV_STATUS_ERR; |
114 | 470 } |
471 dvdnav_get_vobu(this, &this->dsi, &this->pci, &this->vobu); | |
472 /* skip to next, if there is a next */ | |
473 if (this->vobu.vobu_next != SRI_END_OF_CELL) { | |
474 this->vobu.vobu_start += this->vobu.vobu_next; | |
475 this->vobu.vobu_next = 0; | |
476 } | |
477 /* update VM state */ | |
478 this->vm->state.blockN = this->vobu.vobu_start - this->position_next.cell_start; | |
479 } | |
480 } | |
481 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
|
482 /* update VOBU info */ |
8f63f4c25f2f
update position on HOP_CHANNEL, do not rely on a following CELL_CHANGE
mroi
parents:
135
diff
changeset
|
483 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
|
484 this->vobu.vobu_next = 0; |
127 | 485 /* Make blockN == vobu_length to do expected_nav */ |
114 | 486 this->vobu.vobu_length = 0; |
127 | 487 this->vobu.blockN = 0; |
116 | 488 this->sync_wait = 0; |
30 | 489 pthread_mutex_unlock(&this->vm_lock); |
193 | 490 return DVDNAV_STATUS_OK; |
0 | 491 } |
492 | |
116 | 493 /* Check the HIGHLIGHT flag */ |
494 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
|
495 dvdnav_highlight_event_t *hevent = (dvdnav_highlight_event_t *)*buf; |
116 | 496 |
497 (*event) = DVDNAV_HIGHLIGHT; | |
498 #ifdef LOG_DEBUG | |
499 fprintf(MSG_OUT, "libdvdnav: HIGHLIGHT\n"); | |
500 #endif | |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
501 (*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
|
502 hevent->display = 1; |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
503 hevent->buttonN = this->position_next.button; |
116 | 504 this->position_current.button = this->position_next.button; |
505 pthread_mutex_unlock(&this->vm_lock); | |
193 | 506 return DVDNAV_STATUS_OK; |
116 | 507 } |
508 | |
509 /* Check the WAIT flag */ | |
510 if(this->sync_wait) { | |
511 (*event) = DVDNAV_WAIT; | |
512 #ifdef LOG_DEBUG | |
513 fprintf(MSG_OUT, "libdvdnav: WAIT\n"); | |
514 #endif | |
515 (*len) = 0; | |
516 pthread_mutex_unlock(&this->vm_lock); | |
193 | 517 return DVDNAV_STATUS_OK; |
116 | 518 } |
519 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
520 /* Check to see if we need to change the currently opened VOB */ |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
521 if((this->position_current.vts != this->position_next.vts) || |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
522 (this->position_current.domain != this->position_next.domain)) { |
0 | 523 dvd_read_domain_t domain; |
195 | 524 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
|
525 dvdnav_vts_change_event_t *vts_event = (dvdnav_vts_change_event_t *)*buf; |
0 | 526 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
527 if(this->file) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
528 DVDCloseFile(this->file); |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
529 this->file = NULL; |
0 | 530 } |
531 | |
217 | 532 vts_event->old_vtsN = this->position_current.vts; |
533 vts_event->old_domain = this->position_current.domain; | |
0 | 534 |
114 | 535 /* 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
|
536 switch(this->position_next.domain) { |
114 | 537 case FP_DOMAIN: |
538 case VMGM_DOMAIN: | |
0 | 539 domain = DVD_READ_MENU_VOBS; |
540 vtsN = 0; | |
541 break; | |
114 | 542 case VTSM_DOMAIN: |
0 | 543 domain = DVD_READ_MENU_VOBS; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
544 vtsN = this->position_next.vts; |
0 | 545 break; |
114 | 546 case VTS_DOMAIN: |
0 | 547 domain = DVD_READ_TITLE_VOBS; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
548 vtsN = this->position_next.vts; |
0 | 549 break; |
114 | 550 default: |
0 | 551 printerr("Unknown domain when changing VTS."); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
552 pthread_mutex_unlock(&this->vm_lock); |
193 | 553 return DVDNAV_STATUS_ERR; |
0 | 554 } |
555 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
556 this->position_current.vts = this->position_next.vts; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
557 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
|
558 dvdnav_read_cache_clear(this->cache); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
559 this->file = DVDOpenFile(vm_get_dvd_reader(this->vm), vtsN, domain); |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
560 vts_event->new_vtsN = this->position_next.vts; |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
561 vts_event->new_domain = this->position_next.domain; |
0 | 562 |
563 /* 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
|
564 if(this->file == NULL) { |
0 | 565 printerrf("Error opening vtsN=%i, domain=%i.", vtsN, domain); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
566 pthread_mutex_unlock(&this->vm_lock); |
193 | 567 return DVDNAV_STATUS_ERR; |
0 | 568 } |
569 | |
570 /* File opened successfully so return a VTS change event */ | |
571 (*event) = DVDNAV_VTS_CHANGE; | |
114 | 572 #ifdef LOG_DEBUG |
573 fprintf(MSG_OUT, "libdvdnav: VTS_CHANGE\n"); | |
574 #endif | |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
575 (*len) = sizeof(dvdnav_vts_change_event_t); |
0 | 576 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
577 this->spu_clut_changed = 1; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
578 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
|
579 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
|
580 this->position_current.audio_channel = -1; /* Force an update */; |
0 | 581 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
582 pthread_mutex_unlock(&this->vm_lock); |
193 | 583 return DVDNAV_STATUS_OK; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
584 } |
114 | 585 |
586 /* Check if the cell changed */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
587 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
|
588 (this->position_current.cell_restart != this->position_next.cell_restart) || |
114 | 589 (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
|
590 dvdnav_cell_change_event_t *cell_event = (dvdnav_cell_change_event_t *)*buf; |
195 | 591 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
|
592 dvd_state_t *state = &this->vm->state; |
114 | 593 |
269
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
594 this->cur_cell_time = 0; |
114 | 595 (*event) = DVDNAV_CELL_CHANGE; |
596 #ifdef LOG_DEBUG | |
597 fprintf(MSG_OUT, "libdvdnav: CELL_CHANGE\n"); | |
598 #endif | |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
599 (*len) = sizeof(dvdnav_cell_change_event_t); |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
600 |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
601 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
|
602 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
|
603 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
|
604 dvdnav_convert_time(&state->pgc->cell_playback[state->cellN-1].playback_time); |
161 | 605 |
134
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
606 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
|
607 /* 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
|
608 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
|
609 /* 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
|
610 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
|
611 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
|
612 else |
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->nr_of_cells; |
d9d75a22a061
- new event on cell changes to report program and cell number and some time info
mroi
parents:
127
diff
changeset
|
614 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
|
615 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
|
616 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
|
617 cell_event->pgc_length = dvdnav_convert_time(&state->pgc->playback_time); |
151 | 618 |
619 cell_event->cell_start = 0; | |
620 for (i = 1; i < state->cellN; i++) | |
621 cell_event->cell_start += | |
622 dvdnav_convert_time(&state->pgc->cell_playback[i - 1].playback_time); | |
161 | 623 |
624 cell_event->pg_start = 0; | |
625 for (i = 1; i < state->pgc->program_map[state->pgN-1]; i++) | |
626 cell_event->pg_start += | |
627 dvdnav_convert_time(&state->pgc->cell_playback[i - 1].playback_time); | |
628 | |
114 | 629 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
|
630 this->position_current.cell_restart = this->position_next.cell_restart; |
114 | 631 this->position_current.cell_start = this->position_next.cell_start; |
632 this->position_current.block = this->position_next.block; | |
633 | |
634 /* vobu info is used for mid cell resumes */ | |
635 this->vobu.vobu_start = this->position_next.cell_start + this->position_next.block; | |
636 this->vobu.vobu_next = 0; | |
127 | 637 /* Make blockN == vobu_length to do expected_nav */ |
114 | 638 this->vobu.vobu_length = 0; |
127 | 639 this->vobu.blockN = 0; |
114 | 640 |
641 /* update the spu palette at least on PGC changes */ | |
642 this->spu_clut_changed = 1; | |
643 this->position_current.spu_channel = -1; /* Force an update */ | |
644 this->position_current.audio_channel = -1; /* Force an update */ | |
645 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
646 pthread_mutex_unlock(&this->vm_lock); |
193 | 647 return DVDNAV_STATUS_OK; |
0 | 648 } |
649 | |
114 | 650 /* has the CLUT changed? */ |
651 if(this->spu_clut_changed) { | |
652 (*event) = DVDNAV_SPU_CLUT_CHANGE; | |
653 #ifdef LOG_DEBUG | |
654 fprintf(MSG_OUT, "libdvdnav: SPU_CLUT_CHANGE\n"); | |
655 #endif | |
656 (*len) = 16 * sizeof(uint32_t); | |
657 memcpy(*buf, &(state->pgc->palette), 16 * sizeof(uint32_t)); | |
658 this->spu_clut_changed = 0; | |
659 pthread_mutex_unlock(&this->vm_lock); | |
193 | 660 return DVDNAV_STATUS_OK; |
114 | 661 } |
662 | |
663 /* has the SPU channel changed? */ | |
664 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
|
665 dvdnav_spu_stream_change_event_t *stream_change = (dvdnav_spu_stream_change_event_t *)*buf; |
114 | 666 |
667 (*event) = DVDNAV_SPU_STREAM_CHANGE; | |
668 #ifdef LOG_DEBUG | |
669 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE\n"); | |
670 #endif | |
671 (*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
|
672 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
|
673 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
|
674 stream_change->physical_pan_scan = vm_get_subp_active_stream(this->vm, 2); |
114 | 675 this->position_current.spu_channel = this->position_next.spu_channel; |
676 #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
|
677 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
|
678 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
|
679 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
|
680 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE returning DVDNAV_STATUS_OK\n"); |
114 | 681 #endif |
249
5d643668f1e3
I added this code myself a long time ago, but now I am quite convinced that
mroi
parents:
231
diff
changeset
|
682 pthread_mutex_unlock(&this->vm_lock); |
5d643668f1e3
I added this code myself a long time ago, but now I am quite convinced that
mroi
parents:
231
diff
changeset
|
683 return DVDNAV_STATUS_OK; |
114 | 684 } |
0 | 685 |
114 | 686 /* has the audio channel changed? */ |
687 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
|
688 dvdnav_audio_stream_change_event_t *stream_change = (dvdnav_audio_stream_change_event_t *)*buf; |
114 | 689 |
690 (*event) = DVDNAV_AUDIO_STREAM_CHANGE; | |
691 #ifdef LOG_DEBUG | |
692 fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE\n"); | |
693 #endif | |
694 (*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
|
695 stream_change->physical = vm_get_audio_active_stream( this->vm ); |
114 | 696 this->position_current.audio_channel = this->position_next.audio_channel; |
697 #ifdef LOG_DEBUG | |
193 | 698 fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE stream_id=%d returning DVDNAV_STATUS_OK\n",stream_change->physical); |
114 | 699 #endif |
700 pthread_mutex_unlock(&this->vm_lock); | |
193 | 701 return DVDNAV_STATUS_OK; |
114 | 702 } |
703 | |
704 /* Check the STILLFRAME flag */ | |
705 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
|
706 dvdnav_still_event_t *still_event = (dvdnav_still_event_t *)*buf; |
114 | 707 |
708 (*event) = DVDNAV_STILL_FRAME; | |
709 #ifdef LOG_DEBUG | |
710 fprintf(MSG_OUT, "libdvdnav: STILL_FRAME\n"); | |
711 #endif | |
712 (*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
|
713 still_event->length = this->position_current.still; |
114 | 714 pthread_mutex_unlock(&this->vm_lock); |
194 | 715 return DVDNAV_STATUS_OK; |
114 | 716 } |
717 | |
718 /* Have we reached the end of a VOBU? */ | |
719 if (this->vobu.blockN >= this->vobu.vobu_length) { | |
720 | |
721 /* 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
|
722 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
|
723 /* End of Cell from NAV DSI info */ |
31 | 724 #ifdef LOG_DEBUG |
76 | 725 fprintf(MSG_OUT, "libdvdnav: Still set to %x\n", this->position_next.still); |
31 | 726 #endif |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
727 this->position_current.still = this->position_next.still; |
0 | 728 |
116 | 729 /* we are about to leave a cell, so a lot of state changes could occur; |
730 * under certain conditions, the application should get in sync with us before this, | |
731 * otherwise it might show stills or menus too shortly */ | |
732 if ((this->position_current.still || this->pci.hli.hl_gi.hli_ss) && !this->sync_wait_skip) { | |
733 this->sync_wait = 1; | |
734 } else { | |
735 if( this->position_current.still == 0 || this->skip_still ) { | |
736 /* no active cell still -> get us to the next cell */ | |
737 vm_get_next_cell(this->vm); | |
738 this->position_current.still = 0; /* still gets activated at end of cell */ | |
739 this->skip_still = 0; | |
740 this->sync_wait_skip = 0; | |
741 } | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
742 } |
114 | 743 /* handle related state changes in next iteration */ |
744 (*event) = DVDNAV_NOP; | |
745 (*len) = 0; | |
746 pthread_mutex_unlock(&this->vm_lock); | |
193 | 747 return DVDNAV_STATUS_OK; |
114 | 748 } |
0 | 749 |
114 | 750 /* Perform remapping jump if necessary (this is always a |
0 | 751 * VOBU boundary). */ |
114 | 752 if (this->vm->map) { |
753 this->vobu.vobu_next = remap_block( this->vm->map, | |
754 this->vm->state.domain, this->vm->state.TTN_REG, | |
755 this->vm->state.pgN, | |
756 this->vobu.vobu_start, this->vobu.vobu_next); | |
757 } | |
0 | 758 |
114 | 759 /* at the start of the next VOBU -> expecting NAV packet */ |
45 | 760 result = dvdnav_read_cache_block(this->cache, this->vobu.vobu_start + this->vobu.vobu_next, 1, buf); |
0 | 761 |
762 if(result <= 0) { | |
763 printerr("Error reading NAV packet."); | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
764 pthread_mutex_unlock(&this->vm_lock); |
193 | 765 return DVDNAV_STATUS_ERR; |
0 | 766 } |
114 | 767 /* Decode nav into pci and dsi. Then get next VOBU info. */ |
768 if(!dvdnav_decode_packet(this, *buf, &this->dsi, &this->pci)) { | |
0 | 769 printerr("Expected NAV packet but none found."); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
770 pthread_mutex_unlock(&this->vm_lock); |
193 | 771 return DVDNAV_STATUS_ERR; |
0 | 772 } |
114 | 773 /* We need to update the vm state->blockN with which VOBU we are in. |
774 * This is so RSM resumes to the VOBU level and not just the CELL level. | |
28 | 775 */ |
114 | 776 this->vm->state.blockN = this->vobu.vobu_start - this->position_current.cell_start; |
777 | |
778 dvdnav_get_vobu(this, &this->dsi, &this->pci, &this->vobu); | |
779 this->vobu.blockN = 0; | |
780 /* Give the cache a hint about the size of next VOBU. | |
781 * This improves pre-caching, because the VOBU will almost certainly be read entirely. | |
45 | 782 */ |
783 dvdnav_pre_cache_blocks(this->cache, this->vobu.vobu_start+1, this->vobu.vobu_length+1); | |
0 | 784 |
191
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
179
diff
changeset
|
785 /* 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
|
786 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
|
787 this->last_cmd_nav_lbn = SRI_END_OF_CELL; |
191
dbea22936623
when a command has been issued to leave a menu, filter all further commands
mroi
parents:
179
diff
changeset
|
788 |
0 | 789 /* Successfully got a NAV packet */ |
790 (*event) = DVDNAV_NAV_PACKET; | |
114 | 791 #ifdef LOG_DEBUG |
792 fprintf(MSG_OUT, "libdvdnav: NAV_PACKET\n"); | |
793 #endif | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
794 (*len) = 2048; |
269
77e472cef5f8
implemented dvdnav_get_current_time() with obvious meaning
nicodvb
parents:
266
diff
changeset
|
795 this->cur_cell_time = dvdnav_convert_time(&this->dsi.dsi_gi.c_eltm); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
796 pthread_mutex_unlock(&this->vm_lock); |
193 | 797 return DVDNAV_STATUS_OK; |
0 | 798 } |
799 | |
800 /* 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
|
801 if(!this->file) { |
114 | 802 printerr("Attempting to read without opening file."); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
803 pthread_mutex_unlock(&this->vm_lock); |
193 | 804 return DVDNAV_STATUS_ERR; |
0 | 805 } |
806 | |
114 | 807 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
|
808 result = dvdnav_read_cache_block(this->cache, this->vobu.vobu_start + this->vobu.blockN, 1, buf); |
0 | 809 if(result <= 0) { |
810 printerr("Error reading from DVD."); | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
811 pthread_mutex_unlock(&this->vm_lock); |
193 | 812 return DVDNAV_STATUS_ERR; |
0 | 813 } |
114 | 814 (*event) = DVDNAV_BLOCK_OK; |
0 | 815 (*len) = 2048; |
816 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
817 pthread_mutex_unlock(&this->vm_lock); |
193 | 818 return DVDNAV_STATUS_OK; |
0 | 819 } |
820 | |
114 | 821 dvdnav_status_t dvdnav_get_title_string(dvdnav_t *this, const char **title_str) { |
822 (*title_str) = this->vm->dvd_name; | |
193 | 823 return DVDNAV_STATUS_OK; |
114 | 824 } |
825 | |
826 uint8_t dvdnav_get_video_aspect(dvdnav_t *this) { | |
827 uint8_t retval; | |
273
bd734ab914d0
removed nonsensical checks on the sanity of dvdnav_t *this
nicodvb
parents:
272
diff
changeset
|
828 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
829 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
830 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
831 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
832 } |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
833 |
114 | 834 pthread_mutex_lock(&this->vm_lock); |
835 retval = (uint8_t)vm_get_video_aspect(this->vm); | |
836 pthread_mutex_unlock(&this->vm_lock); | |
837 | |
838 return retval; | |
839 } | |
840 | |
841 uint8_t dvdnav_get_video_scale_permission(dvdnav_t *this) { | |
842 uint8_t retval; | |
843 | |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
844 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
845 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
846 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
847 } |
114 | 848 |
849 pthread_mutex_lock(&this->vm_lock); | |
850 retval = (uint8_t)vm_get_video_scale_permission(this->vm); | |
851 pthread_mutex_unlock(&this->vm_lock); | |
852 | |
853 return retval; | |
854 } | |
855 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
856 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
|
857 audio_attr_t attr; |
0 | 858 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
859 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
860 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
861 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
862 } |
0 | 863 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
864 pthread_mutex_lock(&this->vm_lock); |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
865 attr = vm_get_audio_attr(this->vm, stream); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
866 pthread_mutex_unlock(&this->vm_lock); |
0 | 867 |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
868 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
|
869 return 0xffff; |
0 | 870 |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
871 return attr.lang_code; |
0 | 872 } |
873 | |
266 | 874 uint16_t dvdnav_audio_stream_format(dvdnav_t *this, uint8_t stream) { |
875 audio_attr_t attr; | |
876 uint16_t format; | |
877 | |
878 if(!this->started) { | |
879 printerr("Virtual DVD machine not started."); | |
880 return -1; /* 0xffff */ | |
881 } | |
882 | |
883 pthread_mutex_lock(&this->vm_lock); | |
884 attr = vm_get_audio_attr(this->vm, stream); | |
885 pthread_mutex_unlock(&this->vm_lock); | |
886 | |
887 switch(attr.audio_format) { | |
888 case 0: | |
889 format = DVDNAV_FORMAT_AC3; | |
890 break; | |
891 case 2: /* MPEG-1 or MPEG-2 without extension bitstream. */ | |
892 case 3: /* MPEG-2 with extension bitstream. */ | |
893 format = DVDNAV_FORMAT_MPEGAUDIO; | |
894 break; | |
895 case 4: | |
896 format = DVDNAV_FORMAT_LPCM; | |
897 break; | |
898 case 6: | |
899 format = DVDNAV_FORMAT_DTS; | |
900 break; | |
901 case 7: | |
902 format = DVDNAV_FORMAT_SDDS; | |
903 break; | |
904 default: | |
905 format = 0xffff; | |
906 break; | |
907 } | |
908 | |
909 return format; | |
910 } | |
911 | |
272
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
912 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
|
913 audio_attr_t attr; |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
914 |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
915 if(!this->started) { |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
916 printerr("Virtual DVD machine not started."); |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
917 return -1; /* 0xffff */ |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
918 } |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
919 |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
920 pthread_mutex_lock(&this->vm_lock); |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
921 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
|
922 pthread_mutex_unlock(&this->vm_lock); |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
923 |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
924 return attr.channels + 1; |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
925 } |
baec6f29fb76
added dvdnav_audio_stream_channels(); patch by Andreas Oman (andreas olebyn nu)
nicodvb
parents:
269
diff
changeset
|
926 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
927 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
|
928 subp_attr_t attr; |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
929 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
930 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
931 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
932 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
933 } |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
934 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
935 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
|
936 attr = vm_get_subp_attr(this->vm, stream); |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
937 pthread_mutex_unlock(&this->vm_lock); |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
938 |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
939 if(attr.type != 1) |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
940 return 0xffff; |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
941 |
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
942 return attr.lang_code; |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
943 } |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
944 |
114 | 945 int8_t dvdnav_get_audio_logical_stream(dvdnav_t *this, uint8_t audio_num) { |
946 int8_t retval; | |
947 | |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
948 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
949 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
950 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
951 } |
114 | 952 |
953 pthread_mutex_lock(&this->vm_lock); | |
954 if (!this->vm->state.pgc) { | |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
955 printerr("No current PGC."); |
114 | 956 pthread_mutex_unlock(&this->vm_lock); |
957 return -1; | |
958 } | |
959 retval = vm_get_audio_stream(this->vm, audio_num); | |
960 pthread_mutex_unlock(&this->vm_lock); | |
961 | |
962 return retval; | |
963 } | |
964 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
965 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
|
966 int8_t retval; |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
967 |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
968 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
969 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
970 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
971 } |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
972 |
114 | 973 pthread_mutex_lock(&this->vm_lock); |
974 if (!this->vm->state.pgc) { | |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
975 printerr("No current PGC."); |
114 | 976 pthread_mutex_unlock(&this->vm_lock); |
977 return -1; | |
978 } | |
979 retval = vm_get_subp_stream(this->vm, subp_num, 0); | |
980 pthread_mutex_unlock(&this->vm_lock); | |
981 | |
982 return retval; | |
983 } | |
984 | |
985 int8_t dvdnav_get_active_audio_stream(dvdnav_t *this) { | |
986 int8_t retval; | |
987 | |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
988 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
989 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
990 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
991 } |
114 | 992 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
993 pthread_mutex_lock(&this->vm_lock); |
114 | 994 if (!this->vm->state.pgc) { |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
995 printerr("No current PGC."); |
114 | 996 pthread_mutex_unlock(&this->vm_lock); |
997 return -1; | |
998 } | |
999 retval = vm_get_audio_active_stream(this->vm); | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1000 pthread_mutex_unlock(&this->vm_lock); |
114 | 1001 |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1002 return retval; |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1003 } |
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
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_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
|
1006 int8_t retval; |
0 | 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 } |
0 | 1012 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1013 pthread_mutex_lock(&this->vm_lock); |
114 | 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."); |
114 | 1016 pthread_mutex_unlock(&this->vm_lock); |
1017 return -1; | |
1018 } | |
1019 retval = vm_get_subp_active_stream(this->vm, 0); | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1020 pthread_mutex_unlock(&this->vm_lock); |
0 | 1021 |
21
d2d73f2ad8d3
Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents:
17
diff
changeset
|
1022 return retval; |
0 | 1023 } |
1024 | |
114 | 1025 static int8_t dvdnav_is_domain(dvdnav_t *this, domain_t domain) { |
1026 int8_t retval; | |
1027 | |
142
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1028 if(!this->started) { |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1029 printerr("Virtual DVD machine not started."); |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1030 return -1; |
e375b765ebf5
some more sanity checking will prevent segfaults in these functions
mroi
parents:
141
diff
changeset
|
1031 } |
114 | 1032 |
1033 pthread_mutex_lock(&this->vm_lock); | |
1034 retval = (this->vm->state.domain == domain); | |
1035 pthread_mutex_unlock(&this->vm_lock); | |
1036 | |
1037 return retval; | |
1038 } | |
1039 | |
0 | 1040 /* First Play domain. (Menu) */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1041 int8_t dvdnav_is_domain_fp(dvdnav_t *this) { |
114 | 1042 return dvdnav_is_domain(this, FP_DOMAIN); |
0 | 1043 } |
1044 /* Video management Menu domain. (Menu) */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1045 int8_t dvdnav_is_domain_vmgm(dvdnav_t *this) { |
114 | 1046 return dvdnav_is_domain(this, VMGM_DOMAIN); |
0 | 1047 } |
1048 /* Video Title Menu domain (Menu) */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1049 int8_t dvdnav_is_domain_vtsm(dvdnav_t *this) { |
114 | 1050 return dvdnav_is_domain(this, VTSM_DOMAIN); |
0 | 1051 } |
1052 /* Video Title domain (playing movie). */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1053 int8_t dvdnav_is_domain_vts(dvdnav_t *this) { |
114 | 1054 return dvdnav_is_domain(this, VTS_DOMAIN); |
0 | 1055 } |
1056 | |
114 | 1057 /* Generally delegate angle information handling to VM */ |
195 | 1058 dvdnav_status_t dvdnav_angle_change(dvdnav_t *this, int32_t angle) { |
1059 int32_t num, current; | |
0 | 1060 |
114 | 1061 pthread_mutex_lock(&this->vm_lock); |
1062 vm_get_angle_info(this->vm, ¤t, &num); | |
0 | 1063 /* Set angle SPRM if valid */ |
1064 if((angle > 0) && (angle <= num)) { | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
21
diff
changeset
|
1065 this->vm->state.AGL_REG = angle; |
0 | 1066 } else { |
114 | 1067 printerr("Passed an invalid angle number."); |
1068 pthread_mutex_unlock(&this->vm_lock); | |
193 | 1069 return DVDNAV_STATUS_ERR; |
0 | 1070 } |
114 | 1071 pthread_mutex_unlock(&this->vm_lock); |
0 | 1072 |
193 | 1073 return DVDNAV_STATUS_OK; |
0 | 1074 } |
1075 | |
195 | 1076 dvdnav_status_t dvdnav_get_angle_info(dvdnav_t *this, int32_t *current_angle, |
1077 int32_t *number_of_angles) { | |
114 | 1078 pthread_mutex_lock(&this->vm_lock); |
1079 vm_get_angle_info(this->vm, current_angle, number_of_angles); | |
1080 pthread_mutex_unlock(&this->vm_lock); | |
1081 | |
193 | 1082 return DVDNAV_STATUS_OK; |
114 | 1083 } |
0 | 1084 |
67
61c0ee1bbb7a
Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents:
66
diff
changeset
|
1085 pci_t* dvdnav_get_current_nav_pci(dvdnav_t *this) { |
114 | 1086 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
|
1087 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
|
1088 } |
61c0ee1bbb7a
Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents:
66
diff
changeset
|
1089 |
66
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1090 dsi_t* dvdnav_get_current_nav_dsi(dvdnav_t *this) { |
114 | 1091 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
|
1092 return &this->dsi; |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1093 } |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1094 |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1095 uint32_t dvdnav_get_next_still_flag(dvdnav_t *this) { |
114 | 1096 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
|
1097 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
|
1098 } |
2bd4a78eefce
Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents:
60
diff
changeset
|
1099 |
262 | 1100 user_ops_t dvdnav_get_restrictions(dvdnav_t* this) { |
1101 /* | |
1102 * user_ops_t is a structure of 32 bits. We want to compute | |
1103 * the union of two of those bitfields so to make this quicker | |
1104 * than performing 32 ORs, we will access them as 32bits words. | |
1105 */ | |
264 | 1106 union { |
1107 user_ops_t ops_struct; | |
1108 uint32_t ops_int; | |
1109 } ops; | |
1110 | |
1111 ops.ops_int = 0; | |
262 | 1112 |
263 | 1113 if(!this->started) { |
1114 printerr("Virtual DVD machine not started."); | |
264 | 1115 return ops.ops_struct; |
263 | 1116 } |
1117 | |
1118 pthread_mutex_lock(&this->vm_lock); | |
264 | 1119 ops.ops_int |= *(uint32_t*)&this->pci.pci_gi.vobu_uop_ctl; |
262 | 1120 |
1121 if(this->vm && this->vm->state.pgc) | |
264 | 1122 ops.ops_int |= *(uint32_t*)&this->vm->state.pgc->prohibited_ops; |
263 | 1123 pthread_mutex_unlock(&this->vm_lock); |
262 | 1124 |
264 | 1125 return ops.ops_struct; |
262 | 1126 } |