Mercurial > libdvdnav.hg
annotate navigation.c @ 278:ef3b33441db5 src
include inttypes.h wherever necessary
author | nicodvb |
---|---|
date | Mon, 16 Apr 2007 22:43:56 +0000 |
parents | bd734ab914d0 |
children | 52877d182e96 |
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 | |
278 | 28 #include <inttypes.h> |
0 | 29 #include "dvdnav_internal.h" |
30 | |
31 /* Navigation API calls */ | |
32 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
33 dvdnav_status_t dvdnav_still_skip(dvdnav_t *this) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
34 this->position_current.still = 0; |
23 | 35 this->skip_still = 1; |
116 | 36 this->sync_wait = 0; |
37 this->sync_wait_skip = 1; | |
38 | |
193 | 39 return DVDNAV_STATUS_OK; |
116 | 40 } |
41 | |
42 dvdnav_status_t dvdnav_wait_skip(dvdnav_t *this) { | |
43 this->sync_wait = 0; | |
44 this->sync_wait_skip = 1; | |
0 | 45 |
193 | 46 return DVDNAV_STATUS_OK; |
0 | 47 } |
48 | |
195 | 49 dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int32_t *titles) { |
248
5124cfd4725d
fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents:
223
diff
changeset
|
50 if (!this->vm->vmgi) { |
5124cfd4725d
fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents:
223
diff
changeset
|
51 printerr("Bad VM state."); |
223
2d79ef3f3956
we should not start the VM on dvdnav_get_number_of_titles,
mroi
parents:
195
diff
changeset
|
52 return DVDNAV_STATUS_ERR; |
94
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
53 } |
e29110f67f3a
Get xine dvd:///dev/dvd:1.2 i.e. title play working again.
jcdutton
parents:
90
diff
changeset
|
54 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
55 (*titles) = vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts; |
0 | 56 |
193 | 57 return DVDNAV_STATUS_OK; |
0 | 58 } |
59 | |
195 | 60 dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int32_t title, int32_t *parts) { |
248
5124cfd4725d
fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents:
223
diff
changeset
|
61 if (!this->vm->vmgi) { |
5124cfd4725d
fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents:
223
diff
changeset
|
62 printerr("Bad VM state."); |
193 | 63 return DVDNAV_STATUS_ERR; |
95 | 64 } |
65 if ((title < 1) || (title > vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts) ) { | |
114 | 66 printerr("Passed a title number out of range."); |
193 | 67 return DVDNAV_STATUS_ERR; |
95 | 68 } |
114 | 69 |
95 | 70 (*parts) = vm_get_vmgi(this->vm)->tt_srpt->title[title-1].nr_of_ptts; |
114 | 71 |
193 | 72 return DVDNAV_STATUS_OK; |
5
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
73 } |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
74 |
195 | 75 dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int32_t *title, int32_t *part) { |
76 int32_t retval; | |
114 | 77 |
78 pthread_mutex_lock(&this->vm_lock); | |
79 if (!this->vm->vtsi || !this->vm->vmgi) { | |
80 printerr("Bad VM state."); | |
81 pthread_mutex_unlock(&this->vm_lock); | |
193 | 82 return DVDNAV_STATUS_ERR; |
90 | 83 } |
248
5124cfd4725d
fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents:
223
diff
changeset
|
84 if (!this->started) { |
5124cfd4725d
fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents:
223
diff
changeset
|
85 printerr("Virtual DVD machine not started."); |
5124cfd4725d
fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents:
223
diff
changeset
|
86 pthread_mutex_unlock(&this->vm_lock); |
5124cfd4725d
fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents:
223
diff
changeset
|
87 return DVDNAV_STATUS_ERR; |
5124cfd4725d
fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents:
223
diff
changeset
|
88 } |
114 | 89 if (!this->vm->state.pgc) { |
90 printerr("No current PGC."); | |
91 pthread_mutex_unlock(&this->vm_lock); | |
193 | 92 return DVDNAV_STATUS_ERR; |
114 | 93 } |
158 | 94 if ( (this->vm->state.domain == VTSM_DOMAIN) |
95 || (this->vm->state.domain == VMGM_DOMAIN) ) { | |
96 /* Get current Menu ID: into *part. */ | |
97 vm_get_current_menu(this->vm, part); | |
159 | 98 if (*part > -1) { |
99 *title = 0; | |
157
7094c8661c05
Return details about menu number in dvdnav_current_title_info()
jcdutton
parents:
146
diff
changeset
|
100 pthread_mutex_unlock(&this->vm_lock); |
193 | 101 return DVDNAV_STATUS_OK; |
157
7094c8661c05
Return details about menu number in dvdnav_current_title_info()
jcdutton
parents:
146
diff
changeset
|
102 } |
114 | 103 } |
158 | 104 if (this->vm->state.domain == VTS_DOMAIN) { |
105 retval = vm_get_current_title_part(this->vm, title, part); | |
106 pthread_mutex_unlock(&this->vm_lock); | |
193 | 107 return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR; |
158 | 108 } |
109 printerr("Not in a title or menu."); | |
114 | 110 pthread_mutex_unlock(&this->vm_lock); |
193 | 111 return DVDNAV_STATUS_ERR; |
90 | 112 } |
113 | |
195 | 114 dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int32_t title) { |
90 | 115 return dvdnav_part_play(this, title, 1); |
0 | 116 } |
117 | |
195 | 118 dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int32_t title, int32_t part) { |
119 int32_t retval; | |
0 | 120 |
114 | 121 pthread_mutex_lock(&this->vm_lock); |
137 | 122 if (!this->vm->vmgi) { |
114 | 123 printerr("Bad VM state."); |
124 pthread_mutex_unlock(&this->vm_lock); | |
193 | 125 return DVDNAV_STATUS_ERR; |
0 | 126 } |
248
5124cfd4725d
fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents:
223
diff
changeset
|
127 if (!this->started) { |
5124cfd4725d
fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents:
223
diff
changeset
|
128 /* don't report an error but be nice */ |
5124cfd4725d
fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents:
223
diff
changeset
|
129 vm_start(this->vm); |
5124cfd4725d
fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents:
223
diff
changeset
|
130 this->started = 1; |
5124cfd4725d
fix some error conditions (fixes dvdnav_title_part_play())
mroi
parents:
223
diff
changeset
|
131 } |
114 | 132 if (!this->vm->state.pgc) { |
133 printerr("No current PGC."); | |
134 pthread_mutex_unlock(&this->vm_lock); | |
193 | 135 return DVDNAV_STATUS_ERR; |
114 | 136 } |
137 if((title < 1) || (title > this->vm->vmgi->tt_srpt->nr_of_srpts)) { | |
138 printerr("Title out of range."); | |
139 pthread_mutex_unlock(&this->vm_lock); | |
193 | 140 return DVDNAV_STATUS_ERR; |
114 | 141 } |
140 | 142 if((part < 1) || (part > this->vm->vmgi->tt_srpt->title[title-1].nr_of_ptts)) { |
143 printerr("Part out of range."); | |
144 pthread_mutex_unlock(&this->vm_lock); | |
193 | 145 return DVDNAV_STATUS_ERR; |
140 | 146 } |
147 | |
114 | 148 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
|
149 if (retval) |
d09a81cf65ce
determine correct PG and PTT numbers when seeking across PG boundaries
mroi
parents:
116
diff
changeset
|
150 this->vm->hop_channel++; |
114 | 151 pthread_mutex_unlock(&this->vm_lock); |
0 | 152 |
193 | 153 return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR; |
0 | 154 } |
155 | |
195 | 156 dvdnav_status_t dvdnav_part_play_auto_stop(dvdnav_t *this, int32_t title, |
157 int32_t part, int32_t parts_to_play) { | |
114 | 158 /* FIXME: Implement auto-stop */ |
193 | 159 if (dvdnav_part_play(this, title, part) == DVDNAV_STATUS_OK) |
114 | 160 printerr("Not implemented yet."); |
193 | 161 return DVDNAV_STATUS_ERR; |
0 | 162 } |
163 | |
195 | 164 dvdnav_status_t dvdnav_time_play(dvdnav_t *this, int32_t title, |
165 uint64_t time) { | |
0 | 166 /* FIXME: Implement */ |
114 | 167 printerr("Not implemented yet."); |
193 | 168 return DVDNAV_STATUS_ERR; |
0 | 169 } |
170 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
171 dvdnav_status_t dvdnav_stop(dvdnav_t *this) { |
114 | 172 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
|
173 this->vm->stopped = 1; |
114 | 174 pthread_mutex_unlock(&this->vm_lock); |
193 | 175 return DVDNAV_STATUS_OK; |
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_go_up(dvdnav_t *this) { |
0 | 179 /* A nice easy function... delegate to the VM */ |
114 | 180 pthread_mutex_lock(&this->vm_lock); |
181 vm_jump_up(this->vm); | |
182 pthread_mutex_unlock(&this->vm_lock); | |
0 | 183 |
193 | 184 return DVDNAV_STATUS_OK; |
0 | 185 } |