summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunjun Ko <zzoon@igalia.com>2018-06-01 12:36:51 +0900
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2018-06-14 16:41:00 +0200
commita6881b9b5eb55ef080387fc81cbbfdaf4bb9ec64 (patch)
treec7702c5b186bdc592bcbc3d258afe296cbb6c40a
parent8de7dcfe3cc1e23387ed88a3d4b7726a160b24b7 (diff)
libs: display: replace gst_vaapi_display_new() with gst_vaapi_display_config()
Gobjectification for GstVaapiDisplay was almost done by the commit 185da3d1. But still something breaking GObject code convention remains, which is calling gst_vaapi_display_new() in each decendants. This patch replaces it with gst_vaapi_display_config(), defined in private header. https://bugzilla.gnome.org/show_bug.cgi?id=796470
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay.c21
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay_drm.c9
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay_egl.c8
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay_glx.c10
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay_priv.h2
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay_wayland.c26
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay_x11.c14
7 files changed, 68 insertions, 22 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.c b/gst-libs/gst/vaapi/gstvaapidisplay.c
index 1fffcbb2..d8579959 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay.c
@@ -1143,11 +1143,24 @@ gst_vaapi_display_class_init (GstVaapiDisplayClass * klass)
g_object_class_install_properties (object_class, N_PROPERTIES, g_properties);
}
+/**
+ * gst_vaapi_display_config:
+ * @display: instance of #GstVaapiDisplay
+ * @init_type: type of initialization #GstVaapiDisplayInitType
+ * @init_value: a pointer to the structure with the initialization
+ * parameters
+ *
+ * Binds @display to the VA layer; otherwise it is just an empty
+ * structure.
+ *
+ * Returns: the configured @display if it was configured correctly;
+ * otherwise unrefs @display and returns %NULL.
+ **/
GstVaapiDisplay *
-gst_vaapi_display_new (GstVaapiDisplay * display,
+gst_vaapi_display_config (GstVaapiDisplay * display,
GstVaapiDisplayInitType init_type, gpointer init_value)
{
- g_return_val_if_fail (display != NULL, NULL);
+ g_return_val_if_fail (display && GST_VAAPI_IS_DISPLAY (display), NULL);
if (!gst_vaapi_display_create (display, init_type, init_value))
goto error;
@@ -1156,7 +1169,7 @@ gst_vaapi_display_new (GstVaapiDisplay * display,
/* ERRORS */
error:
{
- gst_vaapi_display_unref (display);
+ gst_object_unref (display);
return NULL;
}
}
@@ -1177,7 +1190,7 @@ gst_vaapi_display_new_with_display (VADisplay va_display)
.va_display = va_display,
};
- return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY, NULL),
+ return gst_vaapi_display_config (g_object_new (GST_TYPE_VAAPI_DISPLAY, NULL),
GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY, &info);
}
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_drm.c b/gst-libs/gst/vaapi/gstvaapidisplay_drm.c
index ef68187a..ea05289e 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay_drm.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay_drm.c
@@ -395,8 +395,8 @@ gst_vaapi_display_drm_new (const gchar * device_path)
for (i = 0; i < num_types; i++) {
g_drm_device_type = types[i];
- display =
- gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_DRM, NULL),
+ display = g_object_new (GST_TYPE_VAAPI_DISPLAY_DRM, NULL);
+ display = gst_vaapi_display_config (display,
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) device_path);
if (display || device_path)
break;
@@ -419,9 +419,12 @@ gst_vaapi_display_drm_new (const gchar * device_path)
GstVaapiDisplay *
gst_vaapi_display_drm_new_with_device (gint device)
{
+ GstVaapiDisplay *display;
+
g_return_val_if_fail (device >= 0, NULL);
- return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_DRM, NULL),
+ display = g_object_new (GST_TYPE_VAAPI_DISPLAY_DRM, NULL);
+ return gst_vaapi_display_config (display,
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, GINT_TO_POINTER (device));
}
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_egl.c b/gst-libs/gst/vaapi/gstvaapidisplay_egl.c
index 27d70743..fcffecdb 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay_egl.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay_egl.c
@@ -366,6 +366,7 @@ gst_vaapi_display_egl_class_init (GstVaapiDisplayEGLClass * klass)
GstVaapiDisplay *
gst_vaapi_display_egl_new (GstVaapiDisplay * display, guint gles_version)
{
+ GstVaapiDisplay *wrapper_display;
InitParams params = {
.gles_version = gles_version,
};
@@ -375,7 +376,8 @@ gst_vaapi_display_egl_new (GstVaapiDisplay * display, guint gles_version)
params.display_type = GST_VAAPI_DISPLAY_VADISPLAY_TYPE (display);
}
- return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_EGL, NULL),
+ wrapper_display = g_object_new (GST_TYPE_VAAPI_DISPLAY_EGL, NULL);
+ return gst_vaapi_display_config (wrapper_display,
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, &params);
}
@@ -399,6 +401,7 @@ GstVaapiDisplay *
gst_vaapi_display_egl_new_with_native_display (gpointer native_display,
GstVaapiDisplayType display_type, guint gles_version)
{
+ GstVaapiDisplay *display;
InitParams params = {
.display_type = display_type,
.gl_display = native_display,
@@ -407,7 +410,8 @@ gst_vaapi_display_egl_new_with_native_display (gpointer native_display,
g_return_val_if_fail (native_display != NULL, NULL);
- return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_EGL, NULL),
+ display = g_object_new (GST_TYPE_VAAPI_DISPLAY_EGL, NULL);
+ return gst_vaapi_display_config (display,
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, &params);
}
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_glx.c b/gst-libs/gst/vaapi/gstvaapidisplay_glx.c
index 94686c63..f75ab90f 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay_glx.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay_glx.c
@@ -128,7 +128,10 @@ gst_vaapi_display_glx_class_init (GstVaapiDisplayGLXClass * klass)
GstVaapiDisplay *
gst_vaapi_display_glx_new (const gchar * display_name)
{
- return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_GLX, NULL),
+ GstVaapiDisplay *display;
+
+ display = g_object_new (GST_TYPE_VAAPI_DISPLAY_GLX, NULL);
+ return gst_vaapi_display_config (display,
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) display_name);
}
@@ -146,8 +149,11 @@ gst_vaapi_display_glx_new (const gchar * display_name)
GstVaapiDisplay *
gst_vaapi_display_glx_new_with_display (Display * x11_display)
{
+ GstVaapiDisplay *display;
+
g_return_val_if_fail (x11_display != NULL, NULL);
- return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_GLX, NULL),
+ display = g_object_new (GST_TYPE_VAAPI_DISPLAY_GLX, NULL);
+ return gst_vaapi_display_config (display,
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, x11_display);
}
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_priv.h b/gst-libs/gst/vaapi/gstvaapidisplay_priv.h
index 95272a79..9a34ba8c 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay_priv.h
+++ b/gst-libs/gst/vaapi/gstvaapidisplay_priv.h
@@ -201,7 +201,7 @@ enum _GstVaapiDisplayInitType
};
GstVaapiDisplay *
-gst_vaapi_display_new (GstVaapiDisplay * display,
+gst_vaapi_display_config (GstVaapiDisplay * display,
GstVaapiDisplayInitType init_type, gpointer init_value);
G_END_DECLS
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_wayland.c b/gst-libs/gst/vaapi/gstvaapidisplay_wayland.c
index b06f3883..8fde3efb 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay_wayland.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay_wayland.c
@@ -325,9 +325,11 @@ gst_vaapi_display_wayland_class_init (GstVaapiDisplayWaylandClass * klass)
GstVaapiDisplay *
gst_vaapi_display_wayland_new (const gchar * display_name)
{
- return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_WAYLAND,
- NULL), GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME,
- (gpointer) display_name);
+ GstVaapiDisplay *display;
+
+ display = g_object_new (GST_TYPE_VAAPI_DISPLAY_WAYLAND, NULL);
+ return gst_vaapi_display_config (display,
+ GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) display_name);
}
/**
@@ -344,10 +346,13 @@ gst_vaapi_display_wayland_new (const gchar * display_name)
GstVaapiDisplay *
gst_vaapi_display_wayland_new_with_display (struct wl_display * wl_display)
{
+ GstVaapiDisplay *display;
+
g_return_val_if_fail (wl_display, NULL);
- return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_WAYLAND,
- NULL), GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, wl_display);
+ display = g_object_new (GST_TYPE_VAAPI_DISPLAY_WAYLAND, NULL);
+ return gst_vaapi_display_config (display,
+ GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, wl_display);
}
/**
@@ -368,6 +373,7 @@ GstVaapiDisplay *
gst_vaapi_display_wayland_new_with_va_display (VADisplay va_display,
struct wl_display * wl_display)
{
+ GstVaapiDisplay *display;
GstVaapiDisplayInfo info = {
.va_display = va_display,
.native_display = wl_display,
@@ -375,8 +381,14 @@ gst_vaapi_display_wayland_new_with_va_display (VADisplay va_display,
g_return_val_if_fail (wl_display, NULL);
- return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_WAYLAND,
- NULL), GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY, &info);
+ display = g_object_new (GST_TYPE_VAAPI_DISPLAY_WAYLAND, NULL);
+ if (!gst_vaapi_display_config (display,
+ GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY, &info)) {
+ gst_object_unref (display);
+ return NULL;
+ }
+
+ return display;
}
/**
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_x11.c b/gst-libs/gst/vaapi/gstvaapidisplay_x11.c
index f7517b10..6a3fdbe7 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay_x11.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay_x11.c
@@ -348,7 +348,10 @@ gst_vaapi_display_x11_init (GstVaapiDisplayX11 * display)
GstVaapiDisplay *
gst_vaapi_display_x11_new (const gchar * display_name)
{
- return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_X11, NULL),
+ GstVaapiDisplay *display;
+
+ display = g_object_new (GST_TYPE_VAAPI_DISPLAY_X11, NULL);
+ return gst_vaapi_display_config (display,
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) display_name);
}
@@ -366,9 +369,12 @@ gst_vaapi_display_x11_new (const gchar * display_name)
GstVaapiDisplay *
gst_vaapi_display_x11_new_with_display (Display * x11_display)
{
+ GstVaapiDisplay *display;
+
g_return_val_if_fail (x11_display, NULL);
- return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_X11, NULL),
+ display = g_object_new (GST_TYPE_VAAPI_DISPLAY_X11, NULL);
+ return gst_vaapi_display_config (display,
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, x11_display);
}
@@ -376,6 +382,7 @@ GstVaapiDisplay *
gst_vaapi_display_x11_new_with_va_display (VADisplay va_display,
Display * x11_display)
{
+ GstVaapiDisplay *display;
GstVaapiDisplayInfo info = {
.va_display = va_display,
.native_display = x11_display,
@@ -383,7 +390,8 @@ gst_vaapi_display_x11_new_with_va_display (VADisplay va_display,
g_return_val_if_fail (x11_display, NULL);
- return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_X11, NULL),
+ display = g_object_new (GST_TYPE_VAAPI_DISPLAY_X11, NULL);
+ return gst_vaapi_display_config (display,
GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY, &info);
}