status_t OMXNodeInstance::getParameter(
        OMX_INDEXTYPE index, void *params, size_t size) {
    Mutex::Autolock autoLock(mLock);

    OMX_ERRORTYPE err = OMX_GetParameter(mHandle, index, params);
    return StatusFromOMXError(err);
}
OMX_ERRORTYPE prepare_port_buffers(HTEST *hTest, OMX_U32 nPortIndex)
{
	OMX_COMPONENTTYPE *hComponent = NULL;
	OMX_PARAM_PORTDEFINITIONTYPE sPortDef;
	OMX_BUFFERHEADERTYPE *pBufferHdr = NULL;
	OMX_U8 *pBuffer = NULL;
	OMX_U32 i;

	hComponent = hTest->hComponent;
	OMX_INIT_STRUCT(&sPortDef, OMX_PARAM_PORTDEFINITIONTYPE);
	sPortDef.nPortIndex = nPortIndex;
	OMX_GetParameter(hComponent, OMX_IndexParamPortDefinition, &sPortDef);

	for(i=0; i<sPortDef.nBufferCountActual; i++)
	{
		if(hTest->bAllocater[nPortIndex] == OMX_TRUE)
		{
			OMX_AllocateBuffer(hComponent, &pBufferHdr, nPortIndex, NULL, sPortDef.nBufferSize);
			printf("Allocate buffer done.\n");
		}
		else
		{
			pBuffer = (OMX_U8*)FSL_MALLOC(sPortDef.nBufferSize);
			OMX_UseBuffer(hComponent, &pBufferHdr, nPortIndex, NULL, sPortDef.nBufferSize, pBuffer);
			printf("Use buffer done.\n");
		}
		hTest->pBufferHdr[nPortIndex][i] = pBufferHdr;
	}
	hTest->nBufferHdr[nPortIndex] = sPortDef.nBufferCountActual;


	return OMX_ErrorNone;
}
void graph::gmusicops::do_retrieve_metadata ()
{
  OMX_U32 index = 0;
  const int gmusic_index = 0;
  // Extract metadata from the gmusic source
  while (OMX_ErrorNone == dump_metadata_item (index++, gmusic_index))
  {
  };

  // Now extract metadata from the decoder
  const int decoder_index = 1;
  index = 0;
  const bool use_first_as_heading = false;
  while (OMX_ErrorNone
         == dump_metadata_item (index++, decoder_index, use_first_as_heading))
  {
  };

  OMX_GetParameter (handles_[2], OMX_IndexParamAudioPcm, &renderer_pcmtype_);

  // Now print renderer metadata
  TIZ_PRINTF_MAG (
      "     %ld Ch, %g KHz, %lu:%s:%s \n", renderer_pcmtype_.nChannels,
      ((float)renderer_pcmtype_.nSamplingRate) / 1000,
      renderer_pcmtype_.nBitPerSample,
      renderer_pcmtype_.eNumData == OMX_NumericalDataSigned ? "s" : "u",
      renderer_pcmtype_.eEndian == OMX_EndianBig ? "b" : "l");
}
예제 #4
0
/* Based on allocbufs from omxtx.
   Buffers are connected as a one-way linked list using pAppPrivate as the pointer to the next element */
void omx_alloc_buffers(struct omx_component_t *component, int port)
{
  int i;
  OMX_BUFFERHEADERTYPE *list = NULL, **end = &list;
  OMX_PARAM_PORTDEFINITIONTYPE portdef;

  OMX_INIT_STRUCTURE(portdef);
  portdef.nPortIndex = port;

  OERR(OMX_GetParameter(component->h, OMX_IndexParamPortDefinition, &portdef));

  if (component == &component->pipe->audio_render) {
    DEBUGF("Allocating %d buffers of %d bytes\n",(int)portdef.nBufferCountActual,(int)portdef.nBufferSize);
    DEBUGF("portdef.bEnabled=%d\n",portdef.bEnabled);
  }

  for (i = 0; i < portdef.nBufferCountActual; i++) {
    OMX_U8 *buf;

    buf = vcos_malloc_aligned(portdef.nBufferSize, portdef.nBufferAlignment, "buffer");

    //    printf("Allocated a buffer of %u bytes\n",(unsigned int)portdef.nBufferSize);

    OERR(OMX_UseBuffer(component->h, end, port, NULL, portdef.nBufferSize, buf));

    end = (OMX_BUFFERHEADERTYPE **) &((*end)->pAppPrivate);
  }

  component->buffers = list;
}
OMX_ERRORTYPE
graph::vorbisdecops::set_vorbis_settings ()
{
  // Retrieve the current vorbis settings from the decoder's port #0
  OMX_AUDIO_PARAM_VORBISTYPE vorbistype_orig;
  TIZ_INIT_OMX_PORT_STRUCT (vorbistype_orig, 0 /* port id */);

  tiz_check_omx_err (OMX_GetParameter (handles_[1], OMX_IndexParamAudioVorbis,
                                       &vorbistype_orig));

  // Set the vorbis settings on decoder's port #0
  OMX_AUDIO_PARAM_VORBISTYPE vorbistype;
  TIZ_INIT_OMX_PORT_STRUCT (vorbistype, 0 /* port id */);

  probe_ptr_->get_vorbis_codec_info (vorbistype);
  vorbistype.nPortIndex = 0;
  tiz_check_omx_err (
      OMX_SetParameter (handles_[1], OMX_IndexParamAudioVorbis, &vorbistype));

  // Record whether we need to wait for a port settings change event or not
  // (the decoder output port implements the "slaving" behaviour)
  need_port_settings_changed_evt_
      = ((vorbistype_orig.nSampleRate != vorbistype.nSampleRate)
         || (vorbistype_orig.nChannels != vorbistype.nChannels));

  return OMX_ErrorNone;
}
예제 #6
0
파일: omx.c 프로젝트: alexandrezia/showtime
void
omx_alloc_buffers(omx_component_t *oc, int port)
{
  OMX_PARAM_PORTDEFINITIONTYPE portdef;

  memset(&portdef, 0, sizeof(portdef));
  portdef.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
  portdef.nVersion.nVersion = OMX_VERSION;
  portdef.nPortIndex = port;

  omxchk(OMX_GetParameter(oc->oc_handle, OMX_IndexParamPortDefinition, &portdef));
  if(portdef.bEnabled != OMX_FALSE || portdef.nBufferCountActual == 0 || portdef.nBufferSize == 0)
    exit(2);

  omxdbg("Allocating buffers for %s:%d\n", oc->oc_name, port);
  omxdbg("  buffer count = %d\n", (int)portdef.nBufferCountActual);
  omxdbg("  buffer size  = %d\n", (int)portdef.nBufferSize);

  omx_send_command(oc, OMX_CommandPortEnable, port, NULL, 0);
  int i;
  for(i = 0; i < portdef.nBufferCountActual; i++) {
    OMX_BUFFERHEADERTYPE *buf;
    omxchk(OMX_AllocateBuffer(oc->oc_handle, &buf, port, NULL, portdef.nBufferSize));
    omxdbg("buf=%p\n", buf);
    buf->pAppPrivate = oc->oc_avail;
    oc->oc_avail = buf;
  }
  omx_wait_command(oc); // Waits for the OMX_CommandPortEnable command

}
예제 #7
0
static OMX_ERRORTYPE SetFormat(filter_t *filter, OmxPort *port)
{
    OMX_PARAM_PORTDEFINITIONTYPE *definition;
    filter_sys_t *sys = filter->p_sys;
    OMX_ERRORTYPE omx_error;

    definition = &port->definition;
    definition->format.image.nFrameWidth =
        filter->fmt_in.video.i_width;
    definition->format.image.nFrameHeight =
        filter->fmt_in.video.i_height;
    definition->format.image.nStride =
        ALIGN(definition->format.image.nFrameWidth, 32);
    definition->format.image.nSliceHeight =
        ALIGN(definition->format.image.nFrameHeight, 16);
    definition->nBufferSize = definition->format.image.nStride *
        definition->format.image.nSliceHeight * 3 / 2;

    omx_error = OMX_SetParameter(sys->omx_handle,
            OMX_IndexParamPortDefinition, definition);
    if (omx_error != OMX_ErrorNone)
        msg_Warn(filter, "Could not configure port format (%x: %s).",
            omx_error, ErrorToString(omx_error));
    OMX_GetParameter(sys->omx_handle, OMX_IndexParamPortDefinition,
            &definition);
    msg_Dbg(filter, "Port %u\nFormat: %ux%u (%ux%u)\nnBufferSize: %u",
            (unsigned)definition->nPortIndex,
            (unsigned)definition->format.image.nFrameWidth,
            (unsigned)definition->format.image.nFrameHeight,
            (unsigned)definition->format.image.nStride,
            (unsigned)definition->format.image.nSliceHeight,
            (unsigned)definition->nBufferSize);

    return omx_error;
}
int NonTextureEngine::getFrameCounter()
{
	
	if (!isOpen) 
	{
		return 0;
	}
	OMX_CONFIG_BRCMPORTSTATSTYPE stats;
	
	OMX_INIT_STRUCTURE(stats);
	stats.nPortIndex = VIDEO_RENDER_INPUT_PORT;
	OMX_ERRORTYPE error =OMX_GetParameter(render, OMX_IndexConfigBrcmPortStats, &stats);
	if (error == OMX_ErrorNone)
	{
		/*OMX_U32 nImageCount;
		 OMX_U32 nBufferCount;
		 OMX_U32 nFrameCount;
		 OMX_U32 nFrameSkips;
		 OMX_U32 nDiscards;
		 OMX_U32 nEOS;
		 OMX_U32 nMaxFrameSize;
		 
		 OMX_TICKS nByteCount;
		 OMX_TICKS nMaxTimeDelta;
		 OMX_U32 nCorruptMBs;*/
		//ofLogVerbose(__func__) << "nFrameCount: " << stats.nFrameCount;
		frameCounter = stats.nFrameCount;
	}else
	{		
		ofLog(OF_LOG_ERROR, "error OMX_CONFIG_BRCMPORTSTATSTYPE FAIL error: 0x%08x", error);
		//frameCounter = 0;
	}
	return frameCounter;
}
OMX_ERRORTYPE
graph::gmusicops::set_channels_and_rate_on_decoder (
    const OMX_U32 channels, const OMX_U32 sampling_rate)
{
  const OMX_HANDLETYPE handle = handles_[1];  // decoder's handle
  const OMX_U32 port_id = 0;                  // decoder's input port

  TIZ_LOG (TIZ_PRIORITY_TRACE, "channels = [%d] sampling_rate = [%d]", channels,
           sampling_rate);

  // Retrieve the mp3 settings from the decoder component
  TIZ_INIT_OMX_PORT_STRUCT (decoder_mp3type_, port_id);
  tiz_check_omx (
      OMX_GetParameter (handle, OMX_IndexParamAudioMp3, &decoder_mp3type_));

  TIZ_LOG (TIZ_PRIORITY_TRACE, "channels = [%d] sampling_rate = [%d]", channels,
           sampling_rate);

  // Now assign the actual settings to the pcmtype structure
  decoder_mp3type_.nChannels = channels;
  decoder_mp3type_.nSampleRate = sampling_rate;

  // Set the new mp3 settings
  tiz_check_omx (
      OMX_SetParameter (handle, OMX_IndexParamAudioMp3, &decoder_mp3type_));

  TIZ_LOG (TIZ_PRIORITY_TRACE, "channels = [%d] sampling_rate = [%d]", channels,
           sampling_rate);

  return OMX_ErrorNone;
}
예제 #10
0
static void
rpi_video_port_settings_changed(omx_component_t *oc)
{
  media_codec_t *mc = oc->oc_opaque;
  const rpi_video_codec_t *rvc = mc->opaque;
  media_pipe_t *mp = mc->mp;
  frame_info_t *fi = calloc(1, sizeof(frame_info_t));


  int sar_num = 1;
  int sar_den = 1;

  if(rvc->rvc_sar_num && rvc->rvc_sar_den) {

    sar_num = rvc->rvc_sar_num;
    sar_den = rvc->rvc_sar_den;

  } else {

    OMX_CONFIG_POINTTYPE pixel_aspect;
    OMX_INIT_STRUCTURE(pixel_aspect);
    pixel_aspect.nPortIndex = 131;
    if(OMX_GetParameter(oc->oc_handle, OMX_IndexParamBrcmPixelAspectRatio,
			&pixel_aspect) == OMX_ErrorNone) {
      sar_num = pixel_aspect.nX ?: sar_num;
      sar_den = pixel_aspect.nY ?: sar_den;
    }
  }
OMX_ERRORTYPE
graph::gmusicops::set_gmusic_playlist (const OMX_HANDLETYPE handle,
                                       const std::string &playlist)
{
  // Set the Google Music playlist
  OMX_TIZONIA_AUDIO_PARAM_GMUSICPLAYLISTTYPE playlisttype;
  TIZ_INIT_OMX_STRUCT (playlisttype);
  tiz_check_omx_err (OMX_GetParameter (
      handle,
      static_cast< OMX_INDEXTYPE >(OMX_TizoniaIndexParamAudioGmusicPlaylist),
      &playlisttype));
  copy_omx_string (playlisttype.cPlaylistName, playlist);

  tizgmusicconfig_ptr_t gmusic_config
    = boost::dynamic_pointer_cast< gmusicconfig >(config_);
  assert (gmusic_config);

  playlisttype.ePlaylistType = gmusic_config->get_playlist_type ();
  playlisttype.bShuffle = playlist_->shuffle ();

  return OMX_SetParameter (
      handle,
      static_cast< OMX_INDEXTYPE >(OMX_TizoniaIndexParamAudioGmusicPlaylist),
      &playlisttype);
}
OMX_ERRORTYPE
graph::gmusicops::set_channels_and_rate_on_renderer (
    const OMX_U32 channels, const OMX_U32 sampling_rate,
    const std::string encoding_str)
{
  const OMX_HANDLETYPE handle = handles_[2];  // renderer's handle
  const OMX_U32 port_id = 0;                  // renderer's input port

  TIZ_LOG (TIZ_PRIORITY_TRACE, "channels = [%d] sampling_rate = [%d]", channels,
           sampling_rate);

  // Retrieve the pcm settings from the renderer component
  TIZ_INIT_OMX_PORT_STRUCT (renderer_pcmtype_, port_id);
  tiz_check_omx_err (
      OMX_GetParameter (handle, OMX_IndexParamAudioPcm, &renderer_pcmtype_));

  // Now assign the actual settings to the pcmtype structure
  renderer_pcmtype_.nChannels = channels;
  renderer_pcmtype_.nSamplingRate = sampling_rate;
  renderer_pcmtype_.eNumData = OMX_NumericalDataSigned;
  renderer_pcmtype_.eEndian
      = (encoding_ == OMX_AUDIO_CodingMP3 ? OMX_EndianBig : OMX_EndianLittle);

  // Set the new pcm settings
  tiz_check_omx_err (
      OMX_SetParameter (handle, OMX_IndexParamAudioPcm, &renderer_pcmtype_));

  std::string coding_type_str ("gmusic");
  tiz::graph::util::dump_graph_info (coding_type_str.c_str (),
                                     "Connection established",
                                     playlist_->get_current_uri ().c_str ());
  dump_stream_metadata ();

  return OMX_ErrorNone;
}
    static OMX_ERRORTYPE StdCompCommonImage_PortFormatSupported(
        TEST_CTXTYPE *pCtx,
        OMX_U32 nPortIndex,
        OMX_IMAGE_CODINGTYPE eCompressionFormat,
        OMX_COLOR_FORMATTYPE eColorFormat)
    {
        OMX_ERRORTYPE eError = OMX_ErrorNone;

        OMX_IMAGE_PARAM_PORTFORMATTYPE sPortFormat;

        OMX_CONF_INIT_STRUCT(sPortFormat, OMX_IMAGE_PARAM_PORTFORMATTYPE);

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Verifying port format support\n");

        sPortFormat.nPortIndex = nPortIndex;

        for (sPortFormat.nIndex = 0; ; sPortFormat.nIndex++)
        {
            eError = OMX_GetParameter(pCtx->hWrappedComp, OMX_IndexParamImagePortFormat, (OMX_PTR) & sPortFormat);
            if (OMX_ErrorNoMore == eError)
                eError = OMX_ErrorBadParameter;  // OMX_ErrorBadPortFormatEncoding
            OMX_CONF_BAIL_ON_ERROR(eError);

            if ((sPortFormat.eCompressionFormat == eCompressionFormat) &&
                    (sPortFormat.eColorFormat == eColorFormat))
                break;
        }

OMX_CONF_TEST_BAIL:
        return(eError);
    }
예제 #14
0
static void
get_property (GObject * obj, guint prop_id, GValue * value, GParamSpec * pspec)
{
  GstOmxBaseSink *self;

  self = GST_OMX_BASE_SINK (obj);

  if (gstomx_get_property_helper (self->gomx, prop_id, value))
    return;

  switch (prop_id) {
    case ARG_NUM_INPUT_BUFFERS:
    {
      OMX_PARAM_PORTDEFINITIONTYPE param;
      OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;

      if (G_UNLIKELY (!omx_handle)) {
        GST_WARNING_OBJECT (self, "no component");
        g_value_set_uint (value, 0);
        break;
      }

      G_OMX_INIT_PARAM (param);

      param.nPortIndex = self->in_port->port_index;
      OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);

      g_value_set_uint (value, param.nBufferCountActual);
    }
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
      break;
  }
}
static gboolean
sink_setcaps (GstPad * pad, GstCaps * caps)
{
  GstStructure *structure;
  GstOmxBaseFilter *omx_base;
  OMX_AUDIO_PARAM_AACPROFILETYPE param;
  gint channels = 0;
  gint sample_rate = 0;
  gint mpegversion = 0;
  const gchar *stream_format;
  G_OMX_INIT_PARAM (param);

  omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));

  GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);

  structure = gst_caps_get_structure (caps, 0);

  {
    const GValue *codec_data;
    GstBuffer *buffer;

    codec_data = gst_structure_get_value (structure, "codec_data");
    if (codec_data) {
      buffer = gst_value_get_buffer (codec_data);
      omx_base->codec_data = buffer;
      gst_buffer_ref (buffer);
    }
  }

  gst_structure_get_int(structure, "mpegversion", &mpegversion);
  gst_structure_get_int(structure, "channels", &channels);
  gst_structure_get_int(structure, "rate", &sample_rate);
  stream_format = gst_structure_get_string(structure, "stream-format");

  /* retrieve current in port params */
  param.nPortIndex = omx_base->in_port->port_index;
  OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAac, &param);

  if(channels > 0)
    param.nChannels = (OMX_U32)channels;
  if(sample_rate > 0)
    param.nSampleRate = (OMX_U32)sample_rate;
  if(!g_strcmp0(stream_format, "adif")) {
    param.eAACStreamFormat = OMX_AUDIO_AACStreamFormatADIF;
  }
  else if(!g_strcmp0(stream_format, "raw")) {
    param.eAACStreamFormat = OMX_AUDIO_AACStreamFormatRAW;
  }
  else if(!g_strcmp0(stream_format, "adts")) {
    if(mpegversion == 2)
      param.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP2ADTS;
    else if(mpegversion == 4)
      param.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4ADTS;
  }
  OMX_SetParameter(omx_base->gomx->omx_handle, OMX_IndexParamAudioAac, &param);

  return gst_pad_set_caps (pad, caps);
}
예제 #16
0
OMX_ERRORTYPE Component::allocOutputBuffers()
{
	
    if(!handle) 
    {
        ofLogError(__func__) << getName() << " NO HANDLE";
        return OMX_ErrorNone;
    }
    OMX_ERRORTYPE error = OMX_ErrorNone;
	

	OMX_PARAM_PORTDEFINITIONTYPE portFormat;
	OMX_INIT_STRUCTURE(portFormat);
	portFormat.nPortIndex = outputPort;

	error = OMX_GetParameter(handle, OMX_IndexParamPortDefinition, &portFormat);
    OMX_TRACE(error);
	if(error != OMX_ErrorNone)
	{
		return error;
	}


	if(getState() != OMX_StateIdle)
	{
		if(getState() != OMX_StateLoaded)
		{
			setState(OMX_StateLoaded);
		}
		setState(OMX_StateIdle);
	}

	error = enablePort(outputPort);
    OMX_TRACE(error);
	if(error != OMX_ErrorNone)
	{
		return error;
	}

	for (size_t i = 0; i < portFormat.nBufferCountActual; i++)
	{
		OMX_BUFFERHEADERTYPE *buffer = NULL;
        error = OMX_AllocateBuffer(handle, &buffer, outputPort, NULL, portFormat.nBufferSize);
        OMX_TRACE(error);
        if(error != OMX_ErrorNone)
        {
            return error;
        }
		buffer->nOutputPortIndex = outputPort;
		buffer->nFilledLen       = 0;
		buffer->nOffset          = 0;
		buffer->pAppPrivate      = (void*)i;
        outputBuffers.push_back(buffer);
        outputBuffersAvailable.push(buffer);
	}


	return error;
}
OMX_ERRORTYPE load_component(HTEST *hTest)
{
	OMX_ERRORTYPE ret = OMX_ErrorNone;
	OMX_HANDLETYPE hComponent = NULL;
	OMX_PARAM_PORTDEFINITIONTYPE sPortDef;
	OMX_U32 i;

	ret = OMX_GetHandle(&hComponent, hTest->name, hTest, &gCallBacks);
	if(ret != OMX_ErrorNone)
	{
		printf("Load component %s failed.\n", hTest->name);
		return ret;
	}

	hTest->hComponent = (OMX_COMPONENTTYPE*)hComponent;
	hTest->nPorts = get_component_ports(hComponent);
	OMX_INIT_STRUCT(&sPortDef, OMX_PARAM_PORTDEFINITIONTYPE);
	for(i=0; i<hTest->nPorts; i++)
	{
		sPortDef.nPortIndex = i;
		OMX_GetParameter(hComponent, OMX_IndexParamPortDefinition, &sPortDef);
		if (sPortDef.eDomain == OMX_PortDomainAudio)
			hTest->nAudioTrackNum = i;
		if (sPortDef.eDomain == OMX_PortDomainVideo)
			hTest->nVideoTrackNum = i;

		hTest->PortDir[i] = sPortDef.eDir;
		if(hTest->PortDir[i] == OMX_DirInput)
			hTest->bAllocater[i] = OMX_FALSE;
		if(hTest->PortDir[i] == OMX_DirOutput)
			hTest->bAllocater[i] = OMX_TRUE;
	}
	OMX_PARAM_CONTENTURITYPE *content = NULL;

	content =(OMX_PARAM_CONTENTURITYPE *) fsl_osal_malloc_new(sizeof(OMX_PARAM_CONTENTURITYPE) + 1024);
	if (!content)
		return OMX_ErrorInsufficientResources;

	fsl_osal_memset(content, 0 , sizeof(OMX_PARAM_CONTENTURITYPE)+1024);
	OMX_INIT_STRUCT(content,OMX_PARAM_CONTENTURITYPE);
	char* uri = (char*)&(content->contentURI);
	fsl_osal_memcpy(uri, hTest->media_name, strlen(hTest->media_name)+1);

	ret = OMX_SetParameter(hTest->hComponent,OMX_IndexParamContentURI,content);
	if (ret != OMX_ErrorNone)
	{
		OMX_FreeHandle(hTest->hComponent);
		hTest->hComponent = NULL;
		return ret;
	}




	fsl_osal_thread_create(&hTest->pThreadId, NULL, process_thread, hTest);

	return OMX_ErrorNone;
}
/*========================================================*/
OMX_ERRORTYPE SampleTest_TransitionWait(OMX_STATETYPE eToState,
    SampleCompTestCtxt * pContext)
{
	OMX_ERRORTYPE eError = OMX_ErrorNone;
	OMX_PARAM_PORTDEFINITIONTYPE tPortDef;
	OMX_U32 i, j;

	eError = OMX_SendCommand(pContext->hComp, OMX_CommandStateSet,
	    eToState, NULL);
	OMX_TEST_BAIL_IF_ERROR(eError);

	if ((eToState == OMX_StateIdle) &&
	    (pContext->eState == OMX_StateLoaded))
	{
		for (i = 0; i < NUM_DOMAINS; i++)
		{
			for (j = pContext->sPortParam[i].nStartPortNumber;
			    j < pContext->sPortParam[i].nStartPortNumber
			    + pContext->sPortParam[i].nPorts; j++)
			{

				OMX_TEST_INIT_STRUCT(tPortDef,
				    OMX_PARAM_PORTDEFINITIONTYPE);
				tPortDef.nPortIndex = j;
//printf("\nCalling GetParam before UseBuf on port %d\n",j);
				eError = OMX_GetParameter(pContext->hComp,
				    OMX_IndexParamPortDefinition,
				    (OMX_PTR) & tPortDef);
				OMX_TEST_BAIL_IF_ERROR(eError);

//                    if(tPortDef.bEnabled)//AD
				eError =
				    SampleTest_AllocateBuffers(pContext,
				    &tPortDef);

				OMX_TEST_BAIL_IF_ERROR(eError);
			}
		}
	} else if ((eToState == OMX_StateLoaded) &&
	    (pContext->eState == OMX_StateIdle))
	{

		eError = SampleTest_DeInitBuffers(pContext);
		OMX_TEST_BAIL_IF_ERROR(eError);

	}
	printf("\nWaiting for state set event\n");
	TIMM_OSAL_SemaphoreObtain(pContext->hStateSetEvent,
	    TIMM_OSAL_SUSPEND);
	printf("\nState set event recd.\n");

	if (pContext->eState != eToState)
		OMX_TEST_SET_ERROR_BAIL(OMX_ErrorUndefined,
		    " InComplete Transition \n");

      OMX_TEST_BAIL:
	return eError;
}
int Init_Decoder(OMX_STRING audio_component)
{
    DEBUG_PRINT("Inside %s \n", __FUNCTION__);
    OMX_ERRORTYPE omxresult;
    OMX_U32 total = 0;
    typedef OMX_U8* OMX_U8_PTR;
    char *role ="audio_decoder.aac";

    static OMX_CALLBACKTYPE call_back = {
        &EventHandler,&EmptyBufferDone,&FillBufferDone
    };

    /* Init. the OpenMAX Core */
    DEBUG_PRINT("\nInitializing OpenMAX Core....\n");
    omxresult = OMX_Init();

    if(OMX_ErrorNone != omxresult) {
        DEBUG_PRINT("\n Failed to Init OpenMAX core");
          return -1;
    }
    else {
        DEBUG_PRINT("\nOpenMAX Core Init Done\n");
    }

    /* Query for audio decoders*/
    DEBUG_PRINT("Aac_test: Before entering OMX_GetComponentOfRole");
    OMX_GetComponentsOfRole(role, &total, 0);
    DEBUG_PRINT ("\nTotal components of role=%s :%lu", role, total);


    omxresult = OMX_GetHandle((OMX_HANDLETYPE*)(&aac_dec_handle),
                        (OMX_STRING)audio_component, NULL, &call_back);
    if (FAILED(omxresult)) {
        DEBUG_PRINT("\nFailed to Load the component:%s\n", audio_component);
    return -1;
    }
    else
    {
        DEBUG_PRINT("\nComponent %s is in LOADED state\n", audio_component);
    }

    /* Get the port information */
    CONFIG_VERSION_SIZE(portParam);
    omxresult = OMX_GetParameter(aac_dec_handle, OMX_IndexParamAudioInit,
                                (OMX_PTR)&portParam);

    if(FAILED(omxresult)) {
        DEBUG_PRINT("\nFailed to get Port Param\n");
    return -1;
    }
    else
    {
        DEBUG_PRINT("\nportParam.nPorts:%lu\n", portParam.nPorts);
    DEBUG_PRINT("\nportParam.nStartPortNumber:%lu\n",
                                             portParam.nStartPortNumber);
    }
    return 0;
}
예제 #20
0
static void
setup_ports (GstOmxBaseFilter *self)
{
    GOmxCore *core;
    OMX_PARAM_PORTDEFINITIONTYPE param;

    core = self->gomx;

    memset (&param, 0, sizeof (param));
    param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
    param.nVersion.s.nVersionMajor = 1;
    param.nVersion.s.nVersionMinor = 1;

    /* Input port configuration. */

    param.nPortIndex = 0;
    OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, &param);
    self->in_port = g_omx_core_setup_port (core, &param);
    gst_pad_set_element_private (self->sinkpad, self->in_port);

    /* Output port configuration. */

    param.nPortIndex = 1;
    OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, &param);
    self->out_port = g_omx_core_setup_port (core, &param);
    gst_pad_set_element_private (self->srcpad, self->out_port);

    if (g_getenv ("OMX_ALLOCATE_ON"))
    {
        self->in_port->omx_allocate = TRUE;
        self->out_port->omx_allocate = TRUE;
        self->share_input_buffer = FALSE;
        self->share_output_buffer = FALSE;
    }
    else if (g_getenv ("OMX_SHARE_HACK_ON"))
    {
        self->share_input_buffer = TRUE;
        self->share_output_buffer = TRUE;
    }
    else if (g_getenv ("OMX_SHARE_HACK_OFF"))
    {
        self->share_input_buffer = FALSE;
        self->share_output_buffer = FALSE;
    }
}
OMX_ERRORTYPE graph::httpclntops::get_encoding_type_from_http_source ()
{
  OMX_PARAM_PORTDEFINITIONTYPE port_def;
  const OMX_U32 port_id = 0;
  TIZ_INIT_OMX_PORT_STRUCT (port_def, port_id);
  tiz_check_omx_err (
      OMX_GetParameter (handles_[0], OMX_IndexParamPortDefinition, &port_def));
  encoding_ = port_def.format.audio.eEncoding;
  return OMX_ErrorNone;
}
OMX_U32 get_component_ports(OMX_HANDLETYPE hComponent)
{
    OMX_PORT_PARAM_TYPE sPortPara;
    OMX_U32 aPorts, vPorts, iPorts, oPorts;

    OMX_INIT_STRUCT(&sPortPara, OMX_PORT_PARAM_TYPE);
    aPorts = vPorts = iPorts = oPorts = 0;

    if(OMX_ErrorNone == OMX_GetParameter(hComponent, OMX_IndexParamAudioInit, &sPortPara))
        aPorts = sPortPara.nPorts;
    if(OMX_ErrorNone == OMX_GetParameter(hComponent, OMX_IndexParamVideoInit, &sPortPara))
        vPorts = sPortPara.nPorts;
    if(OMX_ErrorNone == OMX_GetParameter(hComponent, OMX_IndexParamImageInit, &sPortPara))
        iPorts = sPortPara.nPorts;
    if(OMX_ErrorNone == OMX_GetParameter(hComponent, OMX_IndexParamOtherInit, &sPortPara))
        oPorts = sPortPara.nPorts;

    return aPorts + vPorts + iPorts + oPorts;
}
예제 #23
0
static int is_port_enabled(OMX_HANDLETYPE handle, int port)
{
  OMX_PARAM_PORTDEFINITIONTYPE  portdef;

  OMX_INIT_STRUCTURE(portdef);
  portdef.nPortIndex = port;
  OERR(OMX_GetParameter(handle, OMX_IndexParamPortDefinition, &portdef));

  return (portdef.bEnabled == 0 ? 0 : 1);;
}
static void init_component_handle(
        const char *name,
        OMX_HANDLETYPE* hComponent,
        OMX_PTR pAppData,
        OMX_CALLBACKTYPE* callbacks) {
    OMX_ERRORTYPE r;
    char fullname[32];

    // Get handle
    memset(fullname, 0, sizeof(fullname));
    strcat(fullname, "OMX.broadcom.");
    strncat(fullname, name, strlen(fullname) - 1);
    //say("Initializing component %s", fullname);
    if((r = OMX_GetHandle(hComponent, fullname, pAppData, callbacks)) != OMX_ErrorNone) {
        omx_die(r, "Failed to get handle for component %s", fullname);
    }

    // Disable ports
    OMX_INDEXTYPE types[] = {
        OMX_IndexParamAudioInit,
        OMX_IndexParamVideoInit,
        OMX_IndexParamImageInit,
        OMX_IndexParamOtherInit
    };
    OMX_PORT_PARAM_TYPE ports;
    OMX_INIT_STRUCTURE(ports);
    OMX_GetParameter(*hComponent, OMX_IndexParamVideoInit, &ports);

    int i;
    for(i = 0; i < 4; i++) {
        if(OMX_GetParameter(*hComponent, types[i], &ports) == OMX_ErrorNone) {
            OMX_U32 nPortIndex;
            for(nPortIndex = ports.nStartPortNumber; nPortIndex < ports.nStartPortNumber + ports.nPorts; nPortIndex++) {
                //say("Disabling port %d of component %s", nPortIndex, fullname);
                if((r = OMX_SendCommand(*hComponent, OMX_CommandPortDisable, nPortIndex, NULL)) != OMX_ErrorNone) {
                    omx_die(r, "Failed to disable port %d of component %s", nPortIndex, fullname);
                }
                block_until_port_changed(*hComponent, nPortIndex, OMX_FALSE);
            }
        }
    }
}
    static OMX_ERRORTYPE DisableAllPorts(OMX_HANDLETYPE hComp)
    {
        OMX_PORT_PARAM_TYPE          oPortInit;
        OMX_ERRORTYPE eError = OMX_ErrorUndefined;
        OMX_U32 i, d;


        INIT_PARAM(oPortInit);

        for (d = 0; d < 4; d++)
        {
            switch (d)
            {
                case 0:
                    eError = OMX_GetParameter(hComp, OMX_IndexParamOtherInit, &oPortInit);
                    break;
                case 1:
                    eError = OMX_GetParameter(hComp, OMX_IndexParamAudioInit, &oPortInit);
                    break;
                case 2:
                    eError = OMX_GetParameter(hComp, OMX_IndexParamVideoInit, &oPortInit);
                    break;
                case 3:
                    eError = OMX_GetParameter(hComp, OMX_IndexParamImageInit, &oPortInit);
                    break;
                default:
                    return OMX_ErrorUndefined;
            }

            if (OMX_ErrorNone == eError)
            {
                for (i = oPortInit.nStartPortNumber; i < oPortInit.nStartPortNumber + oPortInit.nPorts; i++)
                {
                    eError = OMX_SendCommand(hComp, OMX_CommandPortDisable, i, 0);
                    if (OMX_ErrorNone != eError)
                        return eError;
                }
            }
        }

        return OMX_ErrorNone;
    }
예제 #26
0
OMX_ERRORTYPE omxil_comp::GetParameter(OMX_INDEXTYPE nParamIndex, OMX_PTR pComponentParameterStructure) const
{
	OMX_ERRORTYPE result;

	result = OMX_GetParameter(comp, nParamIndex, pComponentParameterStructure);
	if (result != OMX_ErrorNone) {
		fprintf(stderr, "OMX_GetParameter failed.\n");
	}

	return result;
}
예제 #27
0
static int startupResizer(OMX_RESIZER *resizer, IMAGE *inImage){
	OMX_PARAM_PORTDEFINITIONTYPE portdef;
	int ret;

	ilclient_change_component_state(resizer->component, OMX_StateIdle);

	portdef.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
	portdef.nVersion.nVersion = OMX_VERSION;
	portdef.nPortIndex = resizer->inPort;

	ret = OMX_GetParameter(resizer->handle, OMX_IndexParamPortDefinition, &portdef);
	if (ret != OMX_ErrorNone) {
		return OMX_IMAGE_ERROR_PARAMETER;
	}
	
	portdef.format.image.eCompressionFormat = OMX_IMAGE_CodingUnused;
	portdef.format.image.bFlagErrorConcealment = OMX_FALSE;
	portdef.format.image.nFrameWidth = inImage->width;
	portdef.format.image.nFrameHeight = inImage->height;
	portdef.format.image.nStride = 0;
	portdef.format.image.nSliceHeight = 0;
	
	
	if(inImage->colorSpace == COLOR_SPACE_YUV420P)
		portdef.format.image.eColorFormat = OMX_COLOR_FormatYUV420PackedPlanar;
	else if(inImage->colorSpace == COLOR_SPACE_RGBA)
		portdef.format.image.eColorFormat = OMX_COLOR_Format32bitABGR8888;
	else if(inImage->colorSpace == COLOR_SPACE_RGB16)
		portdef.format.image.eColorFormat = OMX_COLOR_Format16bitRGB565;
		
	portdef.nBufferSize=inImage->nData;
		

	ret = OMX_SetParameter(resizer->handle, OMX_IndexParamPortDefinition, &portdef);
	if (ret != OMX_ErrorNone) {	
		return OMX_IMAGE_ERROR_PARAMETER;
	}
	
	ret = OMX_SendCommand(resizer->handle, OMX_CommandPortEnable, resizer->inPort, NULL);
	if(ret != OMX_ErrorNone){
		return OMX_IMAGE_ERROR_PORTS;
	}

	ret = OMX_UseBuffer(resizer->handle,&resizer->pInputBufferHeader,resizer->inPort, 
			NULL, portdef.nBufferSize, (OMX_U8 *) inImage->pData);
			
	if(ret != OMX_ErrorNone){
		return OMX_IMAGE_ERROR_MEMORY;
	}
	
	ilclient_change_component_state(resizer->component, OMX_StateExecuting);
	
	return OMX_IMAGE_OK;
}
예제 #28
0
OMX_ERRORTYPE Component::getParameter(OMX_INDEXTYPE paramIndex, OMX_PTR paramStruct)
{
	lock();
    
	OMX_ERRORTYPE error = OMX_GetParameter(handle, paramIndex, paramStruct);
    OMX_TRACE(error);


	unlock();
	return error;
}
예제 #29
0
static void
set_property (GObject *obj,
              guint prop_id,
              const GValue *value,
              GParamSpec *pspec)
{
    GstOmxBaseFilter *self;

    self = GST_OMX_BASE_FILTER (obj);

    switch (prop_id)
    {
        case ARG_USE_TIMESTAMPS:
            self->use_timestamps = g_value_get_boolean (value);
            break;
        case ARG_NUM_INPUT_BUFFERS:
        case ARG_NUM_OUTPUT_BUFFERS:
            {
                OMX_PARAM_PORTDEFINITIONTYPE param;
                OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
                OMX_U32 nBufferCountActual;
                GOmxPort *port = (prop_id == ARG_NUM_INPUT_BUFFERS) ?
                        self->in_port : self->out_port;

                if (G_UNLIKELY (!omx_handle))
                {
                    GST_WARNING_OBJECT (self, "no component");
                    break;
                }

                nBufferCountActual = g_value_get_uint (value);

                G_OMX_INIT_PARAM (param);

                param.nPortIndex = port->port_index;
                OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);

                if (nBufferCountActual < param.nBufferCountMin)
                {
                    GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
                            nBufferCountActual, param.nBufferCountMin);
                    return;
                }

                param.nBufferCountActual = nBufferCountActual;

                OMX_SetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
            }
            break;
        default:
            G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
            break;
    }
}
OMX_ERRORTYPE graph::youtubeops::get_container_type_from_youtube_source ()
{
  OMX_PARAM_PORTDEFINITIONTYPE port_def;
  const OMX_U32 port_id = 0;
  TIZ_INIT_OMX_PORT_STRUCT (port_def, port_id);
  tiz_check_omx (
      OMX_GetParameter (handles_[0], OMX_IndexParamPortDefinition, &port_def));
  container_ = port_def.format.audio.eEncoding;
  TIZ_LOG (TIZ_PRIORITY_DEBUG, "container_ = [%X]", container_);
  return OMX_ErrorNone;
}