annotate dvdnav.c @ 428:10c91a9d6a2e src

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