Add some MIME types found in other players
[vlc.git] / include / vlc_vout_display.h
blob70c5640b1950073dbe66ce32adcb8b9e8c2ca705
1 /*****************************************************************************
2 * vlc_vout_display.h: vout_display_t definitions
3 *****************************************************************************
4 * Copyright (C) 2009 Laurent Aimar
5 * $Id$
7 * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program 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 Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifndef VLC_VOUT_DISPLAY_H
25 #define VLC_VOUT_DISPLAY_H 1
27 #include <vlc_es.h>
28 #include <vlc_picture.h>
29 #include <vlc_picture_pool.h>
30 #include <vlc_subpicture.h>
31 #include <vlc_keys.h>
32 #include <vlc_mouse.h>
33 #include <vlc_vout.h>
34 #include <vlc_vout_window.h>
36 /**
37 * \defgroup video_display Video output display
38 * Video output display: output buffers and rendering
40 * \ingroup video_output
41 * @{
42 * \file
43 * Video output display modules interface
46 /* XXX
47 * Do NOT use video_format_t::i_aspect but i_sar_num/den everywhere. i_aspect
48 * will be removed as soon as possible.
51 typedef struct vout_display_t vout_display_t;
52 typedef struct vout_display_sys_t vout_display_sys_t;
53 typedef struct vout_display_owner_t vout_display_owner_t;
54 typedef struct vout_display_owner_sys_t vout_display_owner_sys_t;
56 /**
57 * Possible alignments for vout_display.
59 typedef enum
61 VOUT_DISPLAY_ALIGN_CENTER,
62 /* */
63 VOUT_DISPLAY_ALIGN_LEFT,
64 VOUT_DISPLAY_ALIGN_RIGHT,
65 /* */
66 VOUT_DISPLAY_ALIGN_TOP,
67 VOUT_DISPLAY_ALIGN_BOTTOM,
68 } vout_display_align_t;
70 /**
71 * Window management state.
73 enum {
74 VOUT_WINDOW_STATE_NORMAL=0,
75 VOUT_WINDOW_STATE_ABOVE=1,
76 VOUT_WINDOW_STATE_BELOW=2,
77 VOUT_WINDOW_STACK_MASK=3,
80 /**
81 * Initial/Current configuration for a vout_display_t
83 typedef struct {
84 bool is_fullscreen; /* Is the display fullscreen */
86 /* Display properties */
87 struct {
88 /* Window title (may be NULL) */
89 const char *title;
91 /* Display size */
92 unsigned width;
93 unsigned height;
95 /* Display SAR */
96 struct {
97 unsigned num;
98 unsigned den;
99 } sar;
100 } display;
102 /* Alignment of the picture inside the display */
103 struct {
104 int horizontal;
105 int vertical;
106 } align;
108 /* Do we fill up the display with the video */
109 bool is_display_filled;
111 /* Zoom to use
112 * It will be applied to the whole display if b_display_filled is set, otherwise
113 * only on the video source */
114 struct {
115 int num;
116 int den;
117 } zoom;
119 vlc_viewpoint_t viewpoint;
120 } vout_display_cfg_t;
123 * Information from a vout_display_t to configure
124 * the core behaviour.
126 * By default they are all false or NULL.
129 typedef struct {
130 bool is_slow; /* The picture memory has slow read/write */
131 bool has_double_click; /* Is double-click generated */
132 bool has_hide_mouse; /* Is mouse automatically hidden */
133 bool has_pictures_invalid; /* Will VOUT_DISPLAY_EVENT_PICTURES_INVALID be used */
134 bool needs_event_thread VLC_DEPRECATED; /* Will events (key at least) be emitted using an independent thread */
135 const vlc_fourcc_t *subpicture_chromas; /* List of supported chromas for subpicture rendering. */
136 } vout_display_info_t;
139 * Control query for vout_display_t
141 enum {
142 /* Hide the mouse. It will be sent when
143 * vout_display_t::info.b_hide_mouse is false */
144 VOUT_DISPLAY_HIDE_MOUSE,
146 /* Ask to reset the internal buffers after a VOUT_DISPLAY_EVENT_PICTURES_INVALID
147 * request.
149 VOUT_DISPLAY_RESET_PICTURES,
151 /* Ask the module to acknowledge/refuse the fullscreen state change after
152 * being requested (externally or by VOUT_DISPLAY_EVENT_FULLSCREEN */
153 VOUT_DISPLAY_CHANGE_FULLSCREEN, /* bool fs */
154 #if defined(_WIN32) || defined(__OS2__)
155 /* Ask the module to acknowledge/refuse the window management state change
156 * after being requested externally or by VOUT_DISPLAY_WINDOW_STATE */
157 VOUT_DISPLAY_CHANGE_WINDOW_STATE, /* unsigned state */
158 #endif
159 /* Ask the module to acknowledge/refuse the display size change requested
160 * (externally or by VOUT_DISPLAY_EVENT_DISPLAY_SIZE) */
161 VOUT_DISPLAY_CHANGE_DISPLAY_SIZE, /* const vout_display_cfg_t *p_cfg */
163 /* Ask the module to acknowledge/refuse fill display state change after
164 * being requested externally */
165 VOUT_DISPLAY_CHANGE_DISPLAY_FILLED, /* const vout_display_cfg_t *p_cfg */
167 /* Ask the module to acknowledge/refuse zoom change after being requested
168 * externally */
169 VOUT_DISPLAY_CHANGE_ZOOM, /* const vout_display_cfg_t *p_cfg */
171 /* Ask the module to acknowledge/refuse source aspect ratio after being
172 * requested externally */
173 VOUT_DISPLAY_CHANGE_SOURCE_ASPECT, /* const video_format_t *p_source */
175 /* Ask the module to acknowledge/refuse source crop change after being
176 * requested externally.
177 * The cropping requested is stored by video_format_t::i_x/y_offset and
178 * video_format_t::i_visible_width/height */
179 VOUT_DISPLAY_CHANGE_SOURCE_CROP, /* const video_format_t *p_source */
181 /* Ask the module to acknowledge/refuse VR/360° viewing direction after
182 * being requested externally */
183 VOUT_DISPLAY_CHANGE_VIEWPOINT, /* const vout_display_cfg_t *p_cfg */
187 * Event from vout_display_t
189 * Events modifiying the state may be sent multiple times.
190 * Only the transition will be retained and acted upon.
192 enum {
193 /* TODO:
194 * ZOOM ? DISPLAY_FILLED ? ON_TOP ?
196 /* */
197 VOUT_DISPLAY_EVENT_PICTURES_INVALID, /* The buffer are now invalid and need to be changed */
199 VOUT_DISPLAY_EVENT_FULLSCREEN,
200 #if defined(_WIN32) || defined(__OS2__)
201 VOUT_DISPLAY_EVENT_WINDOW_STATE,
202 #endif
204 VOUT_DISPLAY_EVENT_DISPLAY_SIZE, /* The display size need to change : int i_width, int i_height */
206 /* */
207 VOUT_DISPLAY_EVENT_CLOSE,
208 VOUT_DISPLAY_EVENT_KEY,
210 /* Full mouse state.
211 * You can use it OR use the other mouse events. The core will do
212 * the conversion.
214 VOUT_DISPLAY_EVENT_MOUSE_STATE,
216 /* Mouse event */
217 VOUT_DISPLAY_EVENT_MOUSE_MOVED,
218 VOUT_DISPLAY_EVENT_MOUSE_PRESSED,
219 VOUT_DISPLAY_EVENT_MOUSE_RELEASED,
220 VOUT_DISPLAY_EVENT_MOUSE_DOUBLE_CLICK,
224 * Vout owner structures
226 struct vout_display_owner_t {
227 /* Private place holder for the vout_display_t creator
229 vout_display_owner_sys_t *sys;
231 /* Event coming from the module
233 * This function is set prior to the module instantiation and must not
234 * be overwritten nor used directly (use the vout_display_SendEvent*
235 * wrapper.
237 * You can send it at any time i.e. from any vout_display_t functions or
238 * from another thread.
239 * Be careful, it does not ensure correct serialization if it is used
240 * from multiple threads.
242 void (*event)(vout_display_t *, int, va_list);
244 /* Window management
246 * These functions are set prior to the module instantiation and must not
247 * be overwritten nor used directly (use the vout_display_*Window
248 * wrapper */
249 vout_window_t *(*window_new)(vout_display_t *, unsigned type);
250 void (*window_del)(vout_display_t *, vout_window_t *);
253 struct vout_display_t {
254 VLC_COMMON_MEMBERS
256 /* Module */
257 module_t *module;
259 /* Initial and current configuration.
260 * You cannot modify it directly, you must use the appropriate events.
262 * It reflects the current values, i.e. after the event has been accepted
263 * and applied/configured if needed.
265 const vout_display_cfg_t *cfg;
267 /* video source format.
269 * Cropping is not requested while in the open function.
270 * You cannot change it.
272 video_format_t source;
274 /* picture_t format.
276 * You can only change it inside the module open function to
277 * match what you want, and when a VOUT_DISPLAY_RESET_PICTURES control
278 * request is made and succeeds.
280 * By default, it is equal to ::source except for the aspect ratio
281 * which is undefined(0) and is ignored.
283 video_format_t fmt;
285 /* Information
287 * You can only set them in the open function.
289 vout_display_info_t info;
291 /* Return a pointer over the current picture_pool_t* (mandatory).
293 * For performance reasons, it is best to provide at least count
294 * pictures but it is not mandatory.
295 * You can return NULL when you cannot/do not want to allocate
296 * pictures.
297 * The vout display module keeps the ownership of the pool and can
298 * destroy it only when closing or on invalid pictures control.
300 picture_pool_t *(*pool)(vout_display_t *, unsigned count);
302 /* Prepare a picture and an optional subpicture for display (optional).
304 * It is called before the next pf_display call to provide as much
305 * time as possible to prepare the given picture and the subpicture
306 * for display.
307 * You are guaranted that pf_display will always be called and using
308 * the exact same picture_t and subpicture_t.
309 * You cannot change the pixel content of the picture_t or of the
310 * subpicture_t.
312 void (*prepare)(vout_display_t *, picture_t *, subpicture_t *);
314 /* Display a picture and an optional subpicture (mandatory).
316 * The picture and the optional subpicture must be displayed as soon as
317 * possible.
318 * You cannot change the pixel content of the picture_t or of the
319 * subpicture_t.
321 * This function gives away the ownership of the picture and of the
322 * subpicture, so you must release them as soon as possible.
324 void (*display)(vout_display_t *, picture_t *, subpicture_t *);
326 /* Control on the module (mandatory) */
327 int (*control)(vout_display_t *, int, va_list);
329 /* Manage pending event (optional) */
330 void (*manage)(vout_display_t *);
332 /* Private place holder for the vout_display_t module (optional)
334 * A module is free to use it as it wishes.
336 vout_display_sys_t *sys;
338 /* Reserved for the vout_display_t owner.
340 * It must not be overwritten nor used directly by a module.
342 vout_display_owner_t owner;
345 static inline void vout_display_SendEvent(vout_display_t *vd, int query, ...)
347 va_list args;
348 va_start(args, query);
349 vd->owner.event(vd, query, args);
350 va_end(args);
353 static inline void vout_display_SendEventDisplaySize(vout_display_t *vd, int width, int height)
355 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_DISPLAY_SIZE, width, height);
357 static inline void vout_display_SendEventPicturesInvalid(vout_display_t *vd)
359 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_PICTURES_INVALID);
361 static inline void vout_display_SendEventClose(vout_display_t *vd)
363 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_CLOSE);
365 static inline void vout_display_SendEventKey(vout_display_t *vd, int key)
367 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_KEY, key);
369 static inline void vout_display_SendEventFullscreen(vout_display_t *vd, bool is_fullscreen)
371 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_FULLSCREEN, is_fullscreen);
373 #if defined(_WIN32)
374 static inline void vout_display_SendWindowState(vout_display_t *vd, unsigned state)
376 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_WINDOW_STATE, state);
378 #endif
379 /* The mouse position (State and Moved event) must be expressed against vout_display_t::source unit */
380 static inline void vout_display_SendEventMouseState(vout_display_t *vd, int x, int y, int button_mask)
382 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_STATE, x, y, button_mask);
384 static inline void vout_display_SendEventMouseMoved(vout_display_t *vd, int x, int y)
386 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_MOVED, x, y);
388 static inline void vout_display_SendEventMousePressed(vout_display_t *vd, int button)
390 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_PRESSED, button);
392 static inline void vout_display_SendEventMouseReleased(vout_display_t *vd, int button)
394 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_RELEASED, button);
396 static inline void vout_display_SendEventMouseDoubleClick(vout_display_t *vd)
398 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_DOUBLE_CLICK);
402 * Asks for a new window of a given type.
404 static inline vout_window_t *vout_display_NewWindow(vout_display_t *vd, unsigned type)
406 return vd->owner.window_new(vd, type);
409 * Deletes a window created by vout_display_NewWindow if window is non NULL
410 * or any unused windows otherwise.
412 static inline void vout_display_DeleteWindow(vout_display_t *vd,
413 vout_window_t *window)
415 vd->owner.window_del(vd, window);
418 static inline bool vout_display_IsWindowed(vout_display_t *vd)
420 vout_window_t *window = vout_display_NewWindow(vd, VOUT_WINDOW_TYPE_INVALID);
421 if (window != NULL)
422 vout_display_DeleteWindow(vd, window);
423 return window != NULL;
427 * Computes the default display size given the source and
428 * the display configuration.
430 * This asssumes that the picture is already cropped.
432 VLC_API void vout_display_GetDefaultDisplaySize(unsigned *width, unsigned *height, const video_format_t *source, const vout_display_cfg_t *);
436 * Structure used to store the result of a vout_display_PlacePicture.
438 typedef struct {
439 int x;
440 int y;
441 unsigned width;
442 unsigned height;
443 } vout_display_place_t;
446 * Computes how to place a picture inside the display to respect
447 * the given parameters.
448 * This assumes that cropping is done by an external mean.
450 * \param p_place Place inside the window (window pixel unit)
451 * \param p_source Video source format
452 * \param p_cfg Display configuration
453 * \param b_clip If true, prevent the video to go outside the display (break zoom).
455 VLC_API void vout_display_PlacePicture(vout_display_place_t *place, const video_format_t *source, const vout_display_cfg_t *cfg, bool do_clipping);
459 * Helper function that applies the necessary transforms to the mouse position
460 * and then calls vout_display_SendEventMouseMoved.
462 * \param vd vout_display_t.
463 * \param orient_display The orientation of the picture as seen on screen (probably ORIENT_NORMAL).
464 * \param m_x Mouse x position (relative to place, origin is top left).
465 * \param m_y Mouse y position (relative to place, origin is top left).
466 * \param place Place of the picture.
468 VLC_API void vout_display_SendMouseMovedDisplayCoordinates(vout_display_t *vd, video_orientation_t orient_display, int m_x, int m_y,
469 vout_display_place_t *place);
471 /** @} */
472 #endif /* VLC_VOUT_DISPLAY_H */