mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-21 22:58:16 +00:00
Make it possible to bin an X11 window to GstVaapiWindowX11 with plain
g_object_new() and "xid" property. i.e. get foreign window size in gst_vaapi_window_x11_create().
This commit is contained in:
parent
9ecf541b67
commit
b9bf5678f9
3 changed files with 27 additions and 25 deletions
|
@ -51,12 +51,23 @@ gst_vaapi_window_destroy(GstVaapiWindow *window)
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -119,11 +130,7 @@ gst_vaapi_window_constructed(GObject *object)
|
|||
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)
|
||||
|
|
|
@ -78,7 +78,7 @@ struct _GstVaapiWindowClass {
|
|||
/*< 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);
|
||||
|
|
|
@ -96,18 +96,21 @@ gst_vaapi_window_x11_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;
|
||||
Display * const dpy = GST_VAAPI_DISPLAY_XDISPLAY(priv->display);
|
||||
gboolean ok;
|
||||
|
||||
if (!priv->create_window && priv->xid)
|
||||
return TRUE;
|
||||
|
||||
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);
|
||||
|
@ -349,22 +352,14 @@ gst_vaapi_window_x11_new(GstVaapiDisplay *display, guint width, guint height)
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue