[gst-cvs] gst-openmax: basesink: move omx initalization to pad link
Felipe Contreras
felipec at kemper.freedesktop.org
Sun Apr 26 07:52:52 PDT 2009
Module: gst-openmax
Branch: master
Commit: 4961c6e984185dd6e8a1f75fee8d7221781db5cb
URL: http://cgit.freedesktop.org/gstreamer/gst-openmax/commit/?id=4961c6e984185dd6e8a1f75fee8d7221781db5cb
Author: Felipe Contreras <felipe.contreras at gmail.com>
Date: Thu Jul 31 17:39:51 2008 +0300
basesink: move omx initalization to pad link
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 009f0c9..25fd806 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -61,24 +61,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;
@@ -337,7 +319,6 @@ type_class_init (gpointer g_class,
gobject_class->finalize = finalize;
- 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;
@@ -408,6 +389,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)
@@ -440,6 +455,7 @@ type_instance_init (GTypeInstance *instance,
self->sinkpad = sinkpad = GST_BASE_SINK_PAD (self);
self->base_activatepush = GST_PAD_ACTIVATEPUSHFUNC (sinkpad);
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 12594ce..681e939 100644
--- a/omx/gstomx_base_sink.h
+++ b/omx/gstomx_base_sink.h
@@ -51,6 +51,7 @@ struct GstOmxBaseSink
gboolean ready;
GstPadActivateModeFunction base_activatepush;
+ gboolean initialized;
};
struct GstOmxBaseSinkClass
More information about the Gstreamer-commits
mailing list