d3d11memory: Register mininal compare function for GstD3D11AllocationParams
authorSeungha Yang <seungha.yang@navercorp.com>
Sun, 6 Oct 2019 11:59:51 +0000 (20:59 +0900)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 5 Dec 2019 02:29:18 +0000 (02:29 +0000)
The d3d11 allocation param is stored in GstStructure so it should
provide compare function for later use such as gst_structure_is_equal()

sys/d3d11/gstd3d11memory.c

index 325a8725d4ddd025b139d0fce43efe1d84db22f3..e7d5caeed17e8b75addc142e1c4ad69470d4c95e 100644 (file)
@@ -119,9 +119,36 @@ gst_d3d11_allocation_params_free (GstD3D11AllocationParams * params)
   g_free (params);
 }
 
-G_DEFINE_BOXED_TYPE (GstD3D11AllocationParams, gst_d3d11_allocation_params,
+static gint
+gst_d3d11_allocation_params_compare (const GstD3D11AllocationParams * p1,
+    const GstD3D11AllocationParams * p2)
+{
+  g_return_val_if_fail (p1 != NULL, -1);
+  g_return_val_if_fail (p2 != NULL, -1);
+
+  if (p1 == p2)
+    return 0;
+
+  return -1;
+}
+
+static void
+_init_alloc_params (GType type)
+{
+  static GstValueTable table = {
+    0, (GstValueCompareFunc) gst_d3d11_allocation_params_compare,
+    NULL, NULL
+  };
+
+  table.type = type;
+  gst_value_register (&table);
+}
+
+G_DEFINE_BOXED_TYPE_WITH_CODE (GstD3D11AllocationParams,
+    gst_d3d11_allocation_params,
     (GBoxedCopyFunc) gst_d3d11_allocation_params_copy,
-    (GBoxedFreeFunc) gst_d3d11_allocation_params_free);
+    (GBoxedFreeFunc) gst_d3d11_allocation_params_free,
+    _init_alloc_params (g_define_type_id));
 
 #define gst_d3d11_allocator_parent_class parent_class
 G_DEFINE_TYPE (GstD3D11Allocator, gst_d3d11_allocator, GST_TYPE_ALLOCATOR);