summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2018-05-15 16:21:26 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2018-08-30 10:59:30 +0200
commit457e1b9a5ea17b1055ac153d213d5b9575311c06 (patch)
treeb76fc043c6912ce6382346b76e9c203b9660fb06
parent092788a96810e3897bd143746eb17a25f9f3a5de (diff)
downloadgst-omx-457e1b9a5ea17b1055ac153d213d5b9575311c06.tar.gz
omx: factor out gst_omx_buffer_get/set_omx_buf()
Move the qdata code to helper functions as I'm going to need them in omxvideoenc to implement dmabuf export. https://bugzilla.gnome.org/show_bug.cgi?id=796918
-rw-r--r--omx/gstomx.c18
-rw-r--r--omx/gstomx.h3
-rw-r--r--omx/gstomxbufferpool.c18
3 files changed, 25 insertions, 14 deletions
diff --git a/omx/gstomx.c b/omx/gstomx.c
index c50480b..f7a548f 100644
--- a/omx/gstomx.c
+++ b/omx/gstomx.c
@@ -70,6 +70,8 @@ static GHashTable *core_handles;
G_LOCK_DEFINE_STATIC (buffer_flags_str);
static GHashTable *buffer_flags_str;
+static GQuark gst_omx_buffer_data_quark = 0;
+
GstOMXCore *
gst_omx_core_acquire (const gchar * filename)
{
@@ -2960,6 +2962,20 @@ gst_omx_set_default_role (GstOMXClassData * class_data,
class_data->component_role = default_role;
}
+void
+gst_omx_buffer_set_omx_buf (GstBuffer * buffer, GstOMXBuffer * omx_buf)
+{
+ gst_mini_object_set_qdata (GST_MINI_OBJECT_CAST (buffer),
+ gst_omx_buffer_data_quark, omx_buf, NULL);
+}
+
+GstOMXBuffer *
+gst_omx_buffer_get_omx_buf (GstBuffer * buffer)
+{
+ return gst_mini_object_get_qdata (GST_MINI_OBJECT_CAST (buffer),
+ gst_omx_buffer_data_quark);
+}
+
static void
_class_init (gpointer g_class, gpointer data)
{
@@ -3130,6 +3146,8 @@ plugin_init (GstPlugin * plugin)
GST_DEBUG_CATEGORY_INIT (OMX_PERFORMANCE, "OMX_PERFORMANCE", 0,
"gst-omx performace");
+ gst_omx_buffer_data_quark = g_quark_from_static_string ("GstOMXBufferData");
+
/* Read configuration file gstomx.conf from the preferred
* configuration directories */
env_config_dir = g_strdup (g_getenv (*env_config_name));
diff --git a/omx/gstomx.h b/omx/gstomx.h
index 075cfd6..81b49dd 100644
--- a/omx/gstomx.h
+++ b/omx/gstomx.h
@@ -469,6 +469,9 @@ gboolean gst_omx_buffer_import_fd (GstOMXBuffer * buffer, GstBuffer * i
void gst_omx_set_default_role (GstOMXClassData *class_data, const gchar *default_role);
+void gst_omx_buffer_set_omx_buf (GstBuffer * buffer, GstOMXBuffer * omx_buf);
+GstOMXBuffer * gst_omx_buffer_get_omx_buf (GstBuffer * buffer);
+
/* refered by plugin_init */
GST_DEBUG_CATEGORY_EXTERN (gst_omx_video_debug_category);
diff --git a/omx/gstomxbufferpool.c b/omx/gstomxbufferpool.c
index 2d6923e..4e2033f 100644
--- a/omx/gstomxbufferpool.c
+++ b/omx/gstomxbufferpool.c
@@ -203,8 +203,6 @@ gst_omx_memory_allocator_alloc (GstAllocator * allocator, GstMemoryFlags flags,
* back to the component (OMX_FillThisBuffer()) when it is released.
*/
-static GQuark gst_omx_buffer_data_quark = 0;
-
#define DEBUG_INIT \
GST_DEBUG_CATEGORY_INIT (gst_omx_buffer_pool_debug_category, "omxbufferpool", 0, \
"debug category for gst-omx buffer pool base class");
@@ -491,8 +489,7 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool,
}
}
- gst_mini_object_set_qdata (GST_MINI_OBJECT_CAST (buf),
- gst_omx_buffer_data_quark, omx_buf, NULL);
+ gst_omx_buffer_set_omx_buf (buf, omx_buf);
*buffer = buf;
@@ -514,8 +511,7 @@ gst_omx_buffer_pool_free_buffer (GstBufferPool * bpool, GstBuffer * buffer)
}
GST_OBJECT_UNLOCK (pool);
- gst_mini_object_set_qdata (GST_MINI_OBJECT_CAST (buffer),
- gst_omx_buffer_data_quark, NULL, NULL);
+ gst_omx_buffer_set_omx_buf (buffer, NULL);
GST_BUFFER_POOL_CLASS (gst_omx_buffer_pool_parent_class)->free_buffer (bpool,
buffer);
@@ -544,9 +540,7 @@ gst_omx_buffer_pool_acquire_buffer (GstBufferPool * bpool,
GstOMXBuffer *omx_buf;
if (pool->output_mode == GST_OMX_BUFFER_MODE_DMABUF) {
- omx_buf =
- gst_mini_object_get_qdata (GST_MINI_OBJECT_CAST (buf),
- gst_omx_buffer_data_quark);
+ omx_buf = gst_omx_buffer_get_omx_buf (buf);
} else {
g_assert (mem
&& g_strcmp0 (mem->allocator->mem_type, GST_OMX_MEMORY_TYPE) == 0);
@@ -578,9 +572,7 @@ gst_omx_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer)
g_assert (pool->component && pool->port);
if (!pool->allocating && !pool->deactivated) {
- omx_buf =
- gst_mini_object_get_qdata (GST_MINI_OBJECT_CAST (buffer),
- gst_omx_buffer_data_quark);
+ omx_buf = gst_omx_buffer_get_omx_buf (buffer);
if (pool->port->port_def.eDir == OMX_DirOutput && !omx_buf->used) {
/* Release back to the port, can be filled again */
err = gst_omx_port_release_buffer (pool->port, omx_buf);
@@ -645,8 +637,6 @@ gst_omx_buffer_pool_class_init (GstOMXBufferPoolClass * klass)
GObjectClass *gobject_class = (GObjectClass *) klass;
GstBufferPoolClass *gstbufferpool_class = (GstBufferPoolClass *) klass;
- gst_omx_buffer_data_quark = g_quark_from_static_string ("GstOMXBufferData");
-
gobject_class->finalize = gst_omx_buffer_pool_finalize;
gstbufferpool_class->start = gst_omx_buffer_pool_start;
gstbufferpool_class->stop = gst_omx_buffer_pool_stop;