1 /*****************************************************************************
2 * vlc_vout_display.h: vout_display_t definitions
3 *****************************************************************************
4 * Copyright (C) 2009 Laurent Aimar
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
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>
34 #include <vlc_vout_window.h>
35 #include <vlc_viewpoint.h>
38 * \defgroup video_display Video output display
39 * Video output display: output buffers and rendering
41 * \ingroup video_output
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
;
52 * Possible alignments for vout_display.
56 VOUT_DISPLAY_ALIGN_CENTER
,
58 VOUT_DISPLAY_ALIGN_LEFT
,
59 VOUT_DISPLAY_ALIGN_RIGHT
,
61 VOUT_DISPLAY_ALIGN_TOP
,
62 VOUT_DISPLAY_ALIGN_BOTTOM
,
63 } vout_display_align_t
;
66 * Initial/Current configuration for a vout_display_t
69 struct vout_window_t
*window
; /**< Window */
70 #if defined(_WIN32) || defined(__OS2__)
71 bool is_fullscreen VLC_DEPRECATED
; /* Is the display fullscreen */
74 /* Display properties */
84 /* Alignment of the picture inside the display */
90 /* Do we fill up the display with the video */
91 bool is_display_filled
;
94 * It will be applied to the whole display if b_display_filled is set, otherwise
95 * only on the video source */
101 vlc_viewpoint_t viewpoint
;
102 } vout_display_cfg_t
;
105 * Information from a vout_display_t to configure
106 * the core behaviour.
108 * By default they are all false or NULL.
112 bool is_slow
; /* The picture memory has slow read/write */
113 bool has_double_click
; /* Is double-click generated */
114 bool has_pictures_invalid
; /* Will VOUT_DISPLAY_EVENT_PICTURES_INVALID be used */
115 const vlc_fourcc_t
*subpicture_chromas
; /* List of supported chromas for subpicture rendering. */
116 } vout_display_info_t
;
119 * Control query for vout_display_t
122 /* Ask to reset the internal buffers after a VOUT_DISPLAY_EVENT_PICTURES_INVALID
125 VOUT_DISPLAY_RESET_PICTURES
,
127 #if defined(_WIN32) || defined(__OS2__)
128 /* Ask the module to acknowledge/refuse the fullscreen state change after
129 * being requested (externally or by VOUT_DISPLAY_EVENT_FULLSCREEN */
130 VOUT_DISPLAY_CHANGE_FULLSCREEN VLC_DEPRECATED_ENUM
, /* bool fs */
131 /* Ask the module to acknowledge/refuse the window management state change
132 * after being requested externally or by VOUT_DISPLAY_WINDOW_STATE */
133 VOUT_DISPLAY_CHANGE_WINDOW_STATE VLC_DEPRECATED_ENUM
, /* unsigned state */
135 /* Ask the module to acknowledge the display size change */
136 VOUT_DISPLAY_CHANGE_DISPLAY_SIZE
, /* const vout_display_cfg_t *p_cfg */
138 /* Ask the module to acknowledge/refuse fill display state change after
139 * being requested externally */
140 VOUT_DISPLAY_CHANGE_DISPLAY_FILLED
, /* const vout_display_cfg_t *p_cfg */
142 /* Ask the module to acknowledge/refuse zoom change after being requested
144 VOUT_DISPLAY_CHANGE_ZOOM
, /* const vout_display_cfg_t *p_cfg */
146 /* Ask the module to acknowledge/refuse source aspect ratio after being
147 * requested externally */
148 VOUT_DISPLAY_CHANGE_SOURCE_ASPECT
,
150 /* Ask the module to acknowledge/refuse source crop change after being
151 * requested externally.
152 * The cropping requested is stored by video_format_t::i_x/y_offset and
153 * video_format_t::i_visible_width/height */
154 VOUT_DISPLAY_CHANGE_SOURCE_CROP
,
156 /* Ask the module to acknowledge/refuse VR/360° viewing direction after
157 * being requested externally */
158 VOUT_DISPLAY_CHANGE_VIEWPOINT
, /* const vout_display_cfg_t *p_cfg */
162 * Event from vout_display_t
164 * Events modifiying the state may be sent multiple times.
165 * Only the transition will be retained and acted upon.
169 * ZOOM ? DISPLAY_FILLED ? ON_TOP ?
172 VOUT_DISPLAY_EVENT_PICTURES_INVALID
, /* The buffer are now invalid and need to be changed */
174 #if defined(_WIN32) || defined(__OS2__)
175 VOUT_DISPLAY_EVENT_FULLSCREEN
,
176 VOUT_DISPLAY_EVENT_WINDOW_STATE
,
180 VOUT_DISPLAY_EVENT_MOUSE_MOVED
,
181 VOUT_DISPLAY_EVENT_MOUSE_PRESSED
,
182 VOUT_DISPLAY_EVENT_MOUSE_RELEASED
,
183 VOUT_DISPLAY_EVENT_MOUSE_DOUBLE_CLICK
,
186 VOUT_DISPLAY_EVENT_VIEWPOINT_MOVED
,
190 * Vout owner structures
192 struct vout_display_owner_t
{
193 /* Private place holder for the vout_display_t creator
197 /* Event coming from the module
199 * This function is set prior to the module instantiation and must not
200 * be overwritten nor used directly (use the vout_display_SendEvent*
203 * You can send it at any time i.e. from any vout_display_t functions or
204 * from another thread.
205 * Be careful, it does not ensure correct serialization if it is used
206 * from multiple threads.
208 void (*event
)(vout_display_t
*, int, va_list);
211 struct vout_display_t
{
212 struct vlc_common_members obj
;
217 /* Initial and current configuration.
218 * You cannot modify it directly, you must use the appropriate events.
220 * It reflects the current values, i.e. after the event has been accepted
221 * and applied/configured if needed.
223 const vout_display_cfg_t
*cfg
;
225 /* video source format.
227 * Cropping is not requested while in the open function.
228 * You cannot change it.
230 video_format_t source
;
234 * You can only change it inside the module open function to
235 * match what you want, and when a VOUT_DISPLAY_RESET_PICTURES control
236 * request is made and succeeds.
238 * By default, it is equal to ::source except for the aspect ratio
239 * which is undefined(0) and is ignored.
245 * You can only set them in the open function.
247 vout_display_info_t info
;
249 /* Return a pointer over the current picture_pool_t* (mandatory).
251 * For performance reasons, it is best to provide at least count
252 * pictures but it is not mandatory.
253 * You can return NULL when you cannot/do not want to allocate
255 * The vout display module keeps the ownership of the pool and can
256 * destroy it only when closing or on invalid pictures control.
258 picture_pool_t
*(*pool
)(vout_display_t
*, unsigned count
);
260 /* Prepare a picture and an optional subpicture for display (optional).
262 * It is called before the next pf_display call to provide as much
263 * time as possible to prepare the given picture and the subpicture
265 * You are guaranted that pf_display will always be called and using
266 * the exact same picture_t and subpicture_t.
267 * You cannot change the pixel content of the picture_t or of the
270 void (*prepare
)(vout_display_t
*, picture_t
*, subpicture_t
*,
273 /* Display a picture and an optional subpicture (mandatory).
275 * The picture and the optional subpicture must be displayed as soon as
277 * You cannot change the pixel content of the picture_t or of the
280 * This function gives away the ownership of the picture and of the
281 * subpicture, so you must release them as soon as possible.
283 void (*display
)(vout_display_t
*, picture_t
*, subpicture_t
*);
285 /* Control on the module (mandatory) */
286 int (*control
)(vout_display_t
*, int, va_list);
288 /* Private place holder for the vout_display_t module (optional)
290 * A module is free to use it as it wishes.
292 vout_display_sys_t
*sys
;
294 /* Reserved for the vout_display_t owner.
296 * It must not be overwritten nor used directly by a module.
298 vout_display_owner_t owner
;
301 static inline void vout_display_SendEvent(vout_display_t
*vd
, int query
, ...)
304 va_start(args
, query
);
305 vd
->owner
.event(vd
, query
, args
);
309 VLC_DEPRECATED
/* Use vout_window_ReportSize() in window provider instead. */
310 static inline void vout_display_SendEventDisplaySize(vout_display_t
*vd
,
311 int width
, int height
)
313 vout_window_ReportSize(vd
->cfg
->window
, width
, height
);
316 static inline void vout_display_SendEventPicturesInvalid(vout_display_t
*vd
)
318 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_PICTURES_INVALID
);
321 VLC_DEPRECATED
/* Use vout_window_ReportClose() in window provider instead. */
322 static inline void vout_display_SendEventClose(vout_display_t
*vd
)
324 vout_window_ReportClose(vd
->cfg
->window
);
327 #if defined(_WIN32) || defined(__OS2__)
329 /* Use vout_window_ReportKeyPress() in window provider instead. */
330 static inline void vout_display_SendEventKey(vout_display_t
*vd
, int key
)
332 vout_window_ReportKeyPress(vd
->cfg
->window
, key
);
335 static inline void vout_display_SendEventFullscreen(vout_display_t
*vd
, bool is_fullscreen
)
337 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_FULLSCREEN
, is_fullscreen
);
340 VLC_DEPRECATED
/* Core needs not know about this. Don't call. */
341 static inline void vout_display_SendWindowState(vout_display_t
*vd
, unsigned state
)
343 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_WINDOW_STATE
, state
);
346 static inline void vout_display_SendEventMouseMoved(vout_display_t
*vd
, int x
, int y
)
348 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_MOUSE_MOVED
, x
, y
);
350 static inline void vout_display_SendEventMousePressed(vout_display_t
*vd
, int button
)
352 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_MOUSE_PRESSED
, button
);
354 static inline void vout_display_SendEventMouseReleased(vout_display_t
*vd
, int button
)
356 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_MOUSE_RELEASED
, button
);
358 static inline void vout_display_SendEventMouseDoubleClick(vout_display_t
*vd
)
360 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_MOUSE_DOUBLE_CLICK
);
362 static inline void vout_display_SendEventViewpointMoved(vout_display_t
*vd
,
363 const vlc_viewpoint_t
*vp
)
365 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_VIEWPOINT_MOVED
, vp
);
369 * Asks for a new window of a given type.
371 static inline vout_window_t
*vout_display_NewWindow(vout_display_t
*vd
, unsigned type
)
373 vout_window_t
*wnd
= vd
->cfg
->window
;
375 return (type
== wnd
->type
) ? wnd
: NULL
;
378 static inline bool vout_display_IsWindowed(vout_display_t
*vd
)
380 return vd
->cfg
->window
->type
!= VOUT_WINDOW_TYPE_DUMMY
;
384 * Computes the default display size given the source and
385 * the display configuration.
387 * This asssumes that the picture is already cropped.
389 VLC_API
void vout_display_GetDefaultDisplaySize(unsigned *width
, unsigned *height
, const video_format_t
*source
, const vout_display_cfg_t
*);
393 * Structure used to store the result of a vout_display_PlacePicture.
400 } vout_display_place_t
;
403 * Computes how to place a picture inside the display to respect
404 * the given parameters.
405 * This assumes that cropping is done by an external mean.
407 * \param p_place Place inside the window (window pixel unit)
408 * \param p_source Video source format
409 * \param p_cfg Display configuration
410 * \param b_clip If true, prevent the video to go outside the display (break zoom).
412 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
);
416 * Helper function that applies the necessary transforms to the mouse position
417 * and then calls vout_display_SendEventMouseMoved.
419 * \param vd vout_display_t.
420 * \param orient_display The orientation of the picture as seen on screen (probably ORIENT_NORMAL).
421 * \param m_x Mouse x position (relative to place, origin is top left).
422 * \param m_y Mouse y position (relative to place, origin is top left).
423 * \param place Place of the picture.
425 VLC_API
void vout_display_SendMouseMovedDisplayCoordinates(vout_display_t
*vd
, video_orientation_t orient_display
, int m_x
, int m_y
,
426 vout_display_place_t
*place
);
429 #endif /* VLC_VOUT_DISPLAY_H */