[Gstreamer-openmax] [PATCH 07/10] add input-buffers/output-buffers properties to the base classes

Rob Clark rob at ti.com
Sun Mar 7 15:14:54 PST 2010


---
 omx/gstomx_base_filter.c |   51 +++++++++++++++++++++++++++++++++++++
 omx/gstomx_base_sink.c   |   63 ++++++++++++++++++++++++++++++++++++++++++++++
 omx/gstomx_base_src.c    |   63 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 177 insertions(+), 0 deletions(-)

diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index 16730fa..02cacaa 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -28,6 +28,8 @@
 enum
 {
     ARG_USE_TIMESTAMPS = GSTOMX_LAST_COMMON_PROP,
+    ARG_NUM_INPUT_BUFFERS,
+    ARG_NUM_OUTPUT_BUFFERS,
 };
 
 static void init_interfaces (GType type);
@@ -199,6 +201,31 @@ 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:
+            {
+                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;
+                g_omx_core_get_param (self->gomx, 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;
+
+                g_omx_core_set_param (self->gomx, OMX_IndexParamPortDefinition, &param);
+            }
+            break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
             break;
@@ -222,6 +249,21 @@ 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:
+                {
+                    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;
+                    g_omx_core_get_param (self->gomx, OMX_IndexParamPortDefinition, &param);
+
+                    g_value_set_uint (value, param.nBufferCountActual);
+                }
+                break;
             default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
                 break;
@@ -258,6 +300,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 f990bba..8deeafb 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_LAST_COMMON_PROP,
+};
+
 static gboolean share_input_buffer;
 
 static inline gboolean omx_init (GstOmxBaseSink *self);
@@ -275,6 +280,46 @@ 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:
+            {
+                OMX_PARAM_PORTDEFINITIONTYPE param;
+                OMX_U32 nBufferCountActual = g_value_get_uint (value);
+
+                G_OMX_INIT_PARAM (param);
+
+                param.nPortIndex = self->in_port->port_index;
+                g_omx_core_get_param (self->gomx, 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;
+
+                g_omx_core_set_param (self->gomx, OMX_IndexParamPortDefinition, &param);
+            }
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+            break;
+    }
+}
+
+static void
 get_property (GObject *obj,
               guint prop_id,
               GValue *value,
@@ -288,6 +333,18 @@ get_property (GObject *obj,
     {
         switch (prop_id)
         {
+            case ARG_NUM_INPUT_BUFFERS:
+                {
+                    OMX_PARAM_PORTDEFINITIONTYPE param;
+
+                    G_OMX_INIT_PARAM (param);
+
+                    param.nPortIndex = self->in_port->port_index;
+                    g_omx_core_get_param (self->gomx, OMX_IndexParamPortDefinition, &param);
+
+                    g_value_set_uint (value, param.nBufferCountActual);
+                }
+                break;
             default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
                 break;
@@ -322,9 +379,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 f651644..e8edf5a 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_LAST_COMMON_PROP,
+};
+
 GSTOMX_BOILERPLATE (GstOmxBaseSrc, gst_omx_base_src, GstBaseSrc, GST_TYPE_BASE_SRC);
 
 static void
@@ -338,6 +343,46 @@ 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:
+            {
+                OMX_PARAM_PORTDEFINITIONTYPE param;
+                OMX_U32 nBufferCountActual = g_value_get_uint (value);
+
+                G_OMX_INIT_PARAM (param);
+
+                param.nPortIndex = self->out_port->port_index;
+                g_omx_core_get_param (self->gomx, 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;
+
+                g_omx_core_set_param (self->gomx, OMX_IndexParamPortDefinition, &param);
+            }
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+            break;
+    }
+}
+
+static void
 get_property (GObject *obj,
               guint prop_id,
               GValue *value,
@@ -351,6 +396,18 @@ get_property (GObject *obj,
     {
         switch (prop_id)
         {
+            case ARG_NUM_OUTPUT_BUFFERS:
+                {
+                    OMX_PARAM_PORTDEFINITIONTYPE param;
+
+                    G_OMX_INIT_PARAM (param);
+
+                    param.nPortIndex = self->out_port->port_index;
+                    g_omx_core_get_param (self->gomx, OMX_IndexParamPortDefinition, &param);
+
+                    g_value_set_uint (value, param.nBufferCountActual);
+                }
+                break;
             default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
                 break;
@@ -382,9 +439,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