/** * goo_engine_play: * @self: An #GooEngine instance * * Interchange buffers **/ void goo_engine_play (GooEngine* self) { g_assert (GOO_IS_ENGINE (self)); g_assert (GOO_IS_COMPONENT (self->component)); g_assert (self->component->cur_state == OMX_StateExecuting); GOO_OBJECT_DEBUG (self, "playing"); if (self->enginetype == GOO_ENGINE_FILTER) { /* a filter must has an input and an output port */ g_assert (self->outstream != NULL && self->instream != NULL); } else if (self->enginetype == GOO_ENGINE_SINK) { /* a sink must has an input port */ g_assert (self->instream != NULL); // g_assert (self->outstream == NULL && self->instream != NULL); } else if (self->enginetype == GOO_ENGINE_SRC) { /* a src must has an output port */ g_assert (self->outstream != NULL); // g_assert (self->outstream != NULL && self->instream == NULL); } else { g_assert (self->enginetype != GOO_ENGINE_UNKNOWN); } if (self->enginetype == GOO_ENGINE_SINK || self->enginetype == GOO_ENGINE_FILTER) { GOO_OBJECT_INFO (self, "inport loop"); while (!goo_port_is_eos (self->inport)) { goo_engine_process_input (self); } } else if (self->enginetype == GOO_ENGINE_SRC) { GOO_OBJECT_INFO (self, "outport loop"); while (!goo_port_is_eos (self->outport)) { goo_engine_process_output (self); } } GOO_OBJECT_INFO (self, "Waiting for done..."); goo_component_wait_for_done (self->component); g_print ("\tInput buffers count: %d\n", self->incount); g_print ("\tOutput buffers count: %d\n", self->outcount); return; }
static void omx_wait_for_done (GstGooEncPcm* self) { g_assert (self != NULL); OMX_BUFFERHEADERTYPE* omx_buffer = NULL; OMX_PARAM_PORTDEFINITIONTYPE* param = NULL; param = GOO_PORT_GET_DEFINITION (self->inport); int omxbufsiz = param->nBufferSize; int avail = gst_goo_adapter_available (self->adapter); if (goo_port_is_tunneled (self->inport)) { GST_INFO_OBJECT (self, "Tunneled Input port: Setting done"); goo_component_set_done (self->component); return; } if (avail < omxbufsiz && avail >= 0) { GST_DEBUG_OBJECT (self, "Sending an EOS buffer"); goo_component_send_eos (self->component); } else { /* For some reason the adapter didn't extract all possible buffers */ g_assert_not_reached (); } gst_goo_adapter_clear (self->adapter); GST_INFO_OBJECT (self, "Waiting for done signal"); goo_component_wait_for_done (self->component); return; }
static void gst_goo_filter_wait_for_done (GstGooFilter* self) { g_assert (self != NULL); GstGooFilterPrivate* priv = GST_GOO_FILTER_GET_PRIVATE (self); /* flushing the last buffers in adapter */ OMX_BUFFERHEADERTYPE* omx_buffer; OMX_PARAM_PORTDEFINITIONTYPE* param = GOO_PORT_GET_DEFINITION (self->inport); GstGooAdapter* adapter = self->adapter; int omxbufsiz = param->nBufferSize; int avail = gst_goo_adapter_available (adapter); if (goo_port_is_tunneled (self->inport)) { GST_INFO ("Input port is tunneled: Setting done"); goo_component_set_done (self->component); return; } if (avail < omxbufsiz && avail > 0) { GST_INFO ("Marking EOS buffer"); omx_buffer = goo_port_grab_buffer (self->inport); GST_DEBUG ("Peek to buffer %d bytes", avail); gst_goo_adapter_peek (adapter, avail, omx_buffer); omx_buffer->nFilledLen = avail; /* let's send the EOS flag right now */ omx_buffer->nFlags = OMX_BUFFERFLAG_EOS; /** @todo timestamp the buffers */ priv->incount++; goo_component_release_buffer (self->component, omx_buffer); } else if (avail == 0) { GST_DEBUG ("Sending empty buffer with EOS flag in it"); goo_component_send_eos (self->component); } else { /* For some reason the adapter didn't extract all possible buffers */ GST_ERROR ("Adapter algorithm error!"); goo_component_send_eos (self->component); } gst_goo_adapter_clear (adapter); if (goo_port_is_tunneled (self->outport)) { GST_INFO ("Outport is tunneled: Setting done"); goo_component_set_done (self->component); } else { GST_INFO ("Waiting for done signal"); goo_component_wait_for_done (self->component); } return; }