libs: surface: port to GstMiniObject
authorHe Junyan <junyan.he@hotmail.com>
Thu, 19 Dec 2019 13:19:10 +0000 (14:19 +0100)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 20 Dec 2019 05:01:08 +0000 (05:01 +0000)
GstVaapiMiniObject and GstVaapiObject are deprecated.

This is the first step to remove them by porting GstVaapiSurface as
a GstMiniBuffer descendant.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
28 files changed:
gst-libs/gst/vaapi/gstvaapibufferproxy.c
gst-libs/gst/vaapi/gstvaapibufferproxy_priv.h
gst-libs/gst/vaapi/gstvaapicontext.c
gst-libs/gst/vaapi/gstvaapiencoder_h264_fei.c
gst-libs/gst/vaapi/gstvaapiencoder_objects.c
gst-libs/gst/vaapi/gstvaapifilter.c
gst-libs/gst/vaapi/gstvaapipixmap_x11.c
gst-libs/gst/vaapi/gstvaapisurface.c
gst-libs/gst/vaapi/gstvaapisurface.h
gst-libs/gst/vaapi/gstvaapisurface_drm.c
gst-libs/gst/vaapi/gstvaapisurface_egl.c
gst-libs/gst/vaapi/gstvaapisurface_priv.h
gst-libs/gst/vaapi/gstvaapisurfaceproxy.c
gst-libs/gst/vaapi/gstvaapisurfaceproxy_priv.h
gst-libs/gst/vaapi/gstvaapitexture_egl.c
gst-libs/gst/vaapi/gstvaapitexture_glx.c
gst-libs/gst/vaapi/gstvaapivideopool.c
gst-libs/gst/vaapi/gstvaapiwindow.c
gst-libs/gst/vaapi/gstvaapiwindow_wayland.c
gst-libs/gst/vaapi/gstvaapiwindow_x11.c
gst/vaapi/gstvaapipluginbase.c
gst/vaapi/gstvaapivideomemory.c
gst/vaapi/gstvaapivideometa.c
gst/vaapi/gstvaapivideometa_texture.c
tests/internal/image.c
tests/internal/test-filter.c
tests/internal/test-surfaces.c
tests/internal/test-windows.c

index c177ceb..c8fe234 100644 (file)
@@ -24,6 +24,7 @@
 #include "gstvaapicompat.h"
 #include "gstvaapibufferproxy.h"
 #include "gstvaapibufferproxy_priv.h"
+#include "gstvaapisurface_priv.h"
 #include "gstvaapiutils.h"
 #include "gstvaapiobject_priv.h"
 
@@ -33,6 +34,7 @@
 static gboolean
 gst_vaapi_buffer_proxy_acquire_handle (GstVaapiBufferProxy * proxy)
 {
+  GstVaapiDisplay *display;
   const guint mem_type = proxy->va_info.mem_type;
   VAStatus va_status;
 
@@ -42,10 +44,13 @@ gst_vaapi_buffer_proxy_acquire_handle (GstVaapiBufferProxy * proxy)
   if (!proxy->parent || proxy->va_buf == VA_INVALID_ID)
     return FALSE;
 
-  GST_VAAPI_OBJECT_LOCK_DISPLAY (proxy->parent);
-  va_status = vaAcquireBufferHandle (GST_VAAPI_OBJECT_VADISPLAY (proxy->parent),
+  /* @XXX(victor): parent might be not a surface */
+  display = GST_VAAPI_SURFACE_DISPLAY (GST_VAAPI_SURFACE (proxy->parent));
+
+  GST_VAAPI_DISPLAY_LOCK (display);
+  va_status = vaAcquireBufferHandle (GST_VAAPI_DISPLAY_VADISPLAY (display),
       proxy->va_buf, &proxy->va_info);
-  GST_VAAPI_OBJECT_UNLOCK_DISPLAY (proxy->parent);
+  GST_VAAPI_DISPLAY_UNLOCK (display);
   if (!vaapi_check_status (va_status, "vaAcquireBufferHandle()"))
     return FALSE;
   if (proxy->va_info.mem_type != mem_type)
@@ -56,6 +61,7 @@ gst_vaapi_buffer_proxy_acquire_handle (GstVaapiBufferProxy * proxy)
 static gboolean
 gst_vaapi_buffer_proxy_release_handle (GstVaapiBufferProxy * proxy)
 {
+  GstVaapiDisplay *display;
   VAStatus va_status;
 
   if (!proxy->va_info.handle)
@@ -64,10 +70,13 @@ gst_vaapi_buffer_proxy_release_handle (GstVaapiBufferProxy * proxy)
   if (!proxy->parent || proxy->va_buf == VA_INVALID_ID)
     return FALSE;
 
-  GST_VAAPI_OBJECT_LOCK_DISPLAY (proxy->parent);
-  va_status = vaReleaseBufferHandle (GST_VAAPI_OBJECT_VADISPLAY (proxy->parent),
+  /* @XXX(victor): parent might be not a surface */
+  display = GST_VAAPI_SURFACE_DISPLAY (GST_VAAPI_SURFACE (proxy->parent));
+
+  GST_VAAPI_DISPLAY_LOCK (display);
+  va_status = vaReleaseBufferHandle (GST_VAAPI_DISPLAY_VADISPLAY (display),
       proxy->va_buf);
-  GST_VAAPI_OBJECT_UNLOCK_DISPLAY (proxy->parent);
+  GST_VAAPI_DISPLAY_UNLOCK (display);
   if (!vaapi_check_status (va_status, "vaReleaseBufferHandle()"))
     return FALSE;
   return TRUE;
@@ -87,7 +96,7 @@ gst_vaapi_buffer_proxy_finalize (GstVaapiBufferProxy * proxy)
   if (proxy->destroy_func)
     proxy->destroy_func (proxy->destroy_data);
 
-  gst_vaapi_object_replace (&proxy->parent, NULL);
+  gst_mini_object_replace ((GstMiniObject **) & proxy->parent, NULL);
 }
 
 static inline const GstVaapiMiniObjectClass *
@@ -138,7 +147,7 @@ error_unsupported_mem_type:
 }
 
 GstVaapiBufferProxy *
-gst_vaapi_buffer_proxy_new_from_object (GstVaapiObject * object,
+gst_vaapi_buffer_proxy_new_from_object (GstMiniObject * object,
     VABufferID buf_id, guint type, GDestroyNotify destroy_func, gpointer data)
 {
   GstVaapiBufferProxy *proxy;
@@ -150,7 +159,7 @@ gst_vaapi_buffer_proxy_new_from_object (GstVaapiObject * object,
   if (!proxy)
     return NULL;
 
-  proxy->parent = gst_vaapi_object_ref (object);
+  proxy->parent = gst_mini_object_ref (object);
   proxy->destroy_func = destroy_func;
   proxy->destroy_data = data;
   proxy->type = type;
index d0fb9a2..66bfeb4 100644 (file)
@@ -62,7 +62,7 @@ G_BEGIN_DECLS
 struct _GstVaapiBufferProxy {
   /*< private >*/
   GstVaapiMiniObject    parent_instance;
-  GstVaapiObject       *parent;
+  GstMiniObject        *parent;
 
   GDestroyNotify        destroy_func;
   gpointer              destroy_data;
@@ -74,7 +74,7 @@ struct _GstVaapiBufferProxy {
 
 G_GNUC_INTERNAL
 GstVaapiBufferProxy *
-gst_vaapi_buffer_proxy_new_from_object (GstVaapiObject * object,
+gst_vaapi_buffer_proxy_new_from_object (GstMiniObject * object,
     VABufferID buf_id, guint type, GDestroyNotify destroy_func, gpointer data);
 
 G_GNUC_INTERNAL
index 358fdde..b26bb52 100644 (file)
@@ -147,7 +147,7 @@ context_create_surfaces (GstVaapiContext * context)
   num_surfaces = cip->ref_frames + SCRATCH_SURFACES_COUNT;
   if (!context->surfaces) {
     context->surfaces = g_ptr_array_new_full (num_surfaces,
-        (GDestroyNotify) gst_vaapi_object_unref);
+        (GDestroyNotify) gst_mini_object_unref);
     if (!context->surfaces)
       return FALSE;
   }
@@ -188,7 +188,7 @@ context_create (GstVaapiContext * context)
     GstVaapiSurface *const surface = g_ptr_array_index (context->surfaces, i);
     if (!surface)
       goto cleanup;
-    surface_id = GST_VAAPI_OBJECT_ID (surface);
+    surface_id = GST_VAAPI_SURFACE_ID (surface);
     g_array_append_val (surfaces, surface_id);
   }
   g_assert (surfaces->len == context->surfaces->len);
index 0492745..838c782 100644 (file)
@@ -3833,7 +3833,7 @@ create_context_for_enc (GstVaapiEncoder * fei_encoder,
     GstVaapiSurface *const surface = g_ptr_array_index (context->surfaces, i);
     if (!surface)
       goto cleanup;
-    surface_id = GST_VAAPI_OBJECT_ID (surface);
+    surface_id = GST_VAAPI_SURFACE_ID (surface);
     g_array_append_val (surfaces, surface_id);
   }
   g_assert (surfaces->len == context->surfaces->len);
index 3227607..09fcc18 100644 (file)
@@ -386,7 +386,7 @@ gst_vaapi_enc_picture_create (GstVaapiEncPicture * picture,
   if (!picture->surface)
     return FALSE;
 
-  picture->surface_id = GST_VAAPI_OBJECT_ID (picture->surface);
+  picture->surface_id = GST_VAAPI_SURFACE_ID (picture->surface);
   if (picture->surface_id == VA_INVALID_ID)
     return FALSE;
 
index eabcedf..180804b 100644 (file)
@@ -1124,7 +1124,7 @@ deint_refs_set (GArray * refs, GstVaapiSurface ** surfaces, guint num_surfaces)
     return FALSE;
 
   for (i = 0; i < num_surfaces; i++)
-    g_array_append_val (refs, GST_VAAPI_OBJECT_ID (surfaces[i]));
+    g_array_append_val (refs, GST_VAAPI_SURFACE_ID (surfaces[i]));
   return TRUE;
 }
 
@@ -1617,7 +1617,7 @@ gst_vaapi_filter_process_unlocked (GstVaapiFilter * filter,
     goto error;
 
   memset (pipeline_param, 0, sizeof (*pipeline_param));
-  pipeline_param->surface = GST_VAAPI_OBJECT_ID (src_surface);
+  pipeline_param->surface = GST_VAAPI_SURFACE_ID (src_surface);
   pipeline_param->surface_region = &src_rect;
   pipeline_param->surface_color_standard = VAProcColorStandardNone;
   pipeline_param->output_region = &dst_rect;
@@ -1662,7 +1662,7 @@ gst_vaapi_filter_process_unlocked (GstVaapiFilter * filter,
   vaapi_unmap_buffer (filter->va_display, pipeline_param_buf_id, NULL);
 
   va_status = vaBeginPicture (filter->va_display, filter->va_context,
-      GST_VAAPI_OBJECT_ID (dst_surface));
+      GST_VAAPI_SURFACE_ID (dst_surface));
   if (!vaapi_check_status (va_status, "vaBeginPicture()"))
     goto error;
 
index 9ffccd9..7bdbf5e 100644 (file)
@@ -124,7 +124,7 @@ gst_vaapi_pixmap_x11_render (GstVaapiPixmap * pixmap, GstVaapiSurface * surface,
   VASurfaceID surface_id;
   VAStatus status;
 
-  surface_id = GST_VAAPI_OBJECT_ID (surface);
+  surface_id = GST_VAAPI_SURFACE_ID (surface);
   if (surface_id == VA_INVALID_ID)
     return FALSE;
 
index e206229..5e2e63f 100644 (file)
@@ -34,6 +34,7 @@
 #include "gstvaapisurface_priv.h"
 #include "gstvaapicontext.h"
 #include "gstvaapiimage.h"
+#include "gstvaapiimage_priv.h"
 #include "gstvaapibufferproxy_priv.h"
 
 #define DEBUG 1
@@ -66,13 +67,13 @@ gst_vaapi_surface_destroy_subpictures (GstVaapiSurface * surface)
 }
 
 static void
-gst_vaapi_surface_destroy (GstVaapiSurface * surface)
+gst_vaapi_surface_free (GstVaapiSurface * surface)
 {
-  GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (surface);
+  GstVaapiDisplay *const display = GST_VAAPI_SURFACE_DISPLAY (surface);
   VASurfaceID surface_id;
   VAStatus status;
 
-  surface_id = GST_VAAPI_OBJECT_ID (surface);
+  surface_id = GST_VAAPI_SURFACE_ID (surface);
   GST_DEBUG ("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (surface_id));
 
   gst_vaapi_surface_destroy_subpictures (surface);
@@ -85,16 +86,19 @@ gst_vaapi_surface_destroy (GstVaapiSurface * surface)
     if (!vaapi_check_status (status, "vaDestroySurfaces()"))
       GST_WARNING ("failed to destroy surface %" GST_VAAPI_ID_FORMAT,
           GST_VAAPI_ID_ARGS (surface_id));
-    GST_VAAPI_OBJECT_ID (surface) = VA_INVALID_SURFACE;
+    GST_VAAPI_SURFACE_ID (surface) = VA_INVALID_SURFACE;
   }
   gst_vaapi_buffer_proxy_replace (&surface->extbuf_proxy, NULL);
+  gst_vaapi_display_replace (&GST_VAAPI_SURFACE_DISPLAY (surface), NULL);
+
+  g_slice_free1 (sizeof (GstVaapiSurface), surface);
 }
 
 static gboolean
 gst_vaapi_surface_init (GstVaapiSurface * surface,
     GstVaapiChromaType chroma_type, guint width, guint height)
 {
-  GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (surface);
+  GstVaapiDisplay *const display = GST_VAAPI_SURFACE_DISPLAY (surface);
   VASurfaceID surface_id;
   VAStatus status;
   guint va_chroma_format;
@@ -116,7 +120,7 @@ gst_vaapi_surface_init (GstVaapiSurface * surface,
   GST_VAAPI_SURFACE_HEIGHT (surface) = height;
 
   GST_DEBUG ("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (surface_id));
-  GST_VAAPI_OBJECT_ID (surface) = surface_id;
+  GST_VAAPI_SURFACE_ID (surface) = surface_id;
   return TRUE;
 
   /* ERRORS */
@@ -129,7 +133,7 @@ static gboolean
 gst_vaapi_surface_init_full (GstVaapiSurface * surface,
     const GstVideoInfo * vip, guint flags)
 {
-  GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (surface);
+  GstVaapiDisplay *const display = GST_VAAPI_SURFACE_DISPLAY (surface);
   const GstVideoFormat format = GST_VIDEO_INFO_FORMAT (vip);
   VASurfaceID surface_id;
   VAStatus status;
@@ -207,7 +211,7 @@ gst_vaapi_surface_init_full (GstVaapiSurface * surface,
   GST_VAAPI_SURFACE_HEIGHT (surface) = extbuf.height;
 
   GST_DEBUG ("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (surface_id));
-  GST_VAAPI_OBJECT_ID (surface) = surface_id;
+  GST_VAAPI_SURFACE_ID (surface) = surface_id;
   return TRUE;
 
   /* ERRORS */
@@ -221,7 +225,7 @@ static gboolean
 gst_vaapi_surface_init_from_buffer_proxy (GstVaapiSurface * surface,
     GstVaapiBufferProxy * proxy, const GstVideoInfo * vip)
 {
-  GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (surface);
+  GstVaapiDisplay *const display = GST_VAAPI_SURFACE_DISPLAY (surface);
   GstVideoFormat format;
   VASurfaceID surface_id;
   VAStatus status;
@@ -292,7 +296,7 @@ gst_vaapi_surface_init_from_buffer_proxy (GstVaapiSurface * surface,
   GST_VAAPI_SURFACE_HEIGHT (surface) = height;
 
   GST_DEBUG ("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (surface_id));
-  GST_VAAPI_OBJECT_ID (surface) = surface_id;
+  GST_VAAPI_SURFACE_ID (surface) = surface_id;
   return TRUE;
 
   /* ERRORS */
@@ -302,8 +306,41 @@ error_unsupported_format:
   return FALSE;
 }
 
-#define gst_vaapi_surface_finalize gst_vaapi_surface_destroy
-GST_VAAPI_OBJECT_DEFINE_CLASS (GstVaapiSurface, gst_vaapi_surface);
+GST_DEFINE_MINI_OBJECT_TYPE (GstVaapiSurface, gst_vaapi_surface);
+
+static GstVaapiSurface *
+gst_vaapi_surface_create (GstVaapiDisplay * display)
+{
+  GstVaapiSurface *surface = g_slice_new (GstVaapiSurface);
+  if (!surface)
+    return NULL;
+
+  gst_mini_object_init (GST_MINI_OBJECT_CAST (surface), 0,
+      GST_TYPE_VAAPI_SURFACE, NULL, NULL,
+      (GstMiniObjectFreeFunction) gst_vaapi_surface_free);
+
+  GST_VAAPI_SURFACE_DISPLAY (surface) = gst_object_ref (display);
+  GST_VAAPI_SURFACE_ID (surface) = VA_INVALID_ID;
+  surface->extbuf_proxy = NULL;
+  surface->subpictures = NULL;
+
+  return surface;
+}
+
+/**
+ * gst_vaapi_surface_get_display:
+ * @surface: a #GstVaapiSurface
+ *
+ * Returns the #GstVaapiDisplay this @surface is bound to.
+ *
+ * Return value: the parent #GstVaapiDisplay object
+ */
+GstVaapiDisplay *
+gst_vaapi_surface_get_display (GstVaapiSurface * surface)
+{
+  g_return_val_if_fail (surface != NULL, NULL);
+  return GST_VAAPI_SURFACE_DISPLAY (surface);
+}
 
 /**
  * gst_vaapi_surface_new_from_formats:
@@ -336,7 +373,7 @@ gst_vaapi_surface_new_from_formats (GstVaapiDisplay * display,
 
   /* Fallback: if there's no format valid for the chroma type let's
    * just use the passed chroma */
-  surface = gst_vaapi_object_new (gst_vaapi_surface_class (), display);
+  surface = gst_vaapi_surface_create (display);
   if (!surface)
     return NULL;
   if (!gst_vaapi_surface_init (surface, chroma_type, width, height))
@@ -347,7 +384,7 @@ gst_vaapi_surface_new_from_formats (GstVaapiDisplay * display,
   /* ERRORS */
 error:
   {
-    gst_vaapi_object_unref (surface);
+    gst_vaapi_surface_unref (surface);
     return NULL;
   }
 }
@@ -372,7 +409,7 @@ gst_vaapi_surface_new (GstVaapiDisplay * display,
 
   GST_DEBUG ("size %ux%u, chroma type 0x%x", width, height, chroma_type);
 
-  surface = gst_vaapi_object_new (gst_vaapi_surface_class (), display);
+  surface = gst_vaapi_surface_create (display);
   if (!surface)
     return NULL;
 
@@ -395,7 +432,7 @@ gst_vaapi_surface_new (GstVaapiDisplay * display,
   /* ERRORS */
 error:
   {
-    gst_vaapi_object_unref (surface);
+    gst_vaapi_surface_unref (surface);
     return NULL;
   }
 }
@@ -423,7 +460,7 @@ gst_vaapi_surface_new_full (GstVaapiDisplay * display,
       GST_VIDEO_INFO_HEIGHT (vip),
       gst_vaapi_video_format_to_string (GST_VIDEO_INFO_FORMAT (vip)), flags);
 
-  surface = gst_vaapi_object_new (gst_vaapi_surface_class (), display);
+  surface = gst_vaapi_surface_create (display);
   if (!surface)
     return NULL;
 
@@ -434,7 +471,7 @@ gst_vaapi_surface_new_full (GstVaapiDisplay * display,
   /* ERRORS */
 error:
   {
-    gst_vaapi_object_unref (surface);
+    gst_vaapi_surface_unref (surface);
     return NULL;
   }
 }
@@ -489,7 +526,7 @@ gst_vaapi_surface_new_from_buffer_proxy (GstVaapiDisplay * display,
   g_return_val_if_fail (proxy != NULL, NULL);
   g_return_val_if_fail (info != NULL, NULL);
 
-  surface = gst_vaapi_object_new (gst_vaapi_surface_class (), display);
+  surface = gst_vaapi_surface_create (display);
   if (!surface)
     return NULL;
 
@@ -500,7 +537,7 @@ gst_vaapi_surface_new_from_buffer_proxy (GstVaapiDisplay * display,
   /* ERRORS */
 error:
   {
-    gst_vaapi_object_unref (surface);
+    gst_vaapi_surface_unref (surface);
     return NULL;
   }
 }
@@ -518,7 +555,7 @@ gst_vaapi_surface_get_id (GstVaapiSurface * surface)
 {
   g_return_val_if_fail (surface != NULL, VA_INVALID_SURFACE);
 
-  return GST_VAAPI_OBJECT_ID (surface);
+  return GST_VAAPI_SURFACE_ID (surface);
 }
 
 /**
@@ -652,13 +689,13 @@ gst_vaapi_surface_derive_image (GstVaapiSurface * surface)
 
   g_return_val_if_fail (surface != NULL, NULL);
 
-  display = GST_VAAPI_OBJECT_DISPLAY (surface);
+  display = GST_VAAPI_SURFACE_DISPLAY (surface);
   va_image.image_id = VA_INVALID_ID;
   va_image.buf = VA_INVALID_ID;
 
   GST_VAAPI_DISPLAY_LOCK (display);
   status = vaDeriveImage (GST_VAAPI_DISPLAY_VADISPLAY (display),
-      GST_VAAPI_OBJECT_ID (surface), &va_image);
+      GST_VAAPI_SURFACE_ID (surface), &va_image);
   GST_VAAPI_DISPLAY_UNLOCK (display);
   if (!vaapi_check_status (status, "vaDeriveImage()"))
     return NULL;
@@ -692,7 +729,7 @@ gst_vaapi_surface_get_image (GstVaapiSurface * surface, GstVaapiImage * image)
   g_return_val_if_fail (surface != NULL, FALSE);
   g_return_val_if_fail (image != NULL, FALSE);
 
-  display = GST_VAAPI_OBJECT_DISPLAY (surface);
+  display = GST_VAAPI_SURFACE_DISPLAY (surface);
   if (!display)
     return FALSE;
 
@@ -708,7 +745,7 @@ gst_vaapi_surface_get_image (GstVaapiSurface * surface, GstVaapiImage * image)
 
   GST_VAAPI_DISPLAY_LOCK (display);
   status = vaGetImage (GST_VAAPI_DISPLAY_VADISPLAY (display),
-      GST_VAAPI_OBJECT_ID (surface), 0, 0, width, height, image_id);
+      GST_VAAPI_SURFACE_ID (surface), 0, 0, width, height, image_id);
   GST_VAAPI_DISPLAY_UNLOCK (display);
   if (!vaapi_check_status (status, "vaGetImage()"))
     return FALSE;
@@ -737,7 +774,7 @@ gst_vaapi_surface_put_image (GstVaapiSurface * surface, GstVaapiImage * image)
   g_return_val_if_fail (surface != NULL, FALSE);
   g_return_val_if_fail (image != NULL, FALSE);
 
-  display = GST_VAAPI_OBJECT_DISPLAY (surface);
+  display = GST_VAAPI_SURFACE_DISPLAY (surface);
   if (!display)
     return FALSE;
 
@@ -753,8 +790,8 @@ gst_vaapi_surface_put_image (GstVaapiSurface * surface, GstVaapiImage * image)
 
   GST_VAAPI_DISPLAY_LOCK (display);
   status = vaPutImage (GST_VAAPI_DISPLAY_VADISPLAY (display),
-      GST_VAAPI_OBJECT_ID (surface), image_id, 0, 0, width, height,
-      0, 0, width, height);
+      GST_VAAPI_SURFACE_ID (surface), image_id, 0, 0, width, height, 0, 0,
+      width, height);
   GST_VAAPI_DISPLAY_UNLOCK (display);
   if (!vaapi_check_status (status, "vaPutImage()"))
     return FALSE;
@@ -823,11 +860,11 @@ _gst_vaapi_surface_associate_subpicture (GstVaapiSurface * surface,
   VASurfaceID surface_id;
   VAStatus status;
 
-  display = GST_VAAPI_OBJECT_DISPLAY (surface);
+  display = GST_VAAPI_SURFACE_DISPLAY (surface);
   if (!display)
     return FALSE;
 
-  surface_id = GST_VAAPI_OBJECT_ID (surface);
+  surface_id = GST_VAAPI_SURFACE_ID (surface);
   if (surface_id == VA_INVALID_SURFACE)
     return FALSE;
 
@@ -890,7 +927,7 @@ gst_vaapi_surface_deassociate_subpicture (GstVaapiSurface * surface,
     GST_DEBUG ("subpicture %" GST_VAAPI_ID_FORMAT " was not bound to "
         "surface %" GST_VAAPI_ID_FORMAT,
         GST_VAAPI_ID_ARGS (GST_VAAPI_OBJECT_ID (subpicture)),
-        GST_VAAPI_ID_ARGS (GST_VAAPI_OBJECT_ID (surface)));
+        GST_VAAPI_ID_ARGS (GST_VAAPI_SURFACE_ID (surface)));
     return TRUE;
   }
 
@@ -907,11 +944,11 @@ _gst_vaapi_surface_deassociate_subpicture (GstVaapiSurface * surface,
   VASurfaceID surface_id;
   VAStatus status;
 
-  display = GST_VAAPI_OBJECT_DISPLAY (surface);
+  display = GST_VAAPI_SURFACE_DISPLAY (surface);
   if (!display)
     return FALSE;
 
-  surface_id = GST_VAAPI_OBJECT_ID (surface);
+  surface_id = GST_VAAPI_SURFACE_ID (surface);
   if (surface_id == VA_INVALID_SURFACE)
     return FALSE;
 
@@ -942,13 +979,13 @@ gst_vaapi_surface_sync (GstVaapiSurface * surface)
 
   g_return_val_if_fail (surface != NULL, FALSE);
 
-  display = GST_VAAPI_OBJECT_DISPLAY (surface);
+  display = GST_VAAPI_SURFACE_DISPLAY (surface);
   if (!display)
     return FALSE;
 
   GST_VAAPI_DISPLAY_LOCK (display);
   status = vaSyncSurface (GST_VAAPI_DISPLAY_VADISPLAY (display),
-      GST_VAAPI_OBJECT_ID (surface));
+      GST_VAAPI_SURFACE_ID (surface));
   GST_VAAPI_DISPLAY_UNLOCK (display);
   if (!vaapi_check_status (status, "vaSyncSurface()"))
     return FALSE;
@@ -970,15 +1007,16 @@ gboolean
 gst_vaapi_surface_query_status (GstVaapiSurface * surface,
     GstVaapiSurfaceStatus * pstatus)
 {
+  GstVaapiDisplay *const display = GST_VAAPI_SURFACE_DISPLAY (surface);
   VASurfaceStatus surface_status;
   VAStatus status;
 
   g_return_val_if_fail (surface != NULL, FALSE);
 
-  GST_VAAPI_OBJECT_LOCK_DISPLAY (surface);
-  status = vaQuerySurfaceStatus (GST_VAAPI_OBJECT_VADISPLAY (surface),
-      GST_VAAPI_OBJECT_ID (surface), &surface_status);
-  GST_VAAPI_OBJECT_UNLOCK_DISPLAY (surface);
+  GST_VAAPI_DISPLAY_LOCK (display);
+  status = vaQuerySurfaceStatus (GST_VAAPI_DISPLAY_VADISPLAY (display),
+      GST_VAAPI_SURFACE_ID (surface), &surface_status);
+  GST_VAAPI_DISPLAY_UNLOCK (display);
   if (!vaapi_check_status (status, "vaQuerySurfaceStatus()"))
     return FALSE;
 
@@ -1007,7 +1045,7 @@ gst_vaapi_surface_set_subpictures_from_composition (GstVaapiSurface * surface,
 
   g_return_val_if_fail (surface != NULL, FALSE);
 
-  display = GST_VAAPI_OBJECT_DISPLAY (surface);
+  display = GST_VAAPI_SURFACE_DISPLAY (surface);
   if (!display)
     return FALSE;
 
index c62f7bb..08e5d7d 100644 (file)
@@ -178,9 +178,34 @@ typedef enum
 #define GST_VAAPI_SURFACE(obj) \
     ((GstVaapiSurface *)(obj))
 
+#define GST_TYPE_VAAPI_SURFACE (gst_vaapi_surface_get_type ())
+
+#define GST_VAAPI_SURFACE_ID(surface)      (gst_vaapi_surface_get_id (surface))
+#define GST_VAAPI_SURFACE_DISPLAY(surface) (gst_vaapi_surface_get_display (surface))
+
 typedef struct _GstVaapiSurface                 GstVaapiSurface;
 typedef struct _GstVaapiSurfaceProxy            GstVaapiSurfaceProxy;
 
+GType
+gst_vaapi_surface_get_type (void) G_GNUC_CONST;
+
+/**
+ * gst_vaapi_surface_unref: (skip)
+ * @surface: (transfer full): a #GstVaapiSurface.
+ *
+ * Decreases the refcount of the surface. If the refcount reaches 0, the
+ * surface will be freed.
+ */
+static inline void gst_vaapi_surface_unref(GstVaapiSurface* surface);
+static inline void
+gst_vaapi_surface_unref (GstVaapiSurface * surface)
+{
+  gst_mini_object_unref (GST_MINI_OBJECT_CAST (surface));
+}
+
+GstVaapiDisplay *
+gst_vaapi_surface_get_display (GstVaapiSurface * surface);
+
 GstVaapiSurface *
 gst_vaapi_surface_new_from_formats (GstVaapiDisplay * display,
     GstVaapiChromaType chroma_type, guint width, guint height, GArray * formts);
@@ -256,6 +281,8 @@ gst_vaapi_surface_set_buffer_proxy (GstVaapiSurface * surface,
 GstVaapiBufferProxy *
 gst_vaapi_surface_peek_buffer_proxy (GstVaapiSurface * surface);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVaapiSurface, gst_vaapi_surface_unref)
+
 G_END_DECLS
 
 #endif /* GST_VAAPI_SURFACE_H */
index a7e33e0..7587553 100644 (file)
@@ -38,7 +38,7 @@ gst_vaapi_surface_get_drm_buf_handle (GstVaapiSurface * surface, guint type)
 
   /* The proxy takes ownership if the image, even creation failure. */
   proxy =
-      gst_vaapi_buffer_proxy_new_from_object (GST_VAAPI_OBJECT (surface),
+      gst_vaapi_buffer_proxy_new_from_object (GST_MINI_OBJECT_CAST (surface),
       image->internal_image.buf, type, (GDestroyNotify) gst_vaapi_image_unref,
       image);
   if (!proxy)
index 338cfaf..0299743 100644 (file)
@@ -161,7 +161,7 @@ create_surface_from_egl_image (GstVaapiDisplayEGL * display,
   if (filter_status != GST_VAAPI_FILTER_STATUS_SUCCESS)
     goto error_convert_surface;
 
-  gst_vaapi_object_unref (img_surface);
+  gst_vaapi_surface_unref (img_surface);
   gst_object_unref (filter);
   return out_surface;
 
@@ -179,8 +179,8 @@ error_create_filter:
   GST_ERROR ("failed to create video processing filter");
   // fall-through
 error_cleanup:
-  gst_vaapi_object_replace (&img_surface, NULL);
-  gst_vaapi_object_replace (&out_surface, NULL);
+  gst_mini_object_replace ((GstMiniObject **) & img_surface, NULL);
+  gst_mini_object_replace ((GstMiniObject **) & out_surface, NULL);
   gst_vaapi_filter_replace (&filter, NULL);
   return NULL;
 }
index 48fcf43..f0e8ce7 100644 (file)
 #ifndef GST_VAAPI_SURFACE_PRIV_H
 #define GST_VAAPI_SURFACE_PRIV_H
 
-#include <gst/vaapi/gstvaapicontext.h>
 #include <gst/vaapi/gstvaapisurface.h>
-#include "gstvaapiobject_priv.h"
 
 G_BEGIN_DECLS
 
-typedef struct _GstVaapiSurfaceClass            GstVaapiSurfaceClass;
-
 /**
  * GstVaapiSurface:
  *
@@ -39,7 +35,9 @@ typedef struct _GstVaapiSurfaceClass            GstVaapiSurfaceClass;
 struct _GstVaapiSurface
 {
   /*< private >*/
-  GstVaapiObject parent_instance;
+  GstMiniObject mini_object;
+  GstVaapiDisplay *display;
+  GstVaapiID object_id;
 
   GstVaapiBufferProxy *extbuf_proxy;
   GstVideoFormat format;
@@ -50,15 +48,28 @@ struct _GstVaapiSurface
 };
 
 /**
- * GstVaapiSurfaceClass:
+ * GST_VAAPI_SURFACE_DISPLAY:
+ * @surface: a #GstVaapiSurface
  *
- * A VA surface wrapper class.
+ * Macro that evaluates to the @surface's display.
+ *
+ * This is an internal macro that does not do any run-time type check.
  */
-struct _GstVaapiSurfaceClass
-{
-  /*< private >*/
-  GstVaapiObjectClass parent_class;
-};
+#undef GST_VAAPI_SURFACE_DISPLAY
+#define GST_VAAPI_SURFACE_DISPLAY(surface) \
+  (GST_VAAPI_SURFACE (surface)->display)
+
+/**
+ * GST_VAAPI_SURFACE_ID:
+ * @surface: a #GstVaapiSurface
+ *
+ * Macro that evaluates to the @surface's ID.
+ *
+ * This is an internal macro that does not do any run-time type check.
+ */
+#undef GST_VAAPI_SURFACE_ID
+#define GST_VAAPI_SURFACE_ID(surface) \
+  (GST_VAAPI_SURFACE (surface)->object_id)
 
 /**
  * GST_VAAPI_SURFACE_CHROMA_TYPE:
index 4e2b686..b34afed 100644 (file)
@@ -41,7 +41,7 @@ gst_vaapi_surface_proxy_finalize (GstVaapiSurfaceProxy * proxy)
   if (proxy->surface) {
     if (proxy->pool && !proxy->parent)
       gst_vaapi_video_pool_put_object (proxy->pool, proxy->surface);
-    gst_vaapi_object_unref (proxy->surface);
+    gst_vaapi_surface_unref (proxy->surface);
     proxy->surface = NULL;
   }
   gst_vaapi_video_pool_replace (&proxy->pool, NULL);
@@ -125,7 +125,8 @@ gst_vaapi_surface_proxy_new (GstVaapiSurface * surface)
   proxy->parent = NULL;
   proxy->destroy_func = NULL;
   proxy->pool = NULL;
-  proxy->surface = gst_vaapi_object_ref (surface);
+  proxy->surface =
+      (GstVaapiSurface *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (surface));
   if (!proxy->surface)
     goto error;
   gst_vaapi_surface_proxy_init_properties (proxy);
@@ -168,7 +169,7 @@ gst_vaapi_surface_proxy_new_from_pool (GstVaapiSurfacePool * pool)
   proxy->surface = gst_vaapi_video_pool_get_object (proxy->pool);
   if (!proxy->surface)
     goto error;
-  gst_vaapi_object_ref (proxy->surface);
+  gst_mini_object_ref (GST_MINI_OBJECT_CAST (proxy->surface));
   gst_vaapi_surface_proxy_init_properties (proxy);
   return proxy;
 
@@ -210,7 +211,8 @@ gst_vaapi_surface_proxy_copy (GstVaapiSurfaceProxy * proxy)
   copy->parent = gst_vaapi_surface_proxy_ref (proxy->parent ?
       proxy->parent : proxy);
   copy->pool = proxy->pool ? gst_vaapi_video_pool_ref (proxy->pool) : NULL;
-  copy->surface = gst_vaapi_object_ref (proxy->surface);
+  copy->surface = (GstVaapiSurface *)
+      gst_mini_object_ref (GST_MINI_OBJECT_CAST (proxy->surface));
   copy->view_id = proxy->view_id;
   copy->timestamp = proxy->timestamp;
   copy->duration = proxy->duration;
index 1540c7c..e43ecbc 100644 (file)
@@ -86,7 +86,7 @@ struct _GstVaapiSurfaceProxy
  */
 #undef  GST_VAAPI_SURFACE_PROXY_SURFACE_ID
 #define GST_VAAPI_SURFACE_PROXY_SURFACE_ID(proxy) \
-  (GST_VAAPI_OBJECT_ID (GST_VAAPI_SURFACE_PROXY (proxy)->surface))
+  (GST_VAAPI_SURFACE_ID (GST_VAAPI_SURFACE_PROXY (proxy)->surface))
 
 /**
  * GST_VAAPI_SURFACE_PROXY_VIEW_ID:
index efeced4..e0eb318 100644 (file)
@@ -182,7 +182,7 @@ destroy_objects (GstVaapiTextureEGL * texture)
         texture->egl_image);
     texture->egl_image = EGL_NO_IMAGE_KHR;
   }
-  gst_vaapi_object_replace (&texture->surface, NULL);
+  gst_mini_object_replace ((GstMiniObject **) & texture->surface, NULL);
   gst_vaapi_filter_replace (&texture->filter, NULL);
 }
 
index b1e641b..dab6ebe 100644 (file)
@@ -31,6 +31,7 @@
 #include "gstvaapitexture.h"
 #include "gstvaapitexture_glx.h"
 #include "gstvaapitexture_priv.h"
+#include "gstvaapisurface_priv.h"
 #include "gstvaapicompat.h"
 #include "gstvaapiutils.h"
 #include "gstvaapiutils_glx.h"
@@ -344,7 +345,7 @@ gst_vaapi_texture_glx_put_surface_unlocked (GstVaapiTexture * base_texture,
   };
 
   status = vaPutSurface (GST_VAAPI_OBJECT_VADISPLAY (texture),
-      GST_VAAPI_OBJECT_ID (surface), texture->pixo->pixmap,
+      GST_VAAPI_SURFACE_ID (surface), texture->pixo->pixmap,
       crop_rect->x, crop_rect->y, crop_rect->width, crop_rect->height,
       0, 0, base_texture->width, base_texture->height,
       NULL, 0, from_GstVaapiSurfaceRenderFlags (flags));
index 9e79b95..faba367 100644 (file)
@@ -67,21 +67,8 @@ gst_vaapi_video_pool_init (GstVaapiVideoPool * pool, GstVaapiDisplay * display,
 void
 gst_vaapi_video_pool_finalize (GstVaapiVideoPool * pool)
 {
-  if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE
-      || pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_CODED_BUFFER) {
-    g_list_free_full (pool->used_objects,
-        (GDestroyNotify) gst_mini_object_unref);
-  } else {
-    g_list_free_full (pool->used_objects, gst_vaapi_object_unref);
-  }
-
-  if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE
-      || pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_CODED_BUFFER) {
-    g_queue_foreach (&pool->free_objects, (GFunc) gst_mini_object_unref, NULL);
-  } else {
-    g_queue_foreach (&pool->free_objects, (GFunc) gst_vaapi_object_unref, NULL);
-  }
-
+  g_list_free_full (pool->used_objects, (GDestroyNotify) gst_mini_object_unref);
+  g_queue_foreach (&pool->free_objects, (GFunc) gst_mini_object_unref, NULL);
   g_queue_clear (&pool->free_objects);
   gst_vaapi_display_replace (&pool->display, NULL);
   g_mutex_clear (&pool->mutex);
@@ -196,14 +183,7 @@ gst_vaapi_video_pool_get_object_unlocked (GstVaapiVideoPool * pool)
 
   ++pool->used_count;
   pool->used_objects = g_list_prepend (pool->used_objects, object);
-
-  if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE
-      || pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_CODED_BUFFER) {
-    object = gst_mini_object_ref (GST_MINI_OBJECT_CAST (object));
-  } else {
-    object = gst_vaapi_object_ref (object);
-  }
-  return object;
+  return gst_mini_object_ref (object);
 }
 
 gpointer
@@ -239,13 +219,7 @@ gst_vaapi_video_pool_put_object_unlocked (GstVaapiVideoPool * pool,
   if (!elem)
     return;
 
-  if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE
-      || pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_CODED_BUFFER) {
-    gst_mini_object_unref (GST_MINI_OBJECT_CAST (object));
-  } else {
-    gst_vaapi_object_unref (object);
-  }
-
+  gst_mini_object_unref (object);
   --pool->used_count;
   pool->used_objects = g_list_delete_link (pool->used_objects, elem);
   g_queue_push_tail (&pool->free_objects, object);
@@ -277,13 +251,7 @@ static inline gboolean
 gst_vaapi_video_pool_add_object_unlocked (GstVaapiVideoPool * pool,
     gpointer object)
 {
-  if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE
-      || pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_CODED_BUFFER) {
-    g_queue_push_tail (&pool->free_objects,
-        gst_mini_object_ref (GST_MINI_OBJECT_CAST (object)));
-  } else {
-    g_queue_push_tail (&pool->free_objects, gst_vaapi_object_ref (object));
-  }
+  g_queue_push_tail (&pool->free_objects, gst_mini_object_ref (object));
   return TRUE;
 }
 
index ed01f5e..75b9e0e 100644 (file)
@@ -284,7 +284,7 @@ gst_vaapi_window_vpp_convert_internal (GstVaapiWindow * window,
 error_process_filter:
   {
     GST_ERROR ("failed to process surface %" GST_VAAPI_ID_FORMAT " (error %d)",
-        GST_VAAPI_ID_ARGS (GST_VAAPI_OBJECT_ID (surface)), status);
+        GST_VAAPI_ID_ARGS (GST_VAAPI_SURFACE_ID (surface)), status);
     gst_vaapi_video_pool_put_object (window->surface_pool, vpp_surface);
     return NULL;
   }
index 39a5e02..8e09152 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "sysdeps.h"
 #include "gstvaapicompat.h"
-#include "gstvaapiobject_priv.h"
+#include "gstvaapisurface_priv.h"
 #include "gstvaapiwindow_wayland.h"
 #include "gstvaapiwindow_priv.h"
 #include "gstvaapidisplay_wayland.h"
@@ -555,7 +555,7 @@ gst_vaapi_window_wayland_render (GstVaapiWindow * window,
     GST_VAAPI_WINDOW_LOCK_DISPLAY (window);
     va_flags = from_GstVaapiSurfaceRenderFlags (flags);
     status = vaGetSurfaceBufferWl (GST_VAAPI_DISPLAY_VADISPLAY (display),
-        GST_VAAPI_OBJECT_ID (surface),
+        GST_VAAPI_SURFACE_ID (surface),
         va_flags & (VA_TOP_FIELD | VA_BOTTOM_FIELD), &buffer);
     GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window);
     if (status == VA_STATUS_ERROR_FLAG_NOT_SUPPORTED ||
@@ -583,7 +583,7 @@ gst_vaapi_window_wayland_render (GstVaapiWindow * window,
 
     GST_VAAPI_WINDOW_LOCK_DISPLAY (window);
     status = vaGetSurfaceBufferWl (GST_VAAPI_DISPLAY_VADISPLAY (display),
-        GST_VAAPI_OBJECT_ID (surface), VA_FRAME_PICTURE, &buffer);
+        GST_VAAPI_SURFACE_ID (surface), VA_FRAME_PICTURE, &buffer);
     GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window);
     if (!vaapi_check_status (status, "vaGetSurfaceBufferWl()"))
       return FALSE;
index fd3b045..bf0b65b 100644 (file)
@@ -39,7 +39,6 @@
 #include "gstvaapisurface_priv.h"
 #include "gstvaapiutils.h"
 #include "gstvaapiutils_x11.h"
-#include "gstvaapisurface_priv.h"
 
 GST_DEBUG_CATEGORY_EXTERN (gst_debug_vaapi_window);
 #define GST_CAT_DEFAULT gst_debug_vaapi_window
@@ -449,7 +448,7 @@ gst_vaapi_window_x11_render (GstVaapiWindow * window,
       GST_VAAPI_WINDOW_X11_GET_PRIVATE (window);
   gboolean ret = FALSE;
 
-  surface_id = GST_VAAPI_OBJECT_ID (surface);
+  surface_id = GST_VAAPI_SURFACE_ID (surface);
   if (surface_id == VA_INVALID_ID)
     return FALSE;
 
@@ -476,7 +475,7 @@ conversion:
     if (G_LIKELY (vpp_surface)) {
       GstVaapiRectangle vpp_src_rect;
 
-      surface_id = GST_VAAPI_OBJECT_ID (vpp_surface);
+      surface_id = GST_VAAPI_SURFACE_ID (vpp_surface);
       vpp_src_rect.x = vpp_src_rect.y = 0;
       vpp_src_rect.width = GST_VAAPI_SURFACE_WIDTH (vpp_surface);
       vpp_src_rect.height = GST_VAAPI_SURFACE_HEIGHT (vpp_surface);
index db088be..eba6efd 100644 (file)
@@ -156,7 +156,7 @@ _set_cached_surface (GstBuffer * buf, GstVaapiSurface * surface)
 {
   return gst_mini_object_set_qdata (GST_MINI_OBJECT (buf),
       g_quark_from_static_string ("GstVaapiDMABufSurface"), surface,
-      (GDestroyNotify) gst_vaapi_object_unref);
+      (GDestroyNotify) gst_vaapi_surface_unref);
 }
 
 static gboolean
@@ -1387,7 +1387,7 @@ extract_allowed_surface_formats (GstVaapiDisplay * display,
     if (!image) {
       /* Just reuse the surface if the format is specified */
       if (specified_format == GST_VIDEO_FORMAT_UNKNOWN)
-        gst_vaapi_object_replace (&surface, NULL);
+        gst_mini_object_replace ((GstMiniObject **) & surface, NULL);
 
       continue;
     }
@@ -1404,11 +1404,11 @@ extract_allowed_surface_formats (GstVaapiDisplay * display,
     gst_vaapi_image_unref (image);
     /* Just reuse the surface if the format is specified */
     if (specified_format == GST_VIDEO_FORMAT_UNKNOWN)
-      gst_vaapi_object_replace (&surface, NULL);
+      gst_mini_object_replace ((GstMiniObject **) & surface, NULL);
   }
 
   if (surface)
-    gst_vaapi_object_unref (surface);
+    gst_vaapi_surface_unref (surface);
 
   if (out_formats->len == 0) {
     g_array_unref (out_formats);
index c6af52c..224a7ed 100644 (file)
@@ -789,7 +789,7 @@ allocator_configure_surface_try_specified_format (GstVaapiDisplay * display,
   rinfo = *allocation_info;
 
 out:
-  gst_vaapi_object_unref (surface);
+  gst_vaapi_surface_unref (surface);
 
   *ret_surface_info = rinfo;
   *ret_usage_flag = rflag;
@@ -820,7 +820,7 @@ allocator_configure_surface_try_other_format (GstVaapiDisplay * display,
   surface = gst_vaapi_surface_new_full (display, &sinfo, 0);
   if (!surface)
     goto error_no_surface;
-  gst_vaapi_object_unref (surface);
+  gst_vaapi_surface_unref (surface);
 
   *ret_surface_info = sinfo;
   return TRUE;
@@ -1061,7 +1061,7 @@ gst_vaapi_dmabuf_memory_new (GstAllocator * base_allocator,
 
   if (needs_surface) {
     /* The proxy has incremented the surface ref count.  */
-    gst_vaapi_object_unref (surface);
+    gst_vaapi_surface_unref (surface);
     gst_vaapi_video_meta_set_surface_proxy (meta, proxy);
     gst_vaapi_surface_proxy_unref (proxy);
   }
@@ -1113,14 +1113,14 @@ error_create_surface:
 error_create_surface_proxy:
   {
     GST_ERROR ("failed to create VA surface proxy");
-    gst_vaapi_object_unref (surface);
+    gst_vaapi_surface_unref (surface);
     return NULL;
   }
 error_create_dmabuf_proxy:
   {
     GST_ERROR ("failed to export VA surface to DMABUF");
     if (surface)
-      gst_vaapi_object_unref (surface);
+      gst_vaapi_surface_unref (surface);
     if (proxy)
       gst_vaapi_surface_proxy_unref (proxy);
     return NULL;
@@ -1189,7 +1189,7 @@ gst_vaapi_dmabuf_allocator_new (GstVaapiDisplay * display,
     goto error_no_surface;
   if (!gst_video_info_update_from_surface (&surface_info, surface))
     goto fail;
-  gst_vaapi_object_replace (&surface, NULL);
+  gst_mini_object_replace ((GstMiniObject **) & surface, NULL);
 
   gst_allocator_set_vaapi_video_info (base_allocator, &surface_info,
       surface_alloc_flags);
@@ -1201,7 +1201,7 @@ gst_vaapi_dmabuf_allocator_new (GstVaapiDisplay * display,
   /* ERRORS */
 fail:
   {
-    gst_vaapi_object_replace (&surface, NULL);
+    gst_mini_object_replace ((GstMiniObject **) & surface, NULL);
     gst_object_replace ((GstObject **) & base_allocator, NULL);
     return NULL;
   }
index 3a0d313..68ee20e 100644 (file)
@@ -107,7 +107,7 @@ set_surface_proxy (GstVaapiVideoMeta * meta, GstVaapiSurfaceProxy * proxy)
     return FALSE;
 
   meta->proxy = gst_vaapi_surface_proxy_ref (proxy);
-  set_display (meta, gst_vaapi_object_get_display (GST_VAAPI_OBJECT (surface)));
+  set_display (meta, gst_vaapi_surface_get_display (surface));
   return TRUE;
 }
 
index e3f5f1b..68da63f 100644 (file)
@@ -178,8 +178,7 @@ gst_vaapi_texture_upload (GstVideoGLTextureUploadMeta * meta,
   GstVaapiSurfaceProxy *const proxy =
       gst_vaapi_video_meta_get_surface_proxy (vmeta);
   GstVaapiSurface *const surface = gst_vaapi_surface_proxy_get_surface (proxy);
-  GstVaapiDisplay *const dpy =
-      gst_vaapi_object_get_display (GST_VAAPI_OBJECT (surface));
+  GstVaapiDisplay *const dpy = gst_vaapi_surface_get_display (surface);
   GstVaapiTexture *texture = NULL;
 
   if (!gst_vaapi_display_has_opengl (dpy))
index aba0b14..30256cb 100644 (file)
@@ -360,7 +360,7 @@ image_upload (GstVaapiImage * image, GstVaapiSurface * surface)
   GstVaapiSubpicture *subpicture;
   gboolean success;
 
-  display = gst_vaapi_object_get_display (GST_VAAPI_OBJECT (surface));
+  display = gst_vaapi_surface_get_display (surface);
   if (!display)
     return FALSE;
 
index 926fe7f..fcdd95c 100644 (file)
@@ -141,7 +141,7 @@ error_cleanup:
   if (image)
     gst_vaapi_image_unref (image);
   if (surface)
-    gst_vaapi_object_unref (surface);
+    gst_vaapi_surface_unref (surface);
   if (error_ptr)
     *error_ptr = error;
   else
@@ -441,8 +441,8 @@ main (int argc, char *argv[])
   pause ();
 
   gst_object_unref (filter);
-  gst_vaapi_object_unref (dst_surface);
-  gst_vaapi_object_unref (src_surface);
+  gst_vaapi_surface_unref (dst_surface);
+  gst_vaapi_surface_unref (src_surface);
   gst_object_unref (window);
   gst_object_unref (display);
   video_output_exit ();
index 2f9a90f..d0fbfaf 100644 (file)
@@ -57,7 +57,7 @@ main (int argc, char *argv[])
   g_print ("created surface %" GST_VAAPI_ID_FORMAT "\n",
       GST_VAAPI_ID_ARGS (surface_id));
 
-  gst_vaapi_object_unref (surface);
+  gst_vaapi_surface_unref (surface);
 
   pool = gst_vaapi_surface_pool_new (display, GST_VIDEO_FORMAT_ENCODED,
       width, height);
@@ -74,7 +74,8 @@ main (int argc, char *argv[])
   }
 
   /* Check the pool doesn't return the last free'd surface */
-  surface = gst_vaapi_object_ref (surfaces[1]);
+  surface = (GstVaapiSurface *)
+      gst_mini_object_ref (GST_MINI_OBJECT_CAST (surfaces[1]));
 
   for (i = 0; i < 2; i++)
     gst_vaapi_video_pool_put_object (pool, surfaces[i]);
@@ -100,7 +101,7 @@ main (int argc, char *argv[])
   /* Unref in random order to check objects are correctly refcounted */
   gst_object_unref (display);
   gst_vaapi_video_pool_unref (pool);
-  gst_vaapi_object_unref (surface);
+  gst_vaapi_surface_unref (surface);
   video_output_exit ();
   return 0;
 }
index 5b185ec..b9c9ad1 100644 (file)
@@ -134,7 +134,7 @@ main (int argc, char *argv[])
     gst_object_unref (window);
   }
 
-  gst_vaapi_object_unref (surface);
+  gst_vaapi_surface_unref (surface);
   gst_object_unref (display);
 #endif
 
@@ -199,7 +199,7 @@ main (int argc, char *argv[])
     XDestroyWindow (dpy, win);
   }
 
-  gst_vaapi_object_unref (surface);
+  gst_vaapi_surface_unref (surface);
   gst_object_unref (display);
 #endif
 
@@ -229,7 +229,7 @@ main (int argc, char *argv[])
     gst_object_unref (window);
   }
 
-  gst_vaapi_object_unref (surface);
+  gst_vaapi_surface_unref (surface);
   gst_object_unref (display);
 #endif