annotate dvdnav.c @ 116:4d711d0518e9 src

new event DVDNAV_WAIT
author mroi
date Tue, 25 Feb 2003 14:08:16 +0000
parents b527b7cbfb19
children 545bd4fc0a16
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
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
36 #include <dvdread/nav_read.h>
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));
4
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
54
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
55 /* Set initial values of flags */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
56 this->position_current.still = 0;
23
c2d40c38e12f Name stills work better.
jcdutton
parents: 22
diff changeset
57 this->skip_still = 0;
116
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
58 this->sync_wait = 0;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
59 this->sync_wait_skip = 0;
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
60 this->spu_clut_changed = 0;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
61 this->started = 0;
4
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
62
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
63 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
64
4
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
65 return S_OK;
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
66 }
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
67
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
68 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
69 dvdnav_t *this;
84
ba1121a07120 Properly seed the DVD VM Instruction rand().
jcdutton
parents: 82
diff changeset
70 struct timeval time;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
71
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
72 /* Create a new structure */
100
a767842bc447 Update version info.
jcdutton
parents: 99
diff changeset
73 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
74
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
75 (*dest) = NULL;
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
76 this = (dvdnav_t*)malloc(sizeof(dvdnav_t));
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
77 if(!this)
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
78 return S_ERR;
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
79 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
80
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
81 pthread_mutex_init(&this->vm_lock, NULL);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
82 /* Initialise the error string */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
83 printerr("");
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
84
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
85 /* Initialise the VM */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
86 this->vm = vm_new_vm();
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
87 if(!this->vm) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
88 printerr("Error initialising the DVD VM.");
92
82af243658bd fix memleaks in dvdnav_open
mroi
parents: 89
diff changeset
89 pthread_mutex_destroy(&this->vm_lock);
82af243658bd fix memleaks in dvdnav_open
mroi
parents: 89
diff changeset
90 free(this);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
91 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
92 }
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
93 if(!vm_reset(this->vm, path)) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
94 printerr("Error starting the VM / opening the DVD device.");
92
82af243658bd fix memleaks in dvdnav_open
mroi
parents: 89
diff changeset
95 pthread_mutex_destroy(&this->vm_lock);
82af243658bd fix memleaks in dvdnav_open
mroi
parents: 89
diff changeset
96 vm_free_vm(this->vm);
82af243658bd fix memleaks in dvdnav_open
mroi
parents: 89
diff changeset
97 free(this);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
98 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
99 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
100
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
101 /* 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
102 strncpy(this->path, path, MAX_PATH_LEN);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
103
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
104 /* 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
105 this->file = DVDOpenFile(vm_get_dvd_reader(this->vm), 0, DVD_READ_MENU_VOBS);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
106
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
107 /* 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
108 this->cache = dvdnav_read_cache_new(this);
84
ba1121a07120 Properly seed the DVD VM Instruction rand().
jcdutton
parents: 82
diff changeset
109
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
110 /* Seed the random numbers. So that the DVD VM Command rand()
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
111 * gives a different start value each time a DVD is played. */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
112 gettimeofday(&time, NULL);
84
ba1121a07120 Properly seed the DVD VM Instruction rand().
jcdutton
parents: 82
diff changeset
113 srand(time.tv_usec);
ba1121a07120 Properly seed the DVD VM Instruction rand().
jcdutton
parents: 82
diff changeset
114
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
115 dvdnav_clear(this);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
116
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
117 (*dest) = this;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
118 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
119 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
120
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
121 dvdnav_status_t dvdnav_close(dvdnav_t *this) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
122
31
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
123 #ifdef LOG_DEBUG
76
0e2abe7083de more consistent console output
mroi
parents: 73
diff changeset
124 fprintf(MSG_OUT, "libdvdnav: close:called\n");
31
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
125 #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
126
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
127 if(!this) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
128 printerr("Passed a NULL pointer.");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
129 return S_ERR;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
130 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
131
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
132 if (this->file) {
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
133 DVDCloseFile(this->file);
31
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
134 #ifdef LOG_DEBUG
76
0e2abe7083de more consistent console output
mroi
parents: 73
diff changeset
135 fprintf(MSG_OUT, "libdvdnav: close:file closing\n");
31
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
136 #endif
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
137 this->file = NULL;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
138 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
139
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
140 /* Free the VM */
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
141 if(this->vm)
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
142 vm_free_vm(this->vm);
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
143
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
144 pthread_mutex_destroy(&this->vm_lock);
60
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
145
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
146 /* 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
147 * 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
148 * that must return first. */
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
149 if(this->cache)
60
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
150 dvdnav_read_cache_free(this->cache);
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
151 else
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
152 free(this);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
153
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
154 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
155 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
156
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
157 dvdnav_status_t dvdnav_reset(dvdnav_t *this) {
4
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
158 dvdnav_status_t result;
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
159
31
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
160 #ifdef LOG_DEBUG
76
0e2abe7083de more consistent console output
mroi
parents: 73
diff changeset
161 fprintf(MSG_OUT, "libdvdnav: reset:called\n");
31
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
162 #endif
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
163
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
164 if(!this) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
165 printerr("Passed a NULL pointer.");
4
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
166 return S_ERR;
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
167 }
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
168
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
169 pthread_mutex_lock(&this->vm_lock);
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
170
31
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
171 #ifdef LOG_DEBUG
76
0e2abe7083de more consistent console output
mroi
parents: 73
diff changeset
172 fprintf(MSG_OUT, "libdvdnav: reseting vm\n");
31
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
173 #endif
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
174 if(!vm_reset(this->vm, NULL)) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
175 printerr("Error restarting the VM.");
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
176 pthread_mutex_unlock(&this->vm_lock);
4
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
177 return S_ERR;
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
178 }
31
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
179 #ifdef LOG_DEBUG
76
0e2abe7083de more consistent console output
mroi
parents: 73
diff changeset
180 fprintf(MSG_OUT, "libdvdnav: clearing dvdnav\n");
31
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
181 #endif
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
182 result = dvdnav_clear(this);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
183
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
184 pthread_mutex_unlock(&this->vm_lock);
4
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
185 return result;
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
186 }
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
187
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
188 dvdnav_status_t dvdnav_path(dvdnav_t *this, const char** path) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
189
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
190 if(!this || !path) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
191 printerr("Passed a NULL pointer.");
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
192 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
193 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
194
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
195 (*path) = this->path;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
196
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
197 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
198 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
199
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
200 const char* dvdnav_err_to_string(dvdnav_t *this) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
201
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
202 if(!this)
3
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
203 return "Hey! You gave me a NULL pointer you naughty person!";
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
204
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
205 return this->err_str;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
206 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
207
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
208 /*
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
209 * Returns 1 if block contains NAV packet, 0 otherwise.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
210 * Precesses said NAV packet if present.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
211 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
212 * Most of the code in here is copied from xine's MPEG demuxer
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
213 * so any bugs which are found in that should be corrected here also.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
214 */
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
215 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
216 int bMpeg1 = 0;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
217 uint32_t nHeaderLen;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
218 uint32_t nPacketLen;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
219 uint32_t nStreamID;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
220
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
221 if (p[3] == 0xBA) { /* program stream pack header */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
222 int nStuffingBytes;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
223
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
224 bMpeg1 = (p[4] & 0x40) == 0;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
225
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
226 if (bMpeg1) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
227 p += 12;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
228 } else { /* mpeg2 */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
229 nStuffingBytes = p[0xD] & 0x07;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
230 p += 14 + nStuffingBytes;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
231 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
232 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
233
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
234 if (p[3] == 0xbb) { /* program stream system header */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
235 nHeaderLen = (p[4] << 8) | p[5];
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
236 p += 6 + nHeaderLen;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
237 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
238
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
239 /* we should now have a PES packet here */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
240 if (p[0] || p[1] || (p[2] != 1)) {
76
0e2abe7083de more consistent console output
mroi
parents: 73
diff changeset
241 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
242 return 0;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
243 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
244
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
245 nPacketLen = p[4] << 8 | p[5];
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
246 nStreamID = p[3];
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
247
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
248 nHeaderLen = 6;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
249 p += nHeaderLen;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
250
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
251 if (nStreamID == 0xbf) { /* Private stream 2 */
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
252 #if 0
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
253 int i;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
254 fprintf(MSG_OUT, "libdvdnav: nav packet=%u\n",p-p_start-6);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
255 for(i=0;i<80;i++)
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
256 fprintf(MSG_OUT, "%02x ",p[i-6]);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
257 fprintf(MSG_OUT, "\n");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
258 #endif
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
259
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
260 if(p[0] == 0x00) {
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
261 navRead_PCI(nav_pci, p+1);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
262 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
263
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
264 p += nPacketLen;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
265
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
266 /* We should now have a DSI packet. */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
267 if(p[6] == 0x01) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
268 nPacketLen = p[4] << 8 | p[5];
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
269 p += 6;
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
270 navRead_DSI(nav_dsi, p+1);
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
271 }
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
272 return 1;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
273 }
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
274 return 0;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
275 }
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
276
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
277 /* DSI is used for most angle stuff.
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
278 * 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
279 */
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
280 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
281 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
282 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
283
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
284 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
285 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
286
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
287 /*
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
288 * 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
289 * 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
290 * 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
291 * 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
292 * really happy.
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
293 *
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
294 * 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
295 * 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
296 * Should really assert if bit 31 != 1
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
297 */
33
ef2136c4e7b2 Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents: 31
diff changeset
298
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
299 #if 0
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
300 /* 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
301 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
302 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
303 } 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
304 vobu->vobu_next = vobu->vobu_length;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
305 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
306 #else
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
307 /* Relative offset from vobu_start */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
308 vobu->vobu_next = ( nav_dsi->vobu_sri.next_vobu & 0x3fffffff );
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
309 #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
310
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
311 vm_get_angle_info(this->vm, &angle, &num_angle);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
312
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
313 /* 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
314 #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
315 if((num_angle < angle) && (angle != 1)) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
316 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
317
ef2136c4e7b2 Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents: 31
diff changeset
318 /* 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
319 * finish with angles. */
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
320 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
321 }
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 #endif
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
323
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
324 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
325
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
326 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
327 if((next & 0x3fffffff) != 0) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
328 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
329 vobu->vobu_next = - (int32_t)(next & 0x3fffffff);
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
330 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
331 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
332 }
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
333 } 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
334 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
335
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
336 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
337 vobu->vobu_next = - (int32_t)(next & 0x3fffffff);
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
338 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
339 vobu->vobu_next = + (int32_t)(next & 0x3fffffff);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
340 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
341 }
33
ef2136c4e7b2 Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
richwareham
parents: 31
diff changeset
342
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
343 return 1;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
344 }
60
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
345
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
346 /*
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
347 * 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
348 *
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
349 * 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
350 * hands out pointers targetting directly into the cache.
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
351 * 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
352 * 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
353 * 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
354 * The drawback is the additional memcopy.
28
da60d6379f95 Add some comments, FIXMEs.
jcdutton
parents: 26
diff changeset
355 */
60
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
356
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
357 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
358 int *event, int *len) {
60
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
359 unsigned char *block;
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
360 dvdnav_status_t status;
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
361
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
362 block = buf;
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
363 status = dvdnav_get_next_cache_block(this, &block, event, len);
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
364 if (status == S_OK && block != buf) {
60
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
365 /* 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
366 memcpy(buf, block, DVD_VIDEO_LB_LEN);
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
367 dvdnav_free_cache_block(this, block);
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
368 }
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
369 return status;
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
370 }
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
371
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
372 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
373 int *event, int *len) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
374 dvd_state_t *state;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
375 int result;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
376
60
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
377 if(!this || !event || !len || !buf || !*buf) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
378 printerr("Passed a NULL pointer.");
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
379 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
380 }
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
381
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
382 pthread_mutex_lock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
383
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
384 if(!this->started) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
385 /* Start the VM */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
386 vm_start(this->vm);
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
387 this->started = 1;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
388 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
389
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
390 state = &(this->vm->state);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
391 (*event) = DVDNAV_NOP;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
392 (*len) = 0;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
393
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
394 /* Check the STOP flag */
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
395 if(this->vm->stopped) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
396 (*event) = DVDNAV_STOP;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
397 this->started = 0;
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
398 pthread_mutex_unlock(&this->vm_lock);
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
399 return S_OK;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
400 }
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
401
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
402 vm_position_get(this->vm, &this->position_next);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
403
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
404 #ifdef TRACE
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
405 fprintf(MSG_OUT, "libdvdnav: POS-NEXT ");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
406 vm_position_print(this->vm, &this->position_next);
116
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
407 fprintf(MSG_OUT, "libdvdnav: POS-CUR ");
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
408 vm_position_print(this->vm, &this->position_current);
31
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
409 #endif
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
410
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
411 /* did we hop? */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
412 if(this->position_current.hop_channel != this->position_next.hop_channel) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
413 (*event) = DVDNAV_HOP_CHANNEL;
58
18af52093d13 * fix debug messages
mroi
parents: 55
diff changeset
414 #ifdef LOG_DEBUG
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
415 fprintf(MSG_OUT, "libdvdnav: HOP_CHANNEL\n");
31
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
416 #endif
115
b527b7cbfb19 fix seek detection
mroi
parents: 114
diff changeset
417 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
418 int num_angles = 0, current;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
419
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
420 /* we seeked -> check for multiple angles */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
421 vm_get_angle_info(this->vm, &current, &num_angles);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
422 if (num_angles > 1) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
423 int result, block;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
424 /* 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
425 * because it might belong to the wrong angle */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
426 block = this->position_next.cell_start + this->position_next.block;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
427 result = dvdnav_read_cache_block(this->cache, block, 1, buf);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
428 if(result <= 0) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
429 printerr("Error reading NAV packet.");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
430 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
431 return S_ERR;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
432 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
433 /* Decode nav into pci and dsi. Then get next VOBU info. */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
434 if(!dvdnav_decode_packet(this, *buf, &this->dsi, &this->pci)) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
435 printerr("Expected NAV packet but none found.");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
436 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
437 return S_ERR;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
438 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
439 dvdnav_get_vobu(this, &this->dsi, &this->pci, &this->vobu);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
440 /* skip to next, if there is a next */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
441 if (this->vobu.vobu_next != SRI_END_OF_CELL) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
442 this->vobu.vobu_start += this->vobu.vobu_next;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
443 this->vobu.vobu_next = 0;
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 /* update VM state */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
446 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
447 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
448 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
449 this->position_current.hop_channel = this->position_next.hop_channel;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
450 /* Make blockN > vobu_length to do expected_nav */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
451 this->vobu.vobu_length = 0;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
452 this->vobu.blockN = 1;
116
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
453 this->sync_wait = 0;
30
630b6733e492 Some more cleanups.
jcdutton
parents: 28
diff changeset
454 pthread_mutex_unlock(&this->vm_lock);
630b6733e492 Some more cleanups.
jcdutton
parents: 28
diff changeset
455 return S_OK;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
456 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
457
116
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
458 /* Check the HIGHLIGHT flag */
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
459 if(this->position_current.button != this->position_next.button) {
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
460 dvdnav_highlight_event_t hevent;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
461
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
462 (*event) = DVDNAV_HIGHLIGHT;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
463 #ifdef LOG_DEBUG
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
464 fprintf(MSG_OUT, "libdvdnav: HIGHLIGHT\n");
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
465 #endif
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
466 (*len) = sizeof(hevent);
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
467 hevent.display = 1;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
468 hevent.buttonN = this->position_next.button;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
469 memcpy(*buf, &(hevent), sizeof(hevent));
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
470 this->position_current.button = this->position_next.button;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
471 pthread_mutex_unlock(&this->vm_lock);
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
472 return S_OK;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
473 }
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
474
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
475 /* Check the WAIT flag */
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
476 if(this->sync_wait) {
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
477 (*event) = DVDNAV_WAIT;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
478 #ifdef LOG_DEBUG
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
479 fprintf(MSG_OUT, "libdvdnav: WAIT\n");
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
480 #endif
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
481 (*len) = 0;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
482 pthread_mutex_unlock(&this->vm_lock);
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
483 return S_OK;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
484 }
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
485
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
486 /* 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
487 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
488 (this->position_current.domain != this->position_next.domain)) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
489 dvd_read_domain_t domain;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
490 int vtsN;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
491 dvdnav_vts_change_event_t vts_event;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
492
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
493 if(this->file) {
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
494 DVDCloseFile(this->file);
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
495 this->file = NULL;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
496 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
497
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
498 vts_event.old_vtsN = this->open_vtsN;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
499 vts_event.old_domain = this->open_domain;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
500
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
501 /* 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
502 switch(this->position_next.domain) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
503 case FP_DOMAIN:
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
504 case VMGM_DOMAIN:
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
505 domain = DVD_READ_MENU_VOBS;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
506 vtsN = 0;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
507 break;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
508 case VTSM_DOMAIN:
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
509 domain = DVD_READ_MENU_VOBS;
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
510 vtsN = this->position_next.vts;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
511 break;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
512 case VTS_DOMAIN:
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
513 domain = DVD_READ_TITLE_VOBS;
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
514 vtsN = this->position_next.vts;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
515 break;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
516 default:
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
517 printerr("Unknown domain when changing VTS.");
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
518 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
519 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
520 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
521
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
522 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
523 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
524 dvdnav_read_cache_clear(this->cache);
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
525 this->file = DVDOpenFile(vm_get_dvd_reader(this->vm), vtsN, domain);
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
526 vts_event.new_vtsN = this->position_next.vts;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
527 vts_event.new_domain = this->position_next.domain;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
528
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
529 /* 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
530 if(this->file == NULL) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
531 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
532 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
533 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
534 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
535
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
536 /* File opened successfully so return a VTS change event */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
537 (*event) = DVDNAV_VTS_CHANGE;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
538 #ifdef LOG_DEBUG
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
539 fprintf(MSG_OUT, "libdvdnav: VTS_CHANGE\n");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
540 #endif
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
541 (*len) = sizeof(vts_event);
60
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
542 memcpy(*buf, &(vts_event), sizeof(vts_event));
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
543
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
544 this->spu_clut_changed = 1;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
545 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
546 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
547 this->position_current.audio_channel = -1; /* Force an update */;
0
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 pthread_mutex_unlock(&this->vm_lock);
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
550 return S_OK;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
551 }
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
552
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
553 /* Check if the cell changed */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
554 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
555 (this->position_current.cell_restart != this->position_next.cell_restart) ||
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
556 (this->position_current.cell_start != this->position_next.cell_start) ) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
557
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
558 (*event) = DVDNAV_CELL_CHANGE;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
559 #ifdef LOG_DEBUG
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
560 fprintf(MSG_OUT, "libdvdnav: CELL_CHANGE\n");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
561 #endif
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
562 (*len) = 0;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
563
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
564 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
565 this->position_current.cell_restart = this->position_next.cell_restart;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
566 this->position_current.cell_start = this->position_next.cell_start;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
567 this->position_current.block = this->position_next.block;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
568
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
569 /* vobu info is used for mid cell resumes */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
570 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
571 this->vobu.vobu_next = 0;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
572 /* Make blockN > vobu_length to do expected_nav */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
573 this->vobu.vobu_length = 0;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
574 this->vobu.blockN = 1;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
575
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
576 /* update the spu palette at least on PGC changes */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
577 this->spu_clut_changed = 1;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
578 this->position_current.spu_channel = -1; /* Force an update */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
579 this->position_current.audio_channel = -1; /* Force an update */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
580
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
581 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
582 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
583 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
584
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
585 /* has the CLUT changed? */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
586 if(this->spu_clut_changed) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
587 (*event) = DVDNAV_SPU_CLUT_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: SPU_CLUT_CHANGE\n");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
590 #endif
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
591 (*len) = 16 * sizeof(uint32_t);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
592 memcpy(*buf, &(state->pgc->palette), 16 * sizeof(uint32_t));
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
593 this->spu_clut_changed = 0;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
594 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
595 return S_OK;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
596 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
597
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
598 /* has the SPU channel changed? */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
599 if(this->position_current.spu_channel != this->position_next.spu_channel) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
600 dvdnav_spu_stream_change_event_t stream_change;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
601
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
602 (*event) = DVDNAV_SPU_STREAM_CHANGE;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
603 #ifdef LOG_DEBUG
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
604 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE\n");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
605 #endif
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
606 (*len) = sizeof(dvdnav_spu_stream_change_event_t);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
607 stream_change.physical_wide = vm_get_subp_active_stream(this->vm, 0);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
608 stream_change.physical_letterbox = vm_get_subp_active_stream(this->vm, 1);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
609 stream_change.physical_pan_scan = vm_get_subp_active_stream(this->vm, 2);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
610 memcpy(*buf, &(stream_change), sizeof(dvdnav_spu_stream_change_event_t));
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
611 this->position_current.spu_channel = this->position_next.spu_channel;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
612 #ifdef LOG_DEBUG
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
613 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_wide=%d\n",stream_change.physical_wide);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
614 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_letterbox=%d\n",stream_change.physical_letterbox);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
615 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_pan_scan=%d\n",stream_change.physical_pan_scan);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
616 #endif
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
617 if (stream_change.physical_wide != -1 &&
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
618 stream_change.physical_letterbox != -1 &&
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
619 stream_change.physical_pan_scan != -1) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
620 #ifdef LOG_DEBUG
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
621 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE returning S_OK\n");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
622 #endif
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
623 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
624 return S_OK;
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 }
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
627
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
628 /* has the audio channel changed? */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
629 if(this->position_current.audio_channel != this->position_next.audio_channel) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
630 dvdnav_audio_stream_change_event_t stream_change;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
631
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
632 (*event) = DVDNAV_AUDIO_STREAM_CHANGE;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
633 #ifdef LOG_DEBUG
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
634 fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE\n");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
635 #endif
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
636 (*len) = sizeof(dvdnav_audio_stream_change_event_t);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
637 stream_change.physical = vm_get_audio_active_stream( this->vm );
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
638 memcpy(*buf, &(stream_change), sizeof( dvdnav_audio_stream_change_event_t));
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
639 this->position_current.audio_channel = this->position_next.audio_channel;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
640 #ifdef LOG_DEBUG
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
641 fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE stream_id=%d returning S_OK\n",stream_change.physical);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
642 #endif
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
643 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
644 return S_OK;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
645 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
646
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
647 /* Check the STILLFRAME flag */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
648 if(this->position_current.still != 0) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
649 dvdnav_still_event_t still_event;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
650
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
651 (*event) = DVDNAV_STILL_FRAME;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
652 #ifdef LOG_DEBUG
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
653 fprintf(MSG_OUT, "libdvdnav: STILL_FRAME\n");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
654 #endif
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
655 (*len) = sizeof(dvdnav_still_event_t);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
656 still_event.length = this->position_current.still;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
657 memcpy(*buf, &(still_event), sizeof(dvdnav_still_event_t));
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
658 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
659 return S_OK;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
660 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
661
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
662 /* Have we reached the end of a VOBU? */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
663 if (this->vobu.blockN >= this->vobu.vobu_length) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
664
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
665 /* 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
666 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
667 /* End of Cell from NAV DSI info */
31
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
668 #ifdef LOG_DEBUG
76
0e2abe7083de more consistent console output
mroi
parents: 73
diff changeset
669 fprintf(MSG_OUT, "libdvdnav: Still set to %x\n", this->position_next.still);
31
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
670 #endif
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
671 this->position_current.still = this->position_next.still;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
672
116
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
673 /* 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
674 * under certain conditions, the application should get in sync with us before this,
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
675 * otherwise it might show stills or menus too shortly */
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
676 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
677 this->sync_wait = 1;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
678 } else {
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
679 if( this->position_current.still == 0 || this->skip_still ) {
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
680 /* no active cell still -> get us to the next cell */
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
681 vm_get_next_cell(this->vm);
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
682 this->position_current.still = 0; /* still gets activated at end of cell */
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
683 this->skip_still = 0;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
684 this->sync_wait_skip = 0;
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
685 }
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
686 }
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
687 /* handle related state changes in next iteration */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
688 (*event) = DVDNAV_NOP;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
689 (*len) = 0;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
690 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
691 return S_OK;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
692 }
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
693
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
694 /* Perform remapping jump if necessary (this is always a
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
695 * VOBU boundary). */
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
696 if (this->vm->map) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
697 this->vobu.vobu_next = remap_block( this->vm->map,
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
698 this->vm->state.domain, this->vm->state.TTN_REG,
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
699 this->vm->state.pgN,
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
700 this->vobu.vobu_start, this->vobu.vobu_next);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
701 }
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
702
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
703 /* at the start of the next VOBU -> expecting NAV packet */
45
7bf97b8922b4 Revert back to old read_cache method.
jcdutton
parents: 43
diff changeset
704 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
705
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
706 if(result <= 0) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
707 printerr("Error reading NAV packet.");
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
708 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
709 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
710 }
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
711 /* Decode nav into pci and dsi. Then get next VOBU info. */
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
712 if(!dvdnav_decode_packet(this, *buf, &this->dsi, &this->pci)) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
713 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
714 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
715 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
716 }
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
717 /* 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
718 * 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
719 */
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
720 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
721
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
722 dvdnav_get_vobu(this, &this->dsi, &this->pci, &this->vobu);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
723 this->vobu.blockN = 0;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
724 /* Give the cache a hint about the size of next VOBU.
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
725 * 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
726 */
7bf97b8922b4 Revert back to old read_cache method.
jcdutton
parents: 43
diff changeset
727 dvdnav_pre_cache_blocks(this->cache, this->vobu.vobu_start+1, this->vobu.vobu_length+1);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
728
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
729 /* Successfully got a NAV packet */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
730 (*event) = DVDNAV_NAV_PACKET;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
731 #ifdef LOG_DEBUG
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
732 fprintf(MSG_OUT, "libdvdnav: NAV_PACKET\n");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
733 #endif
3
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
734 (*len) = 2048;
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
735 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
736 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
737 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
738
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
739 /* 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
740 if(!this->file) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
741 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
742 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
743 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
744 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
745
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
746 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
747 result = dvdnav_read_cache_block(this->cache, this->vobu.vobu_start + this->vobu.blockN, 1, buf);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
748 if(result <= 0) {
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
749 printerr("Error reading from DVD.");
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
750 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
751 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
752 }
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
753 (*event) = DVDNAV_BLOCK_OK;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
754 (*len) = 2048;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
755
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
756 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
757 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
758 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
759
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
760 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
761
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
762 if(!this || !title_str) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
763 printerr("Passed a NULL pointer.");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
764 return S_ERR;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
765 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
766
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
767 (*title_str) = this->vm->dvd_name;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
768 return S_OK;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
769 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
770
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
771 uint8_t dvdnav_get_video_aspect(dvdnav_t *this) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
772 uint8_t retval;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
773
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
774 if(!this)
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
775 return -1;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
776
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
777 pthread_mutex_lock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
778 retval = (uint8_t)vm_get_video_aspect(this->vm);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
779 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
780
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
781 return retval;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
782 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
783
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
784 uint8_t dvdnav_get_video_scale_permission(dvdnav_t *this) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
785 uint8_t retval;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
786
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
787 if(!this)
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
788 return -1;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
789
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
790 pthread_mutex_lock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
791 retval = (uint8_t)vm_get_video_scale_permission(this->vm);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
792 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
793
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
794 return retval;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
795 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
796
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
797 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
798 audio_attr_t attr;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
799
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
800 if(!this)
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
801 return -1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
802
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
803 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
804 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
805 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
806
25
df024077cbc1 Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents: 24
diff changeset
807 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
808 return 0xffff;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
809
25
df024077cbc1 Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents: 24
diff changeset
810 return attr.lang_code;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
811 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
812
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
813 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
814 subp_attr_t attr;
21
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
815
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
816 if(!this)
21
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
817 return -1;
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
818
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
819 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
820 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
821 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
822
25
df024077cbc1 Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents: 24
diff changeset
823 if(attr.type != 1)
21
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
824 return 0xffff;
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
825
25
df024077cbc1 Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents: 24
diff changeset
826 return attr.lang_code;
21
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
827 }
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
828
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
829 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
830 int8_t retval;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
831
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
832 if(!this)
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
833 return -1;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
834
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
835 pthread_mutex_lock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
836 if (!this->vm->state.pgc) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
837 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
838 return -1;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
839 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
840 retval = vm_get_audio_stream(this->vm, audio_num);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
841 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
842
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
843 return retval;
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
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
846 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
847 int8_t retval;
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
848
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
849 if(!this)
21
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
850 return -1;
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
851
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
852 pthread_mutex_lock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
853 if (!this->vm->state.pgc) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
854 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
855 return -1;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
856 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
857 retval = vm_get_subp_stream(this->vm, subp_num, 0);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
858 pthread_mutex_unlock(&this->vm_lock);
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 return retval;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
861 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
862
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
863 int8_t dvdnav_get_active_audio_stream(dvdnav_t *this) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
864 int8_t 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 if(!this)
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
867 return -1;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
868
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
869 pthread_mutex_lock(&this->vm_lock);
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
870 if (!this->vm->state.pgc) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
871 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
872 return -1;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
873 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
874 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
875 pthread_mutex_unlock(&this->vm_lock);
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
876
21
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
877 return retval;
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
878 }
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
879
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
880 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
881 int8_t retval;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
882
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
883 if(!this)
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
884 return -1;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
885
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
886 pthread_mutex_lock(&this->vm_lock);
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
887 if (!this->vm->state.pgc) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
888 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
889 return -1;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
890 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
891 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
892 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
893
21
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
894 return retval;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
895 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
896
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
897 static int8_t dvdnav_is_domain(dvdnav_t *this, domain_t domain) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
898 int8_t retval;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
899
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
900 if (!this || !this->started)
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
901 return -1;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
902
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
903 pthread_mutex_lock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
904 retval = (this->vm->state.domain == domain);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
905 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
906
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
907 return retval;
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
908 }
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
909
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
910 /* First Play domain. (Menu) */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
911 int8_t dvdnav_is_domain_fp(dvdnav_t *this) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
912 return dvdnav_is_domain(this, FP_DOMAIN);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
913 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
914 /* Video management Menu domain. (Menu) */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
915 int8_t dvdnav_is_domain_vmgm(dvdnav_t *this) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
916 return dvdnav_is_domain(this, VMGM_DOMAIN);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
917 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
918 /* Video Title Menu domain (Menu) */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
919 int8_t dvdnav_is_domain_vtsm(dvdnav_t *this) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
920 return dvdnav_is_domain(this, VTSM_DOMAIN);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
921 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
922 /* Video Title domain (playing movie). */
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
923 int8_t dvdnav_is_domain_vts(dvdnav_t *this) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
924 return dvdnav_is_domain(this, VTS_DOMAIN);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
925 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
926
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
927 /* 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
928 dvdnav_status_t dvdnav_angle_change(dvdnav_t *this, int angle) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
929 int num, current;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
930
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
931 if(!this) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
932 printerr("Passed a NULL pointer.");
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
933 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
934 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
935
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
936 pthread_mutex_lock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
937 vm_get_angle_info(this->vm, &current, &num);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
938 /* Set angle SPRM if valid */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
939 if((angle > 0) && (angle <= num)) {
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
940 this->vm->state.AGL_REG = angle;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
941 } else {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
942 printerr("Passed an invalid angle number.");
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
943 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
944 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
945 }
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
946 pthread_mutex_unlock(&this->vm_lock);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
947
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
948 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
949 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
950
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
951 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
952 int *number_of_angles) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
953 if(!this || !current_angle || !number_of_angles) {
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
954 printerr("Passed a NULL pointer.");
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
955 return S_ERR;
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
956 }
114
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 pthread_mutex_lock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
959 vm_get_angle_info(this->vm, current_angle, number_of_angles);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
960 pthread_mutex_unlock(&this->vm_lock);
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
961
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
962 return S_OK;
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
963 }
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
964
67
61c0ee1bbb7a Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents: 66
diff changeset
965 pci_t* dvdnav_get_current_nav_pci(dvdnav_t *this) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
966 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
967 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
968 }
61c0ee1bbb7a Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents: 66
diff changeset
969
66
2bd4a78eefce Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents: 60
diff changeset
970 dsi_t* dvdnav_get_current_nav_dsi(dvdnav_t *this) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
971 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
972 return &this->dsi;
2bd4a78eefce Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents: 60
diff changeset
973 }
2bd4a78eefce Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents: 60
diff changeset
974
2bd4a78eefce Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents: 60
diff changeset
975 uint32_t dvdnav_get_next_still_flag(dvdnav_t *this) {
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
976 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
977 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
978 }
2bd4a78eefce Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents: 60
diff changeset
979
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
980 /*
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
981 * $Log$
116
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
982 * Revision 1.42 2003/02/25 14:08:14 mroi
4d711d0518e9 new event DVDNAV_WAIT
mroi
parents: 115
diff changeset
983 * new event DVDNAV_WAIT
115
b527b7cbfb19 fix seek detection
mroi
parents: 114
diff changeset
984 *
114
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
985 * Revision 1.40 2003/02/20 15:32:15 mroi
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
986 * big libdvdnav cleanup, quoting the ChangeLog:
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
987 * * some bugfixes
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
988 * * code cleanup
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
989 * * build process polishing
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
990 * * more sensible event order in get_next_block to ensure useful event delivery
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
991 * * VOBU level resume
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
992 * * fixed: seeking in a multiangle feature briefly showed the wrong angle
b6834e6359cf big libdvdnav cleanup, quoting the ChangeLog:
mroi
parents: 106
diff changeset
993 *
106
e984044bbe7b port Stephen's comment fixing to avoid problems when syncing xine-lib's copy of
mroi
parents: 100
diff changeset
994 * Revision 1.39 2002/10/23 11:38:09 mroi
e984044bbe7b port Stephen's comment fixing to avoid problems when syncing xine-lib's copy of
mroi
parents: 100
diff changeset
995 * port Stephen's comment fixing to avoid problems when syncing xine-lib's copy of
e984044bbe7b port Stephen's comment fixing to avoid problems when syncing xine-lib's copy of
mroi
parents: 100
diff changeset
996 * libdvdnav
e984044bbe7b port Stephen's comment fixing to avoid problems when syncing xine-lib's copy of
mroi
parents: 100
diff changeset
997 *
100
a767842bc447 Update version info.
jcdutton
parents: 99
diff changeset
998 * Revision 1.38 2002/09/19 04:48:28 jcdutton
a767842bc447 Update version info.
jcdutton
parents: 99
diff changeset
999 * Update version info.
a767842bc447 Update version info.
jcdutton
parents: 99
diff changeset
1000 * The "note2" bit if to help developers know which version of libdvdnav the user is using.
a767842bc447 Update version info.
jcdutton
parents: 99
diff changeset
1001 *
99
c5e47a98c883 fix possible unlock on not locked mutex
mroi
parents: 97
diff changeset
1002 * Revision 1.37 2002/09/18 14:26:42 mroi
c5e47a98c883 fix possible unlock on not locked mutex
mroi
parents: 97
diff changeset
1003 * fix possible unlock on not locked mutex
c5e47a98c883 fix possible unlock on not locked mutex
mroi
parents: 97
diff changeset
1004 *
97
c1dff1899bda First patch for personalized dvd viewing. I have not tested it yet.
jcdutton
parents: 92
diff changeset
1005 * Revision 1.36 2002/09/17 11:00:21 jcdutton
c1dff1899bda First patch for personalized dvd viewing. I have not tested it yet.
jcdutton
parents: 92
diff changeset
1006 * First patch for personalized dvd viewing. I have not tested it yet.
c1dff1899bda First patch for personalized dvd viewing. I have not tested it yet.
jcdutton
parents: 92
diff changeset
1007 *
92
82af243658bd fix memleaks in dvdnav_open
mroi
parents: 89
diff changeset
1008 * Revision 1.35 2002/09/05 12:55:05 mroi
82af243658bd fix memleaks in dvdnav_open
mroi
parents: 89
diff changeset
1009 * fix memleaks in dvdnav_open
82af243658bd fix memleaks in dvdnav_open
mroi
parents: 89
diff changeset
1010 *
89
0fbef4901e2c Add a comment so I can tell which version of the CVS a user is using.
jcdutton
parents: 84
diff changeset
1011 * Revision 1.34 2002/09/03 00:41:48 jcdutton
0fbef4901e2c Add a comment so I can tell which version of the CVS a user is using.
jcdutton
parents: 84
diff changeset
1012 * Add a comment so I can tell which version of the CVS a user is using.
0fbef4901e2c Add a comment so I can tell which version of the CVS a user is using.
jcdutton
parents: 84
diff changeset
1013 * Also add a FIXME to remind me to fix the Chapter number display.
0fbef4901e2c Add a comment so I can tell which version of the CVS a user is using.
jcdutton
parents: 84
diff changeset
1014 *
84
ba1121a07120 Properly seed the DVD VM Instruction rand().
jcdutton
parents: 82
diff changeset
1015 * Revision 1.33 2002/08/31 11:05:27 jcdutton
ba1121a07120 Properly seed the DVD VM Instruction rand().
jcdutton
parents: 82
diff changeset
1016 * Properly seed the DVD VM Instruction rand().
ba1121a07120 Properly seed the DVD VM Instruction rand().
jcdutton
parents: 82
diff changeset
1017 *
82
033f011d8152 Improve some debug messages.
jcdutton
parents: 76
diff changeset
1018 * Revision 1.32 2002/08/31 02:50:27 jcdutton
033f011d8152 Improve some debug messages.
jcdutton
parents: 76
diff changeset
1019 * Improve some debug messages.
033f011d8152 Improve some debug messages.
jcdutton
parents: 76
diff changeset
1020 * Add some comments about dvdnav_open memory leaks.
033f011d8152 Improve some debug messages.
jcdutton
parents: 76
diff changeset
1021 *
76
0e2abe7083de more consistent console output
mroi
parents: 73
diff changeset
1022 * Revision 1.31 2002/08/27 19:15:08 mroi
0e2abe7083de more consistent console output
mroi
parents: 73
diff changeset
1023 * more consistent console output
0e2abe7083de more consistent console output
mroi
parents: 73
diff changeset
1024 *
73
a23d50ba81d3 update spu clut, spu channel and audio channel more often
mroi
parents: 67
diff changeset
1025 * Revision 1.30 2002/08/09 21:34:27 mroi
a23d50ba81d3 update spu clut, spu channel and audio channel more often
mroi
parents: 67
diff changeset
1026 * update spu clut, spu channel and audio channel more often
a23d50ba81d3 update spu clut, spu channel and audio channel more often
mroi
parents: 67
diff changeset
1027 *
67
61c0ee1bbb7a Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents: 66
diff changeset
1028 * Revision 1.29 2002/07/25 14:51:40 richwareham
61c0ee1bbb7a Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents: 66
diff changeset
1029 * Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
61c0ee1bbb7a Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents: 66
diff changeset
1030 * check_packet.
61c0ee1bbb7a Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled'
richwareham
parents: 66
diff changeset
1031 *
66
2bd4a78eefce Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents: 60
diff changeset
1032 * Revision 1.28 2002/07/25 14:42:33 richwareham
2bd4a78eefce Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents: 60
diff changeset
1033 * Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
2bd4a78eefce Patch from aschultz@cs.uni-magdeburg.de to allow for still-frame 'peek-ahead'
richwareham
parents: 60
diff changeset
1034 *
60
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
1035 * Revision 1.27 2002/07/12 15:46:44 mroi
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
1036 * use new memcopy'less read ahead cache
30995ad032cf use new memcopy'less read ahead cache
mroi
parents: 58
diff changeset
1037 *
58
18af52093d13 * fix debug messages
mroi
parents: 55
diff changeset
1038 * Revision 1.26 2002/07/06 16:24:54 mroi
18af52093d13 * fix debug messages
mroi
parents: 55
diff changeset
1039 * * fix debug messages
18af52093d13 * fix debug messages
mroi
parents: 55
diff changeset
1040 * * send spu stream change event only, when there are new streams
18af52093d13 * fix debug messages
mroi
parents: 55
diff changeset
1041 * (should fix problems with Terminator disk 2)
18af52093d13 * fix debug messages
mroi
parents: 55
diff changeset
1042 *
55
5674fbd44f26 report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents: 54
diff changeset
1043 * Revision 1.25 2002/07/05 14:18:54 mroi
5674fbd44f26 report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents: 54
diff changeset
1044 * report all spu types (widescreen, letterbox and pan&scan), not widescreen
5674fbd44f26 report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents: 54
diff changeset
1045 * only and report the stream's scale permissions to detect pan&scan material
5674fbd44f26 report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents: 54
diff changeset
1046 *
54
cea44c0d638a Add more debug info for Menu language selection.
jcdutton
parents: 50
diff changeset
1047 * Revision 1.24 2002/07/05 01:42:30 jcdutton
cea44c0d638a Add more debug info for Menu language selection.
jcdutton
parents: 50
diff changeset
1048 * Add more debug info for Menu language selection.
cea44c0d638a Add more debug info for Menu language selection.
jcdutton
parents: 50
diff changeset
1049 * Only do vm_start when we have to.
cea44c0d638a Add more debug info for Menu language selection.
jcdutton
parents: 50
diff changeset
1050 *
50
578ce1d41479 Rename some of the functions in vm.c to help readability.
jcdutton
parents: 45
diff changeset
1051 * Revision 1.23 2002/07/02 22:57:09 jcdutton
578ce1d41479 Rename some of the functions in vm.c to help readability.
jcdutton
parents: 45
diff changeset
1052 * Rename some of the functions in vm.c to help readability.
578ce1d41479 Rename some of the functions in vm.c to help readability.
jcdutton
parents: 45
diff changeset
1053 * Hopefully fix __FUNCTION__ problem. Use __func_ as recommended in C99.
578ce1d41479 Rename some of the functions in vm.c to help readability.
jcdutton
parents: 45
diff changeset
1054 * Fix bug where libdvdnav would not immeadiately replay the same cell due to menu buttons.
578ce1d41479 Rename some of the functions in vm.c to help readability.
jcdutton
parents: 45
diff changeset
1055 *
45
7bf97b8922b4 Revert back to old read_cache method.
jcdutton
parents: 43
diff changeset
1056 * Revision 1.22 2002/06/25 13:37:11 jcdutton
7bf97b8922b4 Revert back to old read_cache method.
jcdutton
parents: 43
diff changeset
1057 * Revert back to old read_cache method.
7bf97b8922b4 Revert back to old read_cache method.
jcdutton
parents: 43
diff changeset
1058 * Some new optimizations added to the old read_cache method, thus reducing the amount of calls to read blocks from the DVD device.
7bf97b8922b4 Revert back to old read_cache method.
jcdutton
parents: 43
diff changeset
1059 *
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
1060 * Revision 1.21 2002/06/06 15:03:09 richwareham
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
1061 * 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.
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
1062 *
42
131ad65a2398 Removed more C++ style comments
richwareham
parents: 39
diff changeset
1063 * Revision 1.20 2002/06/04 13:35:16 richwareham
131ad65a2398 Removed more C++ style comments
richwareham
parents: 39
diff changeset
1064 * Removed more C++ style comments
131ad65a2398 Removed more C++ style comments
richwareham
parents: 39
diff changeset
1065 *
39
2433a5a8069e First draft of removing HAVE_DVDREAD9
richwareham
parents: 34
diff changeset
1066 * Revision 1.19 2002/05/30 23:15:14 richwareham
2433a5a8069e First draft of removing HAVE_DVDREAD9
richwareham
parents: 34
diff changeset
1067 * First draft of removing HAVE_DVDREAD9
2433a5a8069e First draft of removing HAVE_DVDREAD9
richwareham
parents: 34
diff changeset
1068 *
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
1069 * Revision 1.18 2002/05/30 09:52:29 richwareham
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
1070 * 'Objectified' the read-ahead cache in preparation to implement a 'proper' threaded cache a-la that recommended in the DVD Demystified book.
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
1071 *
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
1072 * Revision 1.17 2002/05/09 11:57:24 richwareham
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
1073 * Angles now work (still a few wrinkles though -- e.g. angle does not reset to '1' when returning to menus)
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
1074 *
31
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
1075 * Revision 1.16 2002/04/24 21:15:25 jcdutton
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
1076 * Quiet please!!!
8b08ee66cbff Quiet please!!!
jcdutton
parents: 30
diff changeset
1077 *
30
630b6733e492 Some more cleanups.
jcdutton
parents: 28
diff changeset
1078 * Revision 1.15 2002/04/24 00:47:46 jcdutton
630b6733e492 Some more cleanups.
jcdutton
parents: 28
diff changeset
1079 * Some more cleanups.
630b6733e492 Some more cleanups.
jcdutton
parents: 28
diff changeset
1080 * Improve button passing.
630b6733e492 Some more cleanups.
jcdutton
parents: 28
diff changeset
1081 *
28
da60d6379f95 Add some comments, FIXMEs.
jcdutton
parents: 26
diff changeset
1082 * Revision 1.14 2002/04/23 13:26:08 jcdutton
da60d6379f95 Add some comments, FIXMEs.
jcdutton
parents: 26
diff changeset
1083 * Add some comments, FIXMEs.
da60d6379f95 Add some comments, FIXMEs.
jcdutton
parents: 26
diff changeset
1084 * The main point being that dvdnav_get_next_block is almost in a state where it can be optional whether the application programmer uses it, or implements their own version of the function. That is been the main reason for the re-write of this function recently.
da60d6379f95 Add some comments, FIXMEs.
jcdutton
parents: 26
diff changeset
1085 *
26
794d2e16a4d4 Removed un-needed variables.
jcdutton
parents: 25
diff changeset
1086 * Revision 1.13 2002/04/23 12:55:40 jcdutton
794d2e16a4d4 Removed un-needed variables.
jcdutton
parents: 25
diff changeset
1087 * Removed un-needed variables.
794d2e16a4d4 Removed un-needed variables.
jcdutton
parents: 25
diff changeset
1088 * General Clean up.
794d2e16a4d4 Removed un-needed variables.
jcdutton
parents: 25
diff changeset
1089 *
25
df024077cbc1 Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents: 24
diff changeset
1090 * Revision 1.12 2002/04/23 12:34:39 f1rmb
df024077cbc1 Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents: 24
diff changeset
1091 * Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
df024077cbc1 Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents: 24
diff changeset
1092 * Comment unused var, shut compiler warnings.
df024077cbc1 Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents: 24
diff changeset
1093 *
24
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 23
diff changeset
1094 * Revision 1.11 2002/04/23 02:12:27 jcdutton
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 23
diff changeset
1095 * Re-implemented seeking.
870a0a1eee41 Re-implemented seeking.
jcdutton
parents: 23
diff changeset
1096 *
23
c2d40c38e12f Name stills work better.
jcdutton
parents: 22
diff changeset
1097 * Revision 1.10 2002/04/23 00:07:16 jcdutton
c2d40c38e12f Name stills work better.
jcdutton
parents: 22
diff changeset
1098 * Name stills work better.
c2d40c38e12f Name stills work better.
jcdutton
parents: 22
diff changeset
1099 *
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
1100 * Revision 1.9 2002/04/22 22:00:48 jcdutton
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
1101 * Start of rewrite of libdvdnav. Still need to re-implement seeking.
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 21
diff changeset
1102 *
21
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
1103 * Revision 1.8 2002/04/22 20:57:14 f1rmb
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
1104 * Change/fix SPU active stream id. Same for audio. Few new functions, largely
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
1105 * inspired from libogle ;-).
d2d73f2ad8d3 Change/fix SPU active stream id. Same for audio. Few new functions, largely
f1rmb
parents: 17
diff changeset
1106 *
17
a68c6da98b73 Actually fix the const this time!
jcdutton
parents: 8
diff changeset
1107 * Revision 1.7 2002/04/10 16:45:57 jcdutton
a68c6da98b73 Actually fix the const this time!
jcdutton
parents: 8
diff changeset
1108 * Actually fix the const this time!
a68c6da98b73 Actually fix the const this time!
jcdutton
parents: 8
diff changeset
1109 *
8
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 7
diff changeset
1110 * Revision 1.6 2002/04/07 14:10:11 richwareham
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 7
diff changeset
1111 * Stop C++ bitching about some things and extend the menus example
66708b4a1b5e Stop C++ bitching about some things and extend the menus example
richwareham
parents: 7
diff changeset
1112 *
7
7fdefafa624f Slight correction to handle quicker menu transitions.
jcdutton
parents: 6
diff changeset
1113 * Revision 1.5 2002/04/06 18:42:05 jcdutton
7fdefafa624f Slight correction to handle quicker menu transitions.
jcdutton
parents: 6
diff changeset
1114 * Slight correction to handle quicker menu transitions.
7fdefafa624f Slight correction to handle quicker menu transitions.
jcdutton
parents: 6
diff changeset
1115 *
6
5f319e02e333 Some cleaning up.
jcdutton
parents: 4
diff changeset
1116 * Revision 1.4 2002/04/06 18:31:50 jcdutton
5f319e02e333 Some cleaning up.
jcdutton
parents: 4
diff changeset
1117 * Some cleaning up.
5f319e02e333 Some cleaning up.
jcdutton
parents: 4
diff changeset
1118 * changed exit(1) to assert(0) so they actually get seen by the user so that it helps developers more.
5f319e02e333 Some cleaning up.
jcdutton
parents: 4
diff changeset
1119 *
4
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
1120 * Revision 1.3 2002/04/02 18:22:27 richwareham
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
1121 * Added reset patch from Kees Cook <kees@outflux.net>
99bed5d6db2f Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents: 3
diff changeset
1122 *
3
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
1123 * Revision 1.2 2002/04/01 18:56:28 richwareham
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
1124 * Added initial example programs directory and make sure all debug/error output goes to stderr.
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
1125 *
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
1126 * Revision 1.1.1.1 2002/03/12 19:45:57 richwareham
328eadb3f37e Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents: 0
diff changeset
1127 * Initial import
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1128 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1129 * Revision 1.28 2002/02/02 23:26:20 richwareham
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1130 * Restored title selection
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1131 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1132 * Revision 1.27 2002/02/01 15:48:10 richwareham
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1133 * Re-implemented angle selection and title/chapter display
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1134 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1135 * Revision 1.26 2002/01/31 16:53:49 richwareham
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1136 * Big patch from Daniel Caujolle-Bert to (re)implement SPU/Audio language display
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1137 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1138 * Revision 1.25 2002/01/24 20:53:50 richwareham
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1139 * Added option to _not_ use DVD read-ahead to options
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1140 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1141 * Revision 1.24 2002/01/20 15:54:59 jcdutton
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1142 * Implement seeking.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1143 * It is still a bit buggy, but works sometimes.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1144 * I need to find out how to make the jump clean.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1145 * At the moment, some corruption of the mpeg2 stream occurs,
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1146 * which causes libmpeg2 to crash.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1147 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1148 * Revision 1.23 2002/01/18 00:23:52 jcdutton
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1149 * Support Ejecting of DVD.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1150 * It will first un-mount the DVD, then eject it.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1151 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1152 * Revision 1.22 2002/01/17 14:50:32 jcdutton
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1153 * Fix corruption of stream during menu transitions.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1154 * Menu transitions are now clean.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1155 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1156 * Revision 1.21 2002/01/15 00:37:03 jcdutton
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1157 * Just a few cleanups, and a assert fix. (memset fixed it)
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1158 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1159 * Revision 1.20 2002/01/13 22:17:57 jcdutton
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1160 * Change logging.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1161 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1162 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1163 */