diff --git a/gst-libs/gst/vaapi/gstvaapiwindow.c b/gst-libs/gst/vaapi/gstvaapiwindow.c index 2348540814..d93f7afb8d 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow.c +++ b/gst-libs/gst/vaapi/gstvaapiwindow.c @@ -37,15 +37,17 @@ G_DEFINE_TYPE(GstVaapiWindow, gst_vaapi_window, G_TYPE_OBJECT); GstVaapiWindowPrivate)) struct _GstVaapiWindowPrivate { - guint width; - guint height; - gboolean is_constructed : 1; - guint is_fullscreen : 1; + GstVaapiDisplay *display; + guint width; + guint height; + gboolean is_constructed : 1; + guint is_fullscreen : 1; }; enum { PROP_0, + PROP_DISPLAY, PROP_WIDTH, PROP_HEIGHT }; @@ -53,7 +55,14 @@ enum { static void gst_vaapi_window_destroy(GstVaapiWindow *window) { + GstVaapiWindowPrivate * const priv = window->priv; + GST_VAAPI_WINDOW_GET_CLASS(window)->destroy(window); + + if (priv->display) { + g_object_unref(priv->display); + priv->display = NULL; + } } static gboolean @@ -95,6 +104,9 @@ gst_vaapi_window_set_property( GstVaapiWindow * const window = GST_VAAPI_WINDOW(object); switch (prop_id) { + case PROP_DISPLAY: + window->priv->display = g_object_ref(g_value_get_object(value)); + break; case PROP_WIDTH: gst_vaapi_window_set_width(window, g_value_get_uint(value)); break; @@ -118,6 +130,9 @@ gst_vaapi_window_get_property( GstVaapiWindow * const window = GST_VAAPI_WINDOW(object); switch (prop_id) { + case PROP_DISPLAY: + g_value_set_object(value, gst_vaapi_window_get_display(window)); + break; case PROP_WIDTH: g_value_set_uint(value, gst_vaapi_window_get_width(window)); break; @@ -155,6 +170,20 @@ gst_vaapi_window_class_init(GstVaapiWindowClass *klass) object_class->get_property = gst_vaapi_window_get_property; object_class->constructed = gst_vaapi_window_constructed; + /** + * GstVaapiWindowX11:display: + * + * The #GstVaapiDisplay this window is bound to + */ + g_object_class_install_property + (object_class, + PROP_DISPLAY, + g_param_spec_object("display", + "Display", + "The GstVaapiDisplay this window is bound to", + GST_VAAPI_TYPE_DISPLAY, + G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property (object_class, PROP_WIDTH, @@ -180,12 +209,29 @@ gst_vaapi_window_init(GstVaapiWindow *window) GstVaapiWindowPrivate *priv = GST_VAAPI_WINDOW_GET_PRIVATE(window); window->priv = priv; + priv->display = NULL; priv->width = 1; priv->height = 1; priv->is_constructed = FALSE; priv->is_fullscreen = FALSE; } +/** + * gst_vaapi_window_get_display: + * @window: a #GstVaapiWindow + * + * Returns the #GstVaapiDisplay this @window is bound to. + * + * Return value: the parent #GstVaapiDisplay object + */ +GstVaapiDisplay * +gst_vaapi_window_get_display(GstVaapiWindow *window) +{ + g_return_val_if_fail(GST_VAAPI_IS_WINDOW(window), NULL); + + return window->priv->display; +} + /** * gst_vaapi_window_show: * @window: a #GstVaapiWindow diff --git a/gst-libs/gst/vaapi/gstvaapiwindow.h b/gst-libs/gst/vaapi/gstvaapiwindow.h index d1db986b01..4c2bbcbe8f 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow.h +++ b/gst-libs/gst/vaapi/gstvaapiwindow.h @@ -101,6 +101,9 @@ struct _GstVaapiWindowClass { GType gst_vaapi_window_get_type(void); +GstVaapiDisplay * +gst_vaapi_window_get_display(GstVaapiWindow *window); + void gst_vaapi_window_show(GstVaapiWindow *window); diff --git a/gst-libs/gst/vaapi/gstvaapiwindow_x11.c b/gst-libs/gst/vaapi/gstvaapiwindow_x11.c index c7474e821f..b58ad95a0f 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow_x11.c +++ b/gst-libs/gst/vaapi/gstvaapiwindow_x11.c @@ -53,7 +53,6 @@ struct _GstVaapiWindowX11Private { enum { PROP_0, - PROP_DISPLAY, PROP_XID, }; @@ -336,9 +335,6 @@ gst_vaapi_window_x11_set_property( GstVaapiWindowX11 * const window = GST_VAAPI_WINDOW_X11(object); switch (prop_id) { - case PROP_DISPLAY: - window->priv->display = g_object_ref(g_value_get_object(value)); - break; case PROP_XID: window->priv->xid = g_value_get_uint(value); break; @@ -359,9 +355,6 @@ gst_vaapi_window_x11_get_property( GstVaapiWindowX11 * const window = GST_VAAPI_WINDOW_X11(object); switch (prop_id) { - case PROP_DISPLAY: - g_value_set_object(value, window->priv->display); - break; case PROP_XID: g_value_set_uint(value, gst_vaapi_window_x11_get_xid(window)); break; @@ -375,8 +368,12 @@ static void gst_vaapi_window_x11_constructed(GObject *object) { GstVaapiWindowX11 * const window = GST_VAAPI_WINDOW_X11(object); + GstVaapiDisplay *display; GObjectClass *parent_class; + window->priv->display = + g_object_ref(gst_vaapi_window_get_display(GST_VAAPI_WINDOW(window))); + window->priv->create_window = window->priv->xid == None; parent_class = G_OBJECT_CLASS(gst_vaapi_window_x11_parent_class); @@ -405,20 +402,6 @@ gst_vaapi_window_x11_class_init(GstVaapiWindowX11Class *klass) window_class->resize = gst_vaapi_window_x11_resize; window_class->render = gst_vaapi_window_x11_render; - /** - * GstVaapiWindowX11:display: - * - * The #GstVaapiDisplay this window is bound to - */ - g_object_class_install_property - (object_class, - PROP_DISPLAY, - g_param_spec_object("display", - "Display", - "The GstVaapiDisplay this window is bound to", - GST_VAAPI_TYPE_DISPLAY, - G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)); - /** * GstVaapiWindowX11:xid: *