}
static gboolean
-gst_vaapi_window_create(GstVaapiWindow *window, guint width, guint height)
+gst_vaapi_window_create(GstVaapiWindow *window)
{
- if (width == 0 || height == 0)
+ GstVaapiWindowPrivate * const priv = window->priv;
+ guint width, height;
+
+ width = priv->width;
+ height = priv->height;
+
+ if (!GST_VAAPI_WINDOW_GET_CLASS(window)->create(window, &width, &height))
return FALSE;
- return GST_VAAPI_WINDOW_GET_CLASS(window)->create(window, width, height);
+ if (width != priv->width || height != priv->height) {
+ GST_DEBUG("backend resized window to %ux%u", width, height);
+ priv->width = width;
+ priv->height = height;
+ }
+ return TRUE;
}
static void
GstVaapiWindow * const window = GST_VAAPI_WINDOW(object);
GObjectClass *parent_class;
- window->priv->is_constructed = gst_vaapi_window_create(
- window,
- window->priv->width,
- window->priv->height
- );
+ window->priv->is_constructed = gst_vaapi_window_create(window);
parent_class = G_OBJECT_CLASS(gst_vaapi_window_parent_class);
if (parent_class->constructed)
/*< private >*/
GObjectClass parent_class;
- gboolean (*create) (GstVaapiWindow *window, guint width, guint height);
+ gboolean (*create) (GstVaapiWindow *window, guint *width, guint *height);
void (*destroy)(GstVaapiWindow *window);
gboolean (*show) (GstVaapiWindow *window);
gboolean (*hide) (GstVaapiWindow *window);
}
static gboolean
-gst_vaapi_window_x11_create(GstVaapiWindow *window, guint width, guint height)
+gst_vaapi_window_x11_create(GstVaapiWindow *window, guint *width, guint *height)
{
GstVaapiWindowX11Private * const priv = GST_VAAPI_WINDOW_X11(window)->priv;
- Display *dpy;
-
- if (!priv->create_window && priv->xid)
- return TRUE;
+ Display * const dpy = GST_VAAPI_DISPLAY_XDISPLAY(priv->display);
+ gboolean ok;
- dpy = GST_VAAPI_DISPLAY_XDISPLAY(priv->display);
+ if (!priv->create_window && priv->xid) {
+ GST_VAAPI_DISPLAY_LOCK(priv->display);
+ ok = x11_get_geometry(dpy, priv->xid, NULL, NULL, width, height);
+ GST_VAAPI_DISPLAY_UNLOCK(priv->display);
+ return ok;
+ }
GST_VAAPI_DISPLAY_LOCK(priv->display);
- priv->xid = x11_create_window(dpy, width, height);
+ priv->xid = x11_create_window(dpy, *width, *height);
if (priv->xid)
XRaiseWindow(dpy, priv->xid);
GST_VAAPI_DISPLAY_UNLOCK(priv->display);
GstVaapiWindow *
gst_vaapi_window_x11_new_with_xid(GstVaapiDisplay *display, Window xid)
{
- Display *dpy;
- guint width, height;
-
GST_DEBUG("new window from xid 0x%08x", xid);
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
-
- dpy = GST_VAAPI_DISPLAY_XDISPLAY(display);
- if (!dpy || !x11_get_geometry(dpy, xid, NULL, NULL, &width, &height))
- return NULL;
+ g_return_val_if_fail(xid != None, NULL);
return g_object_new(GST_VAAPI_TYPE_WINDOW_X11,
"display", display,
"xid", xid,
- "width", width,
- "height", height,
NULL);
}