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
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 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 General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, 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
29 * This file defines vout display structures and functions in vlc
33 #include <vlc_picture.h>
34 #include <vlc_picture_pool.h>
35 #include <vlc_subpicture.h>
37 #include <vlc_mouse.h>
38 #include <vlc_vout_window.h>
41 * Do NOT use video_format_t::i_aspect but i_sar_num/den everywhere. i_aspect
42 * will be removed as soon as possible.
45 typedef struct vout_display_t vout_display_t
;
46 typedef struct vout_display_sys_t vout_display_sys_t
;
47 typedef struct vout_display_owner_t vout_display_owner_t
;
48 typedef struct vout_display_owner_sys_t vout_display_owner_sys_t
;
51 * Possible alignments for vout_display.
55 VOUT_DISPLAY_ALIGN_CENTER
,
57 VOUT_DISPLAY_ALIGN_LEFT
,
58 VOUT_DISPLAY_ALIGN_RIGHT
,
60 VOUT_DISPLAY_ALIGN_TOP
,
61 VOUT_DISPLAY_ALIGN_BOTTOM
,
62 } vout_display_align_t
;
65 * Window management state.
68 VOUT_WINDOW_STATE_NORMAL
=0,
69 VOUT_WINDOW_STATE_ABOVE
=1,
70 VOUT_WINDOW_STATE_BELOW
=2,
71 VOUT_WINDOW_STACK_MASK
=3,
75 * Initial/Current configuration for a vout_display_t
78 bool is_fullscreen
; /* Is the display fullscreen */
80 /* Display properties */
82 /* Window title (may be NULL) */
96 /* Alignment of the picture inside the display */
102 /* Do we fill up the display with the video */
103 bool is_display_filled
;
106 * It will be applied to the whole display if b_display_filled is set, otherwise
107 * only on the video source */
113 } vout_display_cfg_t
;
116 * Information from a vout_display_t to configure
117 * the core behaviour.
119 * By default they are all false or NULL.
123 bool is_slow
; /* The picture memory has slow read/write */
124 bool has_double_click
; /* Is double-click generated */
125 bool has_hide_mouse
; /* Is mouse automatically hidden */
126 bool has_pictures_invalid
; /* Will VOUT_DISPLAY_EVENT_PICTURES_INVALID be used */
127 bool has_event_thread
; /* Will events (key at least) be emitted using an independent thread */
128 const vlc_fourcc_t
*subpicture_chromas
; /* List of supported chromas for subpicture rendering. */
129 } vout_display_info_t
;
132 * Control query for vout_display_t
135 /* Hide the mouse. It will be sent when
136 * vout_display_t::info.b_hide_mouse is false */
137 VOUT_DISPLAY_HIDE_MOUSE
,
139 /* Ask to reset the internal buffers after a VOUT_DISPLAY_EVENT_PICTURES_INVALID
142 VOUT_DISPLAY_RESET_PICTURES
,
144 /* Ask the module to acknowledge/refuse the fullscreen state change after
145 * being requested (externally or by VOUT_DISPLAY_EVENT_FULLSCREEN */
146 VOUT_DISPLAY_CHANGE_FULLSCREEN
, /* const vout_display_cfg_t *p_cfg */
148 /* Ask the module to acknowledge/refuse the window management state change
149 * after being requested externally or by VOUT_DISPLAY_WINDOW_STATE */
150 VOUT_DISPLAY_CHANGE_WINDOW_STATE
, /* unsigned state */
152 /* Ask the module to acknowledge/refuse the display size change requested
153 * (externally or by VOUT_DISPLAY_EVENT_DISPLAY_SIZE) */
154 VOUT_DISPLAY_CHANGE_DISPLAY_SIZE
, /* const vout_display_cfg_t *p_cfg, int is_forced */
156 /* Ask the module to acknowledge/refuse fill display state change after
157 * being requested externally */
158 VOUT_DISPLAY_CHANGE_DISPLAY_FILLED
, /* const vout_display_cfg_t *p_cfg */
160 /* Ask the module to acknowledge/refuse zoom change after being requested
162 VOUT_DISPLAY_CHANGE_ZOOM
, /* const vout_display_cfg_t *p_cfg */
164 /* Ask the module to acknowledge/refuse source aspect ratio after being
165 * requested externally */
166 VOUT_DISPLAY_CHANGE_SOURCE_ASPECT
, /* const video_format_t *p_source */
168 /* Ask the module to acknowledge/refuse source crop change after being
169 * requested externally.
170 * The cropping requested is stored by video_format_t::i_x/y_offset and
171 * video_format_t::i_visible_width/height */
172 VOUT_DISPLAY_CHANGE_SOURCE_CROP
, /* const video_format_t *p_source */
174 /* Ask an opengl interface if available. */
175 VOUT_DISPLAY_GET_OPENGL
, /* vlc_gl_t ** */
179 * Event from vout_display_t
181 * Events modifiying the state may be sent multiple times.
182 * Only the transition will be retained and acted upon.
186 * ZOOM ? DISPLAY_FILLED ? ON_TOP ?
189 VOUT_DISPLAY_EVENT_PICTURES_INVALID
, /* The buffer are now invalid and need to be changed */
191 VOUT_DISPLAY_EVENT_FULLSCREEN
,
192 VOUT_DISPLAY_EVENT_WINDOW_STATE
,
194 VOUT_DISPLAY_EVENT_DISPLAY_SIZE
, /* The display size need to change : int i_width, int i_height, bool is_fullscreen */
197 VOUT_DISPLAY_EVENT_CLOSE
,
198 VOUT_DISPLAY_EVENT_KEY
,
201 * You can use it OR use the other mouse events. The core will do
204 VOUT_DISPLAY_EVENT_MOUSE_STATE
,
207 VOUT_DISPLAY_EVENT_MOUSE_MOVED
,
208 VOUT_DISPLAY_EVENT_MOUSE_PRESSED
,
209 VOUT_DISPLAY_EVENT_MOUSE_RELEASED
,
210 VOUT_DISPLAY_EVENT_MOUSE_DOUBLE_CLICK
,
214 * Vout owner structures
216 struct vout_display_owner_t
{
217 /* Private place holder for the vout_display_t creator
219 vout_display_owner_sys_t
*sys
;
221 /* Event coming from the module
223 * This function is set prior to the module instantiation and must not
224 * be overwritten nor used directly (use the vout_display_SendEvent*
227 * You can send it at any time i.e. from any vout_display_t functions or
228 * from another thread.
229 * Be careful, it does not ensure correct serialization if it is used
230 * from multiple threads.
232 void (*event
)(vout_display_t
*, int, va_list);
236 * These functions are set prior to the module instantiation and must not
237 * be overwritten nor used directly (use the vout_display_*Window
239 vout_window_t
*(*window_new
)(vout_display_t
*, const vout_window_cfg_t
*);
240 void (*window_del
)(vout_display_t
*, vout_window_t
*);
243 struct vout_display_t
{
249 /* Initial and current configuration.
250 * You cannot modify it directly, you must use the appropriate events.
252 * It reflects the current values, i.e. after the event has been accepted
253 * and applied/configured if needed.
255 const vout_display_cfg_t
*cfg
;
257 /* video source format.
259 * Cropping is not requested while in the open function.
260 * You cannot change it.
262 video_format_t source
;
266 * You can only change it inside the module open function to
267 * match what you want, and when a VOUT_DISPLAY_RESET_PICTURES control
268 * request is made and succeeds.
270 * By default, it is equal to ::source except for the aspect ratio
271 * which is undefined(0) and is ignored.
277 * You can only set them in the open function.
279 vout_display_info_t info
;
281 /* Return a pointer over the current picture_pool_t* (mandatory).
283 * For performance reasons, it is best to provide at least count
284 * pictures but it is not mandatory.
285 * You can return NULL when you cannot/do not want to allocate
287 * The vout display module keeps the ownership of the pool and can
288 * destroy it only when closing or on invalid pictures control.
290 picture_pool_t
*(*pool
)(vout_display_t
*, unsigned count
);
292 /* Prepare a picture and an optional subpicture for display (optional).
294 * It is called before the next pf_display call to provide as much
295 * time as possible to prepare the given picture and the subpicture
297 * You are guaranted that pf_display will always be called and using
298 * the exact same picture_t and subpicture_t.
299 * You cannot change the pixel content of the picture_t or of the
302 void (*prepare
)(vout_display_t
*, picture_t
*, subpicture_t
*);
304 /* Display a picture and an optional subpicture (mandatory).
306 * The picture and the optional subpicture must be displayed as soon as
308 * You cannot change the pixel content of the picture_t or of the
311 * This function gives away the ownership of the picture and of the
312 * subpicture, so you must release them as soon as possible.
314 void (*display
)(vout_display_t
*, picture_t
*, subpicture_t
*);
316 /* Control on the module (mandatory) */
317 int (*control
)(vout_display_t
*, int, va_list);
319 /* Manage pending event (optional) */
320 void (*manage
)(vout_display_t
*);
322 /* Private place holder for the vout_display_t module (optional)
324 * A module is free to use it as it wishes.
326 vout_display_sys_t
*sys
;
328 /* Reserved for the vout_display_t owner.
330 * It must not be overwritten nor used directly by a module.
332 vout_display_owner_t owner
;
335 static inline void vout_display_SendEvent(vout_display_t
*vd
, int query
, ...)
338 va_start(args
, query
);
339 vd
->owner
.event(vd
, query
, args
);
343 static inline void vout_display_SendEventDisplaySize(vout_display_t
*vd
, int width
, int height
, bool is_fullscreen
)
345 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_DISPLAY_SIZE
, width
, height
, is_fullscreen
);
347 static inline void vout_display_SendEventPicturesInvalid(vout_display_t
*vd
)
349 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_PICTURES_INVALID
);
351 static inline void vout_display_SendEventClose(vout_display_t
*vd
)
353 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_CLOSE
);
355 static inline void vout_display_SendEventKey(vout_display_t
*vd
, int key
)
357 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_KEY
, key
);
359 static inline void vout_display_SendEventFullscreen(vout_display_t
*vd
, bool is_fullscreen
)
361 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_FULLSCREEN
, is_fullscreen
);
363 static inline void vout_display_SendWindowState(vout_display_t
*vd
, unsigned state
)
365 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_WINDOW_STATE
, state
);
367 /* The mouse position (State and Moved event) must be expressed against vout_display_t::source unit */
368 static inline void vout_display_SendEventMouseState(vout_display_t
*vd
, int x
, int y
, int button_mask
)
370 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_MOUSE_STATE
, x
, y
, button_mask
);
372 static inline void vout_display_SendEventMouseMoved(vout_display_t
*vd
, int x
, int y
)
374 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_MOUSE_MOVED
, x
, y
);
376 static inline void vout_display_SendEventMousePressed(vout_display_t
*vd
, int button
)
378 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_MOUSE_PRESSED
, button
);
380 static inline void vout_display_SendEventMouseReleased(vout_display_t
*vd
, int button
)
382 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_MOUSE_RELEASED
, button
);
384 static inline void vout_display_SendEventMouseDoubleClick(vout_display_t
*vd
)
386 vout_display_SendEvent(vd
, VOUT_DISPLAY_EVENT_MOUSE_DOUBLE_CLICK
);
390 * Asks for a new window with the given configuration as hint.
392 * b_standalone/i_x/i_y may be overwritten by the core
394 static inline vout_window_t
*vout_display_NewWindow(vout_display_t
*vd
, const vout_window_cfg_t
*cfg
)
396 return vd
->owner
.window_new(vd
, cfg
);
399 * Deletes a window created by vout_display_NewWindow if window is non NULL
400 * or any unused windows otherwise.
402 static inline void vout_display_DeleteWindow(vout_display_t
*vd
,
403 vout_window_t
*window
)
405 vd
->owner
.window_del(vd
, window
);
409 * Computes the default display size given the source and
410 * the display configuration.
412 * This asssumes that the picture is already cropped.
414 VLC_API
void vout_display_GetDefaultDisplaySize(unsigned *width
, unsigned *height
, const video_format_t
*source
, const vout_display_cfg_t
*);
418 * Structure used to store the result of a vout_display_PlacePicture.
425 } vout_display_place_t
;
428 * Computes how to place a picture inside the display to respect
429 * the given parameters.
430 * This assumes that cropping is done by an external mean.
432 * \param p_place Place inside the window (window pixel unit)
433 * \param p_source Video source format
434 * \param p_cfg Display configuration
435 * \param b_clip If true, prevent the video to go outside the display (break zoom).
437 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
);
439 #endif /* VLC_VOUT_DISPLAY_H */