[Gstreamer-openmax] [PATCH 2/5] basesink: move omx initalization to pad link
Felipe Contreras
felipe.contreras at gmail.com
Tue Mar 24 14:59:04 PDT 2009
Based on the tunneling patch series by Frederik Vermelen (NXP), whom
also gave feedback to this patch.
Signed-off-by: Felipe Contreras <felipe.contreras at gmail.com>
---
omx/gstomx_base_sink.c | 54 +++++++++++++++++++++++++++++++----------------
omx/gstomx_base_sink.h | 1 +
2 files changed, 36 insertions(+), 19 deletions(-)
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index 8ab055c..0f22f14 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -64,24 +64,6 @@ setup_ports (GstOmxBaseSink *self)
}
static gboolean
-start (GstBaseSink *gst_base)
-{
- GstOmxBaseSink *self;
-
- self = GST_OMX_BASE_SINK (gst_base);
-
- GST_LOG_OBJECT (self, "begin");
-
- g_omx_core_init (self->gomx, self->omx_library, self->omx_component);
- if (self->gomx->omx_error)
- return GST_STATE_CHANGE_FAILURE;
-
- GST_LOG_OBJECT (self, "end");
-
- return TRUE;
-}
-
-static gboolean
stop (GstBaseSink *gst_base)
{
GstOmxBaseSink *self;
@@ -341,7 +323,6 @@ type_class_init (gpointer g_class,
gobject_class->dispose = dispose;
- gst_base_sink_class->start = start;
gst_base_sink_class->stop = stop;
gst_base_sink_class->event = handle_event;
gst_base_sink_class->preroll = render;
@@ -409,6 +390,40 @@ activate_push (GstPad *pad,
return result;
}
+static inline gboolean
+omx_init (GstOmxBaseSink *self)
+{
+ g_omx_core_init (self->gomx, self->omx_library, self->omx_component);
+
+ if (self->gomx->omx_error)
+ return FALSE;
+
+ return TRUE;
+}
+
+static GstPadLinkReturn
+pad_sink_link (GstPad *pad,
+ GstPad *peer)
+{
+ GOmxCore *gomx;
+ GstOmxBaseSink *self;
+
+ self = GST_OMX_BASE_SINK (GST_OBJECT_PARENT (pad));
+
+ GST_INFO_OBJECT (self, "link");
+
+ gomx = self->gomx;
+
+ if (!self->initialized)
+ {
+ if (!omx_init (self))
+ return GST_PAD_LINK_REFUSED;
+ self->initialized = TRUE;
+ }
+
+ return GST_PAD_LINK_OK;
+}
+
static void
type_instance_init (GTypeInstance *instance,
gpointer g_class)
@@ -435,6 +450,7 @@ type_instance_init (GTypeInstance *instance,
GstPad *sinkpad;
self->sinkpad = sinkpad = GST_BASE_SINK_PAD (self);
gst_pad_set_activatepush_function (sinkpad, activate_push);
+ gst_pad_set_link_function (sinkpad, pad_sink_link);
}
GST_LOG_OBJECT (self, "end");
diff --git a/omx/gstomx_base_sink.h b/omx/gstomx_base_sink.h
index 2ac371d..1356cf7 100644
--- a/omx/gstomx_base_sink.h
+++ b/omx/gstomx_base_sink.h
@@ -50,6 +50,7 @@ struct GstOmxBaseSink
char *omx_library;
gboolean ready;
+ gboolean initialized;
};
struct GstOmxBaseSinkClass
--
1.6.2.1.316.gedbc2
More information about the Gstreamer-openmax
mailing list