static void omx_clk_init(omx_clk_t *clk, int has_audio) { OMX_TIME_CONFIG_CLOCKSTATETYPE cstate; clk->has_audio = has_audio; clk->seek_in_progress = 0; OMX_INIT_STRUCTURE(cstate); cstate.eState = OMX_TIME_ClockStateStopped; omxchk(OMX_SetParameter(clk->c->oc_handle, OMX_IndexConfigTimeClockState, &cstate)); omx_set_state(clk->c, OMX_StateIdle); OMX_INIT_STRUCTURE(cstate); cstate.eState = OMX_TIME_ClockStateWaitingForStartTime; cstate.nWaitMask = has_audio ? 1 : 2; omxchk(OMX_SetParameter(clk->c->oc_handle, OMX_IndexConfigTimeClockState, &cstate)); OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE refClock; OMX_INIT_STRUCTURE(refClock); refClock.eClock = has_audio ? OMX_TIME_RefClockAudio : OMX_TIME_RefClockVideo; omxchk(OMX_SetConfig(clk->c->oc_handle, OMX_IndexConfigTimeActiveRefClock, &refClock)); omx_set_state(clk->c, OMX_StateExecuting); }
static void omx_mp_init(media_pipe_t *mp) { if(!(mp->mp_flags & MP_VIDEO)) return; #if 0 if(0) { mp->mp_seek_initiate = omx_mp_begin_seek; mp->mp_seek_audio_done = omx_mp_seek_audio_done; mp->mp_seek_video_done = omx_mp_seek_video_done; } #endif mp->mp_hold_changed = omx_mp_hold_changed; omx_clk_t *clk = calloc(1, sizeof(omx_clk_t)); TAILQ_INIT(&clk->q); clk->mp = mp; clk->c = omx_component_create("OMX.broadcom.clock", &mp->mp_mutex, NULL); hts_cond_init(&clk->cond, &mp->mp_mutex); mp->mp_extra = clk; omx_set_state(clk->c, OMX_StateIdle); #if 0 OMX_TIME_CONFIG_CLOCKSTATETYPE cstate; OMX_INIT_STRUCTURE(cstate); cstate.eState = OMX_TIME_ClockStateWaitingForStartTime; cstate.nWaitMask = 1; omxchk(OMX_SetParameter(c->oc_handle, OMX_IndexConfigTimeClockState, &cstate)); OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE refClock; OMX_INIT_STRUCTURE(refClock); refClock.eClock = OMX_TIME_RefClockAudio; // refClock.eClock = OMX_TIME_RefClockVideo; // refClock.eClock = OMX_TIME_RefClockNone; #else OMX_TIME_CONFIG_CLOCKSTATETYPE cstate; OMX_INIT_STRUCTURE(cstate); cstate.eState = OMX_TIME_ClockStateRunning; omxchk(OMX_SetParameter(clk->c->oc_handle, OMX_IndexConfigTimeClockState, &cstate)); OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE refClock; OMX_INIT_STRUCTURE(refClock); refClock.eClock = OMX_TIME_RefClockAudio; #endif omxchk(OMX_SetConfig(clk->c->oc_handle, OMX_IndexConfigTimeActiveRefClock, &refClock)); omx_set_state(clk->c, OMX_StateExecuting); hts_thread_create_joinable("omxclkctrl", &clk->tid, omx_clk_thread, clk, THREAD_PRIO_DEMUXER); }
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; OMX_INIT_STRUCT(&sPortDef, OMX_PARAM_PORTDEFINITIONTYPE); sPortDef.nPortIndex = 1; ret = OMX_GetParameter(hTest->hComponent,OMX_IndexParamPortDefinition,&sPortDef); if (ret != OMX_ErrorNone) return ret; sPortDef.format.video.nFrameWidth = 176; sPortDef.format.video.nFrameHeight = 144; ret = OMX_SetParameter(hTest->hComponent,OMX_IndexParamPortDefinition,&sPortDef); if (ret != OMX_ErrorNone) return ret; sPortDef.nPortIndex = 0; ret = OMX_SetParameter(hTest->hComponent,OMX_IndexParamPortDefinition,&sPortDef); if (ret != OMX_ErrorNone) return ret; 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; if(i == 0) hTest->bAllocater[i] = OMX_FALSE; } fsl_osal_thread_create(&hTest->pThreadId, NULL, process_thread, hTest); return OMX_ErrorNone; }
OMX_ERRORTYPE omxSetAudioRenderInput(struct OMX_COMPONENT_T *component, int sample_rate, int bits_per_coded_sample, int channels) { OMX_ERRORTYPE omxErr; OMX_AUDIO_PARAM_PCMMODETYPE pcmInput; OMX_INIT_STRUCTURE(pcmInput); pcmInput.nPortIndex = component->inputPort; pcmInput.eNumData = OMX_NumericalDataSigned; pcmInput.eEndian = OMX_EndianLittle; pcmInput.bInterleaved = OMX_TRUE; pcmInput.nBitPerSample = bits_per_coded_sample; pcmInput.ePCMMode = OMX_AUDIO_PCMModeLinear; pcmInput.nChannels = channels; pcmInput.nSamplingRate = sample_rate; pcmInput.eChannelMapping[0] = OMX_AUDIO_ChannelLF; pcmInput.eChannelMapping[1] = OMX_AUDIO_ChannelRF; omxErr = OMX_SetParameter(component->handle, OMX_IndexParamAudioPcm, &pcmInput); if(omxErr != OMX_ErrorNone) { logInfo(LOG_OMX, "Error SetParameter OMX_IndexParamAudioPcm for port %d status on component %s omxErr(0x%08x)\n", component->inputPort, component->componentName, (int)omxErr); return omxErr; } OMX_AUDIO_PARAM_PORTFORMATTYPE formatType; OMX_INIT_STRUCTURE(formatType); formatType.nPortIndex = component->inputPort; formatType.eEncoding = OMX_AUDIO_CodingPCM; omxErr = OMX_SetParameter(component->handle, OMX_IndexParamAudioPortFormat, &formatType); if(omxErr != OMX_ErrorNone) { logInfo(LOG_OMX, "Error SetParameter OMX_IndexParamAudioPortFormat for port %d status on component %s omxErr(0x%08x)\n", component->inputPort, component->componentName, (int)omxErr); return omxErr; } OMX_PARAM_PORTDEFINITIONTYPE portDef; OMX_INIT_STRUCTURE(portDef); portDef.nPortIndex = component->inputPort; portDef.format.audio.eEncoding = OMX_AUDIO_CodingPCM; portDef.nBufferSize = ((6144 * 2) + 15) & ~15; portDef.nBufferCountActual = 60; omxErr = OMX_SetParameter(component->handle, OMX_IndexParamPortDefinition, &portDef); if(omxErr != OMX_ErrorNone) { logInfo(LOG_OMX, "Error SetParameter OMX_IndexParamPortDefinition for port %d status on component %s omxErr(0x%08x)\n", component->inputPort, component->componentName, (int)omxErr); return omxErr; } return OMX_ErrorNone; }
status_t OMXNodeInstance::prepareForAdaptivePlayback( OMX_U32 portIndex, OMX_BOOL enable, OMX_U32 maxFrameWidth, OMX_U32 maxFrameHeight) { Mutex::Autolock autolock(mLock); OMX_INDEXTYPE index; OMX_STRING name = const_cast<OMX_STRING>( "OMX.google.android.index.prepareForAdaptivePlayback"); OMX_ERRORTYPE err = OMX_GetExtensionIndex(mHandle, name, &index); if (err != OMX_ErrorNone) { ALOGW_IF(enable, "OMX_GetExtensionIndex %s failed", name); return StatusFromOMXError(err); } PrepareForAdaptivePlaybackParams params; params.nSize = sizeof(params); params.nVersion.s.nVersionMajor = 1; params.nVersion.s.nVersionMinor = 0; params.nVersion.s.nRevision = 0; params.nVersion.s.nStep = 0; params.nPortIndex = portIndex; params.bEnable = enable; params.nMaxFrameWidth = maxFrameWidth; params.nMaxFrameHeight = maxFrameHeight; if ((err = OMX_SetParameter(mHandle, index, ¶ms)) != OMX_ErrorNone) { ALOGW("OMX_SetParameter failed for PrepareForAdaptivePlayback " "with error %d (0x%08x)", err, err); return UNKNOWN_ERROR; } return err; }
void graph::gmusicops::do_reconfigure_second_tunnel () { // Retrieve the pcm settings from the decoder component OMX_AUDIO_PARAM_PCMMODETYPE decoder_pcmtype; const OMX_U32 decoder_port_id = 1; TIZ_INIT_OMX_PORT_STRUCT (decoder_pcmtype, decoder_port_id); G_OPS_BAIL_IF_ERROR ( OMX_GetParameter (handles_[1], OMX_IndexParamAudioPcm, &decoder_pcmtype), "Unable to retrieve the PCM settings from the Mp3 decoder"); // Retrieve the pcm settings from the renderer component OMX_AUDIO_PARAM_PCMMODETYPE renderer_pcmtype; const OMX_U32 renderer_port_id = 0; TIZ_INIT_OMX_PORT_STRUCT (renderer_pcmtype, renderer_port_id); G_OPS_BAIL_IF_ERROR ( OMX_GetParameter (handles_[2], OMX_IndexParamAudioPcm, &renderer_pcmtype), "Unable to retrieve the PCM settings from the pcm renderer"); // Now assign the current settings to the renderer structure renderer_pcmtype.nChannels = decoder_pcmtype.nChannels; renderer_pcmtype.nSamplingRate = decoder_pcmtype.nSamplingRate; // Set the new pcm settings G_OPS_BAIL_IF_ERROR ( OMX_SetParameter (handles_[2], OMX_IndexParamAudioPcm, &renderer_pcmtype), "Unable to set the PCM settings on the audio renderer"); 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"); }
void graph::gmusicops::do_reconfigure_first_tunnel () { // Retrieve the mp3 settings from the gmusic source component OMX_AUDIO_PARAM_MP3TYPE gmusic_mp3type; const OMX_U32 gmusic_port_id = 0; TIZ_INIT_OMX_PORT_STRUCT (gmusic_mp3type, gmusic_port_id); G_OPS_BAIL_IF_ERROR ( OMX_GetParameter (handles_[0], OMX_IndexParamAudioMp3, &gmusic_mp3type), "Unable to retrieve the MP3 settings from the gmusic source"); // Retrieve the mp3 settings from the decoder component OMX_AUDIO_PARAM_MP3TYPE decoder_mp3type; const OMX_U32 decoder_port_id = 0; TIZ_INIT_OMX_PORT_STRUCT (decoder_mp3type, decoder_port_id); G_OPS_BAIL_IF_ERROR ( OMX_GetParameter (handles_[1], OMX_IndexParamAudioMp3, &decoder_mp3type), "Unable to retrieve the MP3 settings from the audio decoder"); // Now assign the current settings to the decoder structure decoder_mp3type.nChannels = gmusic_mp3type.nChannels; decoder_mp3type.nSampleRate = gmusic_mp3type.nSampleRate; // Set the new mp3 settings G_OPS_BAIL_IF_ERROR ( OMX_SetParameter (handles_[1], OMX_IndexParamAudioMp3, &decoder_mp3type), "Unable to set the MP3 settings on the audio decoder"); }
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; }
/* For each domain: force all the component's ports to be suppliers/non-suppliers */ OMX_ERRORTYPE ForceSuppliersPerDomain(OMX_INDEXTYPE nIndex, OMX_HANDLETYPE hComp, OMX_BOOL bSupplier) { OMX_PORT_PARAM_TYPE oParam; OMX_U32 i; OMX_U32 iPort; OMX_ERRORTYPE eError; OMX_PARAM_BUFFERSUPPLIERTYPE oSupplier; OMX_PARAM_PORTDEFINITIONTYPE oPortDef; INIT_PARAM(oSupplier); INIT_PARAM(oParam); INIT_PARAM(oPortDef); oSupplier.eBufferSupplier = bSupplier ? OMX_BufferSupplyInput : OMX_BufferSupplyOutput; if (OMX_ErrorNone != (eError = OMX_GetParameter(hComp, nIndex, &oParam))) return eError; for (i=0;i<oParam.nPorts;i++) { iPort = oParam.nStartPortNumber + i; oPortDef.nPortIndex = iPort; OMX_GetParameter(hComp, OMX_IndexParamPortDefinition, &oPortDef); /* only set inputs */ if (oPortDef.eDir == OMX_DirInput){ oSupplier.nPortIndex = iPort; OMX_SetParameter(hComp, OMX_IndexParamCompBufferSupplier, &oSupplier); } } return OMX_ErrorNone; }
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 (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 ( 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; }
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; }
static void omx_mp_init(media_pipe_t *mp) { if(!(mp->mp_flags & MP_VIDEO)) return; omx_component_t *c; c = omx_component_create("OMX.broadcom.clock", &mp->mp_mutex, NULL); mp->mp_extra = c; omx_set_state(c, OMX_StateIdle); OMX_TIME_CONFIG_CLOCKSTATETYPE cstate; OMX_INIT_STRUCTURE(cstate); cstate.eState = OMX_TIME_ClockStateWaitingForStartTime; cstate.nWaitMask = 1; omxchk(OMX_SetParameter(c->oc_handle, OMX_IndexConfigTimeClockState, &cstate)); OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE refClock; OMX_INIT_STRUCTURE(refClock); refClock.eClock = OMX_TIME_RefClockAudio; // refClock.eClock = OMX_TIME_RefClockVideo; // refClock.eClock = OMX_TIME_RefClockNone; omxchk(OMX_SetConfig(c->oc_handle, OMX_IndexConfigTimeActiveRefClock, &refClock)); omx_set_state(c, OMX_StateExecuting); }
OMX_ERRORTYPE NonTextureEngine::setupDisplay() { OMX_CONFIG_DISPLAYREGIONTYPE region; OMX_INIT_STRUCTURE(region); region.nPortIndex = VIDEO_RENDER_INPUT_PORT; /* Video render input port */ region.set = (OMX_DISPLAYSETTYPE)(OMX_DISPLAY_SET_DEST_RECT | OMX_DISPLAY_SET_FULLSCREEN | OMX_DISPLAY_SET_NOASPECT); region.fullscreen = OMX_FALSE; region.noaspect = OMX_TRUE; region.dest_rect.x_offset = 0; region.dest_rect.y_offset = 0; region.dest_rect.width = omxCameraSettings.width; region.dest_rect.height = omxCameraSettings.height; OMX_ERRORTYPE error = OMX_SetParameter(render, OMX_IndexConfigDisplayRegion, ®ion); if(error == OMX_ErrorNone) { ofLogVerbose(__func__) << "render OMX_IndexConfigDisplayRegion PASS"; }else { ofLog(OF_LOG_ERROR, "render OMX_IndexConfigDisplayRegion FAIL error: 0x%08x", error); } return error; }
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; }
// XXX: This function is here for backwards compatibility. Once the OMX // implementations have been updated this can be removed and useGraphicBuffer2 // can be renamed to useGraphicBuffer. status_t OMXNodeInstance::useGraphicBuffer( OMX_U32 portIndex, const sp<GraphicBuffer>& graphicBuffer, OMX::buffer_id *buffer) { Mutex::Autolock autoLock(mLock); // See if the newer version of the extension is present. OMX_INDEXTYPE index; if (OMX_GetExtensionIndex( mHandle, const_cast<OMX_STRING>("OMX.google.android.index.useAndroidNativeBuffer2"), &index) == OMX_ErrorNone) { return useGraphicBuffer2_l(portIndex, graphicBuffer, buffer); } OMX_STRING name = const_cast<OMX_STRING>( "OMX.google.android.index.useAndroidNativeBuffer"); OMX_ERRORTYPE err = OMX_GetExtensionIndex(mHandle, name, &index); if (err != OMX_ErrorNone) { ALOGE("OMX_GetExtensionIndex %s failed", name); return StatusFromOMXError(err); } BufferMeta *bufferMeta = new BufferMeta(graphicBuffer); OMX_BUFFERHEADERTYPE *header; OMX_VERSIONTYPE ver; ver.s.nVersionMajor = 1; ver.s.nVersionMinor = 0; ver.s.nRevision = 0; ver.s.nStep = 0; UseAndroidNativeBufferParams params = { sizeof(UseAndroidNativeBufferParams), ver, portIndex, bufferMeta, &header, graphicBuffer, }; err = OMX_SetParameter(mHandle, index, ¶ms); if (err != OMX_ErrorNone) { ALOGE("OMX_UseAndroidNativeBuffer failed with error %d (0x%08x)", err, err); delete bufferMeta; bufferMeta = NULL; *buffer = 0; return UNKNOWN_ERROR; } CHECK_EQ(header->pAppPrivate, bufferMeta); *buffer = header; addActiveBuffer(portIndex, *buffer); return OK; }
int decoding_thread_setSpeed(float speed){ printf("try to lock thread\n"); if(ILC_GET_HANDLE(omx_clock) == NULL) return -1; pthread_mutex_lock(&m_lock); OMX_ERRORTYPE omx_err = OMX_ErrorNone; OMX_TIME_CONFIG_SCALETYPE scaleType; OMX_INIT_STRUCTURE(scaleType); scaleType.xScale = floor((speed * pow(2,16))); printf("set speed to : %.2f, %d\n", speed, scaleType.xScale); omx_err = OMX_SetParameter(ILC_GET_HANDLE(omx_clock), OMX_IndexConfigTimeScale, &scaleType); if(omx_err != OMX_ErrorNone) { printf("Speed error setting OMX_IndexConfigTimeClockState : %d\n", omx_err); pthread_mutex_unlock(&m_lock); return -1; } printf("unlock thread\n"); pthread_mutex_unlock(&m_lock); return 0; }
ret_code_t ilcore_set_port_buffers_param(ilcore_comp_h h, int size, int count, int align) { OMX_ERRORTYPE err; OMX_PARAM_PORTDEFINITIONTYPE param; ilcore_comp_ctx_t *ctx = (ilcore_comp_ctx_t *)h; OMX_INIT_STRUCT(param); param.nPortIndex = IL_AUDIO_RENDER_IN_PORT; err = OMX_GetParameter(ctx->handle, OMX_IndexParamPortDefinition, ¶m); if (err != OMX_ErrorNone) { DBG_E("%s: OMX_IndexParamPortDefinition failed. err=0x%x\n", ctx->name, err); return L_FAILED; } param.nBufferSize = size; param.nBufferCountActual = count; param.nBufferAlignment = align; err = OMX_SetParameter(ctx->handle, OMX_IndexParamPortDefinition, ¶m); if (err != OMX_ErrorNone) { DBG_E("%s: OMX_IndexParamPortDefinition failed. err=0x%x\n", ctx->name, err); return L_FAILED; } return L_OK; }
static rpi_pixmap_decoder_t * pixmap_decoder_create(int cfmt) { rpi_pixmap_decoder_t *rpd = calloc(1, sizeof(rpi_pixmap_decoder_t)); hts_mutex_init(&rpd->rpd_mtx); hts_cond_init(&rpd->rpd_cond, &rpd->rpd_mtx); rpd->rpd_decoder = omx_component_create("OMX.broadcom.image_decode", &rpd->rpd_mtx, &rpd->rpd_cond); rpd->rpd_decoder->oc_port_settings_changed_cb = decoder_port_settings_changed; rpd->rpd_decoder->oc_opaque = rpd; rpd->rpd_resizer = omx_component_create("OMX.broadcom.resize", &rpd->rpd_mtx, &rpd->rpd_cond); omx_set_state(rpd->rpd_decoder, OMX_StateIdle); OMX_IMAGE_PARAM_PORTFORMATTYPE fmt; OMX_INIT_STRUCTURE(fmt); fmt.nPortIndex = rpd->rpd_decoder->oc_inport; fmt.eCompressionFormat = cfmt; omxchk(OMX_SetParameter(rpd->rpd_decoder->oc_handle, OMX_IndexParamImagePortFormat, &fmt)); #ifndef NOCOPY omx_alloc_buffers(rpd->rpd_decoder, rpd->rpd_decoder->oc_inport); omx_set_state(rpd->rpd_decoder, OMX_StateExecuting); #endif return rpd; }
static void omx_setup (GstOmxBaseFilter * omx_base) { GstOmxBaseVideoDec *self; GOmxCore *gomx; self = GST_OMX_BASE_VIDEODEC (omx_base); gomx = (GOmxCore *) omx_base->gomx; GST_INFO_OBJECT (omx_base, "begin"); { OMX_PARAM_PORTDEFINITIONTYPE param; G_OMX_INIT_PARAM (param); /* Input port configuration. */ { param.nPortIndex = omx_base->in_port->port_index; OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m); param.format.video.eCompressionFormat = self->compression_format; OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m); } } GST_INFO_OBJECT (omx_base, "end"); }
static void set_video_decoder_input_format(COMPONENT_T *component) { int err; // set input video format printf("Setting video decoder format\n"); OMX_VIDEO_PARAM_PORTFORMATTYPE videoPortFormat; //setHeader(&videoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); memset(&videoPortFormat, 0, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); videoPortFormat.nSize = sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE); videoPortFormat.nVersion.nVersion = OMX_VERSION; videoPortFormat.nPortIndex = 130; videoPortFormat.eCompressionFormat = OMX_VIDEO_CodingMPEG2; // videoPortFormat.eCompressionFormat = OMX_VIDEO_CodingAVC; err = OMX_SetParameter(ilclient_get_handle(component), OMX_IndexParamVideoPortFormat, &videoPortFormat); if (err != OMX_ErrorNone) { fprintf(stderr, "Error setting video decoder format %s\n", err2str(err)); return; // err; } else { printf("Video decoder format set up ok\n"); } }
status_t OMXNodeInstance::storeMetaDataInBuffers( OMX_U32 portIndex, OMX_BOOL enable) { Mutex::Autolock autolock(mLock); OMX_INDEXTYPE index; OMX_STRING name = const_cast<OMX_STRING>( "OMX.google.android.index.storeMetaDataInBuffers"); OMX_ERRORTYPE err = OMX_GetExtensionIndex(mHandle, name, &index); if (err != OMX_ErrorNone) { ALOGE("OMX_GetExtensionIndex %s failed", name); return StatusFromOMXError(err); } StoreMetaDataInBuffersParams params; memset(¶ms, 0, sizeof(params)); params.nSize = sizeof(params); // Version: 1.0.0.0 params.nVersion.s.nVersionMajor = 1; params.nPortIndex = portIndex; params.bStoreMetaData = enable; if ((err = OMX_SetParameter(mHandle, index, ¶ms)) != OMX_ErrorNone) { ALOGE("OMX_SetParameter() failed for StoreMetaDataInBuffers: 0x%08x", err); return UNKNOWN_ERROR; } return err; }
OMX_ERRORTYPE graph::oggopusdecops::set_opus_settings () { // Retrieve the current opus settings from the decoder's port #0 OMX_TIZONIA_AUDIO_PARAM_OPUSTYPE opustype_orig; TIZ_INIT_OMX_PORT_STRUCT (opustype_orig, 0 /* port id */); tiz_check_omx_err (OMX_GetParameter ( handles_[1], static_cast< OMX_INDEXTYPE >(OMX_TizoniaIndexParamAudioOpus), &opustype_orig)); // Set the opus settings on decoder's port #0 OMX_TIZONIA_AUDIO_PARAM_OPUSTYPE opustype; TIZ_INIT_OMX_PORT_STRUCT (opustype, 0 /* port id */); probe_ptr_->get_opus_codec_info (opustype); opustype.nPortIndex = 0; tiz_check_omx_err (OMX_SetParameter ( handles_[1], static_cast< OMX_INDEXTYPE >(OMX_TizoniaIndexParamAudioOpus), &opustype)); // Record whether we need to wait for a port settings change event or not // (the decoder output port implements the "slaving" behaviour) // // TODO: Add bitrate to the list of things that might change. And then remove // the probe_stream_hook hack (see function below) need_port_settings_changed_evt_ = ((opustype_orig.nSampleRate != opustype.nSampleRate) || (opustype_orig.nChannels != opustype.nChannels)); return OMX_ErrorNone; }
void setParamImageFormat(COMPONENT_T *image_encode, enum formatType formatType) { printf("in setParamImageFormat\n"); OMX_ERRORTYPE OMXstatus; //image format stucture */ OMX_IMAGE_PARAM_PORTFORMATTYPE image_format; memset(&image_format, 0, sizeof(image_format)); image_format.nVersion.nVersion = OMX_VERSION; image_format.nSize = sizeof(image_format); image_format.nPortIndex = 341; if(formatType == JPEG_HIGH_FORMAT || formatType == JPEG_MEDIUM_FORMAT || formatType == JPEG_LOW_FORMAT) { image_format.eCompressionFormat = OMX_IMAGE_CodingJPEG; OMX_IMAGE_PARAM_QFACTORTYPE compression_format; memset(&compression_format, 0, sizeof(compression_format)); compression_format.nVersion.nVersion = OMX_VERSION; compression_format.nSize = sizeof(compression_format); compression_format.nPortIndex = 341; if(formatType == JPEG_HIGH_FORMAT) compression_format.nQFactor = 100; else if (formatType == JPEG_MEDIUM_FORMAT) compression_format.nQFactor = 60; else if (formatType == JPEG_LOW_FORMAT) compression_format.nQFactor = 10; OMXstatus = OMX_SetParameter(ilclient_get_handle(image_encode), OMX_IndexParamQFactor, &compression_format); if(OMXstatus != OMX_ErrorNone) printf("Error Setting Paramter Error = %s\n", err2str(OMXstatus)); } OMXstatus = OMX_SetParameter(ilclient_get_handle(image_encode), OMX_IndexParamImagePortFormat, &image_format); if(OMXstatus != OMX_ErrorNone) printf("Error Setting Paramter Error = %s\n", err2str(OMXstatus)); // print the resultant format OMXstatus = OMX_GetParameter(ilclient_get_handle(image_encode), OMX_IndexParamImagePortFormat, &image_format); if(OMXstatus != OMX_ErrorNone) printf("Error Getting Paramter Error = %s\n", err2str(OMXstatus)); print_OMX_IMAGE_PARAM_PORTFORMATTYPE(image_format); }
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, ¶m); 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, ¶m); return gst_pad_set_caps (pad, caps); }
void omx_enable_buffer_marks(omx_component_t *oc) { OMX_CONFIG_BOOLEANTYPE t; OMX_INIT_STRUCTURE(t); t.bEnabled = 1; omxchk(OMX_SetParameter(oc->oc_handle, OMX_IndexParamPassBufferMarks, &t)); }
static int startupDecoder(JPEG_DECODER * decoder){ ilclient_change_component_state(decoder->component,OMX_StateIdle); OMX_IMAGE_PARAM_PORTFORMATTYPE imagePortFormat; memset(&imagePortFormat, 0, sizeof(OMX_IMAGE_PARAM_PORTFORMATTYPE)); imagePortFormat.nSize = sizeof(OMX_IMAGE_PARAM_PORTFORMATTYPE); imagePortFormat.nVersion.nVersion = OMX_VERSION; imagePortFormat.nPortIndex = decoder->inPort; imagePortFormat.eCompressionFormat = OMX_IMAGE_CodingJPEG; OMX_SetParameter(decoder->handle,OMX_IndexParamImagePortFormat, &imagePortFormat); OMX_PARAM_PORTDEFINITIONTYPE portdef; portdef.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); portdef.nVersion.nVersion = OMX_VERSION; portdef.nPortIndex = decoder->inPort; OMX_GetParameter(decoder->handle,OMX_IndexParamPortDefinition, &portdef); portdef.nBufferCountActual = DECODER_BUFFER_NUM; OMX_SetParameter(decoder->handle,OMX_IndexParamPortDefinition, &portdef); OMX_SendCommand(decoder->handle, OMX_CommandPortEnable, decoder->inPort, NULL); int i; for (i = 0; i < DECODER_BUFFER_NUM; i++) { if (OMX_AllocateBuffer(decoder->handle, &(decoder->ppInputBufferHeader[i]), decoder->inPort, NULL, portdef.nBufferSize) != OMX_ErrorNone) { return OMX_IMAGE_ERROR_MEMORY; } } int ret = ilclient_wait_for_event(decoder->component, OMX_EventCmdComplete, OMX_CommandPortEnable, 0, decoder->inPort, 0, 0, TIMEOUT_MS); if (ret != 0) { return OMX_IMAGE_ERROR_PORTS; } ret = OMX_SendCommand(decoder->handle, OMX_CommandStateSet, OMX_StateExecuting, NULL); if (ret != OMX_ErrorNone) { return OMX_IMAGE_ERROR_EXECUTING; } return OMX_IMAGE_OK; }
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; }
status_t OMXNodeInstance::setParameter( OMX_INDEXTYPE index, const void *params, size_t size) { Mutex::Autolock autoLock(mLock); OMX_ERRORTYPE err = OMX_SetParameter( mHandle, index, const_cast<void *>(params)); return StatusFromOMXError(err); }
OMX_ERRORTYPE Component::setParameter(OMX_INDEXTYPE paramIndex, OMX_PTR paramStruct) { lock(); OMX_ERRORTYPE error = OMX_SetParameter(handle, paramIndex, paramStruct); OMX_TRACE(error); unlock(); return error; }