1 | /* |
---|
2 | * DreamDVD V0.9 - DVD-Player for Dreambox |
---|
3 | * Copyright (C) 2007 by Seddi |
---|
4 | * |
---|
5 | * This DVD Player is based upon the great work from the libdvdnav project, |
---|
6 | * a52dec library, ffmpeg and the knowledge from all the people who made |
---|
7 | * watching DVD within linux possible. |
---|
8 | * |
---|
9 | * DreamDVD is free software; you can redistribute it and/or modify |
---|
10 | * it under the terms of the GNU General Public License as published by |
---|
11 | * the Free Software Foundation; either version 2 of the License, or |
---|
12 | * (at your option) any later version. |
---|
13 | * |
---|
14 | * DreamDVD is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
---|
22 | * |
---|
23 | * part of libdreamdvd |
---|
24 | */ |
---|
25 | |
---|
26 | |
---|
27 | /* |
---|
28 | * main struct for ddvd handle |
---|
29 | */ |
---|
30 | struct ddvd; |
---|
31 | |
---|
32 | struct ddvd_resume { |
---|
33 | int title; |
---|
34 | int chapter; |
---|
35 | unsigned long int block; |
---|
36 | int audio_id; |
---|
37 | int audio_lock; |
---|
38 | int spu_id; |
---|
39 | int spu_lock; |
---|
40 | }; |
---|
41 | |
---|
42 | enum ddvd_result { |
---|
43 | DDVD_OK = 0, |
---|
44 | DDVD_INVAL, |
---|
45 | DDVD_NOMEM, |
---|
46 | DDVD_BUSY, |
---|
47 | DDVD_FAIL_OPEN, |
---|
48 | DDVD_FAIL_PREFS, |
---|
49 | DDVD_FAIL_READ, |
---|
50 | DDVD_RESULT_MAX, |
---|
51 | }; |
---|
52 | |
---|
53 | /* |
---|
54 | * functions for initialization and setting options DONT USE THIS FUNCTIONS AFTER STARTING WITH ddvd_run !!! |
---|
55 | */ |
---|
56 | |
---|
57 | // create a ddvd handle with default options PAL, 4:3 LB, EN, AC3 decoding internal (if liba52 is available) |
---|
58 | struct ddvd *ddvd_create(void); |
---|
59 | |
---|
60 | // get message_pipe fd to make polling possible |
---|
61 | int ddvd_get_messagepipe_fd(struct ddvd *pconfig); |
---|
62 | |
---|
63 | // set framebuffer and options libdreamdvd should render buttons and subtitles |
---|
64 | // until this option ist set, ddvd_run will not start playing |
---|
65 | // lfb-> needs a pointer to the real framebuffer or to a backbuffer |
---|
66 | // xres, yres-> screen resolution, normally 720x576 libdreamdvd will scale inside to the given resolution |
---|
67 | // bypp-> bytes per pixel, only 1 (8bit) or 4 (32bit argb) is supported |
---|
68 | // stride-> line length in bytes, normally xres*bypp but not always like on the DM7025 framebuffer |
---|
69 | // canscale-> caller supports ddvd_get_blit_destination |
---|
70 | void ddvd_set_lfb(struct ddvd *pconfig, unsigned char *lfb, int xres, int yres, int bypp, int stride); |
---|
71 | void ddvd_set_lfb_ex(struct ddvd *pconfig, unsigned char *lfb, int xres, int yres, int bypp, int stride, int canscale); |
---|
72 | |
---|
73 | // set path to a dvd block device, a dvd file structure or an dvd iso-file ("/dev/dvd" ...) |
---|
74 | void ddvd_set_dvd_path(struct ddvd *pconfig, const char *path); |
---|
75 | |
---|
76 | // set preferred dvd language in 2 letter iso code (en,de, ...) |
---|
77 | void ddvd_set_language(struct ddvd *pconfig, const char lang[2]); |
---|
78 | |
---|
79 | // set external/internal AC3 decoding 0-> external 1-> internal |
---|
80 | // internal decoding needs liba52 which will be loaded dynamically if available |
---|
81 | // if set to "internal" and liba52 will not be found, the AC3 data will be passed thru |
---|
82 | void ddvd_set_ac3thru(struct ddvd *pconfig, int ac3thru); |
---|
83 | |
---|
84 | // set video options for aspect and the tv system, see enums for possible options |
---|
85 | void ddvd_set_video(struct ddvd *pconfig, int aspect, int tv_mode, int tv_system); |
---|
86 | void ddvd_set_video_ex(struct ddvd *pconfig, int aspect, int tv_mode, int tv_mode2, int tv_system); |
---|
87 | |
---|
88 | // set resume postion for dvd start |
---|
89 | void ddvd_set_resume_pos(struct ddvd *pconfig, struct ddvd_resume resume_info); |
---|
90 | |
---|
91 | // directly set given audio stream id (alternative to iteration through the streams with the DDVD_KEY_AUDIO) |
---|
92 | void ddvd_set_audio(struct ddvd *pconfig, int audio_id); |
---|
93 | |
---|
94 | // directly set given subtitle stream id (alternative to iteration through the streams with the DDVD_KEY_SUBTITLE) |
---|
95 | void ddvd_set_spu(struct ddvd *pconfig, int spu_id); |
---|
96 | |
---|
97 | /* |
---|
98 | * functions for starting the dvd player |
---|
99 | */ |
---|
100 | |
---|
101 | // starting playback, this function should be started inside a thread, because it only comes back after |
---|
102 | // stopping the dvd player |
---|
103 | enum ddvd_result ddvd_run(struct ddvd *pconfig); |
---|
104 | |
---|
105 | |
---|
106 | /* |
---|
107 | * functions for controlling the player while running, these functions are THREAD SAFE (or lets say I hope so ;-) |
---|
108 | */ |
---|
109 | |
---|
110 | // send a remote control key or command to the player, see send_key enum for possible commands |
---|
111 | void ddvd_send_key(struct ddvd *pconfig, int key); |
---|
112 | |
---|
113 | // skip n seconds in playing n>0 forward - n<0 backward |
---|
114 | void ddvd_skip_seconds(struct ddvd *pconfig, int seconds); |
---|
115 | |
---|
116 | // jump to beginning of given title |
---|
117 | void ddvd_set_title(struct ddvd *pconfig, int title); |
---|
118 | |
---|
119 | // jump to beginning of given chapter |
---|
120 | void ddvd_set_chapter(struct ddvd *pconfig, int chapter); |
---|
121 | |
---|
122 | // get and process the next message from the main player |
---|
123 | // use blocked=1 if the function should wait till a message has received, blocked=0 will return |
---|
124 | // immediatly and give you DDVD_NULL if there was no messag in the pipe |
---|
125 | // blocked=0 will be usefull if the main programm runs a loop, blocked=1 if you use fd-polling |
---|
126 | int ddvd_get_next_message(struct ddvd*pconfig, int blocked); |
---|
127 | |
---|
128 | // get last colortable for 8bit mode (4 colors) |
---|
129 | // will give you 4 color structs as array, remember to use the offset (see state enum) |
---|
130 | // struct ddvd_color colortable[4] |
---|
131 | void ddvd_get_last_colortable(struct ddvd*pconfig, void *colortable); |
---|
132 | |
---|
133 | // get last area to update overlay after DDVD_SCREEN_UPDATE |
---|
134 | void ddvd_get_last_blit_area(struct ddvd *pconfig, int *x_start, int *x_end, int *y_start, int *y_end); |
---|
135 | |
---|
136 | #define DDVD_SUPPORTS_16_10_SCALING 1 |
---|
137 | #define DDVD_SUPPORTS_GET_BLIT_DESTINATION 1 |
---|
138 | // get parameters used for blit |
---|
139 | void ddvd_get_blit_destination(struct ddvd *pconfig, int *x_offset, int *y_offset, int *width, int *height); |
---|
140 | |
---|
141 | // get last received playing time |
---|
142 | // struct ddvd_time timestamp |
---|
143 | void ddvd_get_last_time(struct ddvd*pconfig, void *timestamp); |
---|
144 | |
---|
145 | // get actual angle info after DDVD_SHOWOSD_ANGLE |
---|
146 | void ddvd_get_angle_info(struct ddvd*pconfig, int *current, int *num); |
---|
147 | |
---|
148 | // get the actual trickspeed (2-64x) when in trickmode |
---|
149 | // int trickspeed |
---|
150 | void ddvd_get_last_trickspeed(struct ddvd*pconfig, void *trickspeed); |
---|
151 | |
---|
152 | // get last text message from player |
---|
153 | // char text[512] |
---|
154 | void ddvd_get_last_string(struct ddvd*pconfig, void *text); |
---|
155 | |
---|
156 | // get the active audio track |
---|
157 | // int id -> logical track number |
---|
158 | // uint16_t lang -> audio language in 2 letter iso code |
---|
159 | // int type -> audio type, see audio type enum (ac3,mpeg,...) |
---|
160 | void ddvd_get_last_audio(struct ddvd*pconfig, void *id, void *lang, void *type); |
---|
161 | |
---|
162 | // get audio track details for given audio track id |
---|
163 | void ddvd_get_audio_byid(struct ddvd *pconfig, int audio_id, void *lang, void *type); |
---|
164 | |
---|
165 | // get the number of available audio tracks |
---|
166 | void ddvd_get_audio_count(struct ddvd *pconfig, void *count); |
---|
167 | |
---|
168 | // get the active subtitle track |
---|
169 | // int id -> logical track number |
---|
170 | // uint16_t lang -> subtitle language in 2 letter iso code |
---|
171 | // id=-1 means no subtitle track active |
---|
172 | void ddvd_get_last_spu(struct ddvd*pconfig, void *id, void *lang); |
---|
173 | |
---|
174 | // get track details for given subtitle track id |
---|
175 | void ddvd_get_spu_byid(struct ddvd *pconfig, int spu_id, void *lang); |
---|
176 | |
---|
177 | // get the number of available subtitle tracks |
---|
178 | void ddvd_get_spu_count(struct ddvd *pconfig, void *count); |
---|
179 | |
---|
180 | // get dvd title string |
---|
181 | void ddvd_get_title_string(struct ddvd*pconfig, char *title_string); |
---|
182 | |
---|
183 | // get last received position for resume |
---|
184 | void ddvd_get_resume_pos(struct ddvd *pconfig, struct ddvd_resume *resume_info); |
---|
185 | |
---|
186 | #define DDVD_SUPPORTS_PICTURE_INFO 1 |
---|
187 | void ddvd_get_last_size(struct ddvd *pconfig, int *width, int *height, int *aspect); |
---|
188 | void ddvd_get_last_framerate(struct ddvd *pconfig, int *frate); |
---|
189 | void ddvd_get_last_progressive(struct ddvd *pconfig, int *progressive); |
---|
190 | |
---|
191 | /* |
---|
192 | * functions for clean up AFTER the player had stopped |
---|
193 | */ |
---|
194 | |
---|
195 | // destroy ddvd handle, do NOT call this while the player is still running |
---|
196 | // to stop the player you can send the DDVD_KEY_EXIT command via ddvd_send_key |
---|
197 | void ddvd_close(struct ddvd *pconfig); |
---|
198 | |
---|
199 | // returns the dvd aspect |
---|
200 | // needed for titan |
---|
201 | #if defined(__sh__) |
---|
202 | int ddvd_get_dvd_aspect(); |
---|
203 | #endif |
---|
204 | |
---|
205 | /* |
---|
206 | * messages recieved from ddvd_get_next_message |
---|
207 | */ |
---|
208 | |
---|
209 | enum { // state |
---|
210 | DDVD_NULL, // nothing to do |
---|
211 | DDVD_COLORTABLE_UPDATE, // if we are in 8bit graphics mode we have to renew the color table, the color table can be grabbed with |
---|
212 | // ddvd_get_last_colortable function, we need an offset of 252d, means the first struct in the array should be set to 252d in |
---|
213 | // the real colortable, the second struct to 253d and so on, this message will never been send in 32bit mode |
---|
214 | // ATTENTION to clear screen, libdreamdvd uses color 0, so be sure to set color 0 in the host-application to full transparency |
---|
215 | DDVD_SCREEN_UPDATE, // libdreamdvd rendered something to the given framebuffer, so if we are working with a backbuffer in the host app, |
---|
216 | // we have to update our screen. can be ignored if libdreamdvd renders directly to the real framebuffer |
---|
217 | // the rect that have to be updated can be fetched with ddvd_get_last_blit_area |
---|
218 | DDVD_SHOWOSD_STATE_PLAY, // we should display a state icon or text (play, pause, ...) on osd |
---|
219 | DDVD_SHOWOSD_STATE_PAUSE, |
---|
220 | DDVD_SHOWOSD_TIME, // we should display the playing time on osd you can get the time with ddvd_get_last_time |
---|
221 | DDVD_SHOWOSD_STATE_FFWD, // we should display FFWD/FBWD trickmode on osd you can grab the actual time with ddvd_get_last_time |
---|
222 | DDVD_SHOWOSD_STATE_FBWD, // and the trickspeed with ddvd_get_last_trickspeed |
---|
223 | DDVD_SHOWOSD_STRING, // we should display a text on osd (errors, ...) the text can be read with ddvd_get_last_string |
---|
224 | DDVD_SHOWOSD_AUDIO, // new audio track selected you can get the audio id, language, type with ddvd_get_last_audio |
---|
225 | DDVD_SHOWOSD_SUBTITLE, // new subtitle track selected you can get the spu id, language with ddvd_get_last_spu |
---|
226 | DDVD_SHOWOSD_TITLESTRING, |
---|
227 | DDVD_EOF_REACHED, |
---|
228 | DDVD_SOF_REACHED, |
---|
229 | DDVD_MENU_OPENED, |
---|
230 | DDVD_MENU_CLOSED, |
---|
231 | DDVD_SHOWOSD_ANGLE, // show angle info, you can get it with ddvd_get_angle_info |
---|
232 | DDVD_SIZE_CHANGED, |
---|
233 | DDVD_PROGRESSIVE_CHANGED, |
---|
234 | DDVD_FRAMERATE_CHANGED, |
---|
235 | }; |
---|
236 | |
---|
237 | |
---|
238 | /* |
---|
239 | * key/commands to send with ddvd_send_key |
---|
240 | */ |
---|
241 | |
---|
242 | enum { // send_key |
---|
243 | DDVD_KEY_NULL, // will be ignored |
---|
244 | DDVD_KEY_EXIT, // stop end exit the player as fast as possible |
---|
245 | |
---|
246 | /* menus*/ |
---|
247 | DDVD_KEY_LEFT, // cursor control |
---|
248 | DDVD_KEY_RIGHT, |
---|
249 | DDVD_KEY_UP, |
---|
250 | DDVD_KEY_DOWN, |
---|
251 | DDVD_KEY_OK, // activate button |
---|
252 | |
---|
253 | /* inside movie */ |
---|
254 | DDVD_KEY_PLAY, // resume playing if we are "paused" or used any ffwd/fbwd before |
---|
255 | DDVD_KEY_PAUSE, // pause playing (still picture) |
---|
256 | DDVD_KEY_NEXT_CHAPTER, // jump to next chapter |
---|
257 | DDVD_KEY_PREV_CHAPTER, // jump to previous chapter |
---|
258 | DDVD_KEY_NEXT_TITLE, // jump to next title |
---|
259 | DDVD_KEY_PREV_TITLE, // jump to previous title |
---|
260 | DDVD_KEY_FFWD, // start or speed up fast forward mode |
---|
261 | DDVD_KEY_FBWD, // start or speed up fast backward mode |
---|
262 | DDVD_KEY_MENU, // jump into the dvd menu |
---|
263 | DDVD_KEY_AUDIOMENU, // jump into the dvd audio menu |
---|
264 | DDVD_KEY_AUDIO, // change audio track on the fly |
---|
265 | DDVD_KEY_SUBTITLE, // change subtitle track on the fly |
---|
266 | DDVD_GET_TIME, // get actual playing time (see struct ddvd_time) |
---|
267 | DDVD_SKIP_FWD, // jump forward in playing SHOULD NOT BE USED DIRECTLY, USE ddvd_skip_seconds FOR SKIPPING |
---|
268 | DDVD_SKIP_BWD, // jump backward in playing SHOULD NOT BE USED DIRECTLY, USE ddvd_skip_seconds FOR SKIPPING |
---|
269 | DDVD_SET_TITLE, // jump to given title |
---|
270 | DDVD_SET_CHAPTER, // jump to given chapter |
---|
271 | DDVD_SEEK_ABS, // seek to given absolute seconds (from beginning of current title) |
---|
272 | DDVD_SET_MUTE, // just telling dreamdvd that the sound has been muted, libdreamdvd does not mute for you, but has to know |
---|
273 | // the mute state for sound handling on ffwd/fbwd trick mode |
---|
274 | DDVD_UNSET_MUTE, // sound is not muted any more (see DDVD_SET_MUTE) |
---|
275 | DDVD_KEY_ANGLE, // change angle on the fly |
---|
276 | DDVD_GET_ANGLE, // get actual angle info |
---|
277 | DDVD_SET_AUDIO, // set given audio track id |
---|
278 | DDVD_SET_SUBTITLE, // set given subtitle track id |
---|
279 | }; |
---|
280 | |
---|
281 | // if you use the same keys for different functions in different contexts (menu/movie) just send both commands, the player will |
---|
282 | // choose the right one and ignore the other. For example you want to use the right cursor key for "right" in menu and "next chapter" in movie, |
---|
283 | // so you have to send both when you received the key event for your "right cursor key": DDVD_KEY_RIGHT and DDVD_KEY_NEXT_CHAPTER |
---|
284 | |
---|
285 | |
---|
286 | /* |
---|
287 | * config and state enums |
---|
288 | */ |
---|
289 | |
---|
290 | enum { // audio types |
---|
291 | DDVD_UNKNOWN, |
---|
292 | DDVD_AC3, |
---|
293 | DDVD_MPEG, |
---|
294 | DDVD_DTS, |
---|
295 | DDVD_LPCM, |
---|
296 | }; |
---|
297 | |
---|
298 | enum { // tv system |
---|
299 | DDVD_PAL, |
---|
300 | DDVD_NTSC, |
---|
301 | }; |
---|
302 | |
---|
303 | enum { // aspect |
---|
304 | DDVD_4_3, |
---|
305 | DDVD_16_9, |
---|
306 | DDVD_16_10, |
---|
307 | }; |
---|
308 | |
---|
309 | enum { // tv mode |
---|
310 | DDVD_LETTERBOX, |
---|
311 | DDVD_PAN_SCAN, |
---|
312 | DDVD_JUSTSCALE, |
---|
313 | }; |
---|
314 | |
---|
315 | |
---|
316 | /* |
---|
317 | * structs for color palette and osd time and resume info |
---|
318 | */ |
---|
319 | |
---|
320 | struct ddvd_color { |
---|
321 | unsigned short red; |
---|
322 | unsigned short green; |
---|
323 | unsigned short blue; |
---|
324 | unsigned short trans; |
---|
325 | }; |
---|
326 | |
---|
327 | struct ddvd_time { |
---|
328 | int pos_hours; // pos_hours:pos_minutes:pos_seconds -> time already played |
---|
329 | int pos_minutes; // end_hours:end_minutes:end_seconds -> total time of the playing programm |
---|
330 | int pos_seconds; // pos_chapter -> chapter no. we are just playing |
---|
331 | int pos_chapter; // end_chapter -> total chapters of the playing programm |
---|
332 | int pos_title; |
---|
333 | int end_hours; |
---|
334 | int end_minutes; |
---|
335 | int end_seconds; |
---|
336 | int end_chapter; |
---|
337 | int end_title; |
---|
338 | }; |
---|