コード例 #1
0
ファイル: gstdasfsink.c プロジェクト: mrchapp/gst-goo
static void
gst_dasf_enable (GstElement* elem)
{
	GST_INFO ("");
	GstDasfSink *self = GST_DASF_SINK (elem);
	GooTiAudioComponent *component = self->component;
	GstDasfSinkPrivate* priv = GST_DASF_SINK_GET_PRIVATE (self);

	if (self->component == NULL)
	{
		component = GOO_TI_AUDIO_COMPONENT (
				gst_goo_util_find_goo_component (GST_ELEMENT(self), GOO_TYPE_TI_AUDIO_COMPONENT)
			);

		if (component == NULL)
			return;

		self->component = GOO_TI_AUDIO_COMPONENT (g_object_ref (component));

		goo_ti_audio_component_set_dasf_mode (self->component, TRUE);
		GST_DEBUG_OBJECT (self, "set data path");
		goo_ti_audio_component_set_data_path (self->component, 0);
	}

	if (self->pp == NULL)
	{
		/* we haven't yet found a post-processor component.. it could
		 * be that it hasn't been created yet:
		 */
		priv->clock_required = gst_dasf_clock_required (self);

		if (self->pp == NULL)
			return;

		if (priv->clock_source == AUTO_CLOCK)
		{
			priv->clock_source = priv->clock_required;
		}
		GST_INFO ("clock_required=%d, clock_source=%d", priv->clock_required, priv->clock_source);

		/*  Check if OMX will be the clock source and get a new clock instance
			if true */
		if (priv->clock_source == OMX_CLOCK)
		{
			self->clock =
				goo_component_factory_get_component( self->factory,
								    GOO_TI_CLOCK);

			GST_DEBUG ("Clock component clock refcount %d",
					G_OBJECT(self->clock)->ref_count);
		}

		if (priv->clock_source == OMX_CLOCK)
		{
			goo_component_set_clock (GOO_COMPONENT (component), self->clock);
		}
	}

	if (self->clock)
	{
		if (goo_component_get_state(self->clock) == OMX_StateLoaded)
		{
			GST_DEBUG_OBJECT (self, "Setting clock to idle");
			goo_component_set_state_idle (self->clock);
		}
		if (goo_component_get_state(self->clock) == OMX_StateIdle)
		{
			GST_DEBUG_OBJECT (self, "Setting clock to executing");
			goo_component_set_state_executing(self->clock);
			goo_ti_clock_set_starttime (GOO_TI_CLOCK (self->clock), 0);
		}
	}

	return;
}
コード例 #2
0
ファイル: gstdasfsrc.c プロジェクト: ceyusa/gst-goo
static void
gst_dasf_enable (GstDasfSrc* self)
{
	GST_INFO ("");
	GstPad *peer;
	GstElement *next_element;
	GooComponent *component;
	GstBaseSrc *base_src;

	if (self->component != NULL)
	{
		return;
	}

	peer = gst_pad_get_peer (GST_BASE_SRC_PAD (self));

	if (G_UNLIKELY (peer == NULL))
	{
		GST_INFO ("No next pad");
		return;
	}

	next_element = GST_ELEMENT (gst_pad_get_parent (peer));

	if (G_UNLIKELY (next_element == NULL))
	{
		GST_INFO ("Cannot find a next element");
		goto done;
	}

	/** expecting a capsfilter between dasfsrc and goo audio component **/
	while (GST_IS_BASE_TRANSFORM (next_element))
	{
		GST_DEBUG_OBJECT(self, "next element name: %s", gst_element_get_name (next_element));

		gst_object_unref (peer);
		peer = gst_pad_get_peer (GST_BASE_TRANSFORM_SRC_PAD (next_element));
		gst_object_unref (next_element);
		next_element = GST_ELEMENT(gst_pad_get_parent (peer)) ;

		GST_DEBUG_OBJECT (self, "one after element name: %s", gst_element_get_name(next_element));
	}

	/** capsfilter might be found
	 *  element next to the caps filter should be goo **/

	component = GOO_COMPONENT (g_object_get_data
							   (G_OBJECT (next_element), "goo"));

	if (G_UNLIKELY (component == NULL))
	{
		GST_INFO ("Previous element does not have a Goo component");
		goto done;
	}

	if (!GOO_IS_TI_AUDIO_COMPONENT (component))
	{
		GST_WARNING ("The component in previous element is not TI Audio");
		goto done;
	}

	self->component = GOO_TI_AUDIO_COMPONENT (component);
	goo_ti_audio_component_set_dasf_mode (self->component, TRUE);
	GST_DEBUG_OBJECT (self, "set data path");
	goo_ti_audio_component_set_data_path (self->component, 0);

	/** getting num-buffers from base src **/
	base_src = GST_BASE_SRC (self);
	goo_ti_audio_encoder_set_number_buffers (GOO_TI_AUDIO_ENCODER (component), base_src->num_buffers);

done:
	gst_object_unref (peer);
	gst_object_unref (next_element);

	GST_DEBUG_OBJECT (self, "peer refcount = %d",
			  G_OBJECT (peer)->ref_count);

	GST_DEBUG_OBJECT (self, "next element refcount = %d",
			  G_OBJECT (next_element)->ref_count);

	return;
}