[Gstreamer-openmax] [PATCH 6/8] Add input-buffers/output-buffers properties to the base classes

Rob Clark rob at ti.com
Wed Mar 17 16:58:59 PDT 2010


---
 omx/gstomx_base_filter.c |   62 ++++++++++++++++++++++++++++++++++++++
 omx/gstomx_base_sink.c   |   74 ++++++++++++++++++++++++++++++++++++++++++++++
 omx/gstomx_base_src.c    |   74 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 210 insertions(+), 0 deletions(-)

diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index 98b40d5..76ec085 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -28,6 +28,8 @@
 enum
 {
     ARG_USE_TIMESTAMPS = GSTOMX_NUM_COMMON_PROP,
+    ARG_NUM_INPUT_BUFFERS,
+    ARG_NUM_OUTPUT_BUFFERS,
 };
 
 static void init_interfaces (GType type);
@@ -182,6 +184,36 @@ set_property (GObject *obj,
         case ARG_USE_TIMESTAMPS:
             self->use_timestamps = g_value_get_boolean (value);
             break;
+        case ARG_NUM_INPUT_BUFFERS:
+        case ARG_NUM_OUTPUT_BUFFERS:
+            if (G_LIKELY (self->gomx->omx_handle))
+            {
+                OMX_PARAM_PORTDEFINITIONTYPE param;
+                OMX_U32 nBufferCountActual = g_value_get_uint (value);
+                GOmxPort *port = (prop_id == ARG_NUM_INPUT_BUFFERS) ?
+                        self->in_port : self->out_port;
+
+                G_OMX_INIT_PARAM (param);
+
+                param.nPortIndex = port->port_index;
+                OMX_GetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+
+                if (nBufferCountActual < param.nBufferCountMin)
+                {
+                    GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
+                            nBufferCountActual, param.nBufferCountMin);
+                    return;
+                }
+
+                param.nBufferCountActual = nBufferCountActual;
+
+                OMX_SetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+            }
+            else
+            {
+                GST_WARNING_OBJECT (self, "no component");
+            }
+            break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
             break;
@@ -206,6 +238,27 @@ get_property (GObject *obj,
         case ARG_USE_TIMESTAMPS:
             g_value_set_boolean (value, self->use_timestamps);
             break;
+        case ARG_NUM_INPUT_BUFFERS:
+        case ARG_NUM_OUTPUT_BUFFERS:
+            if (G_LIKELY (self->gomx->omx_handle))
+            {
+                OMX_PARAM_PORTDEFINITIONTYPE param;
+                GOmxPort *port = (prop_id == ARG_NUM_INPUT_BUFFERS) ?
+                        self->in_port : self->out_port;
+
+                G_OMX_INIT_PARAM (param);
+
+                param.nPortIndex = port->port_index;
+                OMX_GetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+
+                g_value_set_uint (value, param.nBufferCountActual);
+            }
+            else
+            {
+                GST_WARNING_OBJECT (self, "no component");
+                g_value_set_uint (value, 0);
+            }
+            break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
             break;
@@ -241,6 +294,15 @@ type_class_init (gpointer g_class,
                                          g_param_spec_boolean ("use-timestamps", "Use timestamps",
                                                                "Whether or not to use timestamps",
                                                                TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+        g_object_class_install_property (gobject_class, ARG_NUM_INPUT_BUFFERS,
+                                         g_param_spec_uint ("input-buffers", "Input buffers",
+                                                            "The number of OMX input buffers",
+                                                            1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+        g_object_class_install_property (gobject_class, ARG_NUM_OUTPUT_BUFFERS,
+                                         g_param_spec_uint ("output-buffers", "Output buffers",
+                                                            "The number of OMX output buffers",
+                                                            1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
     }
 }
 
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index 7fd61d5..ce70df8 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -28,6 +28,11 @@
 
 #include <string.h> /* for memcpy */
 
+enum
+{
+    ARG_NUM_INPUT_BUFFERS = GSTOMX_NUM_COMMON_PROP,
+};
+
 static gboolean share_input_buffer;
 
 static inline gboolean omx_init (GstOmxBaseSink *self);
@@ -265,6 +270,51 @@ handle_event (GstBaseSink *gst_base,
 }
 
 static void
+set_property (GObject *obj,
+              guint prop_id,
+              const GValue *value,
+              GParamSpec *pspec)
+{
+    GstOmxBaseSink *self;
+
+    self = GST_OMX_BASE_SINK (obj);
+
+    switch (prop_id)
+    {
+        case ARG_NUM_INPUT_BUFFERS:
+            if (G_LIKELY (self->gomx->omx_handle))
+            {
+                OMX_PARAM_PORTDEFINITIONTYPE param;
+                OMX_U32 nBufferCountActual = g_value_get_uint (value);
+
+                G_OMX_INIT_PARAM (param);
+
+                param.nPortIndex = self->in_port->port_index;
+                OMX_GetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+
+                if (nBufferCountActual < param.nBufferCountMin)
+                {
+                    GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
+                            nBufferCountActual, param.nBufferCountMin);
+                    return;
+                }
+
+                param.nBufferCountActual = nBufferCountActual;
+
+                OMX_SetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+            }
+            else
+            {
+                GST_WARNING_OBJECT (self, "no component");
+            }
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+            break;
+    }
+}
+
+static void
 get_property (GObject *obj,
               guint prop_id,
               GValue *value,
@@ -279,6 +329,24 @@ get_property (GObject *obj,
 
     switch (prop_id)
     {
+        case ARG_NUM_INPUT_BUFFERS:
+            if (G_LIKELY (self->gomx->omx_handle))
+            {
+                OMX_PARAM_PORTDEFINITIONTYPE param;
+
+                G_OMX_INIT_PARAM (param);
+
+                param.nPortIndex = self->in_port->port_index;
+                OMX_GetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+
+                g_value_set_uint (value, param.nBufferCountActual);
+            }
+            else
+            {
+                GST_WARNING_OBJECT (self, "no component");
+                g_value_set_uint (value, 0);
+            }
+            break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
             break;
@@ -312,9 +380,15 @@ type_class_init (gpointer g_class,
 
     /* Properties stuff */
     {
+        gobject_class->set_property = set_property;
         gobject_class->get_property = get_property;
 
         gstomx_install_property_helper (gobject_class);
+
+        g_object_class_install_property (gobject_class, ARG_NUM_INPUT_BUFFERS,
+                                         g_param_spec_uint ("input-buffers", "Input buffers",
+                                                            "The number of OMX input buffers",
+                                                            1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
     }
 }
 
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index 00d27b6..66ed11d 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -24,6 +24,11 @@
 
 #include <string.h> /* for memcpy */
 
+enum
+{
+    ARG_NUM_OUTPUT_BUFFERS = GSTOMX_NUM_COMMON_PROP,
+};
+
 GSTOMX_BOILERPLATE (GstOmxBaseSrc, gst_omx_base_src, GstBaseSrc, GST_TYPE_BASE_SRC);
 
 static void
@@ -326,6 +331,51 @@ handle_event (GstBaseSrc *gst_base,
 }
 
 static void
+set_property (GObject *obj,
+              guint prop_id,
+              const GValue *value,
+              GParamSpec *pspec)
+{
+    GstOmxBaseSrc *self;
+
+    self = GST_OMX_BASE_SRC (obj);
+
+    switch (prop_id)
+    {
+        case ARG_NUM_OUTPUT_BUFFERS:
+            if (G_LIKELY (self->gomx->omx_handle))
+            {
+                OMX_PARAM_PORTDEFINITIONTYPE param;
+                OMX_U32 nBufferCountActual = g_value_get_uint (value);
+
+                G_OMX_INIT_PARAM (param);
+
+                param.nPortIndex = self->out_port->port_index;
+                OMX_GetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+
+                if (nBufferCountActual < param.nBufferCountMin)
+                {
+                    GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
+                            nBufferCountActual, param.nBufferCountMin);
+                    return;
+                }
+
+                param.nBufferCountActual = nBufferCountActual;
+
+                OMX_SetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+            }
+            else
+            {
+                GST_WARNING_OBJECT (self, "no component");
+            }
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+            break;
+    }
+}
+
+static void
 get_property (GObject *obj,
               guint prop_id,
               GValue *value,
@@ -340,6 +390,24 @@ get_property (GObject *obj,
 
     switch (prop_id)
     {
+        case ARG_NUM_OUTPUT_BUFFERS:
+            if (G_LIKELY (self->gomx->omx_handle))
+            {
+                OMX_PARAM_PORTDEFINITIONTYPE param;
+
+                G_OMX_INIT_PARAM (param);
+
+                param.nPortIndex = self->out_port->port_index;
+                OMX_GetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+
+                g_value_set_uint (value, param.nBufferCountActual);
+            }
+            else
+            {
+                GST_WARNING_OBJECT (self, "no component");
+                g_value_set_uint (value, 0);
+            }
+            break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
             break;
@@ -370,9 +438,15 @@ type_class_init (gpointer g_class,
 
     /* Properties stuff */
     {
+        gobject_class->set_property = set_property;
         gobject_class->get_property = get_property;
 
         gstomx_install_property_helper (gobject_class);
+
+        g_object_class_install_property (gobject_class, ARG_NUM_OUTPUT_BUFFERS,
+                                         g_param_spec_uint ("output-buffers", "Output buffers",
+                                                            "The number of OMX output buffers",
+                                                            1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
     }
 }
 
-- 
1.6.3.2





More information about the Gstreamer-openmax mailing list