libs: display: GstVaapiDisplay as GstObject descendant

This patch is to change the inheritance of GstVaapiDisplay to GstObject,
instead of GstVaapiMiniObject. In this way we can use all the available
infrastructure for GObject/GstObject such as GstTracer, GIR, etc.

In addition, a new debug category for GstVaapiDisplay is created to make it
easier to trace debug messages. It is named "vaapidisplay" and it transverse
all the VA display backends (DRM, GLX, EGL, Wayland, ...)

This patch is a step forward to expose GstVaapiDisplay for users in a future
library.

https://bugzilla.gnome.org/show_bug.cgi?id=768266

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
This commit is contained in:
Hyunjun Ko 2016-10-13 12:53:17 +09:00 committed by Víctor Manuel Jáquez Leal
parent 67d4c09341
commit 185da3d1a4
23 changed files with 259 additions and 322 deletions

View file

@ -30,4 +30,9 @@ GST_DEBUG_CATEGORY_EXTERN(gst_debug_vaapi);
#define GST_CAT_DEFAULT gst_debug_vaapi
#endif
#if DEBUG_VAAPI_DISPLAY
GST_DEBUG_CATEGORY_EXTERN(gst_debug_vaapi_display);
#define GST_CAT_DEFAULT gst_debug_vaapi_display
#endif
#endif /* GST_VAAPI_DEBUG_H */

View file

@ -37,11 +37,21 @@
#include "gstvaapiworkarounds.h"
#include "gstvaapiversion.h"
#define DEBUG 1
#include "gstvaapidebug.h"
/* Debug category for all vaapi libs */
GST_DEBUG_CATEGORY (gst_debug_vaapi);
/* Debug category for VaapiDisplay */
GST_DEBUG_CATEGORY (gst_debug_vaapi_display);
#define GST_CAT_DEFAULT gst_debug_vaapi_display
#define _do_init \
G_ADD_PRIVATE (GstVaapiDisplay); \
GST_DEBUG_CATEGORY_INIT (gst_debug_vaapi_display, \
"vaapidisplay", 0, "VA-API Display");
G_DEFINE_TYPE_WITH_CODE (GstVaapiDisplay, gst_vaapi_display, GST_TYPE_OBJECT,
_do_init);
/* Ensure those symbols are actually defined in the resulting libraries */
#undef gst_vaapi_display_ref
#undef gst_vaapi_display_unref
@ -117,7 +127,8 @@ libgstvaapi_init_once (void)
GST_DEBUG_CATEGORY_INIT (gst_debug_vaapi, "vaapi", 0, "VA-API helper");
/* Dump gstreamer-vaapi version for debugging purposes */
GST_INFO ("gstreamer-vaapi version %s", GST_VAAPI_VERSION_ID);
GST_CAT_INFO (gst_debug_vaapi, "gstreamer-vaapi version %s",
GST_VAAPI_VERSION_ID);
gst_vaapi_display_properties_init ();
@ -947,6 +958,7 @@ gst_vaapi_display_create_unlocked (GstVaapiDisplay * display,
return FALSE;
}
GST_INFO_OBJECT (display, "new display addr=%p", display);
g_free (priv->display_name);
priv->display_name = g_strdup (info.display_name);
return TRUE;
@ -995,42 +1007,39 @@ gst_vaapi_display_unlock_default (GstVaapiDisplay * display)
static void
gst_vaapi_display_init (GstVaapiDisplay * display)
{
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
const GstVaapiDisplayClass *const dpy_class =
GST_VAAPI_DISPLAY_GET_CLASS (display);
GstVaapiDisplayPrivate *const priv =
gst_vaapi_display_get_instance_private (display);
display->priv = priv;
priv->display_type = GST_VAAPI_DISPLAY_TYPE_ANY;
priv->par_n = 1;
priv->par_d = 1;
g_rec_mutex_init (&priv->mutex);
if (dpy_class->init)
dpy_class->init (display);
}
static void
gst_vaapi_display_finalize (GstVaapiDisplay * display)
gst_vaapi_display_finalize (GObject * object)
{
GstVaapiDisplay *const display = GST_VAAPI_DISPLAY (object);
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
gst_vaapi_display_destroy (display);
g_rec_mutex_clear (&priv->mutex);
G_OBJECT_CLASS (gst_vaapi_display_parent_class)->finalize (object);
}
void
gst_vaapi_display_class_init (GstVaapiDisplayClass * klass)
{
GstVaapiMiniObjectClass *const object_class =
GST_VAAPI_MINI_OBJECT_CLASS (klass);
GstVaapiDisplayClass *const dpy_class = GST_VAAPI_DISPLAY_CLASS (klass);
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
libgstvaapi_init_once ();
object_class->size = sizeof (GstVaapiDisplay);
object_class->finalize = (GDestroyNotify) gst_vaapi_display_finalize;
dpy_class->lock = gst_vaapi_display_lock_default;
dpy_class->unlock = gst_vaapi_display_unlock_default;
object_class->finalize = gst_vaapi_display_finalize;
klass->lock = gst_vaapi_display_lock_default;
klass->unlock = gst_vaapi_display_unlock_default;
}
static void
@ -1102,31 +1111,12 @@ gst_vaapi_display_properties_init (void)
"The display contrast value", 0.0, 2.0, 1.0, G_PARAM_READWRITE);
}
static inline const GstVaapiDisplayClass *
gst_vaapi_display_class (void)
{
static GstVaapiDisplayClass g_class;
static gsize g_class_init = FALSE;
if (g_once_init_enter (&g_class_init)) {
gst_vaapi_display_class_init (&g_class);
g_once_init_leave (&g_class_init, TRUE);
}
return &g_class;
}
GstVaapiDisplay *
gst_vaapi_display_new (const GstVaapiDisplayClass * klass,
gst_vaapi_display_new (GstVaapiDisplay * display,
GstVaapiDisplayInitType init_type, gpointer init_value)
{
GstVaapiDisplay *display;
g_return_val_if_fail (display != NULL, NULL);
display = (GstVaapiDisplay *)
gst_vaapi_mini_object_new0 (GST_VAAPI_MINI_OBJECT_CLASS (klass));
if (!display)
return NULL;
gst_vaapi_display_init (display);
if (!gst_vaapi_display_create (display, init_type, init_value))
goto error;
return display;
@ -1158,7 +1148,7 @@ gst_vaapi_display_new_with_display (VADisplay va_display)
if (info)
return gst_vaapi_display_ref_internal (info->display);
return gst_vaapi_display_new (gst_vaapi_display_class (),
return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY, NULL),
GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY, va_display);
}
@ -2124,7 +2114,7 @@ gst_vaapi_display_get_vendor_string (GstVaapiDisplay * display)
if (!ensure_vendor_string (display))
return NULL;
return display->priv.vendor_string;
return GST_VAAPI_DISPLAY_GET_PRIVATE (display)->vendor_string;
}
/**

View file

@ -33,8 +33,11 @@
G_BEGIN_DECLS
#define GST_TYPE_VAAPI_DISPLAY (gst_vaapi_display_get_type ())
#define GST_VAAPI_DISPLAY(obj) \
((GstVaapiDisplay *)(obj))
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPI_DISPLAY, GstVaapiDisplay))
#define GST_VAAPI_IS_DISPLAY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPI_DISPLAY))
/**
* GST_VAAPI_DISPLAY_GET_CLASS_TYPE:
@ -109,6 +112,9 @@ typedef enum
GType
gst_vaapi_display_type_get_type (void) G_GNUC_CONST;
GType
gst_vaapi_display_get_type (void) G_GNUC_CONST;
gboolean
gst_vaapi_display_type_is_compatible (GstVaapiDisplayType type1,
GstVaapiDisplayType type2);
@ -260,6 +266,10 @@ gst_vaapi_display_has_opengl (GstVaapiDisplay * display);
void
gst_vaapi_display_reset_texture_map (GstVaapiDisplay * display);
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVaapiDisplay, gst_vaapi_display_unref)
#endif
G_END_DECLS
#endif /* GST_VAAPI_DISPLAY_H */

View file

@ -38,9 +38,15 @@
#include "gstvaapidisplay_drm_priv.h"
#include "gstvaapiwindow_drm.h"
#define DEBUG 1
#define DEBUG_VAAPI_DISPLAY 1
#include "gstvaapidebug.h"
#define _do_init \
G_ADD_PRIVATE (GstVaapiDisplayDRM);
G_DEFINE_TYPE_WITH_CODE (GstVaapiDisplayDRM, gst_vaapi_display_drm,
GST_TYPE_VAAPI_DISPLAY, _do_init);
static const guint g_display_types = 1U << GST_VAAPI_DISPLAY_TYPE_DRM;
typedef enum
@ -322,26 +328,21 @@ gst_vaapi_display_drm_create_window (GstVaapiDisplay * display, GstVaapiID id,
}
static void
gst_vaapi_display_drm_init (GstVaapiDisplay * display)
gst_vaapi_display_drm_init (GstVaapiDisplayDRM * display)
{
GstVaapiDisplayDRMPrivate *const priv =
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
gst_vaapi_display_drm_get_instance_private (display);
display->priv = priv;
priv->drm_device = -1;
}
static void
gst_vaapi_display_drm_class_init (GstVaapiDisplayDRMClass * klass)
{
GstVaapiMiniObjectClass *const object_class =
GST_VAAPI_MINI_OBJECT_CLASS (klass);
GstVaapiDisplayClass *const dpy_class = GST_VAAPI_DISPLAY_CLASS (klass);
gst_vaapi_display_class_init (&klass->parent_class);
object_class->size = sizeof (GstVaapiDisplayDRM);
dpy_class->display_type = GST_VAAPI_DISPLAY_TYPE_DRM;
dpy_class->init = gst_vaapi_display_drm_init;
dpy_class->bind_display = gst_vaapi_display_drm_bind_display;
dpy_class->open_display = gst_vaapi_display_drm_open_display;
dpy_class->close_display = gst_vaapi_display_drm_close_display;
@ -349,19 +350,6 @@ gst_vaapi_display_drm_class_init (GstVaapiDisplayDRMClass * klass)
dpy_class->create_window = gst_vaapi_display_drm_create_window;
}
static inline const GstVaapiDisplayClass *
gst_vaapi_display_drm_class (void)
{
static GstVaapiDisplayDRMClass g_class;
static gsize g_class_init = FALSE;
if (g_once_init_enter (&g_class_init)) {
gst_vaapi_display_drm_class_init (&g_class);
g_once_init_leave (&g_class_init, TRUE);
}
return GST_VAAPI_DISPLAY_CLASS (&g_class);
}
/**
* gst_vaapi_display_drm_new:
* @device_path: the DRM device path
@ -394,7 +382,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 (gst_vaapi_display_drm_class (),
display =
gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_DRM, NULL),
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) device_path);
if (display || device_path)
break;
@ -419,7 +408,7 @@ gst_vaapi_display_drm_new_with_device (gint device)
{
g_return_val_if_fail (device >= 0, NULL);
return gst_vaapi_display_new (gst_vaapi_display_drm_class (),
return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_DRM, NULL),
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, GINT_TO_POINTER (device));
}

View file

@ -27,8 +27,9 @@
G_BEGIN_DECLS
#define GST_TYPE_VAAPI_DISPLAY_DRM (gst_vaapi_display_drm_get_type ())
#define GST_VAAPI_DISPLAY_DRM(obj) \
((GstVaapiDisplayDRM *)(obj))
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPI_DISPLAY_DRM, GstVaapiDisplayDRM))
typedef struct _GstVaapiDisplayDRM GstVaapiDisplayDRM;
@ -45,6 +46,9 @@ const gchar *
gst_vaapi_display_drm_get_device_path (GstVaapiDisplayDRM *
display);
GType
gst_vaapi_display_drm_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* GST_VAAPI_DISPLAY_DRM_H */

View file

@ -29,14 +29,16 @@
G_BEGIN_DECLS
#define GST_VAAPI_IS_DISPLAY_DRM(display) \
((display) != NULL && \
GST_VAAPI_DISPLAY_VADISPLAY_TYPE(display) == GST_VAAPI_DISPLAY_TYPE_DRM)
(G_TYPE_CHECK_INSTANCE_TYPE ((display), GST_TYPE_VAAPI_DISPLAY_DRM))
#define GST_VAAPI_DISPLAY_DRM_CAST(display) \
((GstVaapiDisplayDRM *)(display))
#define GST_VAAPI_DISPLAY_DRM_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VAAPI_DISPLAY_DRM, GstVaapiDisplayDRMClass))
#define GST_VAAPI_DISPLAY_DRM_PRIVATE(display) \
(&GST_VAAPI_DISPLAY_DRM_CAST(display)->priv)
(GST_VAAPI_DISPLAY_DRM_CAST(display)->priv)
typedef struct _GstVaapiDisplayDRMPrivate GstVaapiDisplayDRMPrivate;
typedef struct _GstVaapiDisplayDRMClass GstVaapiDisplayDRMClass;
@ -69,7 +71,7 @@ struct _GstVaapiDisplayDRM
/*< private >*/
GstVaapiDisplay parent_instance;
GstVaapiDisplayDRMPrivate priv;
GstVaapiDisplayDRMPrivate *priv;
};
/**

View file

@ -35,7 +35,11 @@
#include "gstvaapidisplay_wayland.h"
#endif
GST_DEBUG_CATEGORY (gst_debug_vaapidisplay_egl);
#define DEBUG_VAAPI_DISPLAY 1
#include "gstvaapidebug.h"
G_DEFINE_TYPE (GstVaapiDisplayEGL, gst_vaapi_display_egl,
GST_TYPE_VAAPI_DISPLAY);
/* ------------------------------------------------------------------------- */
/* --- EGL backend implementation --- */
@ -90,11 +94,13 @@ ensure_context_is_wrapped (GstVaapiDisplayEGL * display, EGLContext gl_context)
}
static gboolean
gst_vaapi_display_egl_bind_display (GstVaapiDisplayEGL * display,
const InitParams * params)
gst_vaapi_display_egl_bind_display (GstVaapiDisplay * base_display,
gpointer native_params)
{
GstVaapiDisplay *native_display = NULL;
GstVaapiDisplayEGL *display = GST_VAAPI_DISPLAY_EGL (base_display);
EglDisplay *egl_display;
const InitParams *params = (InitParams *) native_params;
if (params->display) {
#if USE_X11
@ -132,14 +138,16 @@ gst_vaapi_display_egl_bind_display (GstVaapiDisplayEGL * display,
}
static void
gst_vaapi_display_egl_close_display (GstVaapiDisplayEGL * display)
gst_vaapi_display_egl_close_display (GstVaapiDisplay * base_display)
{
GstVaapiDisplayEGL *display = GST_VAAPI_DISPLAY_EGL (base_display);
gst_vaapi_display_replace (&display->display, NULL);
}
static void
gst_vaapi_display_egl_lock (GstVaapiDisplayEGL * display)
gst_vaapi_display_egl_lock (GstVaapiDisplay * base_display)
{
GstVaapiDisplayEGL *display = GST_VAAPI_DISPLAY_EGL (base_display);
GstVaapiDisplayClass *const klass =
GST_VAAPI_DISPLAY_GET_CLASS (display->display);
@ -148,8 +156,9 @@ gst_vaapi_display_egl_lock (GstVaapiDisplayEGL * display)
}
static void
gst_vaapi_display_egl_unlock (GstVaapiDisplayEGL * display)
gst_vaapi_display_egl_unlock (GstVaapiDisplay * base_display)
{
GstVaapiDisplayEGL *display = GST_VAAPI_DISPLAY_EGL (base_display);
GstVaapiDisplayClass *const klass =
GST_VAAPI_DISPLAY_GET_CLASS (display->display);
@ -158,8 +167,9 @@ gst_vaapi_display_egl_unlock (GstVaapiDisplayEGL * display)
}
static void
gst_vaapi_display_egl_sync (GstVaapiDisplayEGL * display)
gst_vaapi_display_egl_sync (GstVaapiDisplay * base_display)
{
GstVaapiDisplayEGL *display = GST_VAAPI_DISPLAY_EGL (base_display);
GstVaapiDisplayClass *const klass =
GST_VAAPI_DISPLAY_GET_CLASS (display->display);
@ -170,8 +180,9 @@ gst_vaapi_display_egl_sync (GstVaapiDisplayEGL * display)
}
static void
gst_vaapi_display_egl_flush (GstVaapiDisplayEGL * display)
gst_vaapi_display_egl_flush (GstVaapiDisplay * base_display)
{
GstVaapiDisplayEGL *display = GST_VAAPI_DISPLAY_EGL (base_display);
GstVaapiDisplayClass *const klass =
GST_VAAPI_DISPLAY_GET_CLASS (display->display);
@ -180,9 +191,10 @@ gst_vaapi_display_egl_flush (GstVaapiDisplayEGL * display)
}
static gboolean
gst_vaapi_display_egl_get_display_info (GstVaapiDisplayEGL * display,
gst_vaapi_display_egl_get_display_info (GstVaapiDisplay * base_display,
GstVaapiDisplayInfo * info)
{
GstVaapiDisplayEGL *display = GST_VAAPI_DISPLAY_EGL (base_display);
GstVaapiDisplayClass *const klass =
GST_VAAPI_DISPLAY_GET_CLASS (display->display);
@ -192,9 +204,10 @@ gst_vaapi_display_egl_get_display_info (GstVaapiDisplayEGL * display,
}
static void
gst_vaapi_display_egl_get_size (GstVaapiDisplayEGL * display,
gst_vaapi_display_egl_get_size (GstVaapiDisplay * base_display,
guint * width_ptr, guint * height_ptr)
{
GstVaapiDisplayEGL *display = GST_VAAPI_DISPLAY_EGL (base_display);
GstVaapiDisplayClass *const klass =
GST_VAAPI_DISPLAY_GET_CLASS (display->display);
@ -203,9 +216,10 @@ gst_vaapi_display_egl_get_size (GstVaapiDisplayEGL * display,
}
static void
gst_vaapi_display_egl_get_size_mm (GstVaapiDisplayEGL * display,
gst_vaapi_display_egl_get_size_mm (GstVaapiDisplay * base_display,
guint * width_ptr, guint * height_ptr)
{
GstVaapiDisplayEGL *display = GST_VAAPI_DISPLAY_EGL (base_display);
GstVaapiDisplayClass *const klass =
GST_VAAPI_DISPLAY_GET_CLASS (display->display);
@ -214,9 +228,10 @@ gst_vaapi_display_egl_get_size_mm (GstVaapiDisplayEGL * display,
}
static guintptr
gst_vaapi_display_egl_get_visual_id (GstVaapiDisplayEGL * display,
gst_vaapi_display_egl_get_visual_id (GstVaapiDisplay * base_display,
GstVaapiWindow * window)
{
GstVaapiDisplayEGL *display = GST_VAAPI_DISPLAY_EGL (base_display);
if (!ensure_context (display))
return 0;
return display->egl_context->config->visual_id;
@ -267,73 +282,43 @@ gst_vaapi_display_egl_get_texture_map (GstVaapiDisplay * display)
}
static void
gst_vaapi_display_egl_finalize (GstVaapiDisplay * display)
gst_vaapi_display_egl_finalize (GObject * object)
{
GstVaapiDisplayEGL *dpy = GST_VAAPI_DISPLAY_EGL (display);
GstVaapiDisplayEGL *dpy = GST_VAAPI_DISPLAY_EGL (object);
if (dpy->texture_map)
gst_object_unref (dpy->texture_map);
GST_VAAPI_DISPLAY_EGL_GET_CLASS (display)->parent_finalize (display);
G_OBJECT_CLASS (gst_vaapi_display_egl_parent_class)->finalize (object);
}
static void
gst_vaapi_display_egl_init (GstVaapiDisplayEGL * display)
{
}
static void
gst_vaapi_display_egl_class_init (GstVaapiDisplayEGLClass * klass)
{
GstVaapiMiniObjectClass *const object_class =
GST_VAAPI_MINI_OBJECT_CLASS (klass);
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
GstVaapiDisplayClass *const dpy_class = GST_VAAPI_DISPLAY_CLASS (klass);
GST_DEBUG_CATEGORY_INIT (gst_debug_vaapidisplay_egl, "vaapidisplay_egl", 0,
"VA/EGL backend");
gst_vaapi_display_class_init (dpy_class);
/* chain up destructor */
klass->parent_finalize = object_class->finalize;
object_class->finalize = (GDestroyNotify) gst_vaapi_display_egl_finalize;
object_class->size = sizeof (GstVaapiDisplayEGL);
object_class->finalize = gst_vaapi_display_egl_finalize;
dpy_class->display_type = GST_VAAPI_DISPLAY_TYPE_EGL;
dpy_class->bind_display = (GstVaapiDisplayBindFunc)
gst_vaapi_display_egl_bind_display;
dpy_class->close_display = (GstVaapiDisplayCloseFunc)
gst_vaapi_display_egl_close_display;
dpy_class->lock = (GstVaapiDisplayLockFunc)
gst_vaapi_display_egl_lock;
dpy_class->unlock = (GstVaapiDisplayUnlockFunc)
gst_vaapi_display_egl_unlock;
dpy_class->sync = (GstVaapiDisplaySyncFunc)
gst_vaapi_display_egl_sync;
dpy_class->flush = (GstVaapiDisplayFlushFunc)
gst_vaapi_display_egl_flush;
dpy_class->get_display = (GstVaapiDisplayGetInfoFunc)
gst_vaapi_display_egl_get_display_info;
dpy_class->get_size = (GstVaapiDisplayGetSizeFunc)
gst_vaapi_display_egl_get_size;
dpy_class->get_size_mm = (GstVaapiDisplayGetSizeMFunc)
gst_vaapi_display_egl_get_size_mm;
dpy_class->get_visual_id = (GstVaapiDisplayGetVisualIdFunc)
gst_vaapi_display_egl_get_visual_id;
dpy_class->create_window = (GstVaapiDisplayCreateWindowFunc)
gst_vaapi_display_egl_create_window;
dpy_class->create_texture = (GstVaapiDisplayCreateTextureFunc)
gst_vaapi_display_egl_create_texture;
dpy_class->bind_display = gst_vaapi_display_egl_bind_display;
dpy_class->close_display = gst_vaapi_display_egl_close_display;
dpy_class->lock = gst_vaapi_display_egl_lock;
dpy_class->unlock = gst_vaapi_display_egl_unlock;
dpy_class->sync = gst_vaapi_display_egl_sync;
dpy_class->flush = gst_vaapi_display_egl_flush;
dpy_class->get_display = gst_vaapi_display_egl_get_display_info;
dpy_class->get_size = gst_vaapi_display_egl_get_size;
dpy_class->get_size_mm = gst_vaapi_display_egl_get_size_mm;
dpy_class->get_visual_id = gst_vaapi_display_egl_get_visual_id;
dpy_class->create_window = gst_vaapi_display_egl_create_window;
dpy_class->create_texture = gst_vaapi_display_egl_create_texture;
dpy_class->get_texture_map = gst_vaapi_display_egl_get_texture_map;
}
static inline const GstVaapiDisplayClass *
gst_vaapi_display_egl_class (void)
{
static GstVaapiDisplayEGLClass g_class;
static gsize g_class_init = FALSE;
if (g_once_init_enter (&g_class_init)) {
gst_vaapi_display_egl_class_init (&g_class);
g_once_init_leave (&g_class_init, TRUE);
}
return GST_VAAPI_DISPLAY_CLASS (&g_class);
}
/**
* gst_vaapi_display_egl_new:
* @display: a #GstVaapiDisplay, or %NULL to pick any one
@ -360,7 +345,7 @@ gst_vaapi_display_egl_new (GstVaapiDisplay * display, guint gles_version)
params.display_type = GST_VAAPI_DISPLAY_TYPE_ANY;
}
params.gles_version = gles_version;
return gst_vaapi_display_new (gst_vaapi_display_egl_class (),
return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_EGL, NULL),
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, &params);
}
@ -391,7 +376,7 @@ gst_vaapi_display_egl_new_with_native_display (gpointer native_display,
params.display = native_display;
params.display_type = display_type;
params.gles_version = gles_version;
return gst_vaapi_display_new (gst_vaapi_display_egl_class (),
return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_EGL, NULL),
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, &params);
}

View file

@ -30,8 +30,9 @@ G_BEGIN_DECLS
typedef struct _GstVaapiDisplayEGL GstVaapiDisplayEGL;
#define GST_TYPE_VAAPI_DISPLAY_EGL (gst_vaapi_display_egl_get_type ())
#define GST_VAAPI_DISPLAY_EGL(obj) \
((GstVaapiDisplayEGL *)(obj))
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPI_DISPLAY_EGL, GstVaapiDisplayEGL))
GstVaapiDisplay *
gst_vaapi_display_egl_new (GstVaapiDisplay * display, guint gles_version);
@ -50,6 +51,9 @@ gboolean
gst_vaapi_display_egl_set_gl_context (GstVaapiDisplayEGL * display,
EGLContext gl_context);
GType
gst_vaapi_display_egl_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* GST_VAAPI_DISPLAY_EGL_H */

View file

@ -32,14 +32,16 @@
G_BEGIN_DECLS
#define GST_VAAPI_IS_DISPLAY_EGL(display) \
((display) != NULL && \
GST_VAAPI_DISPLAY_GET_CLASS_TYPE (display) == GST_VAAPI_DISPLAY_TYPE_EGL)
(G_TYPE_CHECK_INSTANCE_TYPE ((display), GST_TYPE_VAAPI_DISPLAY_EGL))
#define GST_VAAPI_DISPLAY_EGL_CLASS(klass) \
((GstVaapiDisplayEGLClass *)(klass))
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VAAPI_DISPLAY_EGL, GstVaapiDisplayEGLClass))
#define GST_VAAPI_DISPLAY_EGL_GET_CLASS(obj) \
GST_VAAPI_DISPLAY_EGL_CLASS (GST_VAAPI_DISPLAY_GET_CLASS (obj))
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VAAPI_DISPLAY_EGL, GstVaapiDisplayEGLClass))
#define GST_VAAPI_DISPLAY_EGL_CAST(obj) \
((GstVaapiDisplayEGL *)(obj))
/**
* GST_VAAPI_DISPLAY_EGL_DISPLAY:
@ -50,7 +52,7 @@ G_BEGIN_DECLS
*/
#undef GST_VAAPI_DISPLAY_EGL_DISPLAY
#define GST_VAAPI_DISPLAY_EGL_DISPLAY(display) \
(GST_VAAPI_DISPLAY_EGL (display)->egl_display)
(GST_VAAPI_DISPLAY_EGL_CAST (display)->egl_display)
/**
* GST_VAAPI_DISPLAY_EGL_CONTEXT:
@ -92,7 +94,6 @@ struct _GstVaapiDisplayEGLClass
{
/*< private >*/
GstVaapiDisplayClass parent_class;
GDestroyNotify parent_finalize;
};
G_GNUC_INTERNAL

View file

@ -38,9 +38,12 @@
#include "gstvaapiwindow_glx.h"
#include "gstvaapitexture_glx.h"
#define DEBUG 1
#define DEBUG_VAAPI_DISPLAY 1
#include "gstvaapidebug.h"
G_DEFINE_TYPE (GstVaapiDisplayGLX, gst_vaapi_display_glx,
GST_TYPE_VAAPI_DISPLAY_X11);
static GstVaapiWindow *
gst_vaapi_display_glx_create_window (GstVaapiDisplay * display, GstVaapiID id,
guint width, guint height)
@ -85,48 +88,33 @@ gst_vaapi_display_glx_get_texture_map (GstVaapiDisplay * display)
}
static void
gst_vaapi_display_glx_finalize (GstVaapiDisplay * display)
gst_vaapi_display_glx_finalize (GObject * object)
{
GstVaapiDisplayGLX *dpy = GST_VAAPI_DISPLAY_GLX (display);
GstVaapiDisplayGLX *dpy = GST_VAAPI_DISPLAY_GLX (object);
if (dpy->texture_map)
gst_object_unref (dpy->texture_map);
GST_VAAPI_DISPLAY_GLX_GET_CLASS (display)->parent_finalize (display);
G_OBJECT_CLASS (gst_vaapi_display_glx_parent_class)->finalize (object);
}
static void
gst_vaapi_display_glx_init (GstVaapiDisplayGLX * display)
{
}
static void
gst_vaapi_display_glx_class_init (GstVaapiDisplayGLXClass * klass)
{
GstVaapiMiniObjectClass *const object_class =
GST_VAAPI_MINI_OBJECT_CLASS (klass);
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
GstVaapiDisplayClass *const dpy_class = GST_VAAPI_DISPLAY_CLASS (klass);
gst_vaapi_display_x11_class_init (&klass->parent_class);
/* chain up destructor */
klass->parent_finalize = object_class->finalize;
object_class->finalize = (GDestroyNotify) gst_vaapi_display_glx_finalize;
object_class->size = sizeof (GstVaapiDisplayGLX);
object_class->finalize = gst_vaapi_display_glx_finalize;
dpy_class->display_type = GST_VAAPI_DISPLAY_TYPE_GLX;
dpy_class->create_window = gst_vaapi_display_glx_create_window;
dpy_class->create_texture = gst_vaapi_display_glx_create_texture;
dpy_class->get_texture_map = gst_vaapi_display_glx_get_texture_map;
}
static inline const GstVaapiDisplayClass *
gst_vaapi_display_glx_class (void)
{
static GstVaapiDisplayGLXClass g_class;
static gsize g_class_init = FALSE;
if (g_once_init_enter (&g_class_init)) {
gst_vaapi_display_glx_class_init (&g_class);
g_once_init_leave (&g_class_init, TRUE);
}
return GST_VAAPI_DISPLAY_CLASS (&g_class);
}
/**
* gst_vaapi_display_glx_new:
* @display_name: the X11 display name
@ -140,7 +128,7 @@ gst_vaapi_display_glx_class (void)
GstVaapiDisplay *
gst_vaapi_display_glx_new (const gchar * display_name)
{
return gst_vaapi_display_new (gst_vaapi_display_glx_class (),
return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_GLX, NULL),
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) display_name);
}
@ -160,6 +148,6 @@ gst_vaapi_display_glx_new_with_display (Display * x11_display)
{
g_return_val_if_fail (x11_display != NULL, NULL);
return gst_vaapi_display_new (gst_vaapi_display_glx_class (),
return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_GLX, NULL),
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, x11_display);
}

View file

@ -29,8 +29,9 @@
G_BEGIN_DECLS
#define GST_TYPE_VAAPI_DISPLAY_GLX (gst_vaapi_display_glx_get_type ())
#define GST_VAAPI_DISPLAY_GLX(obj) \
((GstVaapiDisplayGLX *)(obj))
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPI_DISPLAY_GLX, GstVaapiDisplayGLX))
typedef struct _GstVaapiDisplayGLX GstVaapiDisplayGLX;
@ -40,6 +41,9 @@ gst_vaapi_display_glx_new (const gchar * display_name);
GstVaapiDisplay *
gst_vaapi_display_glx_new_with_display (Display * x11_display);
GType
gst_vaapi_display_glx_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* GST_VAAPI_DISPLAY_GLX_H */

View file

@ -31,17 +31,16 @@
G_BEGIN_DECLS
#define GST_VAAPI_IS_DISPLAY_GLX(display) \
((display) != NULL && \
GST_VAAPI_DISPLAY_GET_CLASS_TYPE (display) == GST_VAAPI_DISPLAY_TYPE_GLX)
(G_TYPE_CHECK_INSTANCE_TYPE ((display), GST_TYPE_VAAPI_DISPLAY_GLX))
#define GST_VAAPI_DISPLAY_GLX_CAST(display) \
((GstVaapiDisplayGLX *)(display))
#define GST_VAAPI_DISPLAY_GLX_CLASS(klass) \
((GstVaapiDisplayGLXClass *)(klass))
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VAAPI_DISPLAY_GLX, GstVaapiDisplayGLXClass))
#define GST_VAAPI_DISPLAY_GLX_GET_CLASS(obj) \
GST_VAAPI_DISPLAY_GLX_CLASS(GST_VAAPI_MINI_OBJECT_GET_CLASS(obj))
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VAAPI_DISPLAY_GLX, GstVaapiDisplayGLXClass))
typedef struct _GstVaapiDisplayGLXClass GstVaapiDisplayGLXClass;
@ -66,7 +65,6 @@ struct _GstVaapiDisplayGLXClass
{
/*< private >*/
GstVaapiDisplayX11Class parent_class;
GDestroyNotify parent_finalize;
};
G_END_DECLS

View file

@ -35,53 +35,24 @@
G_BEGIN_DECLS
#define GST_VAAPI_DISPLAY_CAST(display) \
((GstVaapiDisplay *) (display))
((GstVaapiDisplay *)(display))
#define GST_VAAPI_DISPLAY_GET_PRIVATE(display) \
(&GST_VAAPI_DISPLAY_CAST (display)->priv)
(GST_VAAPI_DISPLAY_CAST (display)->priv)
#define GST_VAAPI_DISPLAY_CLASS(klass) \
((GstVaapiDisplayClass *) (klass))
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VAAPI_DISPLAY, GstVaapiDisplayClass))
#define GST_VAAPI_IS_DISPLAY_CLASS(klass) \
((klass) != NULL)
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VAAPI_DISPLAY))
#define GST_VAAPI_DISPLAY_GET_CLASS(obj) \
GST_VAAPI_DISPLAY_CLASS (GST_VAAPI_MINI_OBJECT_GET_CLASS (obj))
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VAAPI_DISPLAY, GstVaapiDisplayClass))
typedef struct _GstVaapiDisplayPrivate GstVaapiDisplayPrivate;
typedef struct _GstVaapiDisplayClass GstVaapiDisplayClass;
typedef enum _GstVaapiDisplayInitType GstVaapiDisplayInitType;
typedef void (*GstVaapiDisplayInitFunc) (GstVaapiDisplay * display);
typedef gboolean (*GstVaapiDisplayBindFunc) (GstVaapiDisplay * display,
gpointer native_dpy);
typedef gboolean (*GstVaapiDisplayOpenFunc) (GstVaapiDisplay * display,
const gchar * name);
typedef void (*GstVaapiDisplayCloseFunc) (GstVaapiDisplay * display);
typedef void (*GstVaapiDisplayLockFunc) (GstVaapiDisplay * display);
typedef void (*GstVaapiDisplayUnlockFunc) (GstVaapiDisplay * display);
typedef void (*GstVaapiDisplaySyncFunc) (GstVaapiDisplay * display);
typedef void (*GstVaapiDisplayFlushFunc) (GstVaapiDisplay * display);
typedef gboolean (*GstVaapiDisplayGetInfoFunc) (GstVaapiDisplay * display,
GstVaapiDisplayInfo * info);
typedef void (*GstVaapiDisplayGetSizeFunc) (GstVaapiDisplay * display,
guint * pwidth, guint * pheight);
typedef void (*GstVaapiDisplayGetSizeMFunc) (GstVaapiDisplay * display,
guint * pwidth, guint * pheight);
typedef GstVaapiWindow *(*GstVaapiDisplayCreateWindowFunc) (
GstVaapiDisplay * display, GstVaapiID id, guint width, guint height);
typedef GstVaapiTexture *(*GstVaapiDisplayCreateTextureFunc) (
GstVaapiDisplay * display, GstVaapiID id, guint target, guint format,
guint width, guint height);
typedef GstVaapiTextureMap *(*GstVaapiDisplayGetTextureMapFunc) (
GstVaapiDisplay * display);
typedef guintptr (*GstVaapiDisplayGetVisualIdFunc) (GstVaapiDisplay * display,
GstVaapiWindow * window);
typedef guintptr (*GstVaapiDisplayGetColormapFunc) (GstVaapiDisplay * display,
GstVaapiWindow * window);
/**
* GST_VAAPI_DISPLAY_GET_CLASS_TYPE:
* @display: a #GstVaapiDisplay
@ -182,9 +153,9 @@ struct _GstVaapiDisplayPrivate
struct _GstVaapiDisplay
{
/*< private >*/
GstVaapiMiniObject parent_instance;
GstObject parent_instance;
GstVaapiDisplayPrivate priv;
GstVaapiDisplayPrivate *priv;
};
/**
@ -202,34 +173,36 @@ struct _GstVaapiDisplay
* @get_colormap: (optional) virtual function to retrieve the window colormap
* @create_window: (optional) virtual function to create a window
* @create_texture: (optional) virtual function to create a texture
* @get_texture_map: (optional) virtual function to get texture map
*
* Base class for VA displays.
*/
struct _GstVaapiDisplayClass
{
/*< private >*/
GstVaapiMiniObjectClass parent_class;
GstObjectClass parent_class;
/*< protected >*/
guint display_type;
/*< public >*/
GstVaapiDisplayInitFunc init;
GstVaapiDisplayBindFunc bind_display;
GstVaapiDisplayOpenFunc open_display;
GstVaapiDisplayCloseFunc close_display;
GstVaapiDisplayLockFunc lock;
GstVaapiDisplayUnlockFunc unlock;
GstVaapiDisplaySyncFunc sync;
GstVaapiDisplayFlushFunc flush;
GstVaapiDisplayGetInfoFunc get_display;
GstVaapiDisplayGetSizeFunc get_size;
GstVaapiDisplayGetSizeMFunc get_size_mm;
GstVaapiDisplayGetVisualIdFunc get_visual_id;
GstVaapiDisplayGetColormapFunc get_colormap;
GstVaapiDisplayCreateWindowFunc create_window;
GstVaapiDisplayCreateTextureFunc create_texture;
GstVaapiDisplayGetTextureMapFunc get_texture_map;
void (*init) (GstVaapiDisplay * display);
gboolean (*bind_display) (GstVaapiDisplay * display, gpointer native_dpy);
gboolean (*open_display) (GstVaapiDisplay * display, const gchar * name);
void (*close_display) (GstVaapiDisplay * display);
void (*lock) (GstVaapiDisplay * display);
void (*unlock) (GstVaapiDisplay * display);
void (*sync) (GstVaapiDisplay * display);
void (*flush) (GstVaapiDisplay * display);
gboolean (*get_display) (GstVaapiDisplay * display, GstVaapiDisplayInfo * info);
void (*get_size) (GstVaapiDisplay * display, guint * pwidth, guint * pheight);
void (*get_size_mm) (GstVaapiDisplay * display, guint * pwidth, guint * pheight);
guintptr (*get_visual_id) (GstVaapiDisplay * display, GstVaapiWindow * window);
guintptr (*get_colormap) (GstVaapiDisplay * display, GstVaapiWindow * window);
GstVaapiWindow *(*create_window) (GstVaapiDisplay * display, GstVaapiID id, guint width, guint height);
GstVaapiTexture *(*create_texture) (GstVaapiDisplay * display, GstVaapiID id, guint target, guint format,
guint width, guint height);
GstVaapiTextureMap *(*get_texture_map) (GstVaapiDisplay * display);
};
/* Initialization types */
@ -240,36 +213,32 @@ enum _GstVaapiDisplayInitType
GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY
};
void
gst_vaapi_display_class_init (GstVaapiDisplayClass * klass);
GstVaapiDisplay *
gst_vaapi_display_new (const GstVaapiDisplayClass * klass,
gst_vaapi_display_new (GstVaapiDisplay * display,
GstVaapiDisplayInitType init_type, gpointer init_value);
/* Inline reference counting for core libgstvaapi library */
#ifdef IN_LIBGSTVAAPI_CORE
#define gst_vaapi_display_ref_internal(display) \
((gpointer)gst_vaapi_mini_object_ref(GST_VAAPI_MINI_OBJECT(display)))
((gpointer) gst_object_ref (GST_OBJECT (display)))
#define gst_vaapi_display_unref_internal(display) \
gst_vaapi_mini_object_unref(GST_VAAPI_MINI_OBJECT(display))
gst_object_unref (GST_OBJECT (display))
#define gst_vaapi_display_replace_internal(old_display_ptr, new_display) \
gst_vaapi_mini_object_replace((GstVaapiMiniObject **)(old_display_ptr), \
GST_VAAPI_MINI_OBJECT(new_display))
gst_object_replace ((GstObject **)(old_display_ptr), GST_OBJECT (new_display))
#undef gst_vaapi_display_ref
#define gst_vaapi_display_ref(display) \
gst_vaapi_display_ref_internal((display))
gst_vaapi_display_ref_internal ((display))
#undef gst_vaapi_display_unref
#define gst_vaapi_display_unref(display) \
gst_vaapi_display_unref_internal((display))
gst_vaapi_display_unref_internal ((display))
#undef gst_vaapi_display_replace
#define gst_vaapi_display_replace(old_display_ptr, new_display) \
gst_vaapi_display_replace_internal((old_display_ptr), (new_display))
gst_vaapi_display_replace_internal ((old_display_ptr), (new_display))
#endif
G_END_DECLS

View file

@ -33,9 +33,15 @@
#include "gstvaapidisplay_wayland_priv.h"
#include "gstvaapiwindow_wayland.h"
#define DEBUG 1
#define DEBUG_VAAPI_DISPLAY 1
#include "gstvaapidebug.h"
#define _do_init \
G_ADD_PRIVATE (GstVaapiDisplayWayland);
G_DEFINE_TYPE_WITH_CODE (GstVaapiDisplayWayland, gst_vaapi_display_wayland,
GST_TYPE_VAAPI_DISPLAY, _do_init);
static const guint g_display_types = 1U << GST_VAAPI_DISPLAY_TYPE_WAYLAND;
static inline const gchar *
@ -342,26 +348,22 @@ gst_vaapi_display_wayland_create_window (GstVaapiDisplay * display,
}
static void
gst_vaapi_display_wayland_init (GstVaapiDisplay * display)
gst_vaapi_display_wayland_init (GstVaapiDisplayWayland * display)
{
GstVaapiDisplayWaylandPrivate *const priv =
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
gst_vaapi_display_wayland_get_instance_private (display);
display->priv = priv;
priv->event_fd = -1;
}
static void
gst_vaapi_display_wayland_class_init (GstVaapiDisplayWaylandClass * klass)
{
GstVaapiMiniObjectClass *const object_class =
GST_VAAPI_MINI_OBJECT_CLASS (klass);
GstVaapiDisplayClass *const dpy_class = GST_VAAPI_DISPLAY_CLASS (klass);
gst_vaapi_display_class_init (&klass->parent_class);
object_class->size = sizeof (GstVaapiDisplayWayland);
dpy_class->display_type = GST_VAAPI_DISPLAY_TYPE_WAYLAND;
dpy_class->init = gst_vaapi_display_wayland_init;
dpy_class->bind_display = gst_vaapi_display_wayland_bind_display;
dpy_class->open_display = gst_vaapi_display_wayland_open_display;
dpy_class->close_display = gst_vaapi_display_wayland_close_display;
@ -371,19 +373,6 @@ gst_vaapi_display_wayland_class_init (GstVaapiDisplayWaylandClass * klass)
dpy_class->create_window = gst_vaapi_display_wayland_create_window;
}
static inline const GstVaapiDisplayClass *
gst_vaapi_display_wayland_class (void)
{
static GstVaapiDisplayWaylandClass g_class;
static gsize g_class_init = FALSE;
if (g_once_init_enter (&g_class_init)) {
gst_vaapi_display_wayland_class_init (&g_class);
g_once_init_leave (&g_class_init, TRUE);
}
return GST_VAAPI_DISPLAY_CLASS (&g_class);
}
/**
* gst_vaapi_display_wayland_new:
* @display_name: the Wayland display name
@ -397,8 +386,9 @@ gst_vaapi_display_wayland_class (void)
GstVaapiDisplay *
gst_vaapi_display_wayland_new (const gchar * display_name)
{
return gst_vaapi_display_new (gst_vaapi_display_wayland_class (),
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) 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);
}
/**
@ -417,8 +407,8 @@ gst_vaapi_display_wayland_new_with_display (struct wl_display * wl_display)
{
g_return_val_if_fail (wl_display, NULL);
return gst_vaapi_display_new (gst_vaapi_display_wayland_class (),
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, wl_display);
return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_WAYLAND,
NULL), GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, wl_display);
}
/**

View file

@ -29,8 +29,9 @@
G_BEGIN_DECLS
#define GST_TYPE_VAAPI_DISPLAY_WAYLAND (gst_vaapi_display_wayland_get_type ())
#define GST_VAAPI_DISPLAY_WAYLAND(obj) \
((GstVaapiDisplayWayland *)(obj))
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPI_DISPLAY_WAYLAND, GstVaapiDisplayWayland))
typedef struct _GstVaapiDisplayWayland GstVaapiDisplayWayland;
@ -43,6 +44,9 @@ gst_vaapi_display_wayland_new_with_display (struct wl_display * wl_display);
struct wl_display *
gst_vaapi_display_wayland_get_display (GstVaapiDisplayWayland * display);
GType
gst_vaapi_display_wayland_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* GST_VAAPI_DISPLAY_WAYLAND_H */

View file

@ -30,14 +30,16 @@
G_BEGIN_DECLS
#define GST_VAAPI_IS_DISPLAY_WAYLAND(display) \
((display) != NULL && \
GST_VAAPI_DISPLAY_VADISPLAY_TYPE (display) == GST_VAAPI_DISPLAY_TYPE_WAYLAND)
(G_TYPE_CHECK_INSTANCE_TYPE ((display), GST_TYPE_VAAPI_DISPLAY_WAYLAND))
#define GST_VAAPI_DISPLAY_WAYLAND_CAST(display) \
((GstVaapiDisplayWayland *)(display))
#define GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(display) \
(&GST_VAAPI_DISPLAY_WAYLAND_CAST(display)->priv)
(GST_VAAPI_DISPLAY_WAYLAND_CAST(display)->priv)
#define GST_VAAPI_DISPLAY_WAYLAND_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VAAPI_DISPLAY_WAYLAND, GstVaapiDisplayWaylandClass))
typedef struct _GstVaapiDisplayWaylandPrivate GstVaapiDisplayWaylandPrivate;
typedef struct _GstVaapiDisplayWaylandClass GstVaapiDisplayWaylandClass;
@ -79,7 +81,7 @@ struct _GstVaapiDisplayWayland
/*< private >*/
GstVaapiDisplay parent_instance;
GstVaapiDisplayWaylandPrivate priv;
GstVaapiDisplayWaylandPrivate *priv;
};
/**

View file

@ -43,9 +43,15 @@
# include <X11/extensions/Xrender.h>
#endif
#define DEBUG 1
#define DEBUG_VAAPI_DISPLAY 1
#include "gstvaapidebug.h"
#define _do_init \
G_ADD_PRIVATE (GstVaapiDisplayX11);
G_DEFINE_TYPE_WITH_CODE (GstVaapiDisplayX11, gst_vaapi_display_x11,
GST_TYPE_VAAPI_DISPLAY, _do_init);
static const guint g_display_types = 1U << GST_VAAPI_DISPLAY_TYPE_X11;
static gboolean
@ -114,7 +120,7 @@ get_default_display_name (void)
static const gchar *
get_display_name (GstVaapiDisplayX11 * display)
{
GstVaapiDisplayX11Private *const priv = &display->priv;
GstVaapiDisplayX11Private *const priv = display->priv;
const gchar *display_name = priv->display_name;
if (!display_name || *display_name == '\0')
@ -126,7 +132,7 @@ get_display_name (GstVaapiDisplayX11 * display)
static gboolean
set_display_name (GstVaapiDisplayX11 * display, const gchar * display_name)
{
GstVaapiDisplayX11Private *const priv = &display->priv;
GstVaapiDisplayX11Private *const priv = display->priv;
g_free (priv->display_name);
@ -143,7 +149,7 @@ set_display_name (GstVaapiDisplayX11 * display, const gchar * display_name)
static void
set_synchronous (GstVaapiDisplayX11 * display, gboolean synchronous)
{
GstVaapiDisplayX11Private *const priv = &display->priv;
GstVaapiDisplayX11Private *const priv = display->priv;
if (priv->synchronous != synchronous) {
priv->synchronous = synchronous;
@ -159,8 +165,7 @@ set_synchronous (GstVaapiDisplayX11 * display, gboolean synchronous)
static void
check_extensions (GstVaapiDisplayX11 * display)
{
GstVaapiDisplayX11Private *const priv =
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
GstVaapiDisplayX11Private *const priv = display->priv;
int evt_base, err_base;
#ifdef HAVE_XRANDR
@ -178,7 +183,7 @@ gst_vaapi_display_x11_bind_display (GstVaapiDisplay * base_display,
gpointer native_display)
{
GstVaapiDisplayX11 *const display = GST_VAAPI_DISPLAY_X11_CAST (base_display);
GstVaapiDisplayX11Private *const priv = &display->priv;
GstVaapiDisplayX11Private *const priv = display->priv;
priv->x11_display = native_display;
priv->x11_screen = DefaultScreen (native_display);
@ -196,7 +201,8 @@ gst_vaapi_display_x11_open_display (GstVaapiDisplay * base_display,
const gchar * name)
{
GstVaapiDisplayX11 *const display = GST_VAAPI_DISPLAY_X11_CAST (base_display);
GstVaapiDisplayX11Private *const priv = &display->priv;
GstVaapiDisplayX11Private *const priv = display->priv;
GstVaapiDisplayCache *const cache = GST_VAAPI_DISPLAY_CACHE (display);
const GstVaapiDisplayInfo *info;
@ -381,13 +387,8 @@ gst_vaapi_display_x11_create_window (GstVaapiDisplay * display, GstVaapiID id,
void
gst_vaapi_display_x11_class_init (GstVaapiDisplayX11Class * klass)
{
GstVaapiMiniObjectClass *const object_class =
GST_VAAPI_MINI_OBJECT_CLASS (klass);
GstVaapiDisplayClass *const dpy_class = GST_VAAPI_DISPLAY_CLASS (klass);
gst_vaapi_display_class_init (&klass->parent_class);
object_class->size = sizeof (GstVaapiDisplayX11);
dpy_class->display_type = GST_VAAPI_DISPLAY_TYPE_X11;
dpy_class->bind_display = gst_vaapi_display_x11_bind_display;
dpy_class->open_display = gst_vaapi_display_x11_open_display;
@ -400,17 +401,13 @@ gst_vaapi_display_x11_class_init (GstVaapiDisplayX11Class * klass)
dpy_class->create_window = gst_vaapi_display_x11_create_window;
}
static inline const GstVaapiDisplayClass *
gst_vaapi_display_x11_class (void)
static void
gst_vaapi_display_x11_init (GstVaapiDisplayX11 * display)
{
static GstVaapiDisplayX11Class g_class;
static gsize g_class_init = FALSE;
GstVaapiDisplayX11Private *const priv =
gst_vaapi_display_x11_get_instance_private (display);
if (g_once_init_enter (&g_class_init)) {
gst_vaapi_display_x11_class_init (&g_class);
g_once_init_leave (&g_class_init, TRUE);
}
return GST_VAAPI_DISPLAY_CLASS (&g_class);
display->priv = priv;
}
/**
@ -426,7 +423,7 @@ gst_vaapi_display_x11_class (void)
GstVaapiDisplay *
gst_vaapi_display_x11_new (const gchar * display_name)
{
return gst_vaapi_display_new (gst_vaapi_display_x11_class (),
return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_X11, NULL),
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) display_name);
}
@ -446,7 +443,7 @@ gst_vaapi_display_x11_new_with_display (Display * x11_display)
{
g_return_val_if_fail (x11_display, NULL);
return gst_vaapi_display_new (gst_vaapi_display_x11_class (),
return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_X11, NULL),
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, x11_display);
}

View file

@ -30,8 +30,9 @@
G_BEGIN_DECLS
#define GST_TYPE_VAAPI_DISPLAY_X11 (gst_vaapi_display_x11_get_type ())
#define GST_VAAPI_DISPLAY_X11(obj) \
((GstVaapiDisplayX11 *)(obj))
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPI_DISPLAY_X11, GstVaapiDisplayX11))
typedef struct _GstVaapiDisplayX11 GstVaapiDisplayX11;
@ -51,6 +52,9 @@ void
gst_vaapi_display_x11_set_synchronous (GstVaapiDisplayX11 * display,
gboolean synchronous);
GType
gst_vaapi_display_x11_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* GST_VAAPI_DISPLAY_X11_H */

View file

@ -32,14 +32,16 @@
G_BEGIN_DECLS
#define GST_VAAPI_IS_DISPLAY_X11(display) \
((display) != NULL && \
GST_VAAPI_DISPLAY_VADISPLAY_TYPE (display) == GST_VAAPI_DISPLAY_TYPE_X11)
(G_TYPE_CHECK_INSTANCE_TYPE ((display), GST_TYPE_VAAPI_DISPLAY_X11))
#define GST_VAAPI_DISPLAY_X11_CAST(display) \
((GstVaapiDisplayX11 *)(display))
#define GST_VAAPI_DISPLAY_X11_PRIVATE(display) \
(&GST_VAAPI_DISPLAY_X11_CAST(display)->priv)
(GST_VAAPI_DISPLAY_X11_CAST (display)->priv)
#define GST_VAAPI_DISPLAY_X11_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VAAPI_DISPLAY_X11, GstVaapiDisplayX11Class))
typedef struct _GstVaapiDisplayX11Private GstVaapiDisplayX11Private;
typedef struct _GstVaapiDisplayX11Class GstVaapiDisplayX11Class;
@ -97,13 +99,13 @@ struct _GstVaapiDisplayX11
/*< private >*/
GstVaapiDisplay parent_instance;
GstVaapiDisplayX11Private priv;
GstVaapiDisplayX11Private *priv;
};
/**
* GstVaapiDisplayX11Class:
*
* VA/X11 display wrapper clas.
* VA/X11 display wrapper class.
*/
struct _GstVaapiDisplayX11Class
{
@ -111,9 +113,6 @@ struct _GstVaapiDisplayX11Class
GstVaapiDisplayClass parent_class;
};
void
gst_vaapi_display_x11_class_init (GstVaapiDisplayX11Class * klass);
G_GNUC_INTERNAL
GstVideoFormat
gst_vaapi_display_x11_get_pixmap_format (GstVaapiDisplayX11 * display,

View file

@ -37,6 +37,9 @@
#include "gstvaapisurface_egl.h"
#include "gstvaapifilter.h"
#define DEBUG 1
#include "gstvaapidebug.h"
#define GST_VAAPI_TEXTURE_EGL(texture) \
((GstVaapiTextureEGL *) (texture))

View file

@ -23,6 +23,9 @@
#include "sysdeps.h"
#include "gstvaapiutils_egl.h"
#define DEBUG 1
#include "gstvaapidebug.h"
typedef struct egl_message_s EglMessage;
struct egl_message_s
{

View file

@ -29,9 +29,6 @@
#include "egl_compat.h"
#include "gstvaapiminiobject.h"
GST_DEBUG_CATEGORY_EXTERN (gst_debug_vaapidisplay_egl);
#define GST_CAT_DEFAULT gst_debug_vaapidisplay_egl
typedef union egl_handle_s EglHandle;
typedef struct egl_object_s EglObject;
typedef struct egl_object_class_s EglObjectClass;

View file

@ -31,17 +31,6 @@
GST_DEBUG_CATEGORY_STATIC (GST_CAT_CONTEXT);
#define GST_VAAPI_TYPE_DISPLAY \
gst_vaapi_display_get_type ()
/* *INDENT-OFF* */
static GType gst_vaapi_display_get_type (void) G_GNUC_CONST;
/* *INDENT-ON* */
G_DEFINE_BOXED_TYPE (GstVaapiDisplay, gst_vaapi_display,
(GBoxedCopyFunc) gst_vaapi_display_ref,
(GBoxedFreeFunc) gst_vaapi_display_unref);
static void
_init_context_debug (void)
{
@ -65,7 +54,7 @@ gst_vaapi_video_context_set_display (GstContext * context,
structure = gst_context_writable_structure (context);
gst_structure_set (structure, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME,
GST_VAAPI_TYPE_DISPLAY, display, NULL);
GST_TYPE_VAAPI_DISPLAY, display, NULL);
}
GstContext *
@ -91,7 +80,7 @@ gst_vaapi_video_context_get_display (GstContext * context,
structure = gst_context_get_structure (context);
return gst_structure_get (structure, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME,
GST_VAAPI_TYPE_DISPLAY, display_ptr, NULL);
GST_TYPE_VAAPI_DISPLAY, display_ptr, NULL);
}
static gboolean