OMX_ERRORTYPE VideoSource::GetParameter( OMX_INDEXTYPE nParamIndex, OMX_PTR pStructure) { OMX_ERRORTYPE ret = OMX_ErrorNone; switch (nParamIndex) { case OMX_IndexParamCommonSensorMode: { OMX_PARAM_SENSORMODETYPE *pSensorMode; pSensorMode = (OMX_PARAM_SENSORMODETYPE*)pStructure; OMX_CHECK_STRUCT(pSensorMode, OMX_PARAM_SENSORMODETYPE, ret); fsl_osal_memcpy(pSensorMode, &SensorMode, sizeof(OMX_PARAM_SENSORMODETYPE)); } break; case OMX_IndexParamVideoPortFormat: { OMX_VIDEO_PARAM_PORTFORMATTYPE *pPortFormat; pPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE*)pStructure; OMX_CHECK_STRUCT(pPortFormat, OMX_VIDEO_PARAM_PORTFORMATTYPE, ret); fsl_osal_memcpy(pPortFormat, &PortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); } break; default: ret = InstanceGetParameter(nParamIndex, pStructure); break; } return ret; }
OMX_ERRORTYPE LibavAudioDec::AudioFilterGetParameter( OMX_INDEXTYPE nParamIndex, OMX_PTR pComponentParameterStructure) { OMX_ERRORTYPE ret = OMX_ErrorNone; switch ((OMX_U32)nParamIndex) { case OMX_IndexParamStandardComponentRole: fsl_osal_strcpy((OMX_STRING)((OMX_PARAM_COMPONENTROLETYPE*) \ pComponentParameterStructure)->cRole,(OMX_STRING)cRole); break; case OMX_IndexParamAudioAdpcm: { OMX_AUDIO_PARAM_ADPCMMODETYPE *pAdpcmMode; pAdpcmMode = (OMX_AUDIO_PARAM_ADPCMMODETYPE*)pComponentParameterStructure; OMX_CHECK_STRUCT(pAdpcmMode, OMX_AUDIO_PARAM_ADPCMMODETYPE, ret); if(ret != OMX_ErrorNone) break; fsl_osal_memcpy(pAdpcmMode, &(InputMode.AdpcmMode), sizeof(OMX_AUDIO_PARAM_ADPCMMODETYPE)); CodingType = OMX_AUDIO_CodingADPCM; fsl_osal_strcpy((fsl_osal_char*)name, LIBAV_COMP_NAME_ADPCMDEC); } break; case OMX_IndexParamAudioOpus: { OMX_AUDIO_PARAM_OPUSTYPE *pOpusMode; pOpusMode = (OMX_AUDIO_PARAM_OPUSTYPE*)pComponentParameterStructure; OMX_CHECK_STRUCT(pOpusMode, OMX_AUDIO_PARAM_OPUSTYPE, ret); if(ret != OMX_ErrorNone) break; fsl_osal_memcpy(pOpusMode, &(InputMode.OpusMode), sizeof(OMX_AUDIO_PARAM_OPUSTYPE)); CodingType = (OMX_AUDIO_CODINGTYPE)OMX_AUDIO_CodingOPUS; fsl_osal_strcpy((fsl_osal_char*)name, LIBAV_COMP_NAME_OPUSDEC); } break; case OMX_IndexParamAudioApe: { OMX_AUDIO_PARAM_APETYPE *pApeMode; pApeMode = (OMX_AUDIO_PARAM_APETYPE*)pComponentParameterStructure; OMX_CHECK_STRUCT(pApeMode, OMX_AUDIO_PARAM_APETYPE, ret); if(ret != OMX_ErrorNone) break; fsl_osal_memcpy(pApeMode, &(InputMode.ApeMode), sizeof(OMX_AUDIO_PARAM_APETYPE)); CodingType = (OMX_AUDIO_CODINGTYPE)OMX_AUDIO_CodingAPE; fsl_osal_strcpy((fsl_osal_char*)name, LIBAV_COMP_NAME_APEDEC); } break; default: ret = OMX_ErrorUnsupportedIndex; break; } return ret; }
OMX_ERRORTYPE Ac3Dec::AudioFilterGetParameter(OMX_INDEXTYPE nParamIndex, OMX_PTR pComponentParameterStructure) { OMX_ERRORTYPE ret = OMX_ErrorNone; switch ((int)nParamIndex) { case OMX_IndexParamAudioAc3: { OMX_AUDIO_PARAM_AC3TYPE *pAc3Type; pAc3Type = (OMX_AUDIO_PARAM_AC3TYPE*)pComponentParameterStructure; OMX_CHECK_STRUCT(pAc3Type, OMX_AUDIO_PARAM_AC3TYPE, ret); if(ret != OMX_ErrorNone) break; if (pAc3Type->nPortIndex != AUDIO_FILTER_INPUT_PORT) { ret = OMX_ErrorBadPortIndex; break; } fsl_osal_memcpy(pAc3Type, &Ac3Type, sizeof(OMX_AUDIO_PARAM_AC3TYPE)); break; } default: ret = OMX_ErrorUnsupportedIndex; break; } return ret; }
OMX_ERRORTYPE AacEnc::AudioFilterSetParameter( OMX_INDEXTYPE nParamIndex, OMX_PTR pComponentParameterStructure) { OMX_ERRORTYPE ret = OMX_ErrorNone; switch (nParamIndex) { case OMX_IndexParamAudioAac: { OMX_AUDIO_PARAM_AACPROFILETYPE *pAacType; pAacType = (OMX_AUDIO_PARAM_AACPROFILETYPE*)pComponentParameterStructure; OMX_CHECK_STRUCT(pAacType, OMX_AUDIO_PARAM_AACPROFILETYPE, ret); if(ret != OMX_ErrorNone) break; if (pAacType->nPortIndex != AUDIO_FILTER_OUTPUT_PORT) { ret = OMX_ErrorBadPortIndex; break; } fsl_osal_memcpy(&AacType, pAacType, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE)); } return ret; default: ret = OMX_ErrorUnsupportedIndex; break; } return ret; }
OMX_ERRORTYPE AudioFilter::GetParameter( OMX_INDEXTYPE nParamIndex, OMX_PTR pComponentParameterStructure) { OMX_ERRORTYPE ret = OMX_ErrorNone; switch (nParamIndex) { case OMX_IndexParamAudioPcm: { OMX_BOOL bOutputPort = OMX_FALSE; OMX_AUDIO_PARAM_PCMMODETYPE *pPcmMode; pPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*)pComponentParameterStructure; OMX_CHECK_STRUCT(pPcmMode, OMX_AUDIO_PARAM_PCMMODETYPE, ret); if(ret != OMX_ErrorNone) break; if (pPcmMode->nPortIndex == AUDIO_FILTER_OUTPUT_PORT) { bOutputPort = OMX_TRUE; } fsl_osal_memcpy(pPcmMode, &PcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)); } LOG_DEBUG("PcmMode.nSamplingRate = %d\n", PcmMode.nSamplingRate); break; default: ret = AudioFilterGetParameter(nParamIndex, pComponentParameterStructure); break; } return ret; }
OMX_ERRORTYPE WmaDec::AudioFilterSetParameter( OMX_INDEXTYPE nParamIndex, OMX_PTR pComponentParameterStructure) { OMX_ERRORTYPE ret = OMX_ErrorNone; switch ((int)nParamIndex) { case OMX_IndexParamAudioWma: { OMX_AUDIO_PARAM_WMATYPE *pWmaType; pWmaType = (OMX_AUDIO_PARAM_WMATYPE*)pComponentParameterStructure; OMX_CHECK_STRUCT(pWmaType, OMX_AUDIO_PARAM_WMATYPE, ret); if(ret != OMX_ErrorNone) break; if (pWmaType->nPortIndex != AUDIO_FILTER_INPUT_PORT) { ret = OMX_ErrorBadPortIndex; break; } fsl_osal_memcpy(&WmaType, pWmaType, sizeof(OMX_AUDIO_PARAM_WMATYPE)); } return ret; case OMX_IndexParamAudioWmaExt: { OMX_AUDIO_PARAM_WMATYPE_EXT *pWmaTypeExt; pWmaTypeExt = (OMX_AUDIO_PARAM_WMATYPE_EXT*)pComponentParameterStructure; OMX_CHECK_STRUCT(pWmaTypeExt, OMX_AUDIO_PARAM_WMATYPE_EXT, ret); if(ret != OMX_ErrorNone) break; if (pWmaTypeExt->nPortIndex != AUDIO_FILTER_INPUT_PORT) { ret = OMX_ErrorBadPortIndex; break; } fsl_osal_memcpy(&WmaTypeExt, pWmaTypeExt, sizeof(OMX_AUDIO_PARAM_WMATYPE_EXT)); } return ret; default: ret = OMX_ErrorUnsupportedIndex; break; } return ret; }
OMX_ERRORTYPE Clock::MediaTimeRequest( OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE *pRequst) { OMX_ERRORTYPE ret = OMX_ErrorNone; OMX_TIME_MEDIATIMETYPE UpdateType; OMX_TICKS TargetMediaTime, CurMediaTime; fsl_osal_timeval CurWallTime; OMX_S64 WaitTicks; if(CurState != OMX_TIME_ClockStateRunning) { LOG_WARNING("Clock is not running.\n"); return OMX_ErrorIncorrectStateOperation; } OMX_CHECK_STRUCT(pRequst, OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE, ret); if(ret != OMX_ErrorNone) return ret; OMX_INIT_STRUCT(&UpdateType, OMX_TIME_MEDIATIMETYPE); UpdateType.eUpdateType = OMX_TIME_UpdateRequestFulfillment; UpdateType.nClientPrivate = (OMX_U32) pRequst->pClientPrivate; if(Scale >= MIN_TRICK_FORWARD_RATE*Q16_SHIFT || Scale < -Q16_SHIFT) { WaitTicks = (OMX_S64)OMX_TICKS_PER_SECOND*Q16_SHIFT/Scale; WaitTicks = Scale > 0 ? WaitTicks : -WaitTicks; CurMediaAndWallTime(NULL, &CurWallTime); LOG_DEBUG("Scale %d, Cur Media Time: %lld, Wait Time: %lld\n", Scale,CurMediaTime, WaitTicks); fsl_osal_cond_timedwait(Cond, WaitTicks); /* Not drop any frames in trick mode */ UpdateType.nMediaTimestamp = pRequst->nMediaTimestamp; UpdateType.nWallTimeAtMediaTime = WALLTIME2TICKS(CurWallTime); } else { TargetMediaTime = pRequst->nMediaTimestamp; CurMediaAndWallTime(&CurMediaTime, &CurWallTime); WaitTicks = (TargetMediaTime - pRequst->nOffset - CurMediaTime)*Q16_SHIFT/Scale; LOG_DEBUG("Target: %lld, Cur: %lld, Diff: %lld\n", TargetMediaTime, CurMediaTime, WaitTicks); if(WaitTicks > OMX_TICKS_PER_SECOND) { fsl_osal_cond_timedwait(Cond, OMX_TICKS_PER_SECOND); return OMX_ErrorNotReady; } if(WaitTicks > 0) { fsl_osal_cond_timedwait(Cond, WaitTicks); CurMediaTime = pRequst->nMediaTimestamp; } UpdateType.nMediaTimestamp = CurMediaTime; UpdateType.nWallTimeAtMediaTime = WALLTIME2TICKS(CurWallTime); } MediaTimeUpdate(&UpdateType, pRequst->nPortIndex); return OMX_ErrorNone; }
OMX_ERRORTYPE AudioFilter::SetParameter( OMX_INDEXTYPE nParamIndex, OMX_PTR pComponentParameterStructure) { OMX_ERRORTYPE ret = OMX_ErrorNone; switch (nParamIndex) { case OMX_IndexParamAudioPortFormat: { OMX_AUDIO_PARAM_PORTFORMATTYPE *pPortFormat; pPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)pComponentParameterStructure; OMX_CHECK_STRUCT(pPortFormat, OMX_AUDIO_PARAM_PORTFORMATTYPE, ret); if(ret != OMX_ErrorNone) break; if (pPortFormat->nPortIndex > AUDIO_FILTER_PORT_NUMBER - 1) { ret = OMX_ErrorBadPortIndex; break; } fsl_osal_memcpy(&PortFormat[pPortFormat->nPortIndex], pPortFormat, \ sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); } break; case OMX_IndexParamAudioPcm: { OMX_AUDIO_PARAM_PCMMODETYPE *pPcmMode; pPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*)pComponentParameterStructure; OMX_CHECK_STRUCT(pPcmMode, OMX_AUDIO_PARAM_PCMMODETYPE, ret); if(ret != OMX_ErrorNone) break; fsl_osal_memcpy(&PcmMode, pPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)); } AudioFilterSetParameterPCM(); break; default: ret = AudioFilterSetParameter(nParamIndex, pComponentParameterStructure); break; } return ret; }
OMX_ERRORTYPE State::DoEmptyThisBuffer( OMX_BUFFERHEADERTYPE* pBuffer) { OMX_ERRORTYPE ret = OMX_ErrorNone; OMX_U32 nPortIndex; LOG_DEBUG("%s EmptyBuffer %p.\n", base->name, pBuffer); if(pBuffer == NULL) return OMX_ErrorBadParameter; /**< check buffer structure version*/ OMX_CHECK_STRUCT(pBuffer, OMX_BUFFERHEADERTYPE, ret); if(ret != OMX_ErrorNone) return ret; nPortIndex = pBuffer->nInputPortIndex; if(nPortIndex >= base->nPorts || base->ports[nPortIndex]->GetPortDir() != OMX_DirInput) return OMX_ErrorBadPortIndex; if(base->ports[nPortIndex]->IsEnabled() != OMX_TRUE) { LOG_WARNING("%s Port %d is not populated.\n", base->name, nPortIndex); return OMX_ErrorPortUnpopulated; } LOG_DEBUG("%s Sending Input buffer[%p]\n", base->name, pBuffer); if (NULL != pBuffer->hMarkTargetComponent) { OMX_MARKTYPE sMarkData; sMarkData.hMarkTargetComponent = pBuffer->hMarkTargetComponent; sMarkData.pMarkData = pBuffer->pMarkData; if(pBuffer->hMarkTargetComponent != base->GetComponentHandle()) { base->MarkOtherPortsBuffer(&sMarkData); LOG_DEBUG("%s,%d,in component %s relay mark target %x to output port.\n",__FUNCTION__,__LINE__,base->name,sMarkData.hMarkTargetComponent); } else { base->ports[nPortIndex]->MarkBuffer(&sMarkData); LOG_DEBUG("%s,%d,in component %s mark target %x to input port.\n",__FUNCTION__,__LINE__,base->name,pBuffer->hMarkTargetComponent); } } base->ports[nPortIndex]->AddBuffer(pBuffer); if(base->ports[nPortIndex]->NeedReturnBuffers() == OMX_TRUE) return ret; ret = (base->*Process)(BUFFER); return ret; }
OMX_ERRORTYPE Clock::SetStartTime( OMX_TIME_CONFIG_TIMESTAMPTYPE *pStartTime) { OMX_ERRORTYPE ret = OMX_ErrorNone; OMX_TIME_MEDIATIMETYPE UpdateType; OMX_U32 nPortIndex; OMX_U32 i; if(CurState != OMX_TIME_ClockStateWaitingForStartTime) return OMX_ErrorIncorrectStateOperation; OMX_CHECK_STRUCT(pStartTime, OMX_TIME_CONFIG_TIMESTAMPTYPE, ret); if(ret != OMX_ErrorNone) return ret; nPortIndex = pStartTime->nPortIndex; if(nPortIndex >= nPorts) { LOG_ERROR("Bad port index[%d] when set start time to clock.\n", nPortIndex); return OMX_ErrorBadPortIndex; } fsl_osal_mutex_lock(lock); SegmentStartTime = MIN(SegmentStartTime, (OMX_U64)pStartTime->nTimestamp); LOG_DEBUG("%s,%d,set start time from port %d, ts %lld,SegmentStartTime %lld\n",__FUNCTION__,__LINE__,nPortIndex,pStartTime->nTimestamp,SegmentStartTime); StartTimeWaitMask &= ~(1 << nPortIndex); if(StartTimeWaitMask) { fsl_osal_mutex_unlock(lock); return OMX_ErrorNone; } /* start media clock now */ CurState = OMX_TIME_ClockStateRunning; sState.eState = CurState; MediaTimeBase = SegmentStartTime; LOG_DEBUG("%s,%d,start new segment,set media time base to %lld\n",__FUNCTION__,__LINE__,MediaTimeBase); CurMediaAndWallTime(NULL, &WallTimeBase); OMX_INIT_STRUCT(&UpdateType, OMX_TIME_MEDIATIMETYPE); UpdateType.eUpdateType = OMX_TIME_UpdateClockStateChanged; UpdateType.eState = sState.eState; UpdateType.nMediaTimestamp = SegmentStartTime; SegmentStartTime = -1L; fsl_osal_mutex_unlock(lock); for(i=0; i<PORT_NUM; i++) { if(ports[i]->IsEnabled() == OMX_TRUE) MediaTimeUpdate(&UpdateType, i); } return OMX_ErrorNone; }
OMX_ERRORTYPE WmaDec::AudioFilterCheckCodecConfig() { OMX_ERRORTYPE ret = OMX_ErrorNone; OMX_AUDIO_PARAM_WMATYPE *pWmaType; pWmaType = (OMX_AUDIO_PARAM_WMATYPE*)pInBufferHdr->pBuffer; OMX_CHECK_STRUCT(pWmaType, OMX_AUDIO_PARAM_WMATYPE, ret); if(ret != OMX_ErrorNone) { LOG_DEBUG("Wma codec config len: %d\n", pInBufferHdr->nFilledLen); switch (WmaType.eFormat) { case OMX_AUDIO_WMAFormat7: LOG_DEBUG("WMA1 audio\n"); if (pInBufferHdr->nFilledLen >= 4) WmaType.nEncodeOptions = *(OMX_U16*)(pInBufferHdr->pBuffer + 2); break; case OMX_AUDIO_WMAFormat8: LOG_DEBUG("WMA2 audio\n"); if (pInBufferHdr->nFilledLen >= 6) WmaType.nEncodeOptions = *(OMX_U16*)(pInBufferHdr->pBuffer + 4); break; case OMX_AUDIO_WMAFormat9: LOG_DEBUG("WMA3 audio\n"); if (pInBufferHdr->nFilledLen >= 18) { WmaType.eProfile = OMX_AUDIO_WMAProfileL1; dwChannelMask = *(OMX_U32*)(pInBufferHdr->pBuffer + 2); nAdvancedEncodeOpt2 = *(OMX_U16 *)(pInBufferHdr->pBuffer + 10); WmaType.nEncodeOptions = *(OMX_U16 *)(pInBufferHdr->pBuffer + 14); nAdvancedEncodeOpt = *(OMX_U16 *)(pInBufferHdr->pBuffer + 16); } break; default: break; } pInBufferHdr->nFilledLen = 0; return ret; } LOG_DEBUG("Wma codec type len: %d\n", pInBufferHdr->nFilledLen); fsl_osal_memcpy(pWmaType, &WmaType, sizeof(OMX_AUDIO_PARAM_WMATYPE)); pInBufferHdr->nFilledLen = 0; return ret; }
OMX_ERRORTYPE Clock::SetTimeScale( OMX_TIME_CONFIG_SCALETYPE *pScale) { OMX_ERRORTYPE ret = OMX_ErrorNone; OMX_TIME_MEDIATIMETYPE UpdateType; OMX_U32 i; OMX_CHECK_STRUCT(pScale, OMX_TIME_CONFIG_SCALETYPE, ret); if(ret != OMX_ErrorNone) return ret; if(pScale->xScale == Scale) { LOG_INFO("Set same scale value:[%d:%d]\n", pScale->xScale, Scale); return OMX_ErrorNone; } fsl_osal_mutex_lock(lock); CurMediaAndWallTime(&MediaTimeBase, NULL); CurMediaAndWallTime(NULL, &WallTimeBase); Scale = pScale->xScale; OMX_INIT_STRUCT(&UpdateType, OMX_TIME_MEDIATIMETYPE); UpdateType.eUpdateType = OMX_TIME_UpdateScaleChanged; UpdateType.xScale = Scale; fsl_osal_mutex_unlock(lock); for(i=0; i<PORT_NUM; i++) { if(ports[i]->IsEnabled() == OMX_TRUE) MediaTimeUpdate(&UpdateType, i); } fsl_osal_cond_broadcast(Cond); return ret; }
OMX_ERRORTYPE AudioSource::SetConfig( OMX_INDEXTYPE nParamIndex, OMX_PTR pStructure) { OMX_ERRORTYPE ret = OMX_ErrorNone; switch ((int)nParamIndex) { case OMX_IndexConfigAudioVolume: { OMX_AUDIO_CONFIG_VOLUMETYPE *pVolume; pVolume = (OMX_AUDIO_CONFIG_VOLUMETYPE*)pStructure; CHECK_STRUCT(pVolume, OMX_AUDIO_CONFIG_VOLUMETYPE, ret); fsl_osal_memcpy(&Volume, pVolume, sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE)); } break; case OMX_IndexConfigAudioMute: { OMX_AUDIO_CONFIG_MUTETYPE *pMute; pMute = (OMX_AUDIO_CONFIG_MUTETYPE*)pStructure; CHECK_STRUCT(pMute, OMX_AUDIO_CONFIG_MUTETYPE, ret); fsl_osal_memcpy(&Mute, pMute, sizeof(OMX_AUDIO_CONFIG_MUTETYPE)); } break; case OMX_IndexConfigEOS: { OMX_CONFIG_BOOLEANTYPE *pEOS; pEOS = (OMX_CONFIG_BOOLEANTYPE*)pStructure; OMX_CHECK_STRUCT(pEOS, OMX_CONFIG_BOOLEANTYPE, ret); fsl_osal_memcpy(&EOS, pEOS, sizeof(OMX_CONFIG_BOOLEANTYPE)); } break; default: ret = OMX_ErrorUnsupportedIndex; break; } return ret; }
OMX_ERRORTYPE Clock::SetRefClock( OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE *pRefClock) { OMX_ERRORTYPE ret = OMX_ErrorNone; OMX_CHECK_STRUCT(pRefClock, OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE, ret); if(ret != OMX_ErrorNone) return ret; LOG_DEBUG("%s,%d,Set reference clock %d, curr ref clock %d\n",__FUNCTION__,__LINE__, pRefClock->eClock, RefClock); if(RefClock == pRefClock->eClock) { LOG_INFO("Set same reference clock:[%d:%d]\n", pRefClock->eClock, RefClock); return OMX_ErrorNone; } fsl_osal_mutex_lock(lock); RefClock = pRefClock->eClock; fsl_osal_cond_broadcast(Cond); fsl_osal_mutex_unlock(lock); return OMX_ErrorNone; }
OMX_ERRORTYPE State::DoFillThisBuffer( OMX_BUFFERHEADERTYPE* pBuffer) { OMX_ERRORTYPE ret = OMX_ErrorNone; OMX_U32 nPortIndex; LOG_DEBUG("%s FillBuffer %p.\n", base->name, pBuffer); if(pBuffer == NULL) return OMX_ErrorBadParameter; /**< check buffer structure version*/ OMX_CHECK_STRUCT(pBuffer, OMX_BUFFERHEADERTYPE, ret); if(ret != OMX_ErrorNone) return ret; nPortIndex = pBuffer->nOutputPortIndex; if(nPortIndex >= base->nPorts || base->ports[nPortIndex]->GetPortDir() != OMX_DirOutput) return OMX_ErrorBadPortIndex; if(base->ports[nPortIndex]->IsEnabled() != OMX_TRUE) { LOG_WARNING("%s Port %d is not populated.\n", base->name, nPortIndex); return OMX_ErrorPortUnpopulated; } LOG_DEBUG("%s Sending Output buffer[%p]\n", base->name, pBuffer); base->ports[nPortIndex]->AddBuffer(pBuffer); if(base->ports[nPortIndex]->NeedReturnBuffers() == OMX_TRUE) return ret; ret = (base->*Process)(BUFFER); return ret; }
OMX_ERRORTYPE VideoSource::SetConfig( OMX_INDEXTYPE nParamIndex, OMX_PTR pStructure) { OMX_ERRORTYPE ret = OMX_ErrorNone; switch ((int)nParamIndex) { case OMX_IndexConfigCommonWhiteBalance: { OMX_CONFIG_WHITEBALCONTROLTYPE *pWhiteBalControl; pWhiteBalControl = (OMX_CONFIG_WHITEBALCONTROLTYPE*)pStructure; OMX_CHECK_STRUCT(pWhiteBalControl, OMX_CONFIG_WHITEBALCONTROLTYPE, ret); fsl_osal_memcpy(&WhiteBalControl, pWhiteBalControl, sizeof(OMX_CONFIG_WHITEBALCONTROLTYPE)); SetWhiteBalance(); } break; case OMX_IndexConfigCommonDigitalZoom: { OMX_CONFIG_SCALEFACTORTYPE *pScaleFactor; pScaleFactor = (OMX_CONFIG_SCALEFACTORTYPE*)pStructure; OMX_CHECK_STRUCT(pScaleFactor, OMX_CONFIG_SCALEFACTORTYPE, ret); fsl_osal_memcpy(&ScaleFactor, pScaleFactor, sizeof(OMX_CONFIG_SCALEFACTORTYPE)); SetDigitalZoom(); } break; case OMX_IndexConfigCommonExposureValue: { OMX_CONFIG_EXPOSUREVALUETYPE *pExposureValue; pExposureValue = (OMX_CONFIG_EXPOSUREVALUETYPE*)pStructure; OMX_CHECK_STRUCT(pExposureValue, OMX_CONFIG_EXPOSUREVALUETYPE, ret); fsl_osal_memcpy(&ExposureValue, pExposureValue, sizeof(OMX_CONFIG_EXPOSUREVALUETYPE)); SetExposureValue(); } break; case OMX_IndexConfigCapturing: { OMX_CONFIG_BOOLEANTYPE *pCapturing; OMX_TIME_CONFIG_TIMESTAMPTYPE StartTime; OMX_INIT_STRUCT(&StartTime, OMX_TIME_CONFIG_TIMESTAMPTYPE); StartTime.nTimestamp = 0; pCapturing = (OMX_CONFIG_BOOLEANTYPE*)pStructure; OMX_CHECK_STRUCT(pCapturing, OMX_CONFIG_BOOLEANTYPE, ret); fsl_osal_memcpy(&Capturing, pCapturing, sizeof(OMX_CONFIG_BOOLEANTYPE)); if (Capturing.bEnabled == OMX_TRUE) ClockSetConfig(OMX_IndexConfigTimeClientStartTime, &StartTime); } break; case OMX_IndexAutoPauseAfterCapture: { OMX_CONFIG_BOOLEANTYPE *pAutoPauseAfterCapture; pAutoPauseAfterCapture = (OMX_CONFIG_BOOLEANTYPE*)pStructure; OMX_CHECK_STRUCT(pAutoPauseAfterCapture, OMX_CONFIG_BOOLEANTYPE, ret); fsl_osal_memcpy(&AutoPauseAfterCapture, pAutoPauseAfterCapture, sizeof(OMX_CONFIG_BOOLEANTYPE)); } break; case OMX_IndexConfigCommonRotate: { OMX_CONFIG_ROTATIONTYPE *pRotation; pRotation = (OMX_CONFIG_ROTATIONTYPE*)pStructure; OMX_CHECK_STRUCT(pRotation, OMX_CONFIG_ROTATIONTYPE, ret); fsl_osal_memcpy(&Rotation, pRotation, sizeof(OMX_CONFIG_ROTATIONTYPE)); SetRotation(); } break; case OMX_IndexConfigEOS: { OMX_CONFIG_BOOLEANTYPE *pEOS; pEOS = (OMX_CONFIG_BOOLEANTYPE*)pStructure; OMX_CHECK_STRUCT(pEOS, OMX_CONFIG_BOOLEANTYPE, ret); fsl_osal_memcpy(&EOS, pEOS, sizeof(OMX_CONFIG_BOOLEANTYPE)); } break; default: ret = OMX_ErrorUnsupportedIndex; break; } return ret; }
OMX_ERRORTYPE VideoSource::GetConfig( OMX_INDEXTYPE nParamIndex, OMX_PTR pStructure) { OMX_ERRORTYPE ret = OMX_ErrorNone; switch (nParamIndex) { case OMX_IndexConfigCommonWhiteBalance: { OMX_CONFIG_WHITEBALCONTROLTYPE *pWhiteBalControl; pWhiteBalControl = (OMX_CONFIG_WHITEBALCONTROLTYPE*)pStructure; OMX_CHECK_STRUCT(pWhiteBalControl, OMX_CONFIG_WHITEBALCONTROLTYPE, ret); fsl_osal_memcpy(pWhiteBalControl, &WhiteBalControl, sizeof(OMX_CONFIG_WHITEBALCONTROLTYPE)); } break; case OMX_IndexConfigCommonDigitalZoom: { OMX_CONFIG_SCALEFACTORTYPE *pScaleFactor; pScaleFactor = (OMX_CONFIG_SCALEFACTORTYPE*)pStructure; OMX_CHECK_STRUCT(pScaleFactor, OMX_CONFIG_SCALEFACTORTYPE, ret); fsl_osal_memcpy(pScaleFactor, &ScaleFactor, sizeof(OMX_CONFIG_SCALEFACTORTYPE)); } break; case OMX_IndexConfigCommonExposureValue: { OMX_CONFIG_EXPOSUREVALUETYPE *pExposureValue; pExposureValue = (OMX_CONFIG_EXPOSUREVALUETYPE*)pStructure; OMX_CHECK_STRUCT(pExposureValue, OMX_CONFIG_EXPOSUREVALUETYPE, ret); fsl_osal_memcpy(pExposureValue, &ExposureValue, sizeof(OMX_CONFIG_EXPOSUREVALUETYPE)); } break; case OMX_IndexConfigCapturing: { OMX_CONFIG_BOOLEANTYPE *pCapturing; pCapturing = (OMX_CONFIG_BOOLEANTYPE*)pStructure; OMX_CHECK_STRUCT(pCapturing, OMX_CONFIG_BOOLEANTYPE, ret); fsl_osal_memcpy(pCapturing, &Capturing, sizeof(OMX_CONFIG_BOOLEANTYPE)); } break; case OMX_IndexAutoPauseAfterCapture: { OMX_CONFIG_BOOLEANTYPE *pAutoPauseAfterCapture; pAutoPauseAfterCapture = (OMX_CONFIG_BOOLEANTYPE*)pStructure; OMX_CHECK_STRUCT(pAutoPauseAfterCapture, OMX_CONFIG_BOOLEANTYPE, ret); fsl_osal_memcpy(pAutoPauseAfterCapture, &AutoPauseAfterCapture, sizeof(OMX_CONFIG_BOOLEANTYPE)); } break; case OMX_IndexConfigCommonRotate: { OMX_CONFIG_ROTATIONTYPE *pRotation; pRotation = (OMX_CONFIG_ROTATIONTYPE*)pStructure; OMX_CHECK_STRUCT(pRotation, OMX_CONFIG_ROTATIONTYPE, ret); fsl_osal_memcpy(pRotation, &Rotation, sizeof(OMX_CONFIG_ROTATIONTYPE)); } default: ret = OMX_ErrorUnsupportedIndex; break; } return ret; }
OMX_ERRORTYPE VideoSource::SetParameter( OMX_INDEXTYPE nParamIndex, OMX_PTR pStructure) { OMX_ERRORTYPE ret = OMX_ErrorNone; switch ((int)nParamIndex) { case OMX_IndexParamCommonSensorMode: { OMX_PARAM_SENSORMODETYPE *pSensorMode; pSensorMode = (OMX_PARAM_SENSORMODETYPE*)pStructure; OMX_CHECK_STRUCT(pSensorMode, OMX_PARAM_SENSORMODETYPE, ret); fsl_osal_memcpy(&SensorMode, pSensorMode, sizeof(OMX_PARAM_SENSORMODETYPE)); SetSensorMode(); } break; case OMX_IndexParamVideoPortFormat: { OMX_VIDEO_PARAM_PORTFORMATTYPE *pPortFormat; pPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE*)pStructure; OMX_CHECK_STRUCT(pPortFormat, OMX_VIDEO_PARAM_PORTFORMATTYPE, ret); fsl_osal_memcpy(&PortFormat, pPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); if (nParamIndex == CAPTURED_FRAME_PORT) SetVideoFormat(); } break; case OMX_IndexParamStoreMetaDataInBuffers: { OMX_CONFIG_BOOLEANTYPE *pParams = (OMX_CONFIG_BOOLEANTYPE*)pStructure; bStoreMetaData = pParams->bEnabled; } break; case OMX_IndexParamVideoCamera: { cameraPtr = (OMX_PTR)pStructure; } break; case OMX_IndexParamVideoCameraProxy: { cameraProxyPtr = (OMX_PTR)pStructure; } break; case OMX_IndexParamVideoCameraId: { nCameraId = *((OMX_S32*)pStructure); } break; case OMX_IndexParamVideoSurface: { previewSurface = (OMX_PTR)pStructure; } break; case OMX_IndexParamMaxFileDuration: { nMaxDuration = *((OMX_TICKS*)pStructure); } break; case OMX_IndexParamTimeLapseUs: { nTimeLapseUs = *((OMX_TICKS*)pStructure); } break; case OMX_IndexParamClientName: { clientName = (const OMX_U16 *)pStructure; } break; case OMX_IndexParamClientUID: { clientUID = *((OMX_S32*)pStructure); } break; default: ret = InstanceSetParameter(nParamIndex, pStructure); break; } return ret; }
OMX_ERRORTYPE Clock::GetConfig( OMX_INDEXTYPE nParamIndex, OMX_PTR pStructure) { OMX_ERRORTYPE ret = OMX_ErrorNone; switch (nParamIndex) { case OMX_IndexConfigTimeScale: { OMX_TIME_CONFIG_SCALETYPE *pScale = NULL; pScale = (OMX_TIME_CONFIG_SCALETYPE*)pStructure; OMX_CHECK_STRUCT(pScale, OMX_TIME_CONFIG_SCALETYPE, ret); if(ret != OMX_ErrorNone) return ret; pScale->xScale = Scale; } break; case OMX_IndexConfigTimeClockState: { OMX_TIME_CONFIG_CLOCKSTATETYPE *pState = NULL; pState = (OMX_TIME_CONFIG_CLOCKSTATETYPE*)pStructure; OMX_CHECK_STRUCT(pState, OMX_TIME_CONFIG_CLOCKSTATETYPE, ret); if(ret != OMX_ErrorNone) return ret; fsl_osal_memcpy(pState, &sState, sizeof(OMX_TIME_CONFIG_CLOCKSTATETYPE)); } break; case OMX_IndexConfigTimeActiveRefClock: { OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE *pRefClock = NULL; pRefClock = (OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE*)pStructure; OMX_CHECK_STRUCT(pRefClock, OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE, ret); if(ret != OMX_ErrorNone) return ret; pRefClock->eClock = RefClock; } break; case OMX_IndexConfigTimeCurrentMediaTime: { OMX_TIME_CONFIG_TIMESTAMPTYPE *pCurMediaTime = NULL; OMX_TICKS CurMediaTime = 0; pCurMediaTime = (OMX_TIME_CONFIG_TIMESTAMPTYPE*)pStructure; OMX_CHECK_STRUCT(pCurMediaTime, OMX_TIME_CONFIG_TIMESTAMPTYPE, ret); if(ret != OMX_ErrorNone) return ret; if(sState.eState != OMX_TIME_ClockStateRunning) { pCurMediaTime->nTimestamp = 0; break; } CurMediaAndWallTime(&CurMediaTime, NULL); pCurMediaTime->nTimestamp = CurMediaTime; } break; case OMX_IndexConfigTimeCurrentWallTime: { OMX_TIME_CONFIG_TIMESTAMPTYPE *pCurWallTime = NULL; fsl_osal_timeval tv; pCurWallTime = (OMX_TIME_CONFIG_TIMESTAMPTYPE*)pStructure; OMX_CHECK_STRUCT(pCurWallTime, OMX_TIME_CONFIG_TIMESTAMPTYPE, ret); if(ret != OMX_ErrorNone) return ret; CurMediaAndWallTime(NULL, &tv); pCurWallTime->nTimestamp = WALLTIME2TICKS(tv); } break; default : ret = OMX_ErrorUnsupportedIndex; return ret; break; } return OMX_ErrorNone; }
OMX_ERRORTYPE State::DoSetParameter( OMX_INDEXTYPE nParamIndex, OMX_PTR pStructure) { OMX_ERRORTYPE ret = OMX_ErrorNone; if(pStructure == NULL) return OMX_ErrorBadParameter; switch(nParamIndex) { case OMX_IndexParamPortDefinition: { OMX_PARAM_PORTDEFINITIONTYPE *pPortDef; pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE*)pStructure; OMX_CHECK_STRUCT(pPortDef, OMX_PARAM_PORTDEFINITIONTYPE, ret); if(ret != OMX_ErrorNone) return ret; if(pPortDef->nPortIndex >= base->nPorts) return OMX_ErrorBadPortIndex; ret = base->ports[pPortDef->nPortIndex]->SetPortDefinition(pPortDef); if(ret == OMX_ErrorNone) base->PortFormatChanged(pPortDef->nPortIndex); } break; case OMX_IndexParamCompBufferSupplier: { OMX_PARAM_BUFFERSUPPLIERTYPE *pBufferSupplierType; OMX_U32 nPortIndex; pBufferSupplierType = (OMX_PARAM_BUFFERSUPPLIERTYPE*) pStructure; OMX_CHECK_STRUCT(pBufferSupplierType, OMX_PARAM_BUFFERSUPPLIERTYPE, ret); if(ret != OMX_ErrorNone) return ret; nPortIndex = pBufferSupplierType->nPortIndex; if(nPortIndex >= base->nPorts) return OMX_ErrorBadPortIndex; base->ports[nPortIndex]->SetSupplierType(pBufferSupplierType->eBufferSupplier); } break; case OMX_IndexParamAudioPortFormat: { OMX_AUDIO_PARAM_PORTFORMATTYPE *pPortFmt; OMX_PARAM_PORTDEFINITIONTYPE sPortDef; OMX_U32 nParamIndex; pPortFmt = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)pStructure; OMX_CHECK_STRUCT(pPortFmt, OMX_AUDIO_PARAM_PORTFORMATTYPE, ret); if(ret != OMX_ErrorNone) break; if(pPortFmt->nPortIndex >= base->nPorts) return OMX_ErrorBadPortIndex; OMX_INIT_STRUCT(&sPortDef, OMX_PARAM_PORTDEFINITIONTYPE); sPortDef.nPortIndex = pPortFmt->nPortIndex; base->ports[pPortFmt->nPortIndex]->GetPortDefinition(&sPortDef); if(sPortDef.eDomain != OMX_PortDomainAudio) return OMX_ErrorBadPortIndex; sPortDef.format.audio.eEncoding = pPortFmt->eEncoding; base->ports[pPortFmt->nPortIndex]->SetPortDefinition(&sPortDef); } break; case OMX_IndexParamVideoPortFormat: { OMX_VIDEO_PARAM_PORTFORMATTYPE *pPortFmt; OMX_PARAM_PORTDEFINITIONTYPE sPortDef; OMX_U32 nParamIndex; pPortFmt = (OMX_VIDEO_PARAM_PORTFORMATTYPE*)pStructure; OMX_CHECK_STRUCT(pPortFmt, OMX_VIDEO_PARAM_PORTFORMATTYPE, ret); if(ret != OMX_ErrorNone) break; if(pPortFmt->nPortIndex >= base->nPorts) return OMX_ErrorBadPortIndex; OMX_INIT_STRUCT(&sPortDef, OMX_PARAM_PORTDEFINITIONTYPE); sPortDef.nPortIndex = pPortFmt->nPortIndex; base->ports[pPortFmt->nPortIndex]->GetPortDefinition(&sPortDef); if(sPortDef.eDomain != OMX_PortDomainVideo) return OMX_ErrorBadPortIndex; sPortDef.format.video.eCompressionFormat = pPortFmt->eCompressionFormat; sPortDef.format.video.eColorFormat = pPortFmt->eColorFormat; sPortDef.format.video.xFramerate = pPortFmt->xFramerate; base->ports[pPortFmt->nPortIndex]->SetPortDefinition(&sPortDef); } break; case OMX_IndexParamImagePortFormat: { OMX_IMAGE_PARAM_PORTFORMATTYPE *pPortFmt; OMX_PARAM_PORTDEFINITIONTYPE sPortDef; OMX_U32 nParamIndex; pPortFmt = (OMX_IMAGE_PARAM_PORTFORMATTYPE*)pStructure; OMX_CHECK_STRUCT(pPortFmt, OMX_IMAGE_PARAM_PORTFORMATTYPE, ret); if(ret != OMX_ErrorNone) break; if(pPortFmt->nPortIndex >= base->nPorts) return OMX_ErrorBadPortIndex; OMX_INIT_STRUCT(&sPortDef, OMX_PARAM_PORTDEFINITIONTYPE); sPortDef.nPortIndex = pPortFmt->nPortIndex; base->ports[pPortFmt->nPortIndex]->GetPortDefinition(&sPortDef); if(sPortDef.eDomain != OMX_PortDomainImage) return OMX_ErrorBadPortIndex; sPortDef.format.image.eCompressionFormat = pPortFmt->eCompressionFormat; sPortDef.format.image.eColorFormat = pPortFmt->eColorFormat; base->ports[pPortFmt->nPortIndex]->SetPortDefinition(&sPortDef); } break; case OMX_IndexParamOtherPortFormat: { OMX_OTHER_PARAM_PORTFORMATTYPE *pPortFmt; OMX_PARAM_PORTDEFINITIONTYPE sPortDef; OMX_U32 nParamIndex; pPortFmt = (OMX_OTHER_PARAM_PORTFORMATTYPE*)pStructure; OMX_CHECK_STRUCT(pPortFmt, OMX_OTHER_PARAM_PORTFORMATTYPE, ret); if(ret != OMX_ErrorNone) break; if(pPortFmt->nPortIndex >= base->nPorts) return OMX_ErrorBadPortIndex; OMX_INIT_STRUCT(&sPortDef, OMX_PARAM_PORTDEFINITIONTYPE); sPortDef.nPortIndex = pPortFmt->nPortIndex; base->ports[pPortFmt->nPortIndex]->GetPortDefinition(&sPortDef); if(sPortDef.eDomain != OMX_PortDomainOther) return OMX_ErrorBadPortIndex; sPortDef.format.other.eFormat = pPortFmt->eFormat; base->ports[pPortFmt->nPortIndex]->SetPortDefinition(&sPortDef); } break; default: ret = base->SetParameter(nParamIndex, pStructure); } return ret; }
OMX_ERRORTYPE Clock::SetState( OMX_TIME_CONFIG_CLOCKSTATETYPE *pState) { OMX_ERRORTYPE ret = OMX_ErrorNone; OMX_TIME_CLOCKSTATE NewState; OMX_TIME_MEDIATIMETYPE UpdateType; OMX_U32 i; OMX_CHECK_STRUCT(pState, OMX_TIME_CONFIG_CLOCKSTATETYPE, ret); if(ret != OMX_ErrorNone) return ret; NewState = pState->eState; if(NewState == CurState) { LOG_INFO("Set same state to clock: [%d:%d]\n", pState->eState, CurState); return OMX_ErrorNone; } fsl_osal_mutex_lock(lock); switch (NewState) { case OMX_TIME_ClockStateRunning: if(CurState == OMX_TIME_ClockStateWaitingForStartTime) { LOG_ERROR("Clock can't switch from WaitForStartTime to Running directly.\n"); ret = OMX_ErrorIncorrectStateTransition; goto err; } /* Stop -> Running */ fsl_osal_memcpy(&sState, pState, sizeof(OMX_TIME_CONFIG_CLOCKSTATETYPE)); SegmentStartTime = sState.nStartTime; break; case OMX_TIME_ClockStateWaitingForStartTime: if(CurState == OMX_TIME_ClockStateRunning) { LOG_ERROR("Clock can't switch from Running to WaitForStartTime.\n"); ret = OMX_ErrorIncorrectStateTransition; goto err; } /* Stop -> WaitForStartTime */ fsl_osal_memcpy(&sState, pState, sizeof(OMX_TIME_CONFIG_CLOCKSTATETYPE)); StartTimeWaitMask = sState.nWaitMask; break; case OMX_TIME_ClockStateStopped: /* Running->Stop / WaitForStartTime->Stop */ sState.eState = OMX_TIME_ClockStateStopped; break; default : LOG_ERROR("Invalid clock state setting: %d\n", pState->eState); ret = OMX_ErrorIncorrectStateTransition; goto err; } CurState = sState.eState; OMX_INIT_STRUCT(&UpdateType, OMX_TIME_MEDIATIMETYPE); UpdateType.eUpdateType = OMX_TIME_UpdateClockStateChanged; UpdateType.eState = sState.eState; fsl_osal_mutex_unlock(lock); for(i=0; i<PORT_NUM; i++) { if(ports[i]->IsEnabled() == OMX_TRUE) MediaTimeUpdate(&UpdateType, i); } if(sState.eState == OMX_TIME_ClockStateStopped) fsl_osal_cond_broadcast(Cond); return ret; err: fsl_osal_mutex_unlock(lock); return ret; }