mux: mp4: use samplepriv as fallback location for extra
[vlc.git] / include / vlc_vout_display.h
blobd37b05b8af2be27066640662e190b4bd49a7ca64
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_actions.h>
32 #include <vlc_mouse.h>
33 #include <vlc_vout.h>
34 #include <vlc_vout_window.h>
35 #include <vlc_viewpoint.h>
37 /**
38 * \defgroup video_display Video output display
39 * Video output display: output buffers and rendering
41 * \ingroup video_output
42 * @{
43 * \file
44 * Video output display modules interface
47 typedef struct vout_display_t vout_display_t;
48 typedef struct vout_display_sys_t vout_display_sys_t;
49 typedef struct vout_display_owner_t vout_display_owner_t;
51 /**
52 * Possible alignments for vout_display.
54 #define VLC_VIDEO_ALIGN_CENTER 0
55 #define VLC_VIDEO_ALIGN_LEFT 1
56 #define VLC_VIDEO_ALIGN_RIGHT 2
57 #define VLC_VIDEO_ALIGN_TOP 1
58 #define VLC_VIDEO_ALIGN_BOTTOM 2
60 typedef struct vlc_video_align {
61 char horizontal;
62 char vertical;
63 } vlc_video_align_t;
65 /**
66 * Initial/Current configuration for a vout_display_t
68 typedef struct {
69 struct vout_window_t *window; /**< Window */
70 #if defined(_WIN32) || defined(__OS2__)
71 bool is_fullscreen VLC_DEPRECATED; /* Is the display fullscreen */
72 #endif
74 /* Display properties */
75 struct {
76 /* Display size */
77 unsigned width;
78 unsigned height;
80 /* Display SAR */
81 vlc_rational_t sar;
82 } display;
84 /* Alignment of the picture inside the display */
85 vlc_video_align_t align;
87 /* Do we fill up the display with the video */
88 bool is_display_filled;
90 /* Zoom to use
91 * It will be applied to the whole display if b_display_filled is set, otherwise
92 * only on the video source */
93 struct {
94 unsigned num;
95 unsigned den;
96 } zoom;
98 vlc_viewpoint_t viewpoint;
99 } vout_display_cfg_t;
102 * Information from a vout_display_t to configure
103 * the core behaviour.
105 * By default they are all false or NULL.
108 typedef struct {
109 bool is_slow; /* The picture memory has slow read/write */
110 bool has_double_click; /* Is double-click generated */
111 bool has_pictures_invalid; /* Will VOUT_DISPLAY_EVENT_PICTURES_INVALID be used */
112 bool can_scale_spu; /* Handles subpictures with a non default zoom factor */
113 const vlc_fourcc_t *subpicture_chromas; /* List of supported chromas for subpicture rendering. */
114 } vout_display_info_t;
117 * Control query for vout_display_t
119 enum {
120 /* Ask to reset the internal buffers after a VOUT_DISPLAY_EVENT_PICTURES_INVALID
121 * request.
123 VOUT_DISPLAY_RESET_PICTURES, /* const vout_display_cfg_t *, es_format_t * */
125 #if defined(_WIN32) || defined(__OS2__)
126 /* Ask the module to acknowledge/refuse the fullscreen state change after
127 * being requested (externally or by VOUT_DISPLAY_EVENT_FULLSCREEN */
128 VOUT_DISPLAY_CHANGE_FULLSCREEN VLC_DEPRECATED_ENUM, /* bool fs */
129 /* Ask the module to acknowledge/refuse the window management state change
130 * after being requested externally or by VOUT_DISPLAY_WINDOW_STATE */
131 VOUT_DISPLAY_CHANGE_WINDOW_STATE VLC_DEPRECATED_ENUM, /* unsigned state */
132 #endif
133 /* Ask the module to acknowledge the display size change */
134 VOUT_DISPLAY_CHANGE_DISPLAY_SIZE, /* const vout_display_cfg_t *p_cfg */
136 /* Ask the module to acknowledge/refuse fill display state change after
137 * being requested externally */
138 VOUT_DISPLAY_CHANGE_DISPLAY_FILLED, /* const vout_display_cfg_t *p_cfg */
140 /* Ask the module to acknowledge/refuse zoom change after being requested
141 * externally */
142 VOUT_DISPLAY_CHANGE_ZOOM, /* const vout_display_cfg_t *p_cfg */
144 /* Ask the module to acknowledge/refuse source aspect ratio after being
145 * requested externally */
146 VOUT_DISPLAY_CHANGE_SOURCE_ASPECT, /* const vout_display_cfg_t *p_cfg */
148 /* Ask the module to acknowledge/refuse source crop change after being
149 * requested externally.
150 * The cropping requested is stored by source video_format_t::i_x/y_offset
151 * and video_format_t::i_visible_width/height */
152 VOUT_DISPLAY_CHANGE_SOURCE_CROP, /* const vout_display_cfg_t *p_cfg */
154 /* Ask the module to acknowledge/refuse VR/360° viewing direction after
155 * being requested externally */
156 VOUT_DISPLAY_CHANGE_VIEWPOINT, /* const vout_display_cfg_t *p_cfg */
160 * Event from vout_display_t
162 * Events modifiying the state may be sent multiple times.
163 * Only the transition will be retained and acted upon.
165 enum {
166 /* TODO:
167 * ZOOM ? DISPLAY_FILLED ? ON_TOP ?
169 /* */
170 VOUT_DISPLAY_EVENT_PICTURES_INVALID, /* The buffer are now invalid and need to be changed */
172 #if defined(_WIN32) || defined(__OS2__)
173 VOUT_DISPLAY_EVENT_FULLSCREEN,
174 VOUT_DISPLAY_EVENT_WINDOW_STATE,
175 #endif
177 /* Mouse event */
178 VOUT_DISPLAY_EVENT_MOUSE_MOVED,
179 VOUT_DISPLAY_EVENT_MOUSE_PRESSED,
180 VOUT_DISPLAY_EVENT_MOUSE_RELEASED,
181 VOUT_DISPLAY_EVENT_MOUSE_DOUBLE_CLICK,
183 /* VR navigation */
184 VOUT_DISPLAY_EVENT_VIEWPOINT_MOVED,
188 * Vout owner structures
190 struct vout_display_owner_t {
191 /* Private place holder for the vout_display_t creator
193 void *sys;
195 /* Event coming from the module
197 * This function is set prior to the module instantiation and must not
198 * be overwritten nor used directly (use the vout_display_SendEvent*
199 * wrapper.
201 * You can send it at any time i.e. from any vout_display_t functions or
202 * from another thread.
203 * Be careful, it does not ensure correct serialization if it is used
204 * from multiple threads.
206 void (*event)(vout_display_t *, int, va_list);
210 * "vout display" open callback
212 * @param vd vout display context
213 * @param cfg Initial and current configuration.
214 * @param fmtp By default, it is equal to vd->source except for the aspect
215 * ratio which is undefined(0) and is ignored. It can be changed by the module
216 * to request a different format.
217 * @param context XXX: to be defined.
218 * @return VLC_SUCCESS or a VLC error code
220 typedef int (*vout_display_open_cb)(vout_display_t *vd,
221 const vout_display_cfg_t *cfg,
222 video_format_t *fmtp,
223 vlc_video_context *context);
226 * "vout display" close callback
228 * @param vd vout display context
230 typedef int (*vout_display_close_cb)(vout_display_t *vd);
232 struct vout_display_t {
233 struct vlc_common_members obj;
235 /* Module */
236 module_t *module;
238 /* Initial and current configuration.
239 * You cannot modify it directly, you must use the appropriate events.
241 * It reflects the current values, i.e. after the event has been accepted
242 * and applied/configured if needed.
244 const vout_display_cfg_t *cfg;
246 /* video source format.
248 * Cropping is not requested while in the open function.
249 * You cannot change it.
251 video_format_t source;
253 /* picture_t format.
255 * You can only change it inside the module open function to
256 * match what you want, and when a VOUT_DISPLAY_RESET_PICTURES control
257 * request is made and succeeds.
259 * By default, it is equal to ::source except for the aspect ratio
260 * which is undefined(0) and is ignored.
262 video_format_t fmt;
264 /* Information
266 * You can only set them in the open function.
268 vout_display_info_t info;
270 /* Return a pointer over the current picture_pool_t* (mandatory).
272 * For performance reasons, it is best to provide at least count
273 * pictures but it is not mandatory.
274 * You can return NULL when you cannot/do not want to allocate
275 * pictures.
276 * The vout display module keeps the ownership of the pool and can
277 * destroy it only when closing or on invalid pictures control.
279 picture_pool_t *(*pool)(vout_display_t *, unsigned count);
281 /* Prepare a picture and an optional subpicture for display (optional).
283 * It is called before the next pf_display call to provide as much
284 * time as possible to prepare the given picture and the subpicture
285 * for display.
286 * You are guaranted that pf_display will always be called and using
287 * the exact same picture_t and subpicture_t.
288 * You cannot change the pixel content of the picture_t or of the
289 * subpicture_t.
291 void (*prepare)(vout_display_t *, picture_t *, subpicture_t *,
292 vlc_tick_t date);
294 /* Display a picture.
296 * The picture must be displayed as soon as possible.
297 * You cannot change the pixel content of the picture_t.
299 void (*display)(vout_display_t *, picture_t *);
301 /* Control on the module (mandatory) */
302 int (*control)(vout_display_t *, int, va_list);
304 /* Private place holder for the vout_display_t module (optional)
306 * A module is free to use it as it wishes.
308 vout_display_sys_t *sys;
310 /* Reserved for the vout_display_t owner.
312 * It must not be overwritten nor used directly by a module.
314 vout_display_owner_t owner;
317 static inline void vout_display_SendEvent(vout_display_t *vd, int query, ...)
319 va_list args;
320 va_start(args, query);
321 vd->owner.event(vd, query, args);
322 va_end(args);
325 static inline void vout_display_SendEventPicturesInvalid(vout_display_t *vd)
327 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_PICTURES_INVALID);
330 #if defined(_WIN32) || defined(__OS2__)
331 static inline void vout_display_SendEventFullscreen(vout_display_t *vd, bool is_fullscreen)
333 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_FULLSCREEN, is_fullscreen);
336 VLC_DEPRECATED /* Core needs not know about this. Don't call. */
337 static inline void vout_display_SendWindowState(vout_display_t *vd, unsigned state)
339 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_WINDOW_STATE, state);
341 #endif
342 static inline void vout_display_SendEventMouseMoved(vout_display_t *vd, int x, int y)
344 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_MOVED, x, y);
346 static inline void vout_display_SendEventMousePressed(vout_display_t *vd, int button)
348 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_PRESSED, button);
350 static inline void vout_display_SendEventMouseReleased(vout_display_t *vd, int button)
352 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_RELEASED, button);
354 static inline void vout_display_SendEventMouseDoubleClick(vout_display_t *vd)
356 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_DOUBLE_CLICK);
358 static inline void vout_display_SendEventViewpointMoved(vout_display_t *vd,
359 const vlc_viewpoint_t *vp)
361 vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_VIEWPOINT_MOVED, vp);
364 static inline bool vout_display_cfg_IsWindowed(const vout_display_cfg_t *cfg)
366 return cfg->window->type != VOUT_WINDOW_TYPE_DUMMY;
370 * Computes the default display size given the source and
371 * the display configuration.
373 * This asssumes that the picture is already cropped.
375 VLC_API void vout_display_GetDefaultDisplaySize(unsigned *width, unsigned *height, const video_format_t *source, const vout_display_cfg_t *);
379 * Structure used to store the result of a vout_display_PlacePicture.
381 typedef struct {
382 int x;
383 int y;
384 unsigned width;
385 unsigned height;
386 } vout_display_place_t;
389 * Computes how to place a picture inside the display to respect
390 * the given parameters.
391 * This assumes that cropping is done by an external mean.
393 * \param p_place Place inside the window (window pixel unit)
394 * \param p_source Video source format
395 * \param p_cfg Display configuration
397 VLC_API void vout_display_PlacePicture(vout_display_place_t *place, const video_format_t *source, const vout_display_cfg_t *cfg);
401 * Helper function that applies the necessary transforms to the mouse position
402 * and then calls vout_display_SendEventMouseMoved.
404 * \param vd vout_display_t.
405 * \param orient_display The orientation of the picture as seen on screen (probably ORIENT_NORMAL).
406 * \param m_x Mouse x position (relative to place, origin is top left).
407 * \param m_y Mouse y position (relative to place, origin is top left).
408 * \param place Place of the picture.
410 VLC_API void vout_display_SendMouseMovedDisplayCoordinates(vout_display_t *vd, video_orientation_t orient_display, int m_x, int m_y,
411 vout_display_place_t *place);
413 /** @} */
414 #endif /* VLC_VOUT_DISPLAY_H */