cosmetics: stream_cdda.c: reformat
[mplayer.git] / libvo / video_out.h
blob3dd3ca8a8d3d71278458e8b0a4808f99c1325339
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_NEWFRAME,
67 VOCTRL_SKIPFRAME,
68 VOCTRL_REDRAW_FRAME,
70 VOCTRL_ONTOP,
71 VOCTRL_ROOTWIN,
72 VOCTRL_BORDER,
73 VOCTRL_DRAW_EOSD,
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 {
89 const char *name;
90 int value;
93 // VOCTRL_GET_EQUALIZER
94 struct voctrl_get_equalizer_args {
95 const char *name;
96 int *valueptr;
99 // VOCTRL_XOVERLAY_SET_COLORKEY
100 typedef struct {
101 uint32_t x11; // The raw x11 color
102 uint16_t r,g,b;
103 } mp_colorkey_t;
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)
109 } mp_eosd_res_t;
111 // VOCTRL_SCREENSHOT
112 struct voctrl_screenshot_args {
113 // 0: Save image of the currently displayed video frame, in original
114 // resolution.
115 // 1: Save full screenshot of the window. Should contain OSD, EOSD, and the
116 // scaled video.
117 // The value of this variable can be ignored if only a single method is
118 // implemented.
119 int full_window;
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;
128 typedef struct {
129 int x,y;
130 int w,h;
131 } mp_win_t;
133 #define VO_TRUE 1
134 #define VO_FALSE 0
135 #define VO_ERROR -1
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" */
150 const char *name;
151 /* short name (for config strings) ("mga") */
152 const char *short_name;
153 /* author ("Aaron Holtzman <aholtzma@ess.engr.uvic.ca>") */
154 const char *author;
155 /* any additional comments */
156 const char *comment;
157 } vo_info_t;
159 struct vo;
160 struct osd_state;
161 struct mp_image;
163 struct vo_driver {
164 // Driver uses new API
165 bool is_new;
166 // Driver buffers or adds (deinterlace) frames and will keep track
167 // of pts values itself
168 bool buffer_frames;
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.
183 * params:
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,
193 uint32_t format);
196 * Control interface
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:
212 * params:
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,
248 uint32_t format);
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);
258 struct vo {
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
268 bool hasframe; // >= 1 frame has been drawn, so redraw is possible
270 double flip_queue_offset; // queue flip events at most this much in advance
272 const struct vo_driver *driver;
273 void *priv;
274 struct MPOpts *opts;
275 struct vo_x11_state *x11;
276 struct mp_fifo *key_fifo;
277 struct input_ctx *input_ctx;
278 int event_fd; // check_events() should be called when this has input
279 int registered_fd; // set to event_fd when registered in input system
281 // requested position/resolution
282 int dx;
283 int dy;
284 int dwidth;
285 int dheight;
287 int panscan_x;
288 int panscan_y;
289 float panscan_amount;
290 float monitor_aspect;
291 struct aspect_data {
292 int orgw; // real width
293 int orgh; // real height
294 int prew; // prescaled width
295 int preh; // prescaled height
296 int scrw; // horizontal resolution
297 int scrh; // vertical resolution
298 float asp;
299 } aspdat;
302 struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
303 struct mp_fifo *key_fifo,
304 struct input_ctx *input_ctx);
305 int vo_config(struct vo *vo, uint32_t width, uint32_t height,
306 uint32_t d_width, uint32_t d_height, uint32_t flags,
307 uint32_t format);
308 void list_video_out(void);
310 int vo_control(struct vo *vo, uint32_t request, void *data);
311 int vo_draw_image(struct vo *vo, struct mp_image *mpi, double pts);
312 int vo_redraw_frame(struct vo *vo);
313 int vo_get_buffered_frame(struct vo *vo, bool eof);
314 void vo_skip_frame(struct vo *vo);
315 int vo_draw_frame(struct vo *vo, uint8_t *src[]);
316 int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y);
317 void vo_new_frame_imminent(struct vo *vo);
318 void vo_draw_osd(struct vo *vo, struct osd_state *osd);
319 void vo_flip_page(struct vo *vo, unsigned int pts_us, int duration);
320 void vo_check_events(struct vo *vo);
321 void vo_seek_reset(struct vo *vo);
322 void vo_destroy(struct vo *vo);
324 const char *vo_get_window_title(struct vo *vo);
326 // NULL terminated array of all drivers
327 extern const struct vo_driver *video_out_drivers[];
329 extern int xinerama_screen;
330 extern int xinerama_x;
331 extern int xinerama_y;
333 extern int vo_grabpointer;
334 extern int vo_doublebuffering;
335 extern int vo_directrendering;
336 extern int vo_vsync;
337 extern int vo_fs;
338 extern int vo_fsmode;
339 extern float vo_panscan;
340 extern int vo_adapter_num;
341 extern int vo_refresh_rate;
342 extern int vo_keepaspect;
343 extern int vo_rootwin;
344 extern int vo_border;
346 extern int vo_nomouse_input;
347 extern int enable_mouse_movements;
349 extern int vo_pts;
350 extern float vo_fps;
352 extern char *vo_subdevice;
354 extern int vo_colorkey;
356 extern int64_t WinID;
358 typedef struct {
359 float min;
360 float max;
361 } range_t;
363 float range_max(range_t *r);
364 int in_range(range_t *r, float f);
365 range_t *str2range(char *s);
366 extern char *monitor_hfreq_str;
367 extern char *monitor_vfreq_str;
368 extern char *monitor_dotclock_str;
370 struct mp_keymap {
371 int from;
372 int to;
374 int lookup_keymap_table(const struct mp_keymap *map, int key);
375 struct vo_rect {
376 int left, right, top, bottom, width, height;
378 void calc_src_dst_rects(struct vo *vo, int src_width, int src_height,
379 struct vo_rect *src, struct vo_rect *dst,
380 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 */