struct vout_window_t {
VLC_COMMON_MEMBERS
- /* Initial state (reserved).
- * Once the open function is called, it will be set to NULL
- */
- const vout_window_cfg_t *cfg;
-
/* window handle (mandatory)
*
* It must be filled in the open function.
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int Open ( vlc_object_t * );
-static void Close ( vlc_object_t * );
-static void *Thread ( void * );
-static int OpenWindow ( vlc_object_t * );
-static void CloseWindow ( vlc_object_t * );
-static int ControlWindow ( vout_window_t *, int, va_list );
-static gboolean interface_ready ( gpointer );
+static int Open ( vlc_object_t * );
+static void Close ( vlc_object_t * );
+static void *Thread ( void * );
+static int OpenWindow ( vout_window_t *, const vout_window_cfg_t * );
+static void CloseWindow ( vout_window_t * );
+static int ControlWindow ( vout_window_t *, int, va_list );
+static gboolean interface_ready ( gpointer );
/*****************************************************************************
* Module descriptor
/**
* Video output window provider
*/
-static int OpenWindow (vlc_object_t *p_obj)
+static int OpenWindow (vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
{
- vout_window_t *p_wnd = (vout_window_t *)p_obj;
intf_thread_t *p_intf;
vlc_value_t val;
- if (p_wnd->cfg->is_standalone)
+ if (cfg->is_standalone)
return VLC_EGENERIC;
if( var_Get( p_obj->p_libvlc, "hildon-iface", &val ) )
}
}
-static void CloseWindow (vlc_object_t *p_obj)
+static void CloseWindow (vout_window_t *p_wnd)
{
- vout_window_t *p_wnd = (vout_window_t *)p_obj;
intf_thread_t *p_intf = (intf_thread_t *)p_wnd->sys;
if( p_intf->p_sys->b_fullscreen )
#include "../../../share/icons/32x32/vlc.xpm"
#include "../../../share/icons/32x32/vlc-xmas.xpm"
#include <vlc_plugin.h>
+#include <vlc_vout_window.h>
#ifdef WIN32 /* For static builds */
#include <QtPlugin>
static int OpenDialogs ( vlc_object_t * );
static int Open ( vlc_object_t *, bool );
static void Close ( vlc_object_t * );
-static int WindowOpen ( vlc_object_t * );
-static void WindowClose ( vlc_object_t * );
+static int WindowOpen ( vout_window_t *, const vout_window_cfg_t * );
+static void WindowClose ( vout_window_t * );
static void *Thread ( void * );
static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
*
* TODO move it out of here ?
*/
-#include <vlc_vout_window.h>
-
static int WindowControl( vout_window_t *, int i_query, va_list );
-static int WindowOpen( vlc_object_t *p_obj )
+static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg )
{
- vout_window_t *p_wnd = (vout_window_t*)p_obj;
-
/* */
- if( p_wnd->cfg->is_standalone )
+ if( cfg->is_standalone )
return VLC_EGENERIC;
#if defined (Q_WS_X11)
- if( var_InheritBool( p_obj, "video-wallpaper" ) )
+ if( var_InheritBool( p_wnd, "video-wallpaper" ) )
return VLC_EGENERIC;
#endif
- vlc_value_t val;
- if( var_Inherit( p_obj, "qt4-iface", VLC_VAR_ADDRESS, &val ) )
- val.p_address = NULL;
-
- intf_thread_t *p_intf = (intf_thread_t *)val.p_address;
-
+ intf_thread_t *p_intf =
+ (intf_thread_t *)var_InheritAddress( p_wnd, "qt4-iface" );
if( !p_intf )
{ /* If another interface is used, this plugin cannot work */
- msg_Dbg( p_obj, "Qt4 interface not found" );
+ msg_Dbg( p_wnd, "Qt4 interface not found" );
return VLC_EGENERIC;
}
return VLC_EGENERIC;
MainInterface *p_mi = p_intf->p_sys->p_mi;
- msg_Dbg( p_obj, "requesting video..." );
+ msg_Dbg( p_wnd, "requesting video..." );
- int i_x = p_wnd->cfg->x;
- int i_y = p_wnd->cfg->y;
- unsigned i_width = p_wnd->cfg->width;
- unsigned i_height = p_wnd->cfg->height;
+ int i_x = cfg->x;
+ int i_y = cfg->y;
+ unsigned i_width = cfg->width;
+ unsigned i_height = cfg->height;
#if defined (Q_WS_X11)
p_wnd->handle.xid = p_mi->getVideo( &i_x, &i_y, &i_width, &i_height );
return p_mi->controlVideo( i_query, args );
}
-static void WindowClose( vlc_object_t *p_obj )
+static void WindowClose( vout_window_t *p_wnd )
{
- vout_window_t *p_wnd = (vout_window_t*)p_obj;
MainInterface *p_mi = (MainInterface *)p_wnd->sys;
QMutexLocker locker (&lock);
* XCB and Xlib-XCB are fine with that. Plain Xlib wouldn't, */
if (unlikely(!active))
{
- msg_Warn (p_obj, "video already released");
+ msg_Warn (p_wnd, "video already released");
return;
}
- msg_Dbg (p_obj, "releasing video...");
+ msg_Dbg (p_wnd, "releasing video...");
p_mi->releaseVideo();
}
static vlc_mutex_t serializer = VLC_STATIC_MUTEX;
// Callbacks for vout requests
-static int WindowOpen( vlc_object_t *p_this )
+static int WindowOpen( vout_window_t *pWnd, const vout_window_cfg_t *cfg )
{
- vout_window_t *pWnd = (vout_window_t *)p_this;
-
vlc_mutex_lock( &skin_load.mutex );
intf_thread_t *pIntf = skin_load.intf;
if( pIntf )
if( !vlc_object_alive( pIntf ) ||
!var_InheritBool( pIntf, "skinned-video") ||
- pWnd->cfg->is_standalone )
+ cfg->is_standalone )
{
vlc_object_release( pIntf );
return VLC_EGENERIC;
}
}
-static void WindowClose( vlc_object_t *p_this )
+static void WindowClose( vout_window_t *pWnd )
{
- vout_window_t *pWnd = (vout_window_t *)p_this;
intf_thread_t *pIntf = (intf_thread_t *)pWnd->sys;
vlc_mutex_lock( &serializer );
#include <vlc_plugin.h>
#include <vlc_vout_window.h>
-static int Open (vlc_object_t *);
-static void Close(vlc_object_t *);
+static int Open (vout_window_t *, const vout_window_cfg_t *);
+static void Close(vout_window_t *);
/*
* Module descriptor
/**
* Find the drawable set by libvlc application.
*/
-static int Open (vlc_object_t *obj)
+static int Open (vout_window_t *wnd)
{
- vout_window_t *wnd = (vout_window_t *)obj;
void **used, *val;
size_t n = 0;
- if (var_Create (obj->p_libvlc, "hwnd-in-use", VLC_VAR_ADDRESS)
- || var_Create (obj, "drawable-hwnd", VLC_VAR_DOINHERIT | VLC_VAR_ADDRESS))
+ if (var_Create (wnd->p_libvlc, "hwnd-in-use", VLC_VAR_ADDRESS)
+ || var_Create (wnd, "drawable-hwnd", VLC_VAR_DOINHERIT | VLC_VAR_ADDRESS))
return VLC_ENOMEM;
- val = var_GetAddress (obj, "drawable-hwnd");
- var_Destroy (obj, "drawable-hwnd");
+ val = var_GetAddress (wnd, "drawable-hwnd");
+ var_Destroy (wnd, "drawable-hwnd");
/* Keep a list of busy drawables, so we don't overlap videos if there are
* more than one video track in the stream. */
vlc_mutex_lock (&serializer);
- used = var_GetAddress (obj->p_libvlc, "hwnd-in-use");
+ used = var_GetAddress (wnd->p_libvlc, "hwnd-in-use");
if (used != NULL)
{
while (used[n] != NULL)
{
used[n] = val;
used[n + 1] = NULL;
- var_SetAddress (obj->p_libvlc, "hwnd-in-use", used);
+ var_SetAddress (wnd->p_libvlc, "hwnd-in-use", used);
}
else
{
/**
* Release the drawable.
*/
-static void Close (vlc_object_t *obj)
+static void Close (vout_window_t *wnd)
{
- vout_window_t *wnd = (vout_window_t *)obj;
void **used, *val = wnd->sys;
size_t n = 0;
/* Remove this drawable from the list of busy ones */
vlc_mutex_lock (&serializer);
- used = var_GetAddress (obj->p_libvlc, "hwnd-in-use");
+ used = var_GetAddress (wnd->p_libvlc, "hwnd-in-use");
assert (used);
while (used[n] != val)
{
while (used[++n] != NULL);
if (n == 0)
- var_SetAddress (obj->p_libvlc, "hwnd-in-use", NULL);
+ var_SetAddress (wnd->p_libvlc, "hwnd-in-use", NULL);
vlc_mutex_unlock (&serializer);
if (n == 0)
free (used);
/* Variables are reference-counted... */
- var_Destroy (obj->p_libvlc, "hwnd-in-use");
+ var_Destroy (wnd->p_libvlc, "hwnd-in-use");
}
"VLC can embed its video output in an existing X11 window. " \
"This is the X identifier of that window (0 means none).")
-static int Open (vlc_object_t *);
-static void Close (vlc_object_t *);
-static int EmOpen (vlc_object_t *);
-static void EmClose (vlc_object_t *);
+static int Open (vout_window_t *, const vout_window_cfg_t *);
+static void Close (vout_window_t *);
+static int EmOpen (vout_window_t *, const vout_window_cfg_t *);
+static void EmClose (vout_window_t *);
/*
* Module descriptor
/**
* Create an X11 window.
*/
-static int Open (vlc_object_t *obj)
+static int Open (vout_window_t *wnd, const vout_window_cfg_t *cfg)
{
- vout_window_t *wnd = (vout_window_t *)obj;
xcb_generic_error_t *err;
xcb_void_cookie_t ck;
xcb_window_t window = xcb_generate_id (conn);
ck = xcb_create_window_checked (conn, scr->root_depth, window, scr->root,
- wnd->cfg->x, wnd->cfg->y,
- wnd->cfg->width, wnd->cfg->height, 0,
+ cfg->x, cfg->y, cfg->width, cfg->height, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
scr->root_visual, mask, values);
err = xcb_request_check (conn, ck);
wnd->sys = p_sys;
p_sys->conn = conn;
- if (var_InheritBool (obj, "keyboard-events"))
- p_sys->keys = CreateKeyHandler (obj, conn);
+ if (var_InheritBool (wnd, "keyboard-events"))
+ p_sys->keys = CreateKeyHandler (VLC_OBJECT(wnd), conn);
else
p_sys->keys = NULL;
p_sys->root = scr->root;
/* Make the window visible */
xcb_map_window (conn, window);
- if (var_InheritBool (obj, "video-wallpaper"))
+ if (var_InheritBool (wnd, "video-wallpaper"))
{
vout_window_SetState (wnd, VOUT_WINDOW_STATE_BELOW);
vout_window_SetFullScreen (wnd, true);
/**
* Destroys the X11 window.
*/
-static void Close (vlc_object_t *obj)
+static void Close (vout_window_t *wnd)
{
- vout_window_t *wnd = (vout_window_t *)obj;
vout_window_sys_t *p_sys = wnd->sys;
xcb_connection_t *conn = p_sys->conn;
/**
* Wrap an existing X11 window to embed the video.
*/
-static int EmOpen (vlc_object_t *obj)
+static int EmOpen (vout_window_t *wnd, const vout_window_cfg_t *cfg)
{
- vout_window_t *wnd = (vout_window_t *)obj;
-
- xcb_window_t window = var_InheritInteger (obj, "drawable-xid");
+ xcb_window_t window = var_InheritInteger (wnd, "drawable-xid");
if (window == 0)
return VLC_EGENERIC;
- if (AcquireDrawable (obj, window))
+ if (AcquireDrawable (VLC_OBJECT(wnd), window))
return VLC_EGENERIC;
vout_window_sys_t *p_sys = malloc (sizeof (*p_sys));
xcb_get_geometry_reply (conn, xcb_get_geometry (conn, window), NULL);
if (geo == NULL)
{
- msg_Err (obj, "bad X11 window 0x%08"PRIx8, window);
+ msg_Err (wnd, "bad X11 window 0x%08"PRIx8, window);
goto error;
}
p_sys->root = geo->root;
free (geo);
- if (var_InheritBool (obj, "keyboard-events"))
+ if (var_InheritBool (wnd, "keyboard-events"))
{
- p_sys->keys = CreateKeyHandler (obj, conn);
+ p_sys->keys = CreateKeyHandler (VLC_OBJECT(wnd), conn);
if (p_sys->keys != NULL)
{
const uint32_t mask = XCB_CW_EVENT_MASK;
DestroyKeyHandler (p_sys->keys);
xcb_flush (conn);
-
+ (void) cfg;
return VLC_SUCCESS;
error:
xcb_disconnect (conn);
free (p_sys);
- ReleaseDrawable (obj, window);
+ ReleaseDrawable (VLC_OBJECT(wnd), window);
return VLC_EGENERIC;
}
-static void EmClose (vlc_object_t *obj)
+static void EmClose (vout_window_t *wnd)
{
- vout_window_t *wnd = (vout_window_t *)obj;
xcb_window_t window = wnd->handle.xid;
- Close (obj);
- ReleaseDrawable (obj, window);
+ Close (wnd);
+ ReleaseDrawable (VLC_OBJECT(wnd), window);
}
vlc_inhibit_t *inhibit;
} window_t;
+static int vout_window_start(void *func, va_list ap)
+{
+ int (*activate)(vout_window_t *, const vout_window_cfg_t *) = func;
+ vout_window_t *wnd = va_arg(ap, vout_window_t *);
+ const vout_window_cfg_t *cfg = va_arg(ap, const vout_window_cfg_t *);
+
+ return activate(wnd, cfg);
+}
+
vout_window_t *vout_window_New(vlc_object_t *obj,
const char *module,
const vout_window_cfg_t *cfg)
window_t *w = vlc_custom_create(obj, sizeof(*w), VLC_OBJECT_GENERIC, name);
vout_window_t *window = &w->wnd;
- window->cfg = cfg;
memset(&window->handle, 0, sizeof(window->handle));
window->control = NULL;
window->sys = NULL;
assert(0);
}
- w->module = module_need(window, type, module, module && *module != '\0');
+ w->module = vlc_module_load(window, type, module, module && *module,
+ vout_window_start, window, cfg);
if (!w->module) {
vlc_object_release(window);
return NULL;
return window;
}
+static void vout_window_stop(void *func, va_list ap)
+{
+ int (*deactivate)(vout_window_t *) = func;
+ vout_window_t *wnd = va_arg(ap, vout_window_t *);
+
+ deactivate(wnd);
+}
+
void vout_window_Delete(vout_window_t *window)
{
if (!window)
vlc_inhibit_Destroy (w->inhibit);
}
- module_unneed(window, w->module);
-
+ vlc_module_unload(w->module, vout_window_stop, window);
vlc_object_release(window);
}