packetizer: h264: use poc to compute missing pic_struct
[vlc.git] / include / vlc_vout_window.h
blob69a719bd2a59698d5d1f5b48e6ffa26c860a237e
1 /*****************************************************************************
2 * vlc_vout_window.h: vout_window_t definitions
3 *****************************************************************************
4 * Copyright (C) 2008 RĂ©mi Denis-Courmont
5 * Copyright (C) 2009 Laurent Aimar
6 * $Id$
8 * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #ifndef VLC_VOUT_WINDOW_H
26 #define VLC_VOUT_WINDOW_H 1
28 #include <stdarg.h>
29 #include <vlc_common.h>
31 /**
32 * \defgroup video_window Video window
33 * \ingroup video_output
34 * Video output window management
35 * @{
36 * \file
37 * Video output window modules interface
40 typedef struct vout_window_t vout_window_t;
41 typedef struct vout_window_sys_t vout_window_sys_t;
43 struct wl_display;
44 struct wl_surface;
46 /**
47 * Window handle type
49 enum {
50 VOUT_WINDOW_TYPE_INVALID=0,
51 VOUT_WINDOW_TYPE_XID,
52 VOUT_WINDOW_TYPE_HWND,
53 VOUT_WINDOW_TYPE_NSOBJECT,
54 VOUT_WINDOW_TYPE_ANDROID_NATIVE,
55 VOUT_WINDOW_TYPE_WAYLAND,
58 /**
59 * Control query for vout_window_t
61 enum {
62 VOUT_WINDOW_SET_STATE, /* unsigned state */
63 VOUT_WINDOW_SET_SIZE, /* unsigned i_width, unsigned i_height */
64 VOUT_WINDOW_SET_FULLSCREEN, /* int b_fullscreen */
65 VOUT_WINDOW_HIDE_MOUSE, /* bool b_hide */
68 /**
69 * Window mouse event type for vout_window_mouse_event_t
71 enum vout_window_mouse_event_type {
72 VOUT_WINDOW_MOUSE_STATE,
73 VOUT_WINDOW_MOUSE_MOVED,
74 VOUT_WINDOW_MOUSE_PRESSED,
75 VOUT_WINDOW_MOUSE_RELEASED,
76 VOUT_WINDOW_MOUSE_DOUBLE_CLICK,
79 /**
80 * Window mouse event
82 typedef struct vout_window_mouse_event_t
84 enum vout_window_mouse_event_type type;
85 int x;
86 int y;
87 int button_mask;
88 } vout_window_mouse_event_t;
90 typedef struct vout_window_cfg_t {
91 /* Window handle type */
92 unsigned type;
94 /* If true, a standalone window is requested */
95 bool is_standalone;
96 bool is_fullscreen;
98 #ifdef __APPLE__
99 /* Window position hint */
100 int x;
101 int y;
102 #endif
104 /* Windows size hint */
105 unsigned width;
106 unsigned height;
108 } vout_window_cfg_t;
110 typedef struct vout_window_owner {
111 void *sys;
112 void (*resized)(vout_window_t *, unsigned width, unsigned height);
113 void (*closed)(vout_window_t *);
114 void (*mouse_event)(vout_window_t *, const vout_window_mouse_event_t *mouse);
115 } vout_window_owner_t;
118 * FIXME do we need an event system in the window too ?
119 * or the window user will take care of it ?
121 struct vout_window_t {
122 VLC_COMMON_MEMBERS
124 unsigned type; /**< Window handle type */
126 /* window handle (mandatory)
128 * It must be filled in the open function.
130 union {
131 void *hwnd; /* Win32 window handle */
132 uint32_t xid; /* X11 windows ID */
133 void *nsobject; /* Mac OSX view object */
134 void *anativewindow; /* Android native window. */
135 struct wl_surface *wl; /* Wayland surface */
136 } handle;
138 /* display server (mandatory) */
139 union {
140 char *x11; /* X11 display (NULL = use default) */
141 struct wl_display *wl; /* Wayland struct wl_display pointer */
142 } display;
144 /* Control on the module (mandatory)
146 * Do not use it directly; use vout_window_Control instead.
148 int (*control)(vout_window_t *, int query, va_list);
150 /* Private place holder for the vout_window_t module (optional)
152 * A module is free to use it as it wishes.
154 vout_window_sys_t *sys;
156 vout_window_owner_t owner;
160 * Creates a new window.
162 * @param module plugin name (usually "$window")
163 * @note If you are inside a "vout display", you must use
164 / vout_display_NewWindow() and vout_display_DeleteWindow() instead.
165 * This enables recycling windows.
167 VLC_API vout_window_t * vout_window_New(vlc_object_t *, const char *module, const vout_window_cfg_t *, const vout_window_owner_t *);
170 * Deletes a window created by vout_window_New().
172 * @note See vout_window_New() about window recycling.
174 VLC_API void vout_window_Delete(vout_window_t *);
176 static inline int vout_window_vaControl(vout_window_t *window, int query,
177 va_list ap)
179 return window->control(window, query, ap);
183 * Reconfigures a window.
185 * @note The vout_window_* wrappers should be used instead of this function.
187 * @warning The caller must own the window, as vout_window_t is not thread safe.
189 static inline int vout_window_Control(vout_window_t *window, int query, ...)
191 va_list ap;
192 int ret;
194 va_start(ap, query);
195 ret = vout_window_vaControl(window, query, ap);
196 va_end(ap);
197 return ret;
201 * Configures the window manager state for this window.
203 static inline int vout_window_SetState(vout_window_t *window, unsigned state)
205 return vout_window_Control(window, VOUT_WINDOW_SET_STATE, state);
209 * Configures the window display (i.e. inner/useful) size.
211 static inline int vout_window_SetSize(vout_window_t *window,
212 unsigned width, unsigned height)
214 return vout_window_Control(window, VOUT_WINDOW_SET_SIZE, width, height);
218 * Sets fullscreen mode.
220 static inline int vout_window_SetFullScreen(vout_window_t *window, bool full)
222 return vout_window_Control(window, VOUT_WINDOW_SET_FULLSCREEN, full);
226 * Hide the mouse cursor
228 static inline int vout_window_HideMouse(vout_window_t *window, bool hide)
230 return vout_window_Control(window, VOUT_WINDOW_HIDE_MOUSE, hide);
234 * Report current window size
236 * This notifies the user of the window what the pixel dimensions of the
237 * window are (or should be, depending on the windowing system).
239 * \note This function is thread-safe. In case of concurrent call, it is
240 * undefined which one is taken into account (but at least one is).
242 static inline void vout_window_ReportSize(vout_window_t *window,
243 unsigned width, unsigned height)
245 if (window->owner.resized != NULL)
246 window->owner.resized(window, width, height);
249 static inline void vout_window_ReportClose(vout_window_t *window)
251 if (window->owner.closed != NULL)
252 window->owner.closed(window);
255 static inline void vout_window_SendMouseEvent(vout_window_t *window,
256 const vout_window_mouse_event_t *mouse)
258 if (window->owner.mouse_event != NULL)
259 window->owner.mouse_event(window, mouse);
263 * Send a full mouse state
265 * The mouse position must be expressed against window unit. You can use this
266 * function of others vout_window_ReportMouse*() functions.
268 static inline void vout_window_ReportMouseState(vout_window_t *window,
269 int x, int y, int button_mask)
271 const vout_window_mouse_event_t mouse = {
272 VOUT_WINDOW_MOUSE_STATE, x, y, button_mask
274 vout_window_SendMouseEvent(window, &mouse);
278 * Send a mouse movement
280 * The mouse position must be expressed against window unit.
282 static inline void vout_window_ReportMouseMoved(vout_window_t *window,
283 int x, int y)
285 const vout_window_mouse_event_t mouse = {
286 VOUT_WINDOW_MOUSE_MOVED, x, y, 0
288 vout_window_SendMouseEvent(window, &mouse);
292 * Send a mouse pressed event
294 static inline void vout_window_ReportMousePressed(vout_window_t *window,
295 int button)
297 const vout_window_mouse_event_t mouse = {
298 VOUT_WINDOW_MOUSE_PRESSED, 0, 0, button,
300 vout_window_SendMouseEvent(window, &mouse);
304 * Send a mouse released event
306 static inline void vout_window_ReportMouseReleased(vout_window_t *window,
307 int button)
309 const vout_window_mouse_event_t mouse = {
310 VOUT_WINDOW_MOUSE_RELEASED, 0, 0, button,
312 vout_window_SendMouseEvent(window, &mouse);
316 * Send a mouse double click event
318 static inline void vout_window_ReportMouseDoubleClick(vout_window_t *window)
320 const vout_window_mouse_event_t mouse = {
321 VOUT_WINDOW_MOUSE_DOUBLE_CLICK, 0, 0, 0,
323 vout_window_SendMouseEvent(window, &mouse);
326 /** @} */
327 #endif /* VLC_VOUT_WINDOW_H */