Mercurial > libdvdnav.hg
annotate navigation.c @ 22:3c1df0cb3aee src
Start of rewrite of libdvdnav. Still need to re-implement seeking.
author | jcdutton |
---|---|
date | Mon, 22 Apr 2002 22:01:28 +0000 |
parents | c1b55dc1bfed |
children | c2d40c38e12f |
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.h> | |
29 #include "dvdnav_internal.h" | |
30 | |
31 #include "vm.h" | |
32 | |
33 /* Navigation API calls */ | |
34 | |
35 /* Common things we do everytime we do a jump */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
36 void dvdnav_do_post_jump(dvdnav_t *this) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
37 dvd_state_t *state = &(this->vm->state); |
0 | 38 cell_playback_t *cell = &(state->pgc->cell_playback[state->cellN - 1]); |
39 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
40 this->jmp_blockN = 0; /* FIXME: Should this be different? */ |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
41 this->jmp_vobu_start = cell->first_sector; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
42 this->jumping = 1; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
43 this->position_current.still = 0; |
0 | 44 } |
45 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
46 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
|
47 if(!this) |
0 | 48 return S_ERR; |
49 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
50 this->position_current.still = 0; |
0 | 51 |
52 return S_OK; | |
53 } | |
54 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
55 dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int *titles) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
56 if(!this) |
0 | 57 return S_ERR; |
58 | |
59 if(!titles) { | |
60 printerr("Passed a NULL pointer"); | |
61 return S_ERR; | |
62 } | |
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 |
66 return S_OK; | |
67 } | |
68 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
69 dvdnav_status_t dvdnav_get_number_of_programs(dvdnav_t *this, int *programs) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
70 if(!this) |
5
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
71 return S_ERR; |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
72 |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
73 if(!programs) { |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
74 printerr("Passed a NULL pointer"); |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
75 return S_ERR; |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
76 } |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
77 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
78 (*programs) = this->vm->state.pgc->nr_of_programs; |
5
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
79 |
c1b55dc1bfed
Add API call to get number of programmes in current title.
richwareham
parents:
0
diff
changeset
|
80 return S_OK; |
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 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
83 dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int title) { |
0 | 84 int num_titles; |
85 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
86 if(!this) { |
0 | 87 return S_ERR; |
88 } | |
89 | |
90 /* Check number of titles */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
91 dvdnav_get_number_of_titles(this, &num_titles); |
0 | 92 if((title > num_titles) || (title <= 0)) { |
93 printerrf("Invalid title passed (%i, maximum %i)", title, | |
94 num_titles); | |
95 return S_ERR; | |
96 } | |
97 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
98 vm_start_title(this->vm, title); |
0 | 99 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
100 /* this->expecting_nav_packet = 1; */ |
0 | 101 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
102 dvdnav_do_post_jump(this); |
0 | 103 |
104 return S_OK; | |
105 } | |
106 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
107 dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int title, int part) { |
0 | 108 int num_titles, num_progs; |
109 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
110 if(!this) { |
0 | 111 return S_ERR; |
112 } | |
113 | |
114 /* Check number of titles */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
115 dvdnav_get_number_of_titles(this, &num_titles); |
0 | 116 if((title > num_titles) || (title <= 0)) { |
117 printerrf("Invalid title passed (%i, maximum %i)", title, | |
118 num_titles); | |
119 return S_ERR; | |
120 } | |
121 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
122 vm_start_title(this->vm, title); |
0 | 123 |
124 | |
125 /* Check number of parts */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
126 num_progs = this->vm->state.pgc->nr_of_programs; |
0 | 127 if((part > num_progs) || (part <= 0)) { |
128 printerrf("Invalid program passed (%i, maximum %i)", part, | |
129 num_progs); | |
130 return S_ERR; | |
131 } | |
132 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
133 vm_jump_prog(this->vm, part); |
0 | 134 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
135 /* this->expecting_nav_packet = 1; */ |
0 | 136 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
137 dvdnav_do_post_jump(this); |
0 | 138 |
139 return S_OK; | |
140 } | |
141 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
142 dvdnav_status_t dvdnav_part_play_auto_stop(dvdnav_t *this, int title, |
0 | 143 int part, int parts_to_play) { |
144 /* Perform jump as per usual */ | |
145 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
146 return dvdnav_part_play(this, title, part); |
0 | 147 |
148 /* FIXME: Impement auto-stop */ | |
149 | |
150 /* return S_OK;*/ | |
151 } | |
152 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
153 dvdnav_status_t dvdnav_time_play(dvdnav_t *this, int title, |
0 | 154 unsigned long int time) { |
155 /* FIXME: Implement */ | |
156 | |
157 return S_OK; | |
158 } | |
159 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
160 dvdnav_status_t dvdnav_stop(dvdnav_t *this) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
161 if(!this) |
0 | 162 return S_ERR; |
163 | |
164 /* Set the STOP flag */ | |
165 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
166 this->stop = 1; |
0 | 167 |
168 return S_OK; | |
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_go_up(dvdnav_t *this) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
172 if(!this) |
0 | 173 return S_ERR; |
174 | |
175 /* A nice easy function... delegate to the VM */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
176 vm_go_up(this->vm); |
0 | 177 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
5
diff
changeset
|
178 dvdnav_do_post_jump(this); |
0 | 179 |
180 return S_OK; | |
181 } | |
182 | |
183 | |
184 |