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 */
|
|
36 void dvdnav_do_post_jump(dvdnav_t *self) {
|
|
37 dvd_state_t *state = &(self->vm->state);
|
|
38 cell_playback_t *cell = &(state->pgc->cell_playback[state->cellN - 1]);
|
|
39
|
|
40 self->jmp_blockN = 0; /* FIXME: Should this be different? */
|
|
41 self->jmp_vobu_start = cell->first_sector;
|
|
42 self->jumping = 1;
|
|
43 self->still_frame = -1;
|
|
44 }
|
|
45
|
|
46 dvdnav_status_t dvdnav_still_skip(dvdnav_t *self) {
|
|
47 if(!self)
|
|
48 return S_ERR;
|
|
49
|
|
50 self->still_frame = -1;
|
|
51
|
|
52 return S_OK;
|
|
53 }
|
|
54
|
|
55 dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *self, int *titles) {
|
|
56 if(!self)
|
|
57 return S_ERR;
|
|
58
|
|
59 if(!titles) {
|
|
60 printerr("Passed a NULL pointer");
|
|
61 return S_ERR;
|
|
62 }
|
|
63
|
|
64 (*titles) = vm_get_vmgi(self->vm)->tt_srpt->nr_of_srpts;
|
|
65
|
|
66 return S_OK;
|
|
67 }
|
|
68
|
|
69 dvdnav_status_t dvdnav_title_play(dvdnav_t *self, int title) {
|
|
70 int num_titles;
|
|
71
|
|
72 if(!self) {
|
|
73 return S_ERR;
|
|
74 }
|
|
75
|
|
76 /* Check number of titles */
|
|
77 dvdnav_get_number_of_titles(self, &num_titles);
|
|
78 if((title > num_titles) || (title <= 0)) {
|
|
79 printerrf("Invalid title passed (%i, maximum %i)", title,
|
|
80 num_titles);
|
|
81 return S_ERR;
|
|
82 }
|
|
83
|
|
84 vm_start_title(self->vm, title);
|
|
85
|
|
86 /* self->expecting_nav_packet = 1; */
|
|
87
|
|
88 dvdnav_do_post_jump(self);
|
|
89
|
|
90 return S_OK;
|
|
91 }
|
|
92
|
|
93 dvdnav_status_t dvdnav_part_play(dvdnav_t *self, int title, int part) {
|
|
94 int num_titles, num_progs;
|
|
95
|
|
96 if(!self) {
|
|
97 return S_ERR;
|
|
98 }
|
|
99
|
|
100 /* Check number of titles */
|
|
101 dvdnav_get_number_of_titles(self, &num_titles);
|
|
102 if((title > num_titles) || (title <= 0)) {
|
|
103 printerrf("Invalid title passed (%i, maximum %i)", title,
|
|
104 num_titles);
|
|
105 return S_ERR;
|
|
106 }
|
|
107
|
|
108 vm_start_title(self->vm, title);
|
|
109
|
|
110
|
|
111 /* Check number of parts */
|
|
112 num_progs = self->vm->state.pgc->nr_of_programs;
|
|
113 if((part > num_progs) || (part <= 0)) {
|
|
114 printerrf("Invalid program passed (%i, maximum %i)", part,
|
|
115 num_progs);
|
|
116 return S_ERR;
|
|
117 }
|
|
118
|
|
119 vm_jump_prog(self->vm, part);
|
|
120
|
|
121 /* self->expecting_nav_packet = 1; */
|
|
122
|
|
123 dvdnav_do_post_jump(self);
|
|
124
|
|
125 return S_OK;
|
|
126 }
|
|
127
|
|
128 dvdnav_status_t dvdnav_part_play_auto_stop(dvdnav_t *self, int title,
|
|
129 int part, int parts_to_play) {
|
|
130 /* Perform jump as per usual */
|
|
131
|
|
132 return dvdnav_part_play(self, title, part);
|
|
133
|
|
134 /* FIXME: Impement auto-stop */
|
|
135
|
|
136 /* return S_OK;*/
|
|
137 }
|
|
138
|
|
139 dvdnav_status_t dvdnav_time_play(dvdnav_t *self, int title,
|
|
140 unsigned long int time) {
|
|
141 /* FIXME: Implement */
|
|
142
|
|
143 return S_OK;
|
|
144 }
|
|
145
|
|
146 dvdnav_status_t dvdnav_stop(dvdnav_t *self) {
|
|
147 if(!self)
|
|
148 return S_ERR;
|
|
149
|
|
150 /* Set the STOP flag */
|
|
151
|
|
152 self->stop = 1;
|
|
153
|
|
154 return S_OK;
|
|
155 }
|
|
156
|
|
157 dvdnav_status_t dvdnav_go_up(dvdnav_t *self) {
|
|
158 if(!self)
|
|
159 return S_ERR;
|
|
160
|
|
161 /* A nice easy function... delegate to the VM */
|
|
162 vm_go_up(self->vm);
|
|
163
|
|
164 dvdnav_do_post_jump(self);
|
|
165
|
|
166 return S_OK;
|
|
167 }
|
|
168
|
|
169
|
|
170
|