Mercurial > libdvdread4.hg
comparison navigation.c @ 0:427b7da5cbdb src
first split of dvdread; it's just a copy of dvdnav still to be cleaned
author | nicodvb |
---|---|
date | Sun, 01 Jun 2008 08:39:07 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:427b7da5cbdb |
---|---|
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 <inttypes.h> | |
29 #include <limits.h> | |
30 #include <string.h> | |
31 #include <sys/time.h> | |
32 #include "dvd_types.h" | |
33 #include "nav_types.h" | |
34 #include "ifo_types.h" | |
35 #include "remap.h" | |
36 #include "vm/decoder.h" | |
37 #include "vm/vm.h" | |
38 #include "dvdnav.h" | |
39 #include "dvdnav_internal.h" | |
40 | |
41 /* Navigation API calls */ | |
42 | |
43 dvdnav_status_t dvdnav_still_skip(dvdnav_t *this) { | |
44 this->position_current.still = 0; | |
45 this->skip_still = 1; | |
46 this->sync_wait = 0; | |
47 this->sync_wait_skip = 1; | |
48 | |
49 return DVDNAV_STATUS_OK; | |
50 } | |
51 | |
52 dvdnav_status_t dvdnav_wait_skip(dvdnav_t *this) { | |
53 this->sync_wait = 0; | |
54 this->sync_wait_skip = 1; | |
55 | |
56 return DVDNAV_STATUS_OK; | |
57 } | |
58 | |
59 dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int32_t *titles) { | |
60 if (!this->vm->vmgi) { | |
61 printerr("Bad VM state."); | |
62 return DVDNAV_STATUS_ERR; | |
63 } | |
64 | |
65 (*titles) = vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts; | |
66 | |
67 return DVDNAV_STATUS_OK; | |
68 } | |
69 | |
70 dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int32_t title, int32_t *parts) { | |
71 if (!this->vm->vmgi) { | |
72 printerr("Bad VM state."); | |
73 return DVDNAV_STATUS_ERR; | |
74 } | |
75 if ((title < 1) || (title > vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts) ) { | |
76 printerr("Passed a title number out of range."); | |
77 return DVDNAV_STATUS_ERR; | |
78 } | |
79 | |
80 (*parts) = vm_get_vmgi(this->vm)->tt_srpt->title[title-1].nr_of_ptts; | |
81 | |
82 return DVDNAV_STATUS_OK; | |
83 } | |
84 | |
85 dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int32_t *title, int32_t *part) { | |
86 int32_t retval; | |
87 | |
88 pthread_mutex_lock(&this->vm_lock); | |
89 if (!this->vm->vtsi || !this->vm->vmgi) { | |
90 printerr("Bad VM state."); | |
91 pthread_mutex_unlock(&this->vm_lock); | |
92 return DVDNAV_STATUS_ERR; | |
93 } | |
94 if (!this->started) { | |
95 printerr("Virtual DVD machine not started."); | |
96 pthread_mutex_unlock(&this->vm_lock); | |
97 return DVDNAV_STATUS_ERR; | |
98 } | |
99 if (!this->vm->state.pgc) { | |
100 printerr("No current PGC."); | |
101 pthread_mutex_unlock(&this->vm_lock); | |
102 return DVDNAV_STATUS_ERR; | |
103 } | |
104 if ( (this->vm->state.domain == VTSM_DOMAIN) | |
105 || (this->vm->state.domain == VMGM_DOMAIN) ) { | |
106 /* Get current Menu ID: into *part. */ | |
107 if(! vm_get_current_menu(this->vm, part)) { | |
108 pthread_mutex_unlock(&this->vm_lock); | |
109 return DVDNAV_STATUS_ERR; | |
110 } | |
111 if (*part > -1) { | |
112 *title = 0; | |
113 pthread_mutex_unlock(&this->vm_lock); | |
114 return DVDNAV_STATUS_OK; | |
115 } | |
116 } | |
117 if (this->vm->state.domain == VTS_DOMAIN) { | |
118 retval = vm_get_current_title_part(this->vm, title, part); | |
119 pthread_mutex_unlock(&this->vm_lock); | |
120 return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR; | |
121 } | |
122 printerr("Not in a title or menu."); | |
123 pthread_mutex_unlock(&this->vm_lock); | |
124 return DVDNAV_STATUS_ERR; | |
125 } | |
126 | |
127 dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int32_t title) { | |
128 return dvdnav_part_play(this, title, 1); | |
129 } | |
130 | |
131 dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int32_t title, int32_t part) { | |
132 int32_t retval; | |
133 | |
134 pthread_mutex_lock(&this->vm_lock); | |
135 if (!this->vm->vmgi) { | |
136 printerr("Bad VM state."); | |
137 pthread_mutex_unlock(&this->vm_lock); | |
138 return DVDNAV_STATUS_ERR; | |
139 } | |
140 if (!this->started) { | |
141 /* don't report an error but be nice */ | |
142 vm_start(this->vm); | |
143 this->started = 1; | |
144 } | |
145 if (!this->vm->state.pgc) { | |
146 printerr("No current PGC."); | |
147 pthread_mutex_unlock(&this->vm_lock); | |
148 return DVDNAV_STATUS_ERR; | |
149 } | |
150 if((title < 1) || (title > this->vm->vmgi->tt_srpt->nr_of_srpts)) { | |
151 printerr("Title out of range."); | |
152 pthread_mutex_unlock(&this->vm_lock); | |
153 return DVDNAV_STATUS_ERR; | |
154 } | |
155 if((part < 1) || (part > this->vm->vmgi->tt_srpt->title[title-1].nr_of_ptts)) { | |
156 printerr("Part out of range."); | |
157 pthread_mutex_unlock(&this->vm_lock); | |
158 return DVDNAV_STATUS_ERR; | |
159 } | |
160 | |
161 retval = vm_jump_title_part(this->vm, title, part); | |
162 if (retval) | |
163 this->vm->hop_channel++; | |
164 pthread_mutex_unlock(&this->vm_lock); | |
165 | |
166 return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR; | |
167 } | |
168 | |
169 dvdnav_status_t dvdnav_part_play_auto_stop(dvdnav_t *this, int32_t title, | |
170 int32_t part, int32_t parts_to_play) { | |
171 /* FIXME: Implement auto-stop */ | |
172 if (dvdnav_part_play(this, title, part) == DVDNAV_STATUS_OK) | |
173 printerr("Not implemented yet."); | |
174 return DVDNAV_STATUS_ERR; | |
175 } | |
176 | |
177 dvdnav_status_t dvdnav_time_play(dvdnav_t *this, int32_t title, | |
178 uint64_t time) { | |
179 /* FIXME: Implement */ | |
180 printerr("Not implemented yet."); | |
181 return DVDNAV_STATUS_ERR; | |
182 } | |
183 | |
184 dvdnav_status_t dvdnav_stop(dvdnav_t *this) { | |
185 pthread_mutex_lock(&this->vm_lock); | |
186 this->vm->stopped = 1; | |
187 pthread_mutex_unlock(&this->vm_lock); | |
188 return DVDNAV_STATUS_OK; | |
189 } | |
190 | |
191 dvdnav_status_t dvdnav_go_up(dvdnav_t *this) { | |
192 /* A nice easy function... delegate to the VM */ | |
193 pthread_mutex_lock(&this->vm_lock); | |
194 vm_jump_up(this->vm); | |
195 pthread_mutex_unlock(&this->vm_lock); | |
196 | |
197 return DVDNAV_STATUS_OK; | |
198 } |