diff options
author | Rob Clark <rob@ti.com> | 2010-03-29 08:09:26 -0500 |
---|---|---|
committer | Felipe Contreras <felipe.contreras@nokia.com> | 2010-04-16 17:57:48 +0300 |
commit | 8e4576baac229a1c35de21ade18ba1a8efe6a294 (patch) | |
tree | fd1fa8c0726bbf56aca2caff3abf952719104ed0 | |
parent | 2387c3cf19afc90e56fd9c1f6a692eeb2b9d3afc (diff) |
base: add input-buffers/output-buffers properties
Signed-off-by: Felipe Contreras <felipe.contreras@nokia.com>
-rw-r--r-- | omx/gstomx_base_filter.c | 68 | ||||
-rw-r--r-- | omx/gstomx_base_sink.c | 80 | ||||
-rw-r--r-- | omx/gstomx_base_src.c | 80 |
3 files changed, 228 insertions, 0 deletions
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c index 8278040..6a64e7c 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,40 @@ 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_HANDLETYPE omx_handle = self->gomx->omx_handle; + OMX_U32 nBufferCountActual; + GOmxPort *port = (prop_id == ARG_NUM_INPUT_BUFFERS) ? + self->in_port : self->out_port; + + if (G_UNLIKELY (!omx_handle)) + { + GST_WARNING_OBJECT (self, "no component"); + break; + } + + nBufferCountActual = g_value_get_uint (value); + + G_OMX_INIT_PARAM (param); + + param.nPortIndex = port->port_index; + OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, ¶m); + + 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 (omx_handle, OMX_IndexParamPortDefinition, ¶m); + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec); break; @@ -206,6 +242,29 @@ 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; + OMX_HANDLETYPE omx_handle = self->gomx->omx_handle; + GOmxPort *port = (prop_id == ARG_NUM_INPUT_BUFFERS) ? + self->in_port : self->out_port; + + if (G_UNLIKELY (!omx_handle)) + { + GST_WARNING_OBJECT (self, "no component"); + g_value_set_uint (value, 0); + break; + } + + G_OMX_INIT_PARAM (param); + + param.nPortIndex = port->port_index; + OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, ¶m); + + g_value_set_uint (value, param.nBufferCountActual); + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec); break; @@ -241,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 3cc5f99..66e32d6 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,55 @@ 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_HANDLETYPE omx_handle = self->gomx->omx_handle; + OMX_U32 nBufferCountActual; + + if (G_UNLIKELY (!omx_handle)) + { + GST_WARNING_OBJECT (self, "no component"); + break; + } + + nBufferCountActual = g_value_get_uint (value); + + G_OMX_INIT_PARAM (param); + + param.nPortIndex = self->in_port->port_index; + OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, ¶m); + + 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 (omx_handle, OMX_IndexParamPortDefinition, ¶m); + } + 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 +333,26 @@ get_property (GObject *obj, switch (prop_id) { + case ARG_NUM_INPUT_BUFFERS: + { + OMX_PARAM_PORTDEFINITIONTYPE param; + OMX_HANDLETYPE omx_handle = self->gomx->omx_handle; + + if (G_UNLIKELY (!omx_handle)) + { + GST_WARNING_OBJECT (self, "no component"); + g_value_set_uint (value, 0); + break; + } + + G_OMX_INIT_PARAM (param); + + param.nPortIndex = self->in_port->port_index; + OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, ¶m); + + g_value_set_uint (value, param.nBufferCountActual); + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec); break; @@ -312,9 +386,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 af0bd01..37b29f9 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,55 @@ 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_HANDLETYPE omx_handle = self->gomx->omx_handle; + OMX_U32 nBufferCountActual; + + if (G_UNLIKELY (omx_handle)) + { + GST_WARNING_OBJECT (self, "no component"); + break; + } + + nBufferCountActual = g_value_get_uint (value); + + G_OMX_INIT_PARAM (param); + + param.nPortIndex = self->out_port->port_index; + OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, ¶m); + + 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 (omx_handle, OMX_IndexParamPortDefinition, ¶m); + } + 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 +394,26 @@ get_property (GObject *obj, switch (prop_id) { + case ARG_NUM_OUTPUT_BUFFERS: + { + OMX_PARAM_PORTDEFINITIONTYPE param; + OMX_HANDLETYPE omx_handle = self->gomx->omx_handle; + + if (G_UNLIKELY (!omx_handle)) + { + GST_WARNING_OBJECT (self, "no component"); + g_value_set_uint (value, 0); + break; + } + + G_OMX_INIT_PARAM (param); + + param.nPortIndex = self->out_port->port_index; + OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, ¶m); + + g_value_set_uint (value, param.nBufferCountActual); + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec); break; @@ -370,9 +444,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)); } } |