annotate dvdnav.c @ 191:dbea22936623 src

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