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 */
54 VOCTRL_SET_EQUALIZER
, // struct voctrl_set_equalizer_args
55 VOCTRL_GET_EQUALIZER
, // struct voctrl_get_equalizer_args
56 VOCTRL_DUPLICATE_FRAME
,
68 VOCTRL_GET_EOSD_RES
, // struct mp_eosd_res
70 VOCTRL_SET_DEINTERLACE
,
71 VOCTRL_GET_DEINTERLACE
,
73 VOCTRL_UPDATE_SCREENINFO
,
75 VOCTRL_SET_YUV_COLORSPACE
, // struct mp_csp_details
76 VOCTRL_GET_YUV_COLORSPACE
, // struct mp_csp_details
78 VOCTRL_SCREENSHOT
, // struct voctrl_screenshot_args
81 // VOCTRL_SET_EQUALIZER
82 struct voctrl_set_equalizer_args
{
87 // VOCTRL_GET_EQUALIZER
88 struct voctrl_get_equalizer_args
{
94 struct voctrl_screenshot_args
{
95 // 0: Save image of the currently displayed video frame, in original
97 // 1: Save full screenshot of the window. Should contain OSD, EOSD, and the
99 // The value of this variable can be ignored if only a single method is
102 // Will be set to a newly allocated image, that contains the screenshot.
103 // The caller has to free the pointer with free_mp_image().
104 // It is not specified whether the image data is a copy or references the
105 // image data directly.
106 // Is never NULL. (Failure has to be indicated by returning VO_FALSE.)
107 struct mp_image
*out_image
;
118 #define VO_NOTAVAIL -2
119 #define VO_NOTIMPL -3
121 #define VOFLAG_FULLSCREEN 0x01
122 #define VOFLAG_MODESWITCHING 0x02
123 #define VOFLAG_SWSCALE 0x04
124 #define VOFLAG_FLIPPING 0x08
125 #define VOFLAG_HIDDEN 0x10 //< Use to create a hidden window
126 #define VOFLAG_STEREO 0x20 //< Use to create a stereo-capable window
128 typedef struct vo_info_s
130 /* driver name ("Matrox Millennium G200/G400" */
132 /* short name (for config strings) ("vdpau") */
133 const char *short_name
;
134 /* author ("Aaron Holtzman <aholtzma@ess.engr.uvic.ca>") */
136 /* any additional comments */
145 // Driver uses new API
147 // Driver buffers or adds (deinterlace) frames and will keep track
148 // of pts values itself
151 // This is set if the driver is not new and contains pointers to
152 // old-API functions to be used instead of the ones below.
153 struct vo_old_functions
*old_functions
;
155 const vo_info_t
*info
;
157 * Preinitializes driver (real INITIALIZATION)
158 * arg - currently it's vo_subdevice
159 * returns: zero on successful initialization, non-zero on error.
161 int (*preinit
)(struct vo
*vo
, const char *arg
);
163 * Initialize (means CONFIGURE) the display driver.
165 * width,height: image source size
166 * d_width,d_height: size of the requested window size, just a hint
167 * fullscreen: flag, 0=windowd 1=fullscreen, just a hint
168 * title: window title, if available
169 * format: fourcc of pixel format
170 * returns : zero on successful initialization, non-zero on error.
172 int (*config
)(struct vo
*vo
, uint32_t width
, uint32_t height
,
173 uint32_t d_width
, uint32_t d_height
, uint32_t fullscreen
,
179 int (*control
)(struct vo
*vo
, uint32_t request
, void *data
);
181 void (*draw_image
)(struct vo
*vo
, struct mp_image
*mpi
, double pts
);
184 * Get extra frames from the VO, such as those added by VDPAU
185 * deinterlace. Preparing the next such frame if any could be done
186 * automatically by the VO after a previous flip_page(), but having
187 * it as a separate step seems to allow making code more robust.
189 void (*get_buffered_frame
)(struct vo
*vo
, bool eof
);
192 * Draw a planar YUV slice to the buffer:
194 * src[3] = source image planes (Y,U,V)
195 * stride[3] = source image planes line widths (in bytes)
196 * w,h = width*height of area to be copied (in Y pixels)
197 * x,y = position at the destination image (in Y pixels)
199 int (*draw_slice
)(struct vo
*vo
, uint8_t *src
[], int stride
[], int w
,
200 int h
, int x
, int y
);
203 * Draws OSD to the screen buffer
205 void (*draw_osd
)(struct vo
*vo
, struct osd_state
*osd
);
208 * Blit/Flip buffer to the screen. Must be called after each frame!
210 void (*flip_page
)(struct vo
*vo
);
211 void (*flip_page_timed
)(struct vo
*vo
, unsigned int pts_us
, int duration
);
214 * This func is called after every frames to handle keyboard and
215 * other events. It's called in PAUSE mode too!
217 void (*check_events
)(struct vo
*vo
);
220 * Closes driver. Should restore the original state of the system.
222 void (*uninit
)(struct vo
*vo
);
224 // Size of private struct for automatic allocation
227 // List of options to parse into priv struct (requires privsize to be set)
228 const struct m_option
*options
;
231 struct vo_old_functions
{
232 int (*preinit
)(const char *arg
);
233 int (*config
)(uint32_t width
, uint32_t height
, uint32_t d_width
,
234 uint32_t d_height
, uint32_t fullscreen
, char *title
,
236 int (*control
)(uint32_t request
, void *data
);
237 int (*draw_frame
)(uint8_t *src
[]);
238 int (*draw_slice
)(uint8_t *src
[], int stride
[], int w
,int h
, int x
,int y
);
239 void (*draw_osd
)(void);
240 void (*flip_page
)(void);
241 void (*check_events
)(void);
242 void (*uninit
)(void);
246 int config_ok
; // Last config call was successful?
247 int config_count
; // Total number of successful config calls
249 bool frame_loaded
; // Is there a next frame the VO could flip to?
250 struct mp_image
*waiting_mpi
;
251 double next_pts
; // pts value of the next frame if any
252 double next_pts2
; // optional pts of frame after that
253 bool want_redraw
; // visible frame wrong (window resize), needs refresh
254 bool redrawing
; // between redrawing frame and flipping it
255 bool hasframe
; // >= 1 frame has been drawn, so redraw is possible
257 double flip_queue_offset
; // queue flip events at most this much in advance
259 const struct vo_driver
*driver
;
262 struct vo_x11_state
*x11
;
263 struct mp_fifo
*key_fifo
;
264 struct input_ctx
*input_ctx
;
265 int event_fd
; // check_events() should be called when this has input
266 int registered_fd
; // set to event_fd when registered in input system
268 // requested position/resolution
276 float panscan_amount
;
277 float monitor_aspect
;
279 int orgw
; // real width
280 int orgh
; // real height
281 int prew
; // prescaled width
282 int preh
; // prescaled height
283 int scrw
; // horizontal resolution
284 int scrh
; // vertical resolution
289 struct vo
*init_best_video_out(struct MPOpts
*opts
, struct mp_fifo
*key_fifo
,
290 struct input_ctx
*input_ctx
);
291 int vo_config(struct vo
*vo
, uint32_t width
, uint32_t height
,
292 uint32_t d_width
, uint32_t d_height
, uint32_t flags
,
294 void list_video_out(void);
296 int vo_control(struct vo
*vo
, uint32_t request
, void *data
);
297 int vo_draw_image(struct vo
*vo
, struct mp_image
*mpi
, double pts
);
298 int vo_redraw_frame(struct vo
*vo
);
299 int vo_get_buffered_frame(struct vo
*vo
, bool eof
);
300 void vo_skip_frame(struct vo
*vo
);
301 int vo_draw_frame(struct vo
*vo
, uint8_t *src
[]);
302 int vo_draw_slice(struct vo
*vo
, uint8_t *src
[], int stride
[], int w
, int h
, int x
, int y
);
303 void vo_new_frame_imminent(struct vo
*vo
);
304 void vo_draw_osd(struct vo
*vo
, struct osd_state
*osd
);
305 void vo_flip_page(struct vo
*vo
, unsigned int pts_us
, int duration
);
306 void vo_check_events(struct vo
*vo
);
307 void vo_seek_reset(struct vo
*vo
);
308 void vo_destroy(struct vo
*vo
);
310 const char *vo_get_window_title(struct vo
*vo
);
312 // NULL terminated array of all drivers
313 extern const struct vo_driver
*video_out_drivers
[];
315 extern int xinerama_screen
;
316 extern int xinerama_x
;
317 extern int xinerama_y
;
319 extern int vo_grabpointer
;
320 extern int vo_doublebuffering
;
321 extern int vo_directrendering
;
324 extern int vo_fsmode
;
325 extern float vo_panscan
;
326 extern int vo_adapter_num
;
327 extern int vo_refresh_rate
;
328 extern int vo_keepaspect
;
329 extern int vo_rootwin
;
330 extern int vo_border
;
332 extern int vo_nomouse_input
;
333 extern int enable_mouse_movements
;
338 extern int vo_colorkey
;
340 extern int64_t WinID
;
347 float range_max(range_t
*r
);
348 int in_range(range_t
*r
, float f
);
349 range_t
*str2range(char *s
);
350 extern char *monitor_hfreq_str
;
351 extern char *monitor_vfreq_str
;
352 extern char *monitor_dotclock_str
;
358 int lookup_keymap_table(const struct mp_keymap
*map
, int key
);
360 int left
, right
, top
, bottom
, width
, height
;
362 void calc_src_dst_rects(struct vo
*vo
, int src_width
, int src_height
,
363 struct vo_rect
*src
, struct vo_rect
*dst
,
364 struct vo_rect
*borders
, const struct vo_rect
*crop
);
365 void vo_mouse_movement(struct vo
*vo
, int posx
, int posy
);
367 static inline int aspect_scaling(void)
369 return vo_keepaspect
|| vo_fs
;
372 #endif /* MPLAYER_VIDEO_OUT_H */