Mercurial > libdvdnav.hg
annotate navigation.c @ 233:59b5753b09d7 src
Add support for building under MINGW.
author | jcdutton |
---|---|
date | Sun, 01 Feb 2004 17:55:19 +0000 |
parents | 2d79ef3f3956 |
children | 5124cfd4725d |
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 } |
94
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
63 if(!this->started) { |
223
2d79ef3f3956
we should not start the VM on dvdnav_get_number_of_titles,
mroi
parents:
195
diff
changeset
|
64 printerr("Virtual DVD machine not started."); |
2d79ef3f3956
we should not start the VM on dvdnav_get_number_of_titles,
mroi
parents:
195
diff
changeset
|
65 return DVDNAV_STATUS_ERR; |
94
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
66 } |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
67 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
68 (*titles) = vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts; |
0 | 69 |
193 | 70 return DVDNAV_STATUS_OK; |
0 | 71 } |
72 | |
195 | 73 dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int32_t title, int32_t *parts) { |
114 | 74 if(!this || !parts) { |
75 printerr("Passed a NULL pointer."); | |
193 | 76 return DVDNAV_STATUS_ERR; |
5
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
77 } |
95 | 78 if(!this->started) { |
79 printerr("Virtual DVD machine not started."); | |
193 | 80 return DVDNAV_STATUS_ERR; |
95 | 81 } |
82 if ((title < 1) || (title > vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts) ) { | |
114 | 83 printerr("Passed a title number out of range."); |
193 | 84 return DVDNAV_STATUS_ERR; |
95 | 85 } |
114 | 86 |
95 | 87 (*parts) = vm_get_vmgi(this->vm)->tt_srpt->title[title-1].nr_of_ptts; |
114 | 88 |
193 | 89 return DVDNAV_STATUS_OK; |
5
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
90 } |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
91 |
195 | 92 dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int32_t *title, int32_t *part) { |
93 int32_t retval; | |
114 | 94 |
95 if(!this || !title || !part) { | |
96 printerr("Passed a NULL pointer."); | |
193 | 97 return DVDNAV_STATUS_ERR; |
114 | 98 } |
99 | |
100 pthread_mutex_lock(&this->vm_lock); | |
101 if (!this->vm->vtsi || !this->vm->vmgi) { | |
102 printerr("Bad VM state."); | |
103 pthread_mutex_unlock(&this->vm_lock); | |
193 | 104 return DVDNAV_STATUS_ERR; |
90 | 105 } |
114 | 106 if (!this->vm->state.pgc) { |
107 printerr("No current PGC."); | |
108 pthread_mutex_unlock(&this->vm_lock); | |
193 | 109 return DVDNAV_STATUS_ERR; |
114 | 110 } |
158 | 111 if ( (this->vm->state.domain == VTSM_DOMAIN) |
112 || (this->vm->state.domain == VMGM_DOMAIN) ) { | |
113 /* Get current Menu ID: into *part. */ | |
114 vm_get_current_menu(this->vm, part); | |
159 | 115 if (*part > -1) { |
116 *title = 0; | |
157
7094c8661c05
Return details about menu number in dvdnav_current_title_info()
jcdutton
parents:
146
diff
changeset
|
117 pthread_mutex_unlock(&this->vm_lock); |
193 | 118 return DVDNAV_STATUS_OK; |
157
7094c8661c05
Return details about menu number in dvdnav_current_title_info()
jcdutton
parents:
146
diff
changeset
|
119 } |
114 | 120 } |
158 | 121 if (this->vm->state.domain == VTS_DOMAIN) { |
122 retval = vm_get_current_title_part(this->vm, title, part); | |
123 pthread_mutex_unlock(&this->vm_lock); | |
193 | 124 return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR; |
158 | 125 } |
126 printerr("Not in a title or menu."); | |
114 | 127 pthread_mutex_unlock(&this->vm_lock); |
193 | 128 return DVDNAV_STATUS_ERR; |
90 | 129 } |
130 | |
195 | 131 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
|
132 if(!this) { |
114 | 133 printerr("Passed a NULL pointer."); |
193 | 134 return DVDNAV_STATUS_ERR; |
0 | 135 } |
90 | 136 return dvdnav_part_play(this, title, 1); |
0 | 137 } |
138 | |
195 | 139 dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int32_t title, int32_t part) { |
140 int32_t retval; | |
0 | 141 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
142 if(!this) { |
114 | 143 printerr("Passed a NULL pointer."); |
193 | 144 return DVDNAV_STATUS_ERR; |
114 | 145 } |
146 | |
147 pthread_mutex_lock(&this->vm_lock); | |
137 | 148 if (!this->vm->vmgi) { |
114 | 149 printerr("Bad VM state."); |
150 pthread_mutex_unlock(&this->vm_lock); | |
193 | 151 return DVDNAV_STATUS_ERR; |
0 | 152 } |
114 | 153 if (!this->vm->state.pgc) { |
154 printerr("No current PGC."); | |
155 pthread_mutex_unlock(&this->vm_lock); | |
193 | 156 return DVDNAV_STATUS_ERR; |
114 | 157 } |
158 if((title < 1) || (title > this->vm->vmgi->tt_srpt->nr_of_srpts)) { | |
159 printerr("Title out of range."); | |
160 pthread_mutex_unlock(&this->vm_lock); | |
193 | 161 return DVDNAV_STATUS_ERR; |
114 | 162 } |
140 | 163 if((part < 1) || (part > this->vm->vmgi->tt_srpt->title[title-1].nr_of_ptts)) { |
164 printerr("Part out of range."); | |
165 pthread_mutex_unlock(&this->vm_lock); | |
193 | 166 return DVDNAV_STATUS_ERR; |
140 | 167 } |
168 | |
114 | 169 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
|
170 if (retval) |
d09a81cf65ce
determine correct PG and PTT numbers when seeking across PG boundaries
mroi
parents:
116
diff
changeset
|
171 this->vm->hop_channel++; |
114 | 172 pthread_mutex_unlock(&this->vm_lock); |
0 | 173 |
193 | 174 return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR; |
0 | 175 } |
176 | |
195 | 177 dvdnav_status_t dvdnav_part_play_auto_stop(dvdnav_t *this, int32_t title, |
178 int32_t part, int32_t parts_to_play) { | |
114 | 179 /* FIXME: Implement auto-stop */ |
193 | 180 if (dvdnav_part_play(this, title, part) == DVDNAV_STATUS_OK) |
114 | 181 printerr("Not implemented yet."); |
193 | 182 return DVDNAV_STATUS_ERR; |
0 | 183 } |
184 | |
195 | 185 dvdnav_status_t dvdnav_time_play(dvdnav_t *this, int32_t title, |
186 uint64_t time) { | |
114 | 187 if(!this) { |
188 printerr("Passed a NULL pointer."); | |
193 | 189 return DVDNAV_STATUS_ERR; |
114 | 190 } |
191 | |
0 | 192 /* FIXME: Implement */ |
114 | 193 printerr("Not implemented yet."); |
193 | 194 return DVDNAV_STATUS_ERR; |
0 | 195 } |
196 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
197 dvdnav_status_t dvdnav_stop(dvdnav_t *this) { |
114 | 198 if(!this) { |
199 printerr("Passed a NULL pointer."); | |
193 | 200 return DVDNAV_STATUS_ERR; |
114 | 201 } |
0 | 202 |
114 | 203 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
|
204 this->vm->stopped = 1; |
114 | 205 pthread_mutex_unlock(&this->vm_lock); |
193 | 206 return DVDNAV_STATUS_OK; |
0 | 207 } |
208 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
209 dvdnav_status_t dvdnav_go_up(dvdnav_t *this) { |
114 | 210 if(!this) { |
211 printerr("Passed a NULL pointer."); | |
193 | 212 return DVDNAV_STATUS_ERR; |
114 | 213 } |
0 | 214 |
215 /* A nice easy function... delegate to the VM */ | |
114 | 216 pthread_mutex_lock(&this->vm_lock); |
217 vm_jump_up(this->vm); | |
218 pthread_mutex_unlock(&this->vm_lock); | |
0 | 219 |
193 | 220 return DVDNAV_STATUS_OK; |
0 | 221 } |