vlc_vout_window.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_vout_window.h: vout_window_t definitions
00003  *****************************************************************************
00004  * Copyright (C) 2008 Rémi Denis-Courmont
00005  * Copyright (C) 2009 Laurent Aimar
00006  * $Id: ea5e82188fd5f5153ba7860d9e70e932c307c861 $
00007  *
00008  * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
00009  *
00010  * This program is free software; you can redistribute it and/or modify it
00011  * under the terms of the GNU Lesser General Public License as published by
00012  * the Free Software Foundation; either version 2.1 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018  * GNU Lesser General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Lesser General Public License
00021  * along with this program; if not, write to the Free Software Foundation,
00022  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef VLC_VOUT_WINDOW_H
00026 #define VLC_VOUT_WINDOW_H 1
00027 
00028 /**
00029  * \file
00030  * This file defines vout windows structures and functions in vlc
00031  */
00032 
00033 #include <vlc_common.h>
00034 
00035 /* */
00036 typedef struct vout_window_t vout_window_t;
00037 typedef struct vout_window_sys_t vout_window_sys_t;
00038 
00039 
00040 /**
00041  * Window handle type
00042  */
00043 enum {
00044     VOUT_WINDOW_TYPE_XID,
00045     VOUT_WINDOW_TYPE_HWND,
00046     VOUT_WINDOW_TYPE_NSOBJECT,
00047 };
00048 
00049 #if defined (WIN32) || defined (__OS2__)
00050 # define VOUT_WINDOW_TYPE_NATIVE VOUT_WINDOW_TYPE_HWND
00051 #elif defined (__unix__)
00052 # define VOUT_WINDOW_TYPE_NATIVE VOUT_WINDOW_TYPE_XID
00053 #endif
00054 
00055 /**
00056  * Control query for vout_window_t
00057  */
00058 enum {
00059     VOUT_WINDOW_SET_STATE, /* unsigned state */
00060     VOUT_WINDOW_SET_SIZE,   /* unsigned i_width, unsigned i_height */
00061     VOUT_WINDOW_SET_FULLSCREEN, /* int b_fullscreen */
00062 };
00063 
00064 typedef struct {
00065     /* If true, a standalone window is requested */
00066     bool is_standalone;
00067 
00068     /* Window handle type */
00069     int type;
00070 
00071     /* Window position hint */
00072     int x;
00073     int y;
00074 
00075     /* Windows size hint */
00076     unsigned width;
00077     unsigned height;
00078 
00079 } vout_window_cfg_t;
00080 
00081 /**
00082  * FIXME do we need an event system in the window too ?
00083  * or the window user will take care of it ?
00084  */
00085 struct vout_window_t {
00086     VLC_COMMON_MEMBERS
00087 
00088     /* window handle (mandatory)
00089      *
00090      * It must be filled in the open function.
00091      */
00092     union {
00093         void     *hwnd;     /* Win32 window handle */
00094         uint32_t xid;       /* X11 windows ID */
00095         void     *nsobject; /* Mac OSX view object */
00096     } handle;
00097 
00098     /* display server (mandatory) */
00099     union {
00100         char     *x11; /* X11 display (NULL = use default) */
00101     } display;
00102 
00103     /* Control on the module (mandatory)
00104      *
00105      * Do not use it directly; use vout_window_Control instead.
00106      */
00107     int (*control)(vout_window_t *, int query, va_list);
00108 
00109     /* Private place holder for the vout_window_t module (optional)
00110      *
00111      * A module is free to use it as it wishes.
00112      */
00113     vout_window_sys_t *sys;
00114 };
00115 
00116 /**
00117  * Creates a new window.
00118  *
00119  * @param module plugin name (usually "$window")
00120  * @note If you are inside a "vout display", you must use
00121  / vout_display_NewWindow() and vout_display_DeleteWindow() instead.
00122  * This enables recycling windows.
00123  */
00124 VLC_API vout_window_t * vout_window_New(vlc_object_t *, const char *module, const vout_window_cfg_t *);
00125 
00126 /**
00127  * Deletes a window created by vout_window_New().
00128  *
00129  * @note See vout_window_New() about window recycling.
00130  */
00131 VLC_API void vout_window_Delete(vout_window_t *);
00132 
00133 
00134 /**
00135  * Reconfigures a window.
00136  *
00137  * @note The vout_window_* wrappers should be used instead of this function.
00138  *
00139  * @warning The caller must own the window, as vout_window_t is not thread safe.
00140  */
00141 VLC_API int vout_window_Control(vout_window_t *, int query, ...);
00142 
00143 /**
00144  * Configures the window manager state for this window.
00145  */
00146 static inline int vout_window_SetState(vout_window_t *window, unsigned state)
00147 {
00148     return vout_window_Control(window, VOUT_WINDOW_SET_STATE, state);
00149 }
00150 
00151 /**
00152  * Configures the window display (i.e. inner/useful) size.
00153  */
00154 static inline int vout_window_SetSize(vout_window_t *window,
00155                                       unsigned width, unsigned height)
00156 {
00157     return vout_window_Control(window, VOUT_WINDOW_SET_SIZE, width, height);
00158 }
00159 
00160 /**
00161  * Sets fullscreen mode.
00162  */
00163 static inline int vout_window_SetFullScreen(vout_window_t *window, bool full)
00164 {
00165     return vout_window_Control(window, VOUT_WINDOW_SET_FULLSCREEN, full);
00166 }
00167 
00168 #endif /* VLC_VOUT_WINDOW_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines