Mercurial > libdvdnav.hg
annotate navigation.c @ 154:3492d41dc247 src
vm_getbits should be in decoder.c, because
1) it is declared in decoder.h
2) this is needed to compile correctly without tracing enabled
author | mroi |
---|---|
date | Sat, 05 Apr 2003 14:28:07 +0000 |
parents | 7f242ec838fd |
children | 7094c8661c05 |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright (C) 2000 Rich Wareham <richwareham@users.sourceforge.net> | |
3 * | |
4 * This file is part of libdvdnav, a DVD navigation library. | |
5 * | |
6 * libdvdnav is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * libdvdnav is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
19 * | |
20 * $Id$ | |
21 * | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include "config.h" | |
26 #endif | |
27 | |
28 #include "dvdnav_internal.h" | |
29 | |
30 /* Navigation API calls */ | |
31 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
32 dvdnav_status_t dvdnav_still_skip(dvdnav_t *this) { |
114 | 33 if(!this) { |
34 printerr("Passed a NULL pointer."); | |
35 return S_ERR; | |
36 } | |
0 | 37 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
38 this->position_current.still = 0; |
23 | 39 this->skip_still = 1; |
116 | 40 this->sync_wait = 0; |
41 this->sync_wait_skip = 1; | |
42 | |
43 return S_OK; | |
44 } | |
45 | |
46 dvdnav_status_t dvdnav_wait_skip(dvdnav_t *this) { | |
47 if(!this) { | |
48 printerr("Passed a NULL pointer."); | |
49 return S_ERR; | |
50 } | |
51 | |
52 this->sync_wait = 0; | |
53 this->sync_wait_skip = 1; | |
0 | 54 |
55 return S_OK; | |
56 } | |
57 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
58 dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int *titles) { |
114 | 59 if(!this || !titles) { |
60 printerr("Passed a NULL pointer."); | |
0 | 61 return S_ERR; |
62 } | |
63 | |
94
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
64 if(!this->started) { |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
65 /* Start the VM */ |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
66 vm_start(this->vm); |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
67 this->started = 1; |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
68 } |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
69 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
70 (*titles) = vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts; |
0 | 71 |
72 return S_OK; | |
73 } | |
74 | |
95 | 75 dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int title, int *parts) { |
114 | 76 if(!this || !parts) { |
77 printerr("Passed a NULL pointer."); | |
5
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
78 return S_ERR; |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
79 } |
95 | 80 if(!this->started) { |
81 printerr("Virtual DVD machine not started."); | |
82 return S_ERR; | |
83 } | |
84 if ((title < 1) || (title > vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts) ) { | |
114 | 85 printerr("Passed a title number out of range."); |
95 | 86 return S_ERR; |
87 } | |
114 | 88 |
95 | 89 (*parts) = vm_get_vmgi(this->vm)->tt_srpt->title[title-1].nr_of_ptts; |
114 | 90 |
5
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
91 return S_OK; |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
92 } |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
93 |
90 | 94 dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int *title, int *part) { |
114 | 95 int retval; |
96 | |
97 if(!this || !title || !part) { | |
98 printerr("Passed a NULL pointer."); | |
99 return S_ERR; | |
100 } | |
101 | |
102 pthread_mutex_lock(&this->vm_lock); | |
103 if (!this->vm->vtsi || !this->vm->vmgi) { | |
104 printerr("Bad VM state."); | |
105 pthread_mutex_unlock(&this->vm_lock); | |
90 | 106 return S_ERR; |
107 } | |
114 | 108 if (!this->vm->state.pgc) { |
109 printerr("No current PGC."); | |
110 pthread_mutex_unlock(&this->vm_lock); | |
111 return S_ERR; | |
112 } | |
113 if (this->vm->state.domain != VTS_DOMAIN) { | |
114 printerr("Not in VTS domain."); | |
115 pthread_mutex_unlock(&this->vm_lock); | |
116 return S_ERR; | |
117 } | |
118 retval = vm_get_current_title_part(this->vm, title, part); | |
119 pthread_mutex_unlock(&this->vm_lock); | |
120 | |
121 return retval ? S_OK : S_ERR; | |
90 | 122 } |
123 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
124 dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int title) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
125 if(!this) { |
114 | 126 printerr("Passed a NULL pointer."); |
0 | 127 return S_ERR; |
128 } | |
90 | 129 return dvdnav_part_play(this, title, 1); |
0 | 130 } |
131 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
132 dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int title, int part) { |
114 | 133 int retval; |
0 | 134 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
135 if(!this) { |
114 | 136 printerr("Passed a NULL pointer."); |
137 return S_ERR; | |
138 } | |
139 | |
140 pthread_mutex_lock(&this->vm_lock); | |
137 | 141 if (!this->vm->vmgi) { |
114 | 142 printerr("Bad VM state."); |
143 pthread_mutex_unlock(&this->vm_lock); | |
0 | 144 return S_ERR; |
145 } | |
114 | 146 if (!this->vm->state.pgc) { |
147 printerr("No current PGC."); | |
148 pthread_mutex_unlock(&this->vm_lock); | |
149 return S_ERR; | |
150 } | |
151 if((title < 1) || (title > this->vm->vmgi->tt_srpt->nr_of_srpts)) { | |
152 printerr("Title out of range."); | |
153 pthread_mutex_unlock(&this->vm_lock); | |
154 return S_ERR; | |
155 } | |
140 | 156 if((part < 1) || (part > this->vm->vmgi->tt_srpt->title[title-1].nr_of_ptts)) { |
157 printerr("Part out of range."); | |
158 pthread_mutex_unlock(&this->vm_lock); | |
159 return S_ERR; | |
160 } | |
161 | |
114 | 162 retval = vm_jump_title_part(this->vm, title, part); |
133
d09a81cf65ce
determine correct PG and PTT numbers when seeking across PG boundaries
mroi
parents:
116
diff
changeset
|
163 if (retval) |
d09a81cf65ce
determine correct PG and PTT numbers when seeking across PG boundaries
mroi
parents:
116
diff
changeset
|
164 this->vm->hop_channel++; |
114 | 165 pthread_mutex_unlock(&this->vm_lock); |
0 | 166 |
114 | 167 return retval ? S_OK : S_ERR; |
0 | 168 } |
169 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
170 dvdnav_status_t dvdnav_part_play_auto_stop(dvdnav_t *this, int title, |
114 | 171 int part, int parts_to_play) { |
172 /* FIXME: Implement auto-stop */ | |
173 if (dvdnav_part_play(this, title, part) == S_OK) | |
174 printerr("Not implemented yet."); | |
175 return S_ERR; | |
0 | 176 } |
177 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
178 dvdnav_status_t dvdnav_time_play(dvdnav_t *this, int title, |
114 | 179 unsigned long int time) { |
180 if(!this) { | |
181 printerr("Passed a NULL pointer."); | |
182 return S_ERR; | |
183 } | |
184 | |
0 | 185 /* FIXME: Implement */ |
114 | 186 printerr("Not implemented yet."); |
187 return S_ERR; | |
0 | 188 } |
189 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
190 dvdnav_status_t dvdnav_stop(dvdnav_t *this) { |
114 | 191 if(!this) { |
192 printerr("Passed a NULL pointer."); | |
193 return S_ERR; | |
194 } | |
0 | 195 |
114 | 196 pthread_mutex_lock(&this->vm_lock); |
146
7f242ec838fd
do not stop the VM here, get_next_block will do that without races
mroi
parents:
140
diff
changeset
|
197 this->vm->stopped = 1; |
114 | 198 pthread_mutex_unlock(&this->vm_lock); |
0 | 199 return S_OK; |
200 } | |
201 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
202 dvdnav_status_t dvdnav_go_up(dvdnav_t *this) { |
114 | 203 if(!this) { |
204 printerr("Passed a NULL pointer."); | |
205 return S_ERR; | |
206 } | |
0 | 207 |
208 /* A nice easy function... delegate to the VM */ | |
114 | 209 pthread_mutex_lock(&this->vm_lock); |
210 vm_jump_up(this->vm); | |
211 pthread_mutex_unlock(&this->vm_lock); | |
0 | 212 |
213 return S_OK; | |
214 } |