Mercurial > libdvdnav.hg
annotate navigation.c @ 133:d09a81cf65ce src
determine correct PG and PTT numbers when seeking across PG boundaries
author | mroi |
---|---|
date | Mon, 24 Mar 2003 16:42:59 +0000 |
parents | 4d711d0518e9 |
children | 5897ff629f7c |
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 #include "vm.h" | |
31 | |
32 /* Navigation API calls */ | |
33 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
34 dvdnav_status_t dvdnav_still_skip(dvdnav_t *this) { |
114 | 35 if(!this) { |
36 printerr("Passed a NULL pointer."); | |
37 return S_ERR; | |
38 } | |
0 | 39 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
40 this->position_current.still = 0; |
23 | 41 this->skip_still = 1; |
116 | 42 this->sync_wait = 0; |
43 this->sync_wait_skip = 1; | |
44 | |
45 return S_OK; | |
46 } | |
47 | |
48 dvdnav_status_t dvdnav_wait_skip(dvdnav_t *this) { | |
49 if(!this) { | |
50 printerr("Passed a NULL pointer."); | |
51 return S_ERR; | |
52 } | |
53 | |
54 this->sync_wait = 0; | |
55 this->sync_wait_skip = 1; | |
0 | 56 |
57 return S_OK; | |
58 } | |
59 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
60 dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int *titles) { |
114 | 61 if(!this || !titles) { |
62 printerr("Passed a NULL pointer."); | |
0 | 63 return S_ERR; |
64 } | |
65 | |
94
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
66 if(!this->started) { |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
67 /* Start the VM */ |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
68 vm_start(this->vm); |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
69 this->started = 1; |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
70 } |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
71 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
72 (*titles) = vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts; |
0 | 73 |
74 return S_OK; | |
75 } | |
76 | |
95 | 77 dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int title, int *parts) { |
114 | 78 if(!this || !parts) { |
79 printerr("Passed a NULL pointer."); | |
5
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
80 return S_ERR; |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
81 } |
95 | 82 if(!this->started) { |
83 printerr("Virtual DVD machine not started."); | |
84 return S_ERR; | |
85 } | |
86 if ((title < 1) || (title > vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts) ) { | |
114 | 87 printerr("Passed a title number out of range."); |
95 | 88 return S_ERR; |
89 } | |
114 | 90 |
95 | 91 (*parts) = vm_get_vmgi(this->vm)->tt_srpt->title[title-1].nr_of_ptts; |
114 | 92 |
5
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
93 return S_OK; |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
94 } |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
95 |
90 | 96 dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int *title, int *part) { |
114 | 97 int retval; |
98 | |
99 if(!this || !title || !part) { | |
100 printerr("Passed a NULL pointer."); | |
101 return S_ERR; | |
102 } | |
103 | |
104 pthread_mutex_lock(&this->vm_lock); | |
105 if (!this->vm->vtsi || !this->vm->vmgi) { | |
106 printerr("Bad VM state."); | |
107 pthread_mutex_unlock(&this->vm_lock); | |
90 | 108 return S_ERR; |
109 } | |
114 | 110 if (!this->vm->state.pgc) { |
111 printerr("No current PGC."); | |
112 pthread_mutex_unlock(&this->vm_lock); | |
113 return S_ERR; | |
114 } | |
115 if (this->vm->state.domain != VTS_DOMAIN) { | |
116 printerr("Not in VTS domain."); | |
117 pthread_mutex_unlock(&this->vm_lock); | |
118 return S_ERR; | |
119 } | |
120 retval = vm_get_current_title_part(this->vm, title, part); | |
121 pthread_mutex_unlock(&this->vm_lock); | |
122 | |
123 return retval ? S_OK : S_ERR; | |
90 | 124 } |
125 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
126 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
|
127 if(!this) { |
114 | 128 printerr("Passed a NULL pointer."); |
0 | 129 return S_ERR; |
130 } | |
90 | 131 return dvdnav_part_play(this, title, 1); |
0 | 132 } |
133 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
134 dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int title, int part) { |
114 | 135 int retval; |
0 | 136 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
137 if(!this) { |
114 | 138 printerr("Passed a NULL pointer."); |
139 return S_ERR; | |
140 } | |
141 | |
142 pthread_mutex_lock(&this->vm_lock); | |
143 if (!this->vm->vtsi || !this->vm->vmgi) { | |
144 printerr("Bad VM state."); | |
145 pthread_mutex_unlock(&this->vm_lock); | |
0 | 146 return S_ERR; |
147 } | |
114 | 148 if (!this->vm->state.pgc) { |
149 printerr("No current PGC."); | |
150 pthread_mutex_unlock(&this->vm_lock); | |
151 return S_ERR; | |
152 } | |
153 if((title < 1) || (title > this->vm->vmgi->tt_srpt->nr_of_srpts)) { | |
154 printerr("Title out of range."); | |
155 pthread_mutex_unlock(&this->vm_lock); | |
156 return S_ERR; | |
157 } | |
158 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
|
159 if (retval) |
d09a81cf65ce
determine correct PG and PTT numbers when seeking across PG boundaries
mroi
parents:
116
diff
changeset
|
160 this->vm->hop_channel++; |
114 | 161 pthread_mutex_unlock(&this->vm_lock); |
0 | 162 |
114 | 163 return retval ? S_OK : S_ERR; |
0 | 164 } |
165 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
166 dvdnav_status_t dvdnav_part_play_auto_stop(dvdnav_t *this, int title, |
114 | 167 int part, int parts_to_play) { |
168 /* FIXME: Implement auto-stop */ | |
169 if (dvdnav_part_play(this, title, part) == S_OK) | |
170 printerr("Not implemented yet."); | |
171 return S_ERR; | |
0 | 172 } |
173 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
174 dvdnav_status_t dvdnav_time_play(dvdnav_t *this, int title, |
114 | 175 unsigned long int time) { |
176 if(!this) { | |
177 printerr("Passed a NULL pointer."); | |
178 return S_ERR; | |
179 } | |
180 | |
0 | 181 /* FIXME: Implement */ |
114 | 182 printerr("Not implemented yet."); |
183 return S_ERR; | |
0 | 184 } |
185 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
186 dvdnav_status_t dvdnav_stop(dvdnav_t *this) { |
114 | 187 if(!this) { |
188 printerr("Passed a NULL pointer."); | |
189 return S_ERR; | |
190 } | |
0 | 191 |
114 | 192 pthread_mutex_lock(&this->vm_lock); |
193 vm_stop(this->vm); | |
194 pthread_mutex_unlock(&this->vm_lock); | |
0 | 195 return S_OK; |
196 } | |
197 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
198 dvdnav_status_t dvdnav_go_up(dvdnav_t *this) { |
114 | 199 if(!this) { |
200 printerr("Passed a NULL pointer."); | |
201 return S_ERR; | |
202 } | |
0 | 203 |
204 /* A nice easy function... delegate to the VM */ | |
114 | 205 pthread_mutex_lock(&this->vm_lock); |
206 vm_jump_up(this->vm); | |
207 pthread_mutex_unlock(&this->vm_lock); | |
0 | 208 |
209 return S_OK; | |
210 } |