#include <vlc_vout.h>
#include <vlc_window.h>
-static int Open (vlc_object_t *);
+static int OpenXID (vlc_object_t *);
+static int OpenHWND (vlc_object_t *);
static void Close (vlc_object_t *);
+#define XID_TEXT N_("ID of the video output X window")
+#define XID_LONGTEXT N_( \
+ "VLC can embed its video output in an existing X11 window. " \
+ "This is the X identifier of that window (0 means none).")
+
/*
* Module descriptor
*/
vlc_module_begin ()
set_shortname (N_("Drawable"))
- set_description (N_("External embedded video window"))
+ set_description (N_("Embedded X window video"))
set_category (CAT_VIDEO)
set_subcategory (SUBCAT_VIDEO_VOUT)
-#ifdef WIN32
- set_capability ("hwnd", 70)
-#else
set_capability ("xwindow", 70)
-#endif
- set_callbacks (Open, Close)
+ set_callbacks (OpenXID, Close)
+ add_integer ("drawable-xid", 0, NULL, XID_TEXT, XID_LONGTEXT, true)
+ change_unsaveable ()
+ /*change_integer_range (0, 0xffffffff)*/
+
+ add_submodule ()
+ set_description (N_("Embedded Windows video"))
+ set_capability ("hwnd", 70)
+ set_callbacks (OpenHWND, Close)
vlc_module_end ()
/**
* Find the drawable set by libvlc application.
*/
-static int Open (vlc_object_t *obj)
+static int Open (vlc_object_t *obj, const char *varname, bool ptr)
{
- static vlc_mutex_t serializer = VLC_STATIC_MUTEX;
vout_window_t *wnd = (vout_window_t *)obj;
- int drawable = 0;
+ vlc_value_t val;
- if (var_Create (obj->p_libvlc, "drawable-busy", VLC_VAR_BOOL))
+ if (var_Create (obj, varname, VLC_VAR_DOINHERIT
+ | (ptr ? VLC_VAR_ADDRESS : VLC_VAR_INTEGER)))
return VLC_ENOMEM;
+ var_Get (obj, varname, &val);
+ var_Destroy (obj, varname);
- vlc_mutex_lock (&serializer);
- /* Note: We cannot simply clear the drawable variable.
- * It would break libvlc_video_get_parent(). */
- if (!var_GetBool (obj->p_libvlc, "drawable-busy"))
- {
- /* TODO: implement separate variables for XIDs and HWNDs */
- drawable = var_GetInteger (obj->p_libvlc, "drawable");
- if (drawable != 0)
- var_SetBool (obj->p_libvlc, "drawable-busy", true);
- }
- vlc_mutex_unlock (&serializer);
-
- if (drawable == 0)
- {
- var_Destroy (obj->p_libvlc, "drawable-busy");
+ if (ptr ? (val.p_address == NULL) : (val.i_int == 0))
return VLC_EGENERIC;
- }
-#ifdef WIN32
- /* FIXME: don't loose critical bits on Win64 */
- wnd->handle.hwnd = (void *)drawable;
-#else
+ if (ptr)
+ wnd->handle.hwnd = val.p_address;
+ else
+ wnd->handle.xid = val.i_int;
+
/* FIXME: check that X server matches --x11-display (if specified) */
- /* FIXME: get X drawable dimensions */
- wnd->handle.xid = drawable;
-#endif
/* FIXME: get window size (in platform-dependent ways) */
wnd->control = Control;
return VLC_SUCCESS;
}
+static int OpenXID (vlc_object_t *obj)
+{
+ return Open (obj, "drawable-xid", false);
+}
+
+static int OpenHWND (vlc_object_t *obj)
+{
+ return Open (obj, "drawable-hwnd", true);
+}
+
/**
* Release the drawable.
*/
static void Close (vlc_object_t *obj)
{
- /* This is atomic with regards to var_GetBool() in Open(): */
- var_SetBool (obj->p_libvlc, "drawable-busy", false);
-
- /* Variables are reference-counted... */
- var_Destroy (obj->p_libvlc, "drawable-busy");
+ (void)obj;
}
{
switch (query)
{
- case VOUT_GET_SIZE:
- {
- unsigned int *pi_width = va_arg (ap, unsigned int *);
- unsigned int *pi_height = va_arg (ap, unsigned int *);
- *pi_width = wnd->width;
- *pi_height = wnd->height;
- return VLC_SUCCESS;
- }
-
case VOUT_SET_SIZE: /* not allowed */
case VOUT_SET_STAY_ON_TOP: /* not allowed either, would be ugly */
return VLC_EGENERIC;