Mercurial > libdvdnav.hg
annotate navigation.c @ 222:1ebbad52714a src
Put ifo_print.c and .h back in.
author | jcdutton |
---|---|
date | Thu, 01 Jan 2004 15:13:13 +0000 |
parents | 6b1bfe8f5283 |
children | 2d79ef3f3956 |
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."); | |
193 | 35 return DVDNAV_STATUS_ERR; |
114 | 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 | |
193 | 43 return DVDNAV_STATUS_OK; |
116 | 44 } |
45 | |
46 dvdnav_status_t dvdnav_wait_skip(dvdnav_t *this) { | |
47 if(!this) { | |
48 printerr("Passed a NULL pointer."); | |
193 | 49 return DVDNAV_STATUS_ERR; |
116 | 50 } |
51 | |
52 this->sync_wait = 0; | |
53 this->sync_wait_skip = 1; | |
0 | 54 |
193 | 55 return DVDNAV_STATUS_OK; |
0 | 56 } |
57 | |
195 | 58 dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int32_t *titles) { |
114 | 59 if(!this || !titles) { |
60 printerr("Passed a NULL pointer."); | |
193 | 61 return DVDNAV_STATUS_ERR; |
0 | 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 |
193 | 72 return DVDNAV_STATUS_OK; |
0 | 73 } |
74 | |
195 | 75 dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int32_t title, int32_t *parts) { |
114 | 76 if(!this || !parts) { |
77 printerr("Passed a NULL pointer."); | |
193 | 78 return DVDNAV_STATUS_ERR; |
5
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."); | |
193 | 82 return DVDNAV_STATUS_ERR; |
95 | 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."); |
193 | 86 return DVDNAV_STATUS_ERR; |
95 | 87 } |
114 | 88 |
95 | 89 (*parts) = vm_get_vmgi(this->vm)->tt_srpt->title[title-1].nr_of_ptts; |
114 | 90 |
193 | 91 return DVDNAV_STATUS_OK; |
5
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 |
195 | 94 dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int32_t *title, int32_t *part) { |
95 int32_t retval; | |
114 | 96 |
97 if(!this || !title || !part) { | |
98 printerr("Passed a NULL pointer."); | |
193 | 99 return DVDNAV_STATUS_ERR; |
114 | 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); | |
193 | 106 return DVDNAV_STATUS_ERR; |
90 | 107 } |
114 | 108 if (!this->vm->state.pgc) { |
109 printerr("No current PGC."); | |
110 pthread_mutex_unlock(&this->vm_lock); | |
193 | 111 return DVDNAV_STATUS_ERR; |
114 | 112 } |
158 | 113 if ( (this->vm->state.domain == VTSM_DOMAIN) |
114 || (this->vm->state.domain == VMGM_DOMAIN) ) { | |
115 /* Get current Menu ID: into *part. */ | |
116 vm_get_current_menu(this->vm, part); | |
159 | 117 if (*part > -1) { |
118 *title = 0; | |
157
7094c8661c05
Return details about menu number in dvdnav_current_title_info()
jcdutton
parents:
146
diff
changeset
|
119 pthread_mutex_unlock(&this->vm_lock); |
193 | 120 return DVDNAV_STATUS_OK; |
157
7094c8661c05
Return details about menu number in dvdnav_current_title_info()
jcdutton
parents:
146
diff
changeset
|
121 } |
114 | 122 } |
158 | 123 if (this->vm->state.domain == VTS_DOMAIN) { |
124 retval = vm_get_current_title_part(this->vm, title, part); | |
125 pthread_mutex_unlock(&this->vm_lock); | |
193 | 126 return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR; |
158 | 127 } |
128 printerr("Not in a title or menu."); | |
114 | 129 pthread_mutex_unlock(&this->vm_lock); |
193 | 130 return DVDNAV_STATUS_ERR; |
90 | 131 } |
132 | |
195 | 133 dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int32_t title) { |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
134 if(!this) { |
114 | 135 printerr("Passed a NULL pointer."); |
193 | 136 return DVDNAV_STATUS_ERR; |
0 | 137 } |
90 | 138 return dvdnav_part_play(this, title, 1); |
0 | 139 } |
140 | |
195 | 141 dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int32_t title, int32_t part) { |
142 int32_t retval; | |
0 | 143 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
144 if(!this) { |
114 | 145 printerr("Passed a NULL pointer."); |
193 | 146 return DVDNAV_STATUS_ERR; |
114 | 147 } |
148 | |
149 pthread_mutex_lock(&this->vm_lock); | |
137 | 150 if (!this->vm->vmgi) { |
114 | 151 printerr("Bad VM state."); |
152 pthread_mutex_unlock(&this->vm_lock); | |
193 | 153 return DVDNAV_STATUS_ERR; |
0 | 154 } |
114 | 155 if (!this->vm->state.pgc) { |
156 printerr("No current PGC."); | |
157 pthread_mutex_unlock(&this->vm_lock); | |
193 | 158 return DVDNAV_STATUS_ERR; |
114 | 159 } |
160 if((title < 1) || (title > this->vm->vmgi->tt_srpt->nr_of_srpts)) { | |
161 printerr("Title out of range."); | |
162 pthread_mutex_unlock(&this->vm_lock); | |
193 | 163 return DVDNAV_STATUS_ERR; |
114 | 164 } |
140 | 165 if((part < 1) || (part > this->vm->vmgi->tt_srpt->title[title-1].nr_of_ptts)) { |
166 printerr("Part out of range."); | |
167 pthread_mutex_unlock(&this->vm_lock); | |
193 | 168 return DVDNAV_STATUS_ERR; |
140 | 169 } |
170 | |
114 | 171 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
|
172 if (retval) |
d09a81cf65ce
determine correct PG and PTT numbers when seeking across PG boundaries
mroi
parents:
116
diff
changeset
|
173 this->vm->hop_channel++; |
114 | 174 pthread_mutex_unlock(&this->vm_lock); |
0 | 175 |
193 | 176 return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR; |
0 | 177 } |
178 | |
195 | 179 dvdnav_status_t dvdnav_part_play_auto_stop(dvdnav_t *this, int32_t title, |
180 int32_t part, int32_t parts_to_play) { | |
114 | 181 /* FIXME: Implement auto-stop */ |
193 | 182 if (dvdnav_part_play(this, title, part) == DVDNAV_STATUS_OK) |
114 | 183 printerr("Not implemented yet."); |
193 | 184 return DVDNAV_STATUS_ERR; |
0 | 185 } |
186 | |
195 | 187 dvdnav_status_t dvdnav_time_play(dvdnav_t *this, int32_t title, |
188 uint64_t time) { | |
114 | 189 if(!this) { |
190 printerr("Passed a NULL pointer."); | |
193 | 191 return DVDNAV_STATUS_ERR; |
114 | 192 } |
193 | |
0 | 194 /* FIXME: Implement */ |
114 | 195 printerr("Not implemented yet."); |
193 | 196 return DVDNAV_STATUS_ERR; |
0 | 197 } |
198 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
199 dvdnav_status_t dvdnav_stop(dvdnav_t *this) { |
114 | 200 if(!this) { |
201 printerr("Passed a NULL pointer."); | |
193 | 202 return DVDNAV_STATUS_ERR; |
114 | 203 } |
0 | 204 |
114 | 205 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
|
206 this->vm->stopped = 1; |
114 | 207 pthread_mutex_unlock(&this->vm_lock); |
193 | 208 return DVDNAV_STATUS_OK; |
0 | 209 } |
210 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
211 dvdnav_status_t dvdnav_go_up(dvdnav_t *this) { |
114 | 212 if(!this) { |
213 printerr("Passed a NULL pointer."); | |
193 | 214 return DVDNAV_STATUS_ERR; |
114 | 215 } |
0 | 216 |
217 /* A nice easy function... delegate to the VM */ | |
114 | 218 pthread_mutex_lock(&this->vm_lock); |
219 vm_jump_up(this->vm); | |
220 pthread_mutex_unlock(&this->vm_lock); | |
0 | 221 |
193 | 222 return DVDNAV_STATUS_OK; |
0 | 223 } |