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
29 #include "libmpcodecs/img_format.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
39 /* does the device support the required format */
40 VOCTRL_QUERY_FORMAT
= 1,
41 /* signal a device reset seek */
43 /* used to switch to fullscreen */
45 /* signal a device pause */
47 /* start/resume playback */
49 /* libmpcodecs direct rendering */
52 VOCTRL_SET_SPU_PALETTE
,
55 VOCTRL_SET_EQUALIZER
, // struct voctrl_set_equalizer_args
56 VOCTRL_GET_EQUALIZER
, // struct voctrl_get_equalizer_args
57 VOCTRL_DUPLICATE_FRAME
,
61 // Vo can be used by xover
62 VOCTRL_XOVERLAY_SUPPORT
,
63 VOCTRL_XOVERLAY_SET_COLORKEY
, // mp_colorkey_t
64 VOCTRL_XOVERLAY_SET_WIN
,
74 VOCTRL_GET_EOSD_RES
, // struct mp_eosd_res
76 VOCTRL_SET_DEINTERLACE
,
77 VOCTRL_GET_DEINTERLACE
,
79 VOCTRL_UPDATE_SCREENINFO
,
81 VOCTRL_SET_YUV_COLORSPACE
, // struct mp_csp_details
82 VOCTRL_GET_YUV_COLORSPACE
, // struct mp_csp_details
84 VOCTRL_SCREENSHOT
, // struct voctrl_screenshot_args
87 // VOCTRL_SET_EQUALIZER
88 struct voctrl_set_equalizer_args
{
93 // VOCTRL_GET_EQUALIZER
94 struct voctrl_get_equalizer_args
{
99 // VOCTRL_XOVERLAY_SET_COLORKEY
101 uint32_t x11
; // The raw x11 color
105 // VOCTRL_GET_EOSD_RES
106 typedef struct mp_eosd_res
{
107 int w
, h
; // screen dimensions, including black borders
108 int mt
, mb
, ml
, mr
; // borders (top, bottom, left, right)
112 struct voctrl_screenshot_args
{
113 // 0: Save image of the currently displayed video frame, in original
115 // 1: Save full screenshot of the window. Should contain OSD, EOSD, and the
117 // The value of this variable can be ignored if only a single method is
120 // Will be set to a newly allocated image, that contains the screenshot.
121 // The caller has to free the pointer with free_mp_image().
122 // It is not specified whether the image data is a copy or references the
123 // image data directly.
124 // Is never NULL. (Failure has to be indicated by returning VO_FALSE.)
125 struct mp_image
*out_image
;
136 #define VO_NOTAVAIL -2
137 #define VO_NOTIMPL -3
139 #define VOFLAG_FULLSCREEN 0x01
140 #define VOFLAG_MODESWITCHING 0x02
141 #define VOFLAG_SWSCALE 0x04
142 #define VOFLAG_FLIPPING 0x08
143 #define VOFLAG_HIDDEN 0x10 //< Use to create a hidden window
144 #define VOFLAG_STEREO 0x20 //< Use to create a stereo-capable window
145 #define VOFLAG_XOVERLAY_SUB_VO 0x10000
147 typedef struct vo_info_s
149 /* driver name ("Matrox Millennium G200/G400" */
151 /* short name (for config strings) ("mga") */
152 const char *short_name
;
153 /* author ("Aaron Holtzman <aholtzma@ess.engr.uvic.ca>") */
155 /* any additional comments */
164 // Driver uses new API
166 // Driver buffers or adds (deinterlace) frames and will keep track
167 // of pts values itself
170 // This is set if the driver is not new and contains pointers to
171 // old-API functions to be used instead of the ones below.
172 struct vo_old_functions
*old_functions
;
174 const vo_info_t
*info
;
176 * Preinitializes driver (real INITIALIZATION)
177 * arg - currently it's vo_subdevice
178 * returns: zero on successful initialization, non-zero on error.
180 int (*preinit
)(struct vo
*vo
, const char *arg
);
182 * Initialize (means CONFIGURE) the display driver.
184 * width,height: image source size
185 * d_width,d_height: size of the requested window size, just a hint
186 * fullscreen: flag, 0=windowd 1=fullscreen, just a hint
187 * title: window title, if available
188 * format: fourcc of pixel format
189 * returns : zero on successful initialization, non-zero on error.
191 int (*config
)(struct vo
*vo
, uint32_t width
, uint32_t height
,
192 uint32_t d_width
, uint32_t d_height
, uint32_t fullscreen
,
198 int (*control
)(struct vo
*vo
, uint32_t request
, void *data
);
200 void (*draw_image
)(struct vo
*vo
, struct mp_image
*mpi
, double pts
);
203 * Get extra frames from the VO, such as those added by VDPAU
204 * deinterlace. Preparing the next such frame if any could be done
205 * automatically by the VO after a previous flip_page(), but having
206 * it as a separate step seems to allow making code more robust.
208 void (*get_buffered_frame
)(struct vo
*vo
, bool eof
);
211 * Draw a planar YUV slice to the buffer:
213 * src[3] = source image planes (Y,U,V)
214 * stride[3] = source image planes line widths (in bytes)
215 * w,h = width*height of area to be copied (in Y pixels)
216 * x,y = position at the destination image (in Y pixels)
218 int (*draw_slice
)(struct vo
*vo
, uint8_t *src
[], int stride
[], int w
,
219 int h
, int x
, int y
);
222 * Draws OSD to the screen buffer
224 void (*draw_osd
)(struct vo
*vo
, struct osd_state
*osd
);
227 * Blit/Flip buffer to the screen. Must be called after each frame!
229 void (*flip_page
)(struct vo
*vo
);
230 void (*flip_page_timed
)(struct vo
*vo
, unsigned int pts_us
, int duration
);
233 * This func is called after every frames to handle keyboard and
234 * other events. It's called in PAUSE mode too!
236 void (*check_events
)(struct vo
*vo
);
239 * Closes driver. Should restore the original state of the system.
241 void (*uninit
)(struct vo
*vo
);
244 struct vo_old_functions
{
245 int (*preinit
)(const char *arg
);
246 int (*config
)(uint32_t width
, uint32_t height
, uint32_t d_width
,
247 uint32_t d_height
, uint32_t fullscreen
, char *title
,
249 int (*control
)(uint32_t request
, void *data
);
250 int (*draw_frame
)(uint8_t *src
[]);
251 int (*draw_slice
)(uint8_t *src
[], int stride
[], int w
,int h
, int x
,int y
);
252 void (*draw_osd
)(void);
253 void (*flip_page
)(void);
254 void (*check_events
)(void);
255 void (*uninit
)(void);
259 int config_ok
; // Last config call was successful?
260 int config_count
; // Total number of successful config calls
262 bool frame_loaded
; // Is there a next frame the VO could flip to?
263 struct mp_image
*waiting_mpi
;
264 double next_pts
; // pts value of the next frame if any
265 double next_pts2
; // optional pts of frame after that
266 bool want_redraw
; // visible frame wrong (window resize), needs refresh
267 bool redrawing
; // between redrawing frame and flipping it
269 double flip_queue_offset
; // queue flip events at most this much in advance
271 const struct vo_driver
*driver
;
274 struct vo_x11_state
*x11
;
275 struct mp_fifo
*key_fifo
;
276 struct input_ctx
*input_ctx
;
277 int event_fd
; // check_events() should be called when this has input
278 int registered_fd
; // set to event_fd when registered in input system
280 // requested position/resolution
288 float panscan_amount
;
289 float monitor_aspect
;
291 int orgw
; // real width
292 int orgh
; // real height
293 int prew
; // prescaled width
294 int preh
; // prescaled height
295 int scrw
; // horizontal resolution
296 int scrh
; // vertical resolution
301 struct vo
*init_best_video_out(struct MPOpts
*opts
, struct vo_x11_state
*x11
,
302 struct mp_fifo
*key_fifo
,
303 struct input_ctx
*input_ctx
);
304 int vo_config(struct vo
*vo
, uint32_t width
, uint32_t height
,
305 uint32_t d_width
, uint32_t d_height
, uint32_t flags
,
307 void list_video_out(void);
309 int vo_control(struct vo
*vo
, uint32_t request
, void *data
);
310 int vo_draw_image(struct vo
*vo
, struct mp_image
*mpi
, double pts
);
311 int vo_redraw_frame(struct vo
*vo
);
312 int vo_get_buffered_frame(struct vo
*vo
, bool eof
);
313 void vo_skip_frame(struct vo
*vo
);
314 int vo_draw_frame(struct vo
*vo
, uint8_t *src
[]);
315 int vo_draw_slice(struct vo
*vo
, uint8_t *src
[], int stride
[], int w
, int h
, int x
, int y
);
316 void vo_new_frame_imminent(struct vo
*vo
);
317 void vo_draw_osd(struct vo
*vo
, struct osd_state
*osd
);
318 void vo_flip_page(struct vo
*vo
, unsigned int pts_us
, int duration
);
319 void vo_check_events(struct vo
*vo
);
320 void vo_seek_reset(struct vo
*vo
);
321 void vo_destroy(struct vo
*vo
);
323 const char *vo_get_window_title(struct vo
*vo
);
325 // NULL terminated array of all drivers
326 extern const struct vo_driver
*video_out_drivers
[];
328 extern int xinerama_screen
;
329 extern int xinerama_x
;
330 extern int xinerama_y
;
332 extern int vo_grabpointer
;
333 extern int vo_doublebuffering
;
334 extern int vo_directrendering
;
337 extern int vo_fsmode
;
338 extern float vo_panscan
;
339 extern int vo_adapter_num
;
340 extern int vo_refresh_rate
;
341 extern int vo_keepaspect
;
342 extern int vo_rootwin
;
343 extern int vo_border
;
345 extern int vo_nomouse_input
;
346 extern int enable_mouse_movements
;
351 extern char *vo_subdevice
;
353 extern int vo_colorkey
;
355 extern int64_t WinID
;
362 float range_max(range_t
*r
);
363 int in_range(range_t
*r
, float f
);
364 range_t
*str2range(char *s
);
365 extern char *monitor_hfreq_str
;
366 extern char *monitor_vfreq_str
;
367 extern char *monitor_dotclock_str
;
373 int lookup_keymap_table(const struct mp_keymap
*map
, int key
);
375 int left
, right
, top
, bottom
, width
, height
;
377 void calc_src_dst_rects(struct vo
*vo
, int src_width
, int src_height
,
378 struct vo_rect
*src
, struct vo_rect
*dst
,
379 struct vo_rect
*borders
, const struct vo_rect
*crop
);
381 void vo_mouse_movement(struct vo
*vo
, int posx
, int posy
);
383 static inline int aspect_scaling(void)
385 return vo_keepaspect
|| vo_fs
;
388 #endif /* MPLAYER_VIDEO_OUT_H */