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