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