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