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