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
This commit is contained in:
Hyunjun Ko 2018-06-01 12:36:51 +09:00 committed by Víctor Manuel Jáquez Leal
parent 8de7dcfe3c
commit a6881b9b5e
7 changed files with 68 additions and 22 deletions

View file

@ -1143,11 +1143,24 @@ gst_vaapi_display_class_init (GstVaapiDisplayClass * klass)
g_object_class_install_properties (object_class, N_PROPERTIES, g_properties); 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 * GstVaapiDisplay *
gst_vaapi_display_new (GstVaapiDisplay * display, gst_vaapi_display_config (GstVaapiDisplay * display,
GstVaapiDisplayInitType init_type, gpointer init_value) 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)) if (!gst_vaapi_display_create (display, init_type, init_value))
goto error; goto error;
@ -1156,7 +1169,7 @@ gst_vaapi_display_new (GstVaapiDisplay * display,
/* ERRORS */ /* ERRORS */
error: error:
{ {
gst_vaapi_display_unref (display); gst_object_unref (display);
return NULL; return NULL;
} }
} }
@ -1177,7 +1190,7 @@ gst_vaapi_display_new_with_display (VADisplay va_display)
.va_display = 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); GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY, &info);
} }

View file

@ -395,8 +395,8 @@ gst_vaapi_display_drm_new (const gchar * device_path)
for (i = 0; i < num_types; i++) { for (i = 0; i < num_types; i++) {
g_drm_device_type = types[i]; g_drm_device_type = types[i];
display = display = g_object_new (GST_TYPE_VAAPI_DISPLAY_DRM, NULL);
gst_vaapi_display_new (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); GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) device_path);
if (display || device_path) if (display || device_path)
break; break;
@ -419,9 +419,12 @@ gst_vaapi_display_drm_new (const gchar * device_path)
GstVaapiDisplay * GstVaapiDisplay *
gst_vaapi_display_drm_new_with_device (gint device) gst_vaapi_display_drm_new_with_device (gint device)
{ {
GstVaapiDisplay *display;
g_return_val_if_fail (device >= 0, NULL); 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)); GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, GINT_TO_POINTER (device));
} }

View file

@ -366,6 +366,7 @@ gst_vaapi_display_egl_class_init (GstVaapiDisplayEGLClass * klass)
GstVaapiDisplay * GstVaapiDisplay *
gst_vaapi_display_egl_new (GstVaapiDisplay * display, guint gles_version) gst_vaapi_display_egl_new (GstVaapiDisplay * display, guint gles_version)
{ {
GstVaapiDisplay *wrapper_display;
InitParams params = { InitParams params = {
.gles_version = gles_version, .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); 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); GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, &params);
} }
@ -399,6 +401,7 @@ GstVaapiDisplay *
gst_vaapi_display_egl_new_with_native_display (gpointer native_display, gst_vaapi_display_egl_new_with_native_display (gpointer native_display,
GstVaapiDisplayType display_type, guint gles_version) GstVaapiDisplayType display_type, guint gles_version)
{ {
GstVaapiDisplay *display;
InitParams params = { InitParams params = {
.display_type = display_type, .display_type = display_type,
.gl_display = native_display, .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); 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); GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, &params);
} }

View file

@ -128,7 +128,10 @@ gst_vaapi_display_glx_class_init (GstVaapiDisplayGLXClass * klass)
GstVaapiDisplay * GstVaapiDisplay *
gst_vaapi_display_glx_new (const gchar * display_name) 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); GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) display_name);
} }
@ -146,8 +149,11 @@ gst_vaapi_display_glx_new (const gchar * display_name)
GstVaapiDisplay * GstVaapiDisplay *
gst_vaapi_display_glx_new_with_display (Display * x11_display) gst_vaapi_display_glx_new_with_display (Display * x11_display)
{ {
GstVaapiDisplay *display;
g_return_val_if_fail (x11_display != NULL, NULL); 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); GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, x11_display);
} }

View file

@ -201,7 +201,7 @@ enum _GstVaapiDisplayInitType
}; };
GstVaapiDisplay * GstVaapiDisplay *
gst_vaapi_display_new (GstVaapiDisplay * display, gst_vaapi_display_config (GstVaapiDisplay * display,
GstVaapiDisplayInitType init_type, gpointer init_value); GstVaapiDisplayInitType init_type, gpointer init_value);
G_END_DECLS G_END_DECLS

View file

@ -325,9 +325,11 @@ gst_vaapi_display_wayland_class_init (GstVaapiDisplayWaylandClass * klass)
GstVaapiDisplay * GstVaapiDisplay *
gst_vaapi_display_wayland_new (const gchar * display_name) gst_vaapi_display_wayland_new (const gchar * display_name)
{ {
return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_WAYLAND, GstVaapiDisplay *display;
NULL), GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME,
(gpointer) display_name); 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 * GstVaapiDisplay *
gst_vaapi_display_wayland_new_with_display (struct wl_display * wl_display) gst_vaapi_display_wayland_new_with_display (struct wl_display * wl_display)
{ {
GstVaapiDisplay *display;
g_return_val_if_fail (wl_display, NULL); g_return_val_if_fail (wl_display, NULL);
return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_WAYLAND, display = g_object_new (GST_TYPE_VAAPI_DISPLAY_WAYLAND, NULL);
NULL), GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, wl_display); 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, gst_vaapi_display_wayland_new_with_va_display (VADisplay va_display,
struct wl_display * wl_display) struct wl_display * wl_display)
{ {
GstVaapiDisplay *display;
GstVaapiDisplayInfo info = { GstVaapiDisplayInfo info = {
.va_display = va_display, .va_display = va_display,
.native_display = wl_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); g_return_val_if_fail (wl_display, NULL);
return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_WAYLAND, display = g_object_new (GST_TYPE_VAAPI_DISPLAY_WAYLAND, NULL);
NULL), GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY, &info); if (!gst_vaapi_display_config (display,
GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY, &info)) {
gst_object_unref (display);
return NULL;
}
return display;
} }
/** /**

View file

@ -348,7 +348,10 @@ gst_vaapi_display_x11_init (GstVaapiDisplayX11 * display)
GstVaapiDisplay * GstVaapiDisplay *
gst_vaapi_display_x11_new (const gchar * display_name) 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); GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) display_name);
} }
@ -366,9 +369,12 @@ gst_vaapi_display_x11_new (const gchar * display_name)
GstVaapiDisplay * GstVaapiDisplay *
gst_vaapi_display_x11_new_with_display (Display * x11_display) gst_vaapi_display_x11_new_with_display (Display * x11_display)
{ {
GstVaapiDisplay *display;
g_return_val_if_fail (x11_display, NULL); 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); 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, gst_vaapi_display_x11_new_with_va_display (VADisplay va_display,
Display * x11_display) Display * x11_display)
{ {
GstVaapiDisplay *display;
GstVaapiDisplayInfo info = { GstVaapiDisplayInfo info = {
.va_display = va_display, .va_display = va_display,
.native_display = x11_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); 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); GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY, &info);
} }