libvo: remove title argument from struct vo_driver.config
[mplayer.git] / libvo / video_out.h
blobe5d2f78c8a906f9f064a3e32170ea359018d970c
1 /*
2 * Copyright (C) Aaron Holtzman - Aug 1999
3 * Strongly modified, most parts rewritten: A'rpi/ESP-team - 2000-2001
4 * (C) MPlayer developers
6 * This file is part of MPlayer.
8 * MPlayer is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * MPlayer is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef MPLAYER_VIDEO_OUT_H
24 #define MPLAYER_VIDEO_OUT_H
26 #include <inttypes.h>
27 #include <stdbool.h>
29 #include "libmpcodecs/img_format.h"
30 #include "mpcommon.h"
32 #define VO_EVENT_EXPOSE 1
33 #define VO_EVENT_RESIZE 2
34 #define VO_EVENT_KEYPRESS 4
35 #define VO_EVENT_REINIT 8
36 #define VO_EVENT_MOVE 16
38 enum mp_voctrl {
39 /* does the device support the required format */
40 VOCTRL_QUERY_FORMAT = 1,
41 /* signal a device reset seek */
42 VOCTRL_RESET,
43 /* used to switch to fullscreen */
44 VOCTRL_FULLSCREEN,
45 /* signal a device pause */
46 VOCTRL_PAUSE,
47 /* start/resume playback */
48 VOCTRL_RESUME,
49 /* libmpcodecs direct rendering */
50 VOCTRL_GET_IMAGE,
51 VOCTRL_DRAW_IMAGE,
52 VOCTRL_SET_SPU_PALETTE,
53 VOCTRL_GET_PANSCAN,
54 VOCTRL_SET_PANSCAN,
55 VOCTRL_SET_EQUALIZER, // struct voctrl_set_equalizer_args
56 VOCTRL_GET_EQUALIZER, // struct voctrl_get_equalizer_args
57 VOCTRL_DUPLICATE_FRAME,
59 VOCTRL_START_SLICE,
61 // Vo can be used by xover
62 VOCTRL_XOVERLAY_SUPPORT,
63 VOCTRL_XOVERLAY_SET_COLORKEY, // mp_colorkey_t
64 VOCTRL_XOVERLAY_SET_WIN,
66 VOCTRL_REDRAW_OSD,
68 VOCTRL_ONTOP,
69 VOCTRL_ROOTWIN,
70 VOCTRL_BORDER,
71 VOCTRL_DRAW_EOSD,
72 VOCTRL_GET_EOSD_RES, // struct mp_eosd_res
74 VOCTRL_SET_DEINTERLACE,
75 VOCTRL_GET_DEINTERLACE,
77 VOCTRL_UPDATE_SCREENINFO,
79 VOCTRL_SET_YUV_COLORSPACE, // struct mp_csp_details
80 VOCTRL_GET_YUV_COLORSPACE, // struct mp_csp_details
82 VOCTRL_SCREENSHOT, // struct voctrl_screenshot_args
85 // VOCTRL_SET_EQUALIZER
86 struct voctrl_set_equalizer_args {
87 const char *name;
88 int value;
91 // VOCTRL_GET_EQUALIZER
92 struct voctrl_get_equalizer_args {
93 const char *name;
94 int *valueptr;
97 // VOCTRL_XOVERLAY_SET_COLORKEY
98 typedef struct {
99 uint32_t x11; // The raw x11 color
100 uint16_t r,g,b;
101 } mp_colorkey_t;
103 // VOCTRL_GET_EOSD_RES
104 typedef struct mp_eosd_res {
105 int w, h; // screen dimensions, including black borders
106 int mt, mb, ml, mr; // borders (top, bottom, left, right)
107 } mp_eosd_res_t;
109 // VOCTRL_SCREENSHOT
110 struct voctrl_screenshot_args {
111 // 0: Save image of the currently displayed video frame, in original
112 // resolution.
113 // 1: Save full screenshot of the window. Should contain OSD, EOSD, and the
114 // scaled video.
115 // The value of this variable can be ignored if only a single method is
116 // implemented.
117 int full_window;
118 // Will be set to a newly allocated image, that contains the screenshot.
119 // The caller has to free the pointer with free_mp_image().
120 // It is not specified whether the image data is a copy or references the
121 // image data directly.
122 // Is never NULL. (Failure has to be indicated by returning VO_FALSE.)
123 struct mp_image *out_image;
126 typedef struct {
127 int x,y;
128 int w,h;
129 } mp_win_t;
131 #define VO_TRUE 1
132 #define VO_FALSE 0
133 #define VO_ERROR -1
134 #define VO_NOTAVAIL -2
135 #define VO_NOTIMPL -3
137 #define VOFLAG_FULLSCREEN 0x01
138 #define VOFLAG_MODESWITCHING 0x02
139 #define VOFLAG_SWSCALE 0x04
140 #define VOFLAG_FLIPPING 0x08
141 #define VOFLAG_HIDDEN 0x10 //< Use to create a hidden window
142 #define VOFLAG_STEREO 0x20 //< Use to create a stereo-capable window
143 #define VOFLAG_XOVERLAY_SUB_VO 0x10000
145 typedef struct vo_info_s
147 /* driver name ("Matrox Millennium G200/G400" */
148 const char *name;
149 /* short name (for config strings) ("mga") */
150 const char *short_name;
151 /* author ("Aaron Holtzman <aholtzma@ess.engr.uvic.ca>") */
152 const char *author;
153 /* any additional comments */
154 const char *comment;
155 } vo_info_t;
157 struct vo;
158 struct osd_state;
159 struct mp_image;
161 struct vo_driver {
162 // Driver uses new API
163 bool is_new;
164 // Driver buffers or adds (deinterlace) frames and will keep track
165 // of pts values itself
166 bool buffer_frames;
168 // This is set if the driver is not new and contains pointers to
169 // old-API functions to be used instead of the ones below.
170 struct vo_old_functions *old_functions;
172 const vo_info_t *info;
174 * Preinitializes driver (real INITIALIZATION)
175 * arg - currently it's vo_subdevice
176 * returns: zero on successful initialization, non-zero on error.
178 int (*preinit)(struct vo *vo, const char *arg);
180 * Initialize (means CONFIGURE) the display driver.
181 * params:
182 * width,height: image source size
183 * d_width,d_height: size of the requested window size, just a hint
184 * fullscreen: flag, 0=windowd 1=fullscreen, just a hint
185 * title: window title, if available
186 * format: fourcc of pixel format
187 * returns : zero on successful initialization, non-zero on error.
189 int (*config)(struct vo *vo, uint32_t width, uint32_t height,
190 uint32_t d_width, uint32_t d_height, uint32_t fullscreen,
191 uint32_t format);
194 * Control interface
196 int (*control)(struct vo *vo, uint32_t request, void *data);
198 void (*draw_image)(struct vo *vo, struct mp_image *mpi, double pts);
201 * Get extra frames from the VO, such as those added by VDPAU
202 * deinterlace. Preparing the next such frame if any could be done
203 * automatically by the VO after a previous flip_page(), but having
204 * it as a separate step seems to allow making code more robust.
206 void (*get_buffered_frame)(struct vo *vo, bool eof);
209 * Draw a planar YUV slice to the buffer:
210 * params:
211 * src[3] = source image planes (Y,U,V)
212 * stride[3] = source image planes line widths (in bytes)
213 * w,h = width*height of area to be copied (in Y pixels)
214 * x,y = position at the destination image (in Y pixels)
216 int (*draw_slice)(struct vo *vo, uint8_t *src[], int stride[], int w,
217 int h, int x, int y);
220 * Draws OSD to the screen buffer
222 void (*draw_osd)(struct vo *vo, struct osd_state *osd);
225 * Blit/Flip buffer to the screen. Must be called after each frame!
227 void (*flip_page)(struct vo *vo);
228 void (*flip_page_timed)(struct vo *vo, unsigned int pts_us, int duration);
231 * This func is called after every frames to handle keyboard and
232 * other events. It's called in PAUSE mode too!
234 void (*check_events)(struct vo *vo);
237 * Closes driver. Should restore the original state of the system.
239 void (*uninit)(struct vo *vo);
242 struct vo_old_functions {
243 int (*preinit)(const char *arg);
244 int (*config)(uint32_t width, uint32_t height, uint32_t d_width,
245 uint32_t d_height, uint32_t fullscreen, char *title,
246 uint32_t format);
247 int (*control)(uint32_t request, void *data);
248 int (*draw_frame)(uint8_t *src[]);
249 int (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
250 void (*draw_osd)(void);
251 void (*flip_page)(void);
252 void (*check_events)(void);
253 void (*uninit)(void);
256 struct vo {
257 int config_ok; // Last config call was successful?
258 int config_count; // Total number of successful config calls
260 bool frame_loaded; // Is there a next frame the VO could flip to?
261 double next_pts; // pts value of the next frame if any
262 double next_pts2; // optional pts of frame after that
264 double flip_queue_offset; // queue flip events at most this much in advance
266 const struct vo_driver *driver;
267 void *priv;
268 struct MPOpts *opts;
269 struct vo_x11_state *x11;
270 struct mp_fifo *key_fifo;
271 struct input_ctx *input_ctx;
272 int event_fd; // check_events() should be called when this has input
273 int registered_fd; // set to event_fd when registered in input system
275 // requested position/resolution
276 int dx;
277 int dy;
278 int dwidth;
279 int dheight;
281 int panscan_x;
282 int panscan_y;
283 float panscan_amount;
284 float monitor_aspect;
285 struct aspect_data {
286 int orgw; // real width
287 int orgh; // real height
288 int prew; // prescaled width
289 int preh; // prescaled height
290 int scrw; // horizontal resolution
291 int scrh; // vertical resolution
292 float asp;
293 } aspdat;
296 struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
297 struct mp_fifo *key_fifo,
298 struct input_ctx *input_ctx);
299 int vo_config(struct vo *vo, uint32_t width, uint32_t height,
300 uint32_t d_width, uint32_t d_height, uint32_t flags,
301 uint32_t format);
302 void list_video_out(void);
304 int vo_control(struct vo *vo, uint32_t request, void *data);
305 int vo_draw_image(struct vo *vo, struct mp_image *mpi, double pts);
306 int vo_get_buffered_frame(struct vo *vo, bool eof);
307 void vo_skip_frame(struct vo *vo);
308 int vo_draw_frame(struct vo *vo, uint8_t *src[]);
309 int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y);
310 void vo_draw_osd(struct vo *vo, struct osd_state *osd);
311 void vo_flip_page(struct vo *vo, unsigned int pts_us, int duration);
312 void vo_check_events(struct vo *vo);
313 void vo_seek_reset(struct vo *vo);
314 void vo_destroy(struct vo *vo);
316 const char *vo_get_window_title(struct vo *vo);
318 // NULL terminated array of all drivers
319 extern const struct vo_driver *video_out_drivers[];
321 extern int xinerama_screen;
322 extern int xinerama_x;
323 extern int xinerama_y;
325 extern int vo_grabpointer;
326 extern int vo_doublebuffering;
327 extern int vo_directrendering;
328 extern int vo_vsync;
329 extern int vo_fs;
330 extern int vo_fsmode;
331 extern float vo_panscan;
332 extern int vo_adapter_num;
333 extern int vo_refresh_rate;
334 extern int vo_keepaspect;
335 extern int vo_rootwin;
336 extern int vo_border;
338 extern int vo_nomouse_input;
339 extern int enable_mouse_movements;
341 extern int vo_pts;
342 extern float vo_fps;
344 extern char *vo_subdevice;
346 extern int vo_colorkey;
348 extern int64_t WinID;
350 typedef struct {
351 float min;
352 float max;
353 } range_t;
355 float range_max(range_t *r);
356 int in_range(range_t *r, float f);
357 range_t *str2range(char *s);
358 extern char *monitor_hfreq_str;
359 extern char *monitor_vfreq_str;
360 extern char *monitor_dotclock_str;
362 struct mp_keymap {
363 int from;
364 int to;
366 int lookup_keymap_table(const struct mp_keymap *map, int key);
367 struct vo_rect {
368 int left, right, top, bottom, width, height;
370 void calc_src_dst_rects(struct vo *vo, int src_width, int src_height,
371 struct vo_rect *src, struct vo_rect *dst,
372 struct vo_rect *borders, const struct vo_rect *crop);
373 struct input_ctx;
374 void vo_mouse_movement(struct vo *vo, int posx, int posy);
376 static inline int aspect_scaling(void)
378 return vo_keepaspect || vo_fs;
381 #endif /* MPLAYER_VIDEO_OUT_H */