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