END_TEST START_TEST (test_g711dec_2) { GooComponentFactory* factory = goo_ti_component_factory_get_instance (); GooComponent* component = goo_component_factory_get_component (factory, GOO_TI_G711_DECODER); /* audio properties */ g_object_set (G_OBJECT (component), "dasf-mode", TRUE, "data-path", NULL, "mute", FALSE, "volume", 100, NULL); /* input component parameters */ { GOO_TI_G711DEC_GET_INPUT_PARAM (component)->nChannels = 1; GOO_TI_G711DEC_GET_INPUT_PARAM (component)->ePCMMode = OMX_AUDIO_PCMModeALaw; } /* input component parameters */ { GOO_TI_G711DEC_GET_OUTPUT_PARAM (component)->nChannels = 1; GOO_TI_G711DEC_GET_OUTPUT_PARAM (component)->nSamplingRate = 8000; GOO_TI_G711DEC_GET_OUTPUT_PARAM (component)->ePCMMode = OMX_AUDIO_PCMModeLinear; } GOO_OBJECT_WARNING (component, "stream ID = %d", goo_ti_audio_component_get_stream_id (GOO_TI_AUDIO_COMPONENT (component))); goo_component_set_state_idle (component); goo_component_set_state_executing (component); GooEngine* engine = goo_engine_new ( component, "/omx/patterns/mono_8000Hz_80_alaw.bit", NULL); goo_engine_play (engine); goo_component_set_state_idle (component); goo_component_set_state_loaded (component); g_object_unref (G_OBJECT (engine)); g_object_unref (G_OBJECT (component)); g_object_unref (G_OBJECT (factory)); }
END_TEST #if 0 START_TEST (test_pcmenc_2) { GooComponentFactory *factory = goo_ti_component_factory_get_instance (); GooComponent *component = goo_component_factory_get_component (factory, GOO_TI_PCM_ENCODER); /* audio properties */ g_object_set (G_OBJECT (component), "dasf-mode", TRUE, "data-path", NULL, "mute", FALSE, NULL); { GOO_TI_PCMENC_GET_INPUT_PORT_PARAM (component)->nPortIndex = OMX_DirInput; GOO_TI_PCMENC_GET_INPUT_PORT_PARAM (component)->nChannels = 1; } /* output port component parameters */ { GOO_TI_PCMENC_GET_OUTPUT_PORT_PARAM (component)->nPortIndex = OMX_DirOutput; GOO_TI_PCMENC_GET_OUTPUT_PORT_PARAM (component)->nChannels = 1; GOO_TI_PCMENC_GET_OUTPUT_PORT_PARAM (component)->nSamplingRate = 8000; } GOO_OBJECT_WARNING (component, "stream ID = %d", goo_ti_audio_component_get_stream_id (GOO_TI_AUDIO_COMPONENT (component))); GooEngine *engine = goo_engine_new (component, NULL, "/tmp/check_goo_8000.pcm"); g_object_set (engine, "num-buffers", 500, NULL); goo_component_set_state_idle (component); goo_component_set_state_executing (component); goo_engine_play (engine); goo_component_set_state_idle (component); goo_component_set_state_loaded (component); g_object_unref (G_OBJECT (engine)); g_object_unref (G_OBJECT (component)); g_object_unref (G_OBJECT (factory)); }
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; }
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; }
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; }
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; }
END_TEST START_TEST (test_pcmenc_2) { GooComponentFactory *factory = goo_ti_component_factory_get_instance (); GooComponent *component = goo_component_factory_get_component (factory, GOO_TI_PCM_ENCODER); /* audio properties */ g_object_set (G_OBJECT (component), "dasf-mode", FALSE, "data-path", NULL, NULL); { GOO_TI_PCMENC_GET_INPUT_PORT_PARAM (component)->nPortIndex = 0; GOO_TI_PCMENC_GET_INPUT_PORT_PARAM (component)->nChannels = 1; } /* output port component parameters */ { GOO_TI_PCMENC_GET_OUTPUT_PORT_PARAM (component)->nPortIndex = 1; GOO_TI_PCMENC_GET_OUTPUT_PORT_PARAM (component)->nChannels = 1; } GOO_OBJECT_WARNING (component, "stream ID = %d", goo_ti_audio_component_get_stream_id (GOO_TI_AUDIO_COMPONENT (component))); GooEngine *engine = goo_engine_new (component, "/omx/patterns/m16.wav", "/tmp/m_16000.pcm"); goo_component_set_state_idle (component); goo_component_set_state_executing (component); goo_engine_play (engine); goo_component_set_state_idle (component); goo_component_set_state_loaded (component); g_object_unref (G_OBJECT (engine)); g_object_unref (G_OBJECT (component)); g_object_unref (G_OBJECT (factory)); }
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); } }
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); }
static GstStateChangeReturn gst_goo_filter_change_state (GstElement* element, GstStateChange transition) { GST_LOG (""); GstGooFilter* self = GST_GOO_FILTER (element); GstStateChangeReturn result; GstGooFilterPrivate* priv = GST_GOO_FILTER_GET_PRIVATE (self); 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: break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: break; default: break; } result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); switch (transition) { case GST_STATE_CHANGE_PLAYING_TO_PAUSED: /* goo_component_set_state_paused (self->component); */ break; case GST_STATE_CHANGE_PAUSED_TO_READY: GST_INFO ("going to idle"); goo_component_set_state_idle (self->component); GST_INFO ("going to loaded"); goo_component_set_state_loaded (self->component); break; case GST_STATE_CHANGE_READY_TO_NULL: break; default: break; } return result; }
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; }
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; }
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; }
static void gst_dasf_change_peer_omx_state (GstDasfSrc* self) { GST_INFO (""); GstPad *peer; GstElement *next_element; GooComponent *component; GstBaseSrc *base_src; 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"); gst_object_unref (next_element); return; } /** 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"); gst_object_unref (peer); gst_object_unref (next_element); return; } if (!GOO_IS_TI_AUDIO_COMPONENT (component)) { GST_WARNING ("The component in previous element is not TI Audio"); gst_object_unref (peer); gst_object_unref (next_element); return; } self->peer_element = g_object_ref (GST_GOO_AUDIO_FILTER (next_element)); /* Work with a queue on the output buffers */ g_object_set (GST_GOO_AUDIO_FILTER (next_element)->component, "outport-queue", TRUE, NULL); /** This fixates the caps on the next goo element to configure the output omx port **/ gst_goo_audio_filter_check_fixed_src_caps (GST_GOO_AUDIO_FILTER (next_element)); g_object_set (GST_GOO_AUDIO_FILTER (next_element)->inport, "buffercount", 1, NULL); g_object_set (GST_GOO_AUDIO_FILTER (next_element)->outport, "buffercount", 1, NULL); GST_INFO ("Setting peer omx component to idle"); goo_component_set_state_idle (GST_GOO_AUDIO_FILTER (next_element)->component); GST_INFO ("Setting peer omx component to executing"); goo_component_set_state_executing (GST_GOO_AUDIO_FILTER (next_element)->component); 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; }
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; }
static void process (gchar *infile, gint width, gint height, gint outcolor, GooTiVideoDecoderProcessMode process_mode) { fail_unless (infile != NULL, "unspecified filename in test"); fail_unless (g_file_test (infile, G_FILE_TEST_IS_REGULAR), "file don't exist"); gchar outfile[100]; gchar *fn, *fn1; gboolean vopparser; fn = g_path_get_basename (infile); fn1 = strchr (fn, '.'); fn1[0] = '\0'; g_snprintf (outfile, 100, "/tmp/%s.yuv", fn); g_free (fn); /* input port */ { GooPort* port = goo_component_get_port (component, "input0"); g_assert (port != NULL); OMX_PARAM_PORTDEFINITIONTYPE* param = GOO_PORT_GET_DEFINITION (port); param->nBufferCountActual = 4; param->format.video.nFrameWidth = width; param->format.video.nFrameHeight = height; param->format.video.eColorFormat = OMX_COLOR_FormatCbYCrY; g_object_unref (G_OBJECT (port)); } /* output port */ { GooPort* port = goo_component_get_port (component, "output0"); g_assert (port != NULL); OMX_PARAM_PORTDEFINITIONTYPE* param = GOO_PORT_GET_DEFINITION (port); param->nBufferCountActual = 4; param->format.video.nFrameWidth = width; param->format.video.nFrameHeight = height; param->format.video.eColorFormat = outcolor; g_object_unref (G_OBJECT (port)); } /* video properties */ g_object_set (G_OBJECT (component), "process-mode", process_mode, NULL); vopparser = (process_mode == GOO_TI_VIDEO_DECODER_FRAMEMODE) ? TRUE : FALSE; /* GooEngine* engine = goo_engine_new_vop (component, infile, outfile, vopparser); */ GooEngine* engine = goo_engine_new_vop (component, infile, "/dev/null", vopparser); goo_component_set_state_idle (component); goo_component_set_state_executing (component); goo_engine_play (engine); goo_component_set_state_idle (component); goo_component_set_state_loaded (component); g_object_unref (G_OBJECT (engine)); return; }