Ejemplo n.º 1
0
static void
omx_start (GstGooEncPcm* self)
{
	g_assert (self != NULL);
	g_assert (self->component != NULL);

	if (!goo_port_is_tunneled (self->inport))
	{
		goo_port_set_process_buffer_function (self->outport,
						      omx_output_buffer_cb);
	}

	if (goo_component_get_state (self->component) == OMX_StateLoaded)
	{
		omx_sync (self);
		GST_INFO_OBJECT (self, "going to idle");
		goo_component_set_state_idle (self->component);
	}

	if (goo_component_get_state (self->component) == OMX_StateIdle)
	{
		GST_INFO_OBJECT (self, "going to executing");
		goo_component_set_state_executing (self->component);
	}

	return;
}
Ejemplo n.º 2
0
static void
omx_stop (GstGooEncPcm* self)
{
	g_assert (self != NULL);
	g_assert (self->component != NULL);

  GST_INFO_OBJECT (self,
									"self->component %x state %d",
									self->component,
									goo_component_get_state (self->component) == OMX_StatePause);
	if (goo_component_get_state (self->component) == OMX_StateExecuting ||
			goo_component_get_state (self->component) == OMX_StatePause)
	{
		GST_INFO_OBJECT (self, "Going to idle");
		goo_component_set_state_idle (self->component);
	}

	if (goo_component_get_state (self->component) == OMX_StateIdle)
	{
		GST_INFO_OBJECT (self, "Going to loaded");
		goo_component_set_state_loaded (self->component);
	}
  GST_INFO_OBJECT (self, "");
	return;
}
Ejemplo n.º 3
0
static gboolean
omx_stop (GstGooEncJpeg* self)
{
	g_assert (self != NULL);
	g_assert (self->component != NULL);

	GST_OBJECT_LOCK (self);
	if (goo_component_get_state (self->component) == OMX_StateExecuting ||
	    goo_component_get_state (self->component) == OMX_StatePause)
	{
		GST_INFO ("going to idle");
		goo_component_set_state_idle (self->component);
	}

	if (goo_component_get_state (self->component) == OMX_StateIdle)
	{
		GST_INFO ("going to loaded");
		goo_component_set_state_loaded (self->component);
	}
	GST_OBJECT_UNLOCK (self);

	GST_DEBUG ("");

	return TRUE;
}
Ejemplo n.º 4
0
static gboolean
omx_start (GstGooEncJpeg* self)
{
	g_assert (self != NULL);
	g_assert (self->component != NULL);

	GST_OBJECT_LOCK (self);
	if (goo_component_get_state (self->component) == OMX_StateLoaded)
	{
		omx_sync (self);

		GST_INFO_OBJECT (self, "going to idle");
		goo_component_set_state_idle (self->component);
	}

	if (goo_component_get_state (self->component) == OMX_StateIdle ||
	    goo_component_get_state (self->component) == OMX_StatePause)
	{
		GST_INFO_OBJECT (self, "going to executing");
		goo_component_set_state_executing (self->component);
	}
	GST_OBJECT_UNLOCK (self);

	return TRUE;
}
Ejemplo n.º 5
0
void
gst_goo_util_ensure_executing (GooComponent *component)
{
	if (goo_component_get_state (component) == OMX_StateLoaded)
	{
		goo_component_set_state_idle (component);
	}

	if (goo_component_get_state (component) == OMX_StateIdle)
	{
		goo_component_set_state_executing (component);
	}
}
Ejemplo n.º 6
0
static GstStateChangeReturn
gst_dasf_sink_change_state (GstElement* element, GstStateChange transition)
{
	GstDasfSink *self = GST_DASF_SINK (element);
	GstDasfSinkPrivate* priv = GST_DASF_SINK_GET_PRIVATE (element);
	GST_LOG ("transition=%d", transition);

	switch (transition)
	{
//	case GST_STATE_CHANGE_NULL_TO_READY:
	case GST_STATE_CHANGE_READY_TO_PAUSED:
		/* When going to pause, all components should be already linked, so
		 * we can call again this function in order to ensure that everything
		 * that was not set in the linkage process is set here (this was
		 * added to ensure that OMX Clock is set no matter
		 * how the linkage is done before going to PAUSED)
		 */
		gst_dasf_enable(element);
		break;
	case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
		/* acquire "virtual" ringbuffer */
		priv->ring_buffer_acquired = TRUE;
		break;
	case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
	case GST_STATE_CHANGE_PAUSED_TO_READY:
	case GST_STATE_CHANGE_READY_TO_NULL:
		/* release "virtual" ringbuffer */
		priv->ring_buffer_acquired = FALSE;
		if (self->clock)
		{
			if (goo_component_get_state(self->clock) == OMX_StateExecuting)
			{
				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 loaded");
				goo_component_set_state_loaded(self->clock);
			}
		}
		break;
	default:
		break;
	}

	return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
}
Ejemplo n.º 7
0
static void omx_stop (GstGooEncGsmHr* self)
{
	g_assert (self != NULL);
	g_assert (self->component != NULL);

	if (goo_component_get_state (self->component) == OMX_StateExecuting)
	{
		GST_INFO_OBJECT (self, "going to idle");
		goo_component_set_state_idle (self->component);
	}

	if (goo_component_get_state (self->component) == OMX_StateIdle)
	{
		GST_INFO_OBJECT (self, "going to loaded");
		goo_component_set_state_loaded (self->component);
	}

	return;
}
Ejemplo n.º 8
0
static void
omx_start (GstGooEncArmAac* self)
{
	g_assert (self != NULL);
	g_assert (self->component != NULL);

	GST_OBJECT_LOCK (self);
	if (goo_component_get_state (self->component) == OMX_StateLoaded)
	{
		omx_sync (self);

		GST_INFO_OBJECT (self, "going to idle");
		goo_component_set_state_idle (self->component);
	}

	if (goo_component_get_state (self->component) == OMX_StateIdle)
	{
		GST_INFO_OBJECT (self, "going to executing");
		goo_component_set_state_executing (self->component);
	}
	GST_OBJECT_UNLOCK (self);

	return;
}
Ejemplo n.º 9
0
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;
}
Ejemplo n.º 10
0
static GstFlowReturn
gst_goo_filter_chain (GstPad* pad, GstBuffer* buffer)
{
	GST_LOG ("");

	GstGooFilter* self = GST_GOO_FILTER (gst_pad_get_parent (pad));
	GstGooFilterPrivate* priv = GST_GOO_FILTER_GET_PRIVATE (self);
	GstGooAdapter* adapter = self->adapter;
	GstFlowReturn ret = GST_FLOW_OK;
	static OMX_S64 omx_normalize_timestamp;

	GstClockTime timestamp = GST_BUFFER_TIMESTAMP (buffer);

	if (priv->incount == 0)
	{
		omx_normalize_timestamp	= (gint64)timestamp / CONVERSION;
	}

	if (goo_port_is_tunneled (self->inport))
	{
		/* shall we send a ghost buffer here ? */
		GST_INFO ("port is tunneled");
		ret = GST_FLOW_OK;

		GST_DEBUG_OBJECT (self, "Buffer timestamp: time %" GST_TIME_FORMAT,
						GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));

		GST_DEBUG_OBJECT (self, "Buffer duration: %" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)));

		GST_DEBUG_OBJECT (self, "Pushing buffer to next element. Size =%d", GST_BUFFER_SIZE (buffer));

		/** FIXME GStreamer should not insert the header.  OMX component should take
		 * care of it.	Remove this function upon resolution of DR OMAPS00140835 and
		 * OMAPS00140836 **/
 		priv->outcount++;
		buffer = gst_goo_filter_insert_header (self, buffer, priv->outcount);

		gst_buffer_set_caps (buffer, GST_PAD_CAPS (self->srcpad));
		gst_pad_push (self->srcpad, buffer);

		goto done;
	}

	if (goo_port_is_eos (self->inport))
	{
		GST_INFO ("port is eos");
		ret = GST_FLOW_UNEXPECTED;
		goto fail;
	}

	/** @todo GstGooAdapter! */
	if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) {
		gst_goo_adapter_clear (adapter);
	}

	if (priv->incount == 0 &&
	    goo_component_get_state (self->component) == OMX_StateLoaded)
	{

		/** Some filters require header processing,
			apended to the first buffer **/
		buffer = gst_goo_filter_codec_data_processing (self, GST_BUFFER (buffer));

		/** Todo: Use the gst_caps_fixatecaps_func to make
		    this cleaner **/
		if (!gst_goo_filter_check_fixed_src_caps (self))
			return GST_FLOW_NOT_NEGOTIATED;
		/** Remove gst_goo_filter_check_fixed_src_caps function when fixed **/

		g_object_set (self->inport,
				"buffercount",
				priv->num_input_buffers, NULL);
		g_object_set (self->outport,
				"buffercount",
				priv->num_output_buffers, NULL);

		GST_INFO ("going to idle");
		goo_component_set_state_idle (self->component);
		GST_INFO ("going to executing");
		goo_component_set_state_executing (self->component);

	}

	/** Function to perform post buffering processing **/
	buffer = gst_goo_filter_extra_buffer_processing (self, GST_BUFFER (buffer));

	gst_goo_adapter_push (adapter, buffer);

	if (self->component->cur_state != OMX_StateExecuting)
	{
		goto done;
	}

	int omxbufsiz;

	if (priv->process_mode == STREAMMODE)
		omxbufsiz = GOO_PORT_GET_DEFINITION (self->inport)->nBufferSize;
	else
		omxbufsiz = GST_BUFFER_SIZE (buffer);

	while (gst_goo_adapter_available (adapter) >= omxbufsiz &&
	       ret == GST_FLOW_OK && omxbufsiz != 0)
	{

		GST_DEBUG ("Adapter available =%d  omxbufsiz = %d", gst_goo_adapter_available (adapter), omxbufsiz);

		OMX_BUFFERHEADERTYPE* omx_buffer;
		omx_buffer = goo_port_grab_buffer (self->inport);
		GST_DEBUG ("memcpy to buffer %d bytes", omxbufsiz);
		gst_goo_adapter_peek (adapter, omxbufsiz, omx_buffer);
		omx_buffer->nFilledLen = omxbufsiz;
		gst_goo_adapter_flush (adapter, omxbufsiz);
		/* transfer timestamp to openmax */
		{

			GST_DEBUG_OBJECT (self, "checking timestamp: time %" GST_TIME_FORMAT,
					GST_TIME_ARGS (timestamp));

			if (GST_CLOCK_TIME_IS_VALID (timestamp))
			{
				gint64 buffer_ts = (gint64)timestamp;
				omx_buffer->nTimeStamp = (OMX_S64)buffer_ts / CONVERSION;
				omx_buffer->nTimeStamp = omx_buffer->nTimeStamp - omx_normalize_timestamp;

			} else GST_WARNING_OBJECT (self, "Invalid timestamp!");
		}

		priv->incount++;
		goo_component_release_buffer (self->component, omx_buffer);
		ret = GST_FLOW_OK;
	}

	if (goo_port_is_tunneled (self->outport))
	{
		/** @todo send a ghost buffer */
		GstBuffer *ghost_buffer = (GstBuffer*) gst_ghost_buffer_new ();
		GST_BUFFER_TIMESTAMP (ghost_buffer) = timestamp;
		gst_pad_push (self->srcpad, ghost_buffer);
	}

	goto done;

fail:
	gst_goo_adapter_clear (adapter);
done:
	gst_object_unref (self);
	gst_buffer_unref (buffer);
	return ret;
}
Ejemplo n.º 11
0
static GstStateChangeReturn
gst_goo_encjpeg_change_state (GstElement* element, GstStateChange transition)
{
	GST_LOG ("");

	GstGooEncJpeg* self = GST_GOO_ENCJPEG (element);
	GstStateChange result;

	g_assert (self->component != NULL);
	g_assert (self->inport != NULL);
	g_assert (self->outport != NULL);

	switch (transition)
	{
	case GST_STATE_CHANGE_NULL_TO_READY:
		break;
	case GST_STATE_CHANGE_READY_TO_PAUSED:
	{
		GstGooEncJpegPrivate* priv =
			GST_GOO_ENCJPEG_GET_PRIVATE (self);
		priv->num_input_buffers = NUM_INPUT_BUFFERS_DEFAULT;
		priv->num_output_buffers = NUM_OUTPUT_BUFFERS_DEFAULT;
		priv->incount = 0;
		priv->outcount = 0;
		priv->quality = QUALITY_DEFAULT;
		priv->colorformat = COLOR_FORMAT_DEFAULT;
		priv->width = WIDTH_DEFAULT;
		priv->height = HEIGHT_DEFAULT;
		priv->omxbufsiz = 0;
		break;
	}
	case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
		GST_OBJECT_LOCK (self);
		if (goo_component_get_state (self->component) ==
		   	OMX_StatePause)
		{
			goo_component_set_state_executing (self->component);
		}
		GST_OBJECT_UNLOCK (self);
		break;
	default:
		break;
	}

	result = GST_ELEMENT_CLASS (parent_class)->change_state (element,
								 transition);

	switch (transition)
	{
	case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
		GST_OBJECT_LOCK (self);
		goo_component_set_state_pause (self->component);
		GST_OBJECT_UNLOCK (self);
		break;
	case GST_STATE_CHANGE_PAUSED_TO_READY:
		if ( ! (goo_port_is_tunneled (self->inport)) )
		{
		omx_stop (self);
		}
		break;
	case GST_STATE_CHANGE_READY_TO_NULL:
		break;
	default:
		break;
	}

	return result;
}
Ejemplo n.º 12
0
static gboolean
gst_goo_encjpeg_setcaps (GstPad* pad, GstCaps* caps)
{
	GstGooEncJpeg* self = GST_GOO_ENCJPEG (gst_pad_get_parent (pad));
	GstGooEncJpegPrivate* priv = GST_GOO_ENCJPEG_GET_PRIVATE (self);

	GstStructure* structure;
	const GValue* framerate;
	guint32 fourcc;
	GstPad* otherpad;
	GstCaps* othercaps;
	gboolean ret;

	otherpad = (pad == self->srcpad) ? self->sinkpad : self->srcpad;
	othercaps = gst_caps_copy (gst_pad_get_pad_template_caps (otherpad));

	structure = gst_caps_get_structure (caps, 0);

	gst_structure_get_int (structure, "width", &priv->width);
	gst_structure_get_int (structure, "height", &priv->height);
	gst_structure_get_fourcc (structure, "format", &fourcc);

	switch (fourcc)
	{
	case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
		priv->colorformat = OMX_COLOR_FormatCbYCrY;
		break;
	case GST_MAKE_FOURCC ('I', '4', '2', '0'):
		priv->colorformat = OMX_COLOR_FormatYUV420PackedPlanar;
		break;
	default:
		GST_ERROR ("format not supported");
		return FALSE;
	}

	g_object_set (self->component, "width", priv->width, NULL);
	g_object_set (self->component, "height", priv->height, NULL);

	priv->omxbufsiz = (priv->colorformat == OMX_COLOR_FormatCbYCrY) ?
		priv->width * priv->height * 2 :
		priv->width * priv->height * 1.5;

	framerate = gst_structure_get_value (structure, "framerate");

	if (G_LIKELY (framerate))
	{
		gst_caps_set_simple
			(othercaps,
			 "width", G_TYPE_INT, priv->width,
			 "height", G_TYPE_INT, priv->height,
			 "framerate", GST_TYPE_FRACTION,
			 gst_value_get_fraction_numerator (framerate),
			 gst_value_get_fraction_denominator (framerate),
			 NULL);
	}
	else
	{
		gst_caps_set_simple
			(othercaps,
			 "width", G_TYPE_INT, priv->width,
			 "height", G_TYPE_INT, priv->height,
			 NULL);
	}

	ret = gst_pad_set_caps (self->srcpad, othercaps);
	gst_caps_unref (othercaps);

	if (GST_PAD_LINK_SUCCESSFUL (ret) &&
	    goo_component_get_state (self->component) == OMX_StateLoaded)
	{
		omx_start (self);
	}

	gst_object_unref (self);

	return ret;
}