glbasememory: take a pointer as the wrapped gpu handle
authorMatthew Waters <matthew@centricular.com>
Tue, 3 May 2016 14:19:44 +0000 (00:19 +1000)
committerMatthew Waters <matthew@centricular.com>
Wed, 4 May 2016 02:51:59 +0000 (12:51 +1000)
Allows passing arbitrary data to wrap the the specific memory implementation
which is required for some memory implementations.

docs/libs/gst-plugins-bad-libs-sections.txt
gst-libs/gst/gl/gstglbasememory.c
gst-libs/gst/gl/gstglbasememory.h
gst-libs/gst/gl/gstglmemory.c
gst-libs/gst/gl/gstglmemory.h
gst-libs/gst/gl/gstglmemorypbo.c

index 5014d89..a0d2de4 100644 (file)
@@ -1184,6 +1184,7 @@ gst_gl_video_allocation_params_free_data
 gst_gl_video_allocation_params_init_full
 gst_gl_video_allocation_params_new
 gst_gl_video_allocation_params_new_wrapped_data
+gst_gl_video_allocation_params_new_wrapped_gl_handle
 gst_gl_video_allocation_params_new_wrapped_texture
 GstGLMemoryAllocator
 GstGLMemoryAllocatorClass
index 7fc1d00..915e19e 100644 (file)
@@ -606,7 +606,7 @@ gst_gl_allocation_params_init (GstGLAllocationParams * params,
     gsize struct_size, guint alloc_flags, GstGLAllocationParamsCopyFunc copy,
     GstGLAllocationParamsFreeFunc free, GstGLContext * context,
     gsize alloc_size, GstAllocationParams * alloc_params,
-    gpointer wrapped_data, guint gl_handle, gpointer user_data,
+    gpointer wrapped_data, gpointer gl_handle, gpointer user_data,
     GDestroyNotify notify)
 {
   memset (params, 0, sizeof (*params));
index f862c85..642684a 100644 (file)
@@ -173,7 +173,7 @@ struct _GstGLAllocationParams
   /* GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM only */
   gpointer                          wrapped_data;
   /* GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE only */
-  guint                             gl_handle;
+  gpointer                          gl_handle;
 };
 
 gboolean                gst_gl_allocation_params_init       (GstGLAllocationParams * params,
@@ -185,7 +185,7 @@ gboolean                gst_gl_allocation_params_init       (GstGLAllocationPara
                                                              gsize alloc_size,
                                                              GstAllocationParams * alloc_params,
                                                              gpointer wrapped_data,
-                                                             guint gl_handle,
+                                                             gpointer gl_handle,
                                                              gpointer user_data,
                                                              GDestroyNotify notify);
 
index f75a842..8228ae5 100644 (file)
@@ -821,7 +821,7 @@ _default_gl_tex_alloc (GstGLMemoryAllocator * allocator,
   mem = g_new0 (GstGLMemory, 1);
 
   if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
-    mem->tex_id = params->parent.gl_handle;
+    mem->tex_id = GPOINTER_TO_UINT (params->parent.gl_handle);
     mem->texture_wrapped = TRUE;
   }
 
@@ -1080,7 +1080,7 @@ gst_gl_video_allocation_params_init_full (GstGLVideoAllocationParams * params,
     GstGLAllocationParamsFreeFunc free, GstGLContext * context,
     GstAllocationParams * alloc_params, GstVideoInfo * v_info,
     guint plane, GstVideoAlignment * valign, GstGLTextureTarget target,
-    gpointer wrapped_data, guint gl_handle, gpointer user_data,
+    gpointer wrapped_data, gpointer gl_handle, gpointer user_data,
     GDestroyNotify notify)
 {
   guint i;
@@ -1188,26 +1188,30 @@ gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context,
 }
 
 /**
- * gst_gl_video_allocation_params_new_wrapped_texture:
+ * gst_gl_video_allocation_params_new_wrapped_gl_handle:
  * @context: a #GstGLContext
  * @alloc_params: (allow-none): the #GstAllocationParams for @tex_id
  * @v_info: the #GstVideoInfo for @tex_id
  * @plane: the video plane @tex_id represents
  * @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @tex_id
  * @target: the #GstGLTextureTarget for @tex_id
- * @tex_id: the GL texture to wrap
+ * @gl_handle: the GL handle to wrap
  * @user_data: (allow-none): user data to call @notify with
  * @notify: (allow-none): a #GDestroyNotify
  *
- * Returns: a new #GstGLVideoAllocationParams for wrapping @tex_id
+ * @gl_handle is defined by the specific OpenGL handle being wrapped
+ * For #GstGLMemory and #GstGLMemoryPBO it is an OpenGL texture id.
+ * Other memory types may define it to require a different type of parameter.
+ *
+ * Returns: a new #GstGLVideoAllocationParams for wrapping @gl_handle
  *
  * Since: 1.8
  */
 GstGLVideoAllocationParams *
-gst_gl_video_allocation_params_new_wrapped_texture (GstGLContext * context,
+gst_gl_video_allocation_params_new_wrapped_gl_handle (GstGLContext * context,
     GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane,
     GstVideoAlignment * valign, GstGLTextureTarget target,
-    guint tex_id, gpointer user_data, GDestroyNotify notify)
+    gpointer gl_handle, gpointer user_data, GDestroyNotify notify)
 {
   GstGLVideoAllocationParams *params = g_new0 (GstGLVideoAllocationParams, 1);
 
@@ -1219,7 +1223,7 @@ gst_gl_video_allocation_params_new_wrapped_texture (GstGLContext * context,
           gst_gl_video_allocation_params_copy_data,
           (GstGLAllocationParamsFreeFunc)
           gst_gl_video_allocation_params_free_data, context, alloc_params,
-          v_info, plane, valign, target, NULL, tex_id, user_data, notify)) {
+          v_info, plane, valign, target, NULL, gl_handle, user_data, notify)) {
     g_free (params);
     return NULL;
   }
@@ -1228,6 +1232,33 @@ gst_gl_video_allocation_params_new_wrapped_texture (GstGLContext * context,
 }
 
 /**
+ * gst_gl_video_allocation_params_new_wrapped_texture:
+ * @context: a #GstGLContext
+ * @alloc_params: (allow-none): the #GstAllocationParams for @tex_id
+ * @v_info: the #GstVideoInfo for @tex_id
+ * @plane: the video plane @tex_id represents
+ * @valign: (allow-none): any #GstVideoAlignment applied to symem mappings of @tex_id
+ * @target: the #GstGLTextureTarget for @tex_id
+ * @tex_id: the GL texture to wrap
+ * @user_data: (allow-none): user data to call @notify with
+ * @notify: (allow-none): a #GDestroyNotify
+ *
+ * Returns: a new #GstGLVideoAllocationParams for wrapping @tex_id
+ *
+ * Since: 1.8
+ */
+GstGLVideoAllocationParams *
+gst_gl_video_allocation_params_new_wrapped_texture (GstGLContext * context,
+    GstAllocationParams * alloc_params, GstVideoInfo * v_info, guint plane,
+    GstVideoAlignment * valign, GstGLTextureTarget target,
+    guint tex_id, gpointer user_data, GDestroyNotify notify)
+{
+  return gst_gl_video_allocation_params_new_wrapped_gl_handle (context,
+      alloc_params, v_info, plane, valign, target, GUINT_TO_POINTER (tex_id),
+      user_data, notify);
+}
+
+/**
  * gst_gl_video_allocation_params_free_data:
  * @params: a #GstGLVideoAllocationParams
  *
index b032a5c..9a40d48 100644 (file)
@@ -106,7 +106,7 @@ gboolean        gst_gl_video_allocation_params_init_full        (GstGLVideoAlloc
                                                                  GstVideoAlignment * valign,
                                                                  GstGLTextureTarget target,
                                                                  gpointer wrapped_data,
-                                                                 guint gl_handle,
+                                                                 gpointer gl_handle,
                                                                  gpointer user_data,
                                                                  GDestroyNotify notify);
 GstGLVideoAllocationParams * gst_gl_video_allocation_params_new (GstGLContext * context,
@@ -135,6 +135,16 @@ GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_texture
                                                                                  gpointer user_data,
                                                                                  GDestroyNotify notify);
 
+GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_gl_handle (GstGLContext * context,
+                                                                                 GstAllocationParams * alloc_params,
+                                                                                 GstVideoInfo * v_info,
+                                                                                 guint plane,
+                                                                                 GstVideoAlignment * valign,
+                                                                                 GstGLTextureTarget target,
+                                                                                 gpointer gl_handle,
+                                                                                 gpointer user_data,
+                                                                                 GDestroyNotify notify);
+
 /* subclass usage */
 void            gst_gl_video_allocation_params_free_data    (GstGLVideoAllocationParams * params);
 /* subclass usage */
index d8fa710..f959dce 100644 (file)
@@ -674,7 +674,7 @@ _gl_mem_pbo_alloc (GstGLBaseMemoryAllocator * allocator,
   mem = g_new0 (GstGLMemoryPBO, 1);
 
   if (alloc_flags & GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE) {
-    mem->mem.tex_id = params->parent.gl_handle;
+    mem->mem.tex_id = GPOINTER_TO_UINT (params->parent.gl_handle);
     mem->mem.texture_wrapped = TRUE;
   }