+
+/**
+ * Video output window provider
+ */
+#include <vlc_window.h>
+
+static int WindowControl (vout_window_t *, int, va_list);
+
+static int WindowOpen (vlc_object_t *obj)
+{
+ vout_window_t *wnd = (vout_window_t *)obj;
+
+ if (config_GetInt (obj, "embedded-video") <= 0)
+ return VLC_EGENERIC;
+
+ intf_thread_t *intf = (intf_thread_t *)
+ vlc_object_find_name (obj, "qt4", FIND_ANYWHERE);
+ if (intf == NULL)
+ return VLC_EGENERIC; /* Qt4 not in use */
+ assert (intf->i_object_type == VLC_OBJECT_INTF);
+
+ var_Create (intf, "window_widget", VLC_VAR_ADDRESS);
+
+ vlc_value_t ptrval;
+
+ windowLock.lock ();
+ msg_Dbg (obj, "waiting for interface...");
+ for (;;)
+ {
+ var_Get (intf, "window_widget", &ptrval);
+ if (ptrval.p_address != NULL)
+ break;
+ windowWait.wait (&windowLock);
+ }
+
+ msg_Dbg (obj, "requesting window...");
+ QPointer<MainInterface> *miP = (QPointer<MainInterface> *)ptrval.p_address;
+ miP = new QPointer<MainInterface> (*miP); /* create our own copy */
+ vlc_object_release (intf);
+
+ if (miP->isNull ())
+ return VLC_EGENERIC;
+
+ wnd->handle = (*miP)->requestVideo (wnd->vout, &wnd->pos_x, &wnd->pos_y,
+ &wnd->width, &wnd->height);
+ windowLock.unlock ();
+ wnd->control = WindowControl;
+ wnd->p_private = miP;
+ return VLC_SUCCESS;
+}
+
+static int WindowControl (vout_window_t *wnd, int query, va_list args)
+{
+ QPointer<MainInterface> *miP = (QPointer<MainInterface> *)wnd->p_private;
+ QMutexLocker locker (&windowLock);
+
+ if (miP->isNull ())
+ return VLC_EGENERIC;
+ return (*miP)->controlVideo (wnd->handle, query, args);
+}
+
+static void WindowClose (vlc_object_t *obj)
+{
+ vout_window_t *wnd = (vout_window_t *)obj;
+ QPointer<MainInterface> *miP = (QPointer<MainInterface> *)wnd->p_private;
+ QMutexLocker locker (&windowLock);
+
+ if (!miP->isNull ())
+ (*miP)->releaseVideo( wnd->vout, wnd->handle );
+ delete miP;
+}