OMX_ERRORTYPE omx_clocksrc_component_SetParameter( OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure) { OMX_ERRORTYPE err = OMX_ErrorNone; OMX_OTHER_PARAM_PORTFORMATTYPE *pOtherPortFormat; OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE*)hComponent; omx_clocksrc_component_PrivateType* omx_clocksrc_component_Private = openmaxStandComp->pComponentPrivate; omx_base_clock_PortType* pPort; OMX_PARAM_COMPONENTROLETYPE *pComponentRole; if (ComponentParameterStructure == NULL) { return OMX_ErrorBadParameter; } DEBUG(DEB_LEV_SIMPLE_SEQ, " Setting parameter %i\n", nParamIndex); /* Check which structure we are being fed and fill its header */ switch(nParamIndex) { case OMX_IndexParamOtherPortFormat: pOtherPortFormat = (OMX_OTHER_PARAM_PORTFORMATTYPE*)ComponentParameterStructure; /*Check Structure Header and verify component state*/ err = omx_base_component_ParameterSanityCheck(hComponent, pOtherPortFormat->nPortIndex, pOtherPortFormat, sizeof(OMX_OTHER_PARAM_PORTFORMATTYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n", __func__, err); break; } if (pOtherPortFormat->nPortIndex < omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts) { pPort = (omx_base_clock_PortType *) omx_clocksrc_component_Private->ports[pOtherPortFormat->nPortIndex]; memcpy(&pPort->sOtherParam,pOtherPortFormat,sizeof(OMX_OTHER_PARAM_PORTFORMATTYPE)); } else { return OMX_ErrorBadPortIndex; } break; case OMX_IndexParamStandardComponentRole: pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)ComponentParameterStructure; if (omx_clocksrc_component_Private->state != OMX_StateLoaded && omx_clocksrc_component_Private->state != OMX_StateWaitForResources) { DEBUG(DEB_LEV_ERR, "In %s Incorrect State=%x lineno=%d\n",__func__, omx_clocksrc_component_Private->state, __LINE__); return OMX_ErrorIncorrectStateOperation; } if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone) { break; } if (strcmp( (char*) pComponentRole->cRole, "")) { return OMX_ErrorBadParameter; } break; default: /*Call the base component function*/ return omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure); } return err; }
OMX_ERRORTYPE omx_videosrc_component_SetParameter( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, OMX_IN OMX_PTR ComponentParameterStructure) { OMX_ERRORTYPE err = OMX_ErrorNone; OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoPortFormat; OMX_U32 portIndex; /* Check which structure we are being fed and make control its header */ OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE*)hComponent; omx_videosrc_component_PrivateType* omx_videosrc_component_Private = openmaxStandComp->pComponentPrivate; omx_base_video_PortType* pPort = (omx_base_video_PortType *) omx_videosrc_component_Private->ports[OMX_BASE_SOURCE_OUTPUTPORT_INDEX]; if(ComponentParameterStructure == NULL) { return OMX_ErrorBadParameter; } DEBUG(DEB_LEV_SIMPLE_SEQ, " Setting parameter %i\n", nParamIndex); switch(nParamIndex) { case OMX_IndexParamVideoPortFormat: pVideoPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure; portIndex = pVideoPortFormat->nPortIndex; /*Check Structure Header and verify component state*/ err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } if (portIndex < 1) { memcpy(&pPort->sVideoParam,pVideoPortFormat,sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); } else { return OMX_ErrorBadPortIndex; } break; case OMX_IndexParamPortDefinition: err = omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure); if(err == OMX_ErrorNone) { if(pPort->sPortParam.format.video.nFrameWidth > 640 || pPort->sPortParam.format.video.nFrameWidth <160 || pPort->sPortParam.format.video.nFrameHeight > 480 || pPort->sPortParam.format.video.nFrameHeight < 120) { pPort->sPortParam.format.video.nFrameWidth = 160; pPort->sPortParam.format.video.nFrameHeight = 120; DEBUG(DEB_LEV_ERR, "In %s Frame Width Range[160..640] Frame Height Range[120..480]\n",__func__); return OMX_ErrorBadParameter; } else { pPort->sPortParam.nBufferSize = pPort->sPortParam.format.video.nFrameWidth* pPort->sPortParam.format.video.nFrameHeight*3/2; // YUV } } default: /*Call the base component function*/ return omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure); } return err; }
OMX_ERRORTYPE omx_volume_component_SetParameter( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, OMX_IN OMX_PTR ComponentParameterStructure) { OMX_ERRORTYPE err = OMX_ErrorNone; OMX_AUDIO_PARAM_PORTFORMATTYPE *pAudioPortFormat; OMX_U32 portIndex; omx_base_audio_PortType *port; /* Check which structure we are being fed and make control its header */ OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent; omx_volume_component_PrivateType* omx_volume_component_Private = openmaxStandComp->pComponentPrivate; if (ComponentParameterStructure == NULL) { return OMX_ErrorBadParameter; } DEBUG(DEB_LEV_SIMPLE_SEQ, " Setting parameter %i\n", nParamIndex); switch(nParamIndex) { case OMX_IndexParamAudioPortFormat: pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure; portIndex = pAudioPortFormat->nPortIndex; err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } if (portIndex <= 1) { port= (omx_base_audio_PortType *)omx_volume_component_Private->ports[portIndex]; memcpy(&port->sAudioParam, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); } else { err = OMX_ErrorBadPortIndex; } break; default: err = omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure); } return err; }
OMX_ERRORTYPE omx_audio_capturer_SetParameter( OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure) { int omxErr = OMX_ErrorNone; OMX_AUDIO_PARAM_PORTFORMATTYPE *pAudioPortFormat; OMX_U32 portIndex; if (ComponentParameterStructure == NULL) { return OMX_ErrorBadParameter; } DEBUG(DEB_LEV_SIMPLE_SEQ, " Setting parameter %i\n", nParamIndex); switch(nParamIndex) { case OMX_IndexParamAudioPortFormat: pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure; portIndex = pAudioPortFormat->nPortIndex; /*Check Structure Header and verify component state*/ omxErr = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); if(omxErr!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n", __func__, omxErr); break; } if (portIndex != 0) { return OMX_ErrorBadPortIndex; } break; default: /*Call the base component function*/ return omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure); } return omxErr; }
/*************************************************************************** * Function : omx_ImageDecoderJpeg_SetParameter * * Description : this function sets the parameter values regarding audio format & index * * Params : * * Name Type In/Out Description * hComponent OMX_HANDLETYPE Out Component Handle * nParamIndex OMX_INDEXTYPE In Parameter Index * ComponentParameterStructure OMX_PTR In Component Parameter Structure * * Return: * OMX_ErrorBadParameter if there is no Parameter structure or the parameter is not for this component role * OMX_ErrorBadPortIndex if portindex is wrong * * Note: * * Revision: * * Author Date Version Description * yuyiwei 2008.10.9 1.0.0 * ***************************************************************************/ OMX_ERRORTYPE omx_ImageDecoderJpeg_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, OMX_IN OMX_PTR ComponentParameterStructure) { OMX_ERRORTYPE err = OMX_ErrorNone; OMX_IMAGE_PARAM_PORTFORMATTYPE *pImagePortFormat; OMX_PARAM_COMPONENTROLETYPE *pComponentRole; OMX_U32 portIndex; /* Check which structure we are being fed and make control its header */ OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE*)hComponent; omx_jpegdec_component_PrivateType *omx_jpegdec_component_Private = openmaxStandComp->pComponentPrivate; omx_jpegdec_component_PortType *port; if (ComponentParameterStructure == NULL) { /** no parameter structure */ return OMX_ErrorBadParameter; } DEBUG(DEB_LEV_SIMPLE_SEQ, " Setting parameter %i\n", nParamIndex); switch (nParamIndex) { case OMX_IndexParamImagePortFormat: pImagePortFormat = (OMX_IMAGE_PARAM_PORTFORMATTYPE*)ComponentParameterStructure; portIndex = pImagePortFormat->nPortIndex; /*Check Structure Header and verify component state*/ err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pImagePortFormat, sizeof(OMX_IMAGE_PARAM_PORTFORMATTYPE)); if (err != OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n", __func__, err); break; } if (portIndex <= 1) { /** set the parameter to omx_jpegenc_component_PortType structure */ port = (omx_jpegdec_component_PortType*)omx_jpegdec_component_Private->ports[portIndex]; memcpy(&port->sImageParam, pImagePortFormat, sizeof(OMX_IMAGE_PARAM_PORTFORMATTYPE)); } else { return OMX_ErrorBadPortIndex; } break; case OMX_IndexParamStandardComponentRole: pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)ComponentParameterStructure; if (!strcmp((char*)pComponentRole->cRole, IMAGE_DEC_JPEG_ROLE)) { omx_jpegdec_component_Private->image_coding_type = OMX_IMAGE_CodingJPEG; } else { return OMX_ErrorBadParameter; } omx_ImageDecoderJpeg_SetInternalParameters(openmaxStandComp); break; default: /*Call the base component function*/ return omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure); } return err; }
OMX_ERRORTYPE omx_amr_audiodec_component_SetParameter( OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure) { OMX_ERRORTYPE err = OMX_ErrorNone; OMX_AUDIO_PARAM_PORTFORMATTYPE *pAudioPortFormat; OMX_AUDIO_PARAM_PCMMODETYPE* pAudioPcmMode; OMX_AUDIO_PARAM_AMRTYPE *pAudioAmr; OMX_PARAM_COMPONENTROLETYPE * pComponentRole; OMX_U32 portIndex; /* Check which structure we are being fed and make control its header */ OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent; omx_amr_audiodec_component_PrivateType* omx_amr_audiodec_component_Private = openmaxStandComp->pComponentPrivate; omx_base_audio_PortType *port; if (ComponentParameterStructure == NULL) { return OMX_ErrorBadParameter; } DEBUG(DEB_LEV_SIMPLE_SEQ, " Setting parameter %i\n", nParamIndex); switch(nParamIndex) { case OMX_IndexParamAudioPortFormat: pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure; portIndex = pAudioPortFormat->nPortIndex; /*Check Structure Header and verify component state*/ err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } if (portIndex <= 1) { port = (omx_base_audio_PortType *) omx_amr_audiodec_component_Private->ports[portIndex]; memcpy(&port->sAudioParam,pAudioPortFormat,sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); } else { return OMX_ErrorBadPortIndex; } break; case OMX_IndexParamAudioPcm: pAudioPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*)ComponentParameterStructure; portIndex = pAudioPcmMode->nPortIndex; /*Check Structure Header and verify component state*/ err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } memcpy(&omx_amr_audiodec_component_Private->pAudioPcmMode,pAudioPcmMode,sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)); break; case OMX_IndexParamStandardComponentRole: pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)ComponentParameterStructure; if (omx_amr_audiodec_component_Private->state != OMX_StateLoaded && omx_amr_audiodec_component_Private->state != OMX_StateWaitForResources) { DEBUG(DEB_LEV_ERR, "In %s Incorrect State=%x lineno=%d\n",__func__,omx_amr_audiodec_component_Private->state,__LINE__); return OMX_ErrorIncorrectStateOperation; } if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone) { break; } if (!strcmp((char*)pComponentRole->cRole, AUDIO_DEC_AMR_ROLE)) { omx_amr_audiodec_component_Private->audio_coding_type = OMX_AUDIO_CodingAMR; } else { return OMX_ErrorBadParameter; } omx_amr_audiodec_component_SetInternalParameters(openmaxStandComp); break; case OMX_IndexParamAudioAmr: pAudioAmr = (OMX_AUDIO_PARAM_AMRTYPE*) ComponentParameterStructure; portIndex = pAudioAmr->nPortIndex; err = omx_base_component_ParameterSanityCheck(hComponent,portIndex,pAudioAmr,sizeof(OMX_AUDIO_PARAM_AMRTYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } if (pAudioAmr->nPortIndex == 0) { memcpy(&omx_amr_audiodec_component_Private->pAudioAmr,pAudioAmr,sizeof(OMX_AUDIO_PARAM_AMRTYPE)); } else { return OMX_ErrorBadPortIndex; } break; default: /*Call the base component function*/ return omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure); } return err; }
OMX_ERRORTYPE omx_xvideo_sink_component_SetParameter( OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure) { OMX_ERRORTYPE err = OMX_ErrorNone; OMX_PARAM_PORTDEFINITIONTYPE *pPortDef; OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoPortFormat; OMX_U32 portIndex; /* Check which structure we are being fed and make control its header */ OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent; omx_xvideo_sink_component_PrivateType* omx_xvideo_sink_component_Private = openmaxStandComp->pComponentPrivate; omx_xvideo_sink_component_PortType *pPort; if (ComponentParameterStructure == NULL) { return OMX_ErrorBadParameter; } DEBUG(DEB_LEV_SIMPLE_SEQ, " Setting parameter %i\n", nParamIndex); switch(nParamIndex) { case OMX_IndexParamPortDefinition: pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure; portIndex = pPortDef->nPortIndex; err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } if(portIndex > (omx_xvideo_sink_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts)) { return OMX_ErrorBadPortIndex; } if(portIndex == 0) { pPort = (omx_xvideo_sink_component_PortType *) omx_xvideo_sink_component_Private->ports[portIndex]; pPort->sPortParam.nBufferCountActual = pPortDef->nBufferCountActual; // Copy stuff from OMX_VIDEO_PORTDEFINITIONTYPE structure if(pPortDef->format.video.cMIMEType != NULL) { strcpy(pPort->sPortParam.format.video.cMIMEType , pPortDef->format.video.cMIMEType); } pPort->sPortParam.format.video.nFrameWidth = pPortDef->format.video.nFrameWidth; pPort->sPortParam.format.video.nFrameHeight = pPortDef->format.video.nFrameHeight; pPort->sPortParam.format.video.nBitrate = pPortDef->format.video.nBitrate; pPort->sPortParam.format.video.xFramerate = pPortDef->format.video.xFramerate; pPort->sPortParam.format.video.bFlagErrorConcealment = pPortDef->format.video.bFlagErrorConcealment; pPort->sVideoParam.eColorFormat = pPortDef->format.video.eColorFormat;; pPort->sPortParam.format.video.eColorFormat = pPortDef->format.video.eColorFormat; // Figure out stride, slice height, min buffer size pPort->sPortParam.format.video.nStride = calcStride(pPort->sPortParam.format.video.nFrameWidth, pPort->sVideoParam.eColorFormat); pPort->sPortParam.format.video.nSliceHeight = pPort->sPortParam.format.video.nFrameHeight; // No support for slices yet // Read-only field by spec pPort->sPortParam.nBufferSize = (OMX_U32) abs(pPort->sPortParam.format.video.nStride) * pPort->sPortParam.format.video.nSliceHeight; pPort->omxConfigCrop.nWidth = pPort->sPortParam.format.video.nFrameWidth; pPort->omxConfigCrop.nHeight = pPort->sPortParam.format.video.nFrameHeight; } break; case OMX_IndexParamVideoPortFormat: // FIXME: How do we handle the nIndex member? pVideoPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure; portIndex = pVideoPortFormat->nPortIndex; err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } pPort = (omx_xvideo_sink_component_PortType *) omx_xvideo_sink_component_Private->ports[portIndex]; if(portIndex != 0) { return OMX_ErrorBadPortIndex; } if (pVideoPortFormat->eCompressionFormat != OMX_VIDEO_CodingUnused) { // No compression allowed return OMX_ErrorUnsupportedSetting; } if(pVideoPortFormat->xFramerate > 0) { nFrameProcessTime = 1000000 / pVideoPortFormat->xFramerate; } pPort->sVideoParam.xFramerate = pVideoPortFormat->xFramerate; pPort->sVideoParam.eCompressionFormat = pVideoPortFormat->eCompressionFormat; pPort->sVideoParam.eColorFormat = pVideoPortFormat->eColorFormat; pPort->sPortParam.format.video.eColorFormat = pVideoPortFormat->eColorFormat; // Figure out stride, slice height, min buffer size pPort->sPortParam.format.video.nStride = calcStride(pPort->sPortParam.format.video.nFrameWidth, pPort->sVideoParam.eColorFormat); pPort->sPortParam.format.video.nSliceHeight = pPort->sPortParam.format.video.nFrameHeight; // No support for slices yet pPort->sPortParam.nBufferSize = (OMX_U32) abs(pPort->sPortParam.format.video.nStride) * pPort->sPortParam.format.video.nSliceHeight; break; default: /*Call the base component function*/ return omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure); } return err; }
OMX_ERRORTYPE omx_shvpudec_component_SetParameter( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, OMX_IN OMX_PTR ComponentParameterStructure) { OMX_ERRORTYPE eError = OMX_ErrorNone; OMX_U32 portIndex; /* Check which structure we are being fed and make control its header */ OMX_COMPONENTTYPE *openmaxStandComp = hComponent; omx_shvpudec_component_PrivateType* omx_shvpudec_component_Private = openmaxStandComp->pComponentPrivate; omx_base_video_PortType *port; if (ComponentParameterStructure == NULL) { return OMX_ErrorBadParameter; } DEBUG(DEB_LEV_SIMPLE_SEQ, " Setting parameter %i\n", nParamIndex); switch(nParamIndex) { case OMX_IndexParamPortDefinition: { eError = omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure); if(eError == OMX_ErrorNone) { OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE*)ComponentParameterStructure; UpdateFrameSize (openmaxStandComp); portIndex = pPortDef->nPortIndex; port = (omx_base_video_PortType *)omx_shvpudec_component_Private->ports[portIndex]; port->sVideoParam.eColorFormat = port->sPortParam.format.video.eColorFormat; } break; } case OMX_IndexParamVideoPortFormat: { OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoPortFormat; pVideoPortFormat = ComponentParameterStructure; portIndex = pVideoPortFormat->nPortIndex; /*Check Structure Header and verify component state*/ eError = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); if(eError!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,eError); break; } if (portIndex <= 1) { port = (omx_base_video_PortType *)omx_shvpudec_component_Private->ports[portIndex]; memcpy(&port->sVideoParam, pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); omx_shvpudec_component_Private->ports[portIndex]->sPortParam.format.video.eColorFormat = port->sVideoParam.eColorFormat; if (portIndex == 1) { #if 0 switch(port->sVideoParam.eColorFormat) { case OMX_COLOR_Format24bitRGB888 : omx_shvpudec_component_Private->eOutFramePixFmt = PIX_FMT_RGB24; break; case OMX_COLOR_Format24bitBGR888 : omx_shvpudec_component_Private->eOutFramePixFmt = PIX_FMT_BGR24; break; case OMX_COLOR_Format32bitBGRA8888 : omx_shvpudec_component_Private->eOutFramePixFmt = PIX_FMT_BGR32; break; case OMX_COLOR_Format32bitARGB8888 : omx_shvpudec_component_Private->eOutFramePixFmt = PIX_FMT_RGB32; break; case OMX_COLOR_Format16bitARGB1555 : omx_shvpudec_component_Private->eOutFramePixFmt = PIX_FMT_RGB555; break; case OMX_COLOR_Format16bitRGB565 : omx_shvpudec_component_Private->eOutFramePixFmt = PIX_FMT_RGB565; break; case OMX_COLOR_Format16bitBGR565 : omx_shvpudec_component_Private->eOutFramePixFmt = PIX_FMT_BGR565; break; default: omx_shvpudec_component_Private->eOutFramePixFmt = PIX_FMT_YUV420P; break; } #endif UpdateFrameSize (openmaxStandComp); } } else { return OMX_ErrorBadPortIndex; } break; } case OMX_IndexParamVideoAvc: { OMX_VIDEO_PARAM_AVCTYPE *pVideoAvc; pVideoAvc = ComponentParameterStructure; portIndex = pVideoAvc->nPortIndex; eError = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pVideoAvc, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); if(eError!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,eError); break; } memcpy(&omx_shvpudec_component_Private->pVideoAvc, pVideoAvc, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); break; } case OMX_IndexParamStandardComponentRole: { OMX_PARAM_COMPONENTROLETYPE *pComponentRole; pComponentRole = ComponentParameterStructure; if (omx_shvpudec_component_Private->state != OMX_StateLoaded && omx_shvpudec_component_Private->state != OMX_StateWaitForResources) { DEBUG(DEB_LEV_ERR, "In %s Incorrect State=%x lineno=%d\n",__func__,omx_shvpudec_component_Private->state,__LINE__); return OMX_ErrorIncorrectStateOperation; } if ((eError = checkHeader(ComponentParameterStructure, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone) { break; } if (!strcmp((char *)pComponentRole->cRole, VIDEO_DEC_MPEG4_ROLE)) { omx_shvpudec_component_Private->video_coding_type = OMX_VIDEO_CodingMPEG4; } else if (!strcmp((char *)pComponentRole->cRole, VIDEO_DEC_H264_ROLE)) { omx_shvpudec_component_Private->video_coding_type = OMX_VIDEO_CodingAVC; } else { return OMX_ErrorBadParameter; } SetInternalVideoParameters(openmaxStandComp); break; } case OMX_IndexParamVideoMpeg4: { OMX_VIDEO_PARAM_MPEG4TYPE *pVideoMpeg4; pVideoMpeg4 = ComponentParameterStructure; portIndex = pVideoMpeg4->nPortIndex; eError = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pVideoMpeg4, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); if(eError!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,eError); break; } if (pVideoMpeg4->nPortIndex == 0) { memcpy(&omx_shvpudec_component_Private->pVideoMpeg4, pVideoMpeg4, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); } else { return OMX_ErrorBadPortIndex; } break; } default: /*Call the base component function*/ return omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure); } return eError; }
OMX_ERRORTYPE omx_video_scheduler_component_SetParameter( OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure) { OMX_ERRORTYPE err = OMX_ErrorNone; OMX_PARAM_PORTDEFINITIONTYPE *pPortDef; OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoPortFormat; OMX_OTHER_PARAM_PORTFORMATTYPE *pOtherPortFormat; OMX_U32 portIndex; OMX_PARAM_COMPONENTROLETYPE *pComponentRole; /* Check which structure we are being fed and make control its header */ OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent; omx_video_scheduler_component_PrivateType* omx_video_scheduler_component_Private = openmaxStandComp->pComponentPrivate; omx_base_video_PortType *pPort; omx_base_clock_PortType *pClockPort; if (ComponentParameterStructure == NULL) { return OMX_ErrorBadParameter; } DEBUG(DEB_LEV_SIMPLE_SEQ, " Setting parameter %i\n", nParamIndex); switch(nParamIndex) { case OMX_IndexParamPortDefinition: pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure; portIndex = pPortDef->nPortIndex; err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } if(portIndex > (omx_video_scheduler_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts + omx_video_scheduler_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts)) { return OMX_ErrorBadPortIndex; } if(portIndex < CLOCKPORT_INDEX) { pPort = (omx_base_video_PortType *) omx_video_scheduler_component_Private->ports[portIndex]; pPort->sPortParam.nBufferCountActual = pPortDef->nBufferCountActual; // Copy stuff from OMX_VIDEO_PORTDEFINITIONTYPE structure if(pPortDef->format.video.cMIMEType != NULL) { strcpy(pPort->sPortParam.format.video.cMIMEType , pPortDef->format.video.cMIMEType); } pPort->sPortParam.format.video.nFrameWidth = pPortDef->format.video.nFrameWidth; pPort->sPortParam.format.video.nFrameHeight = pPortDef->format.video.nFrameHeight; pPort->sPortParam.format.video.nBitrate = pPortDef->format.video.nBitrate; pPort->sPortParam.format.video.xFramerate = pPortDef->format.video.xFramerate; pPort->sPortParam.format.video.bFlagErrorConcealment = pPortDef->format.video.bFlagErrorConcealment; // Figure out stride, slice height, min buffer size pPort->sPortParam.format.video.nStride = pPortDef->format.video.nStride; pPort->sPortParam.format.video.nSliceHeight = pPort->sPortParam.format.video.nFrameHeight; // No support for slices yet // Read-only field by spec pPort->sPortParam.nBufferSize = (OMX_U32) abs(pPort->sPortParam.format.video.nStride) * pPort->sPortParam.format.video.nSliceHeight; } else { pClockPort = (omx_base_clock_PortType *) omx_video_scheduler_component_Private->ports[portIndex]; pClockPort->sPortParam.nBufferCountActual = pPortDef->nBufferCountActual; pClockPort->sPortParam.format.other.eFormat = pPortDef->format.other.eFormat; } break; case OMX_IndexParamVideoPortFormat: // FIXME: How do we handle the nIndex member? pVideoPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure; portIndex = pVideoPortFormat->nPortIndex; err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } pPort = (omx_base_video_PortType *) omx_video_scheduler_component_Private->ports[portIndex]; if(portIndex > 1) { return OMX_ErrorBadPortIndex; } if (pVideoPortFormat->eCompressionFormat != OMX_VIDEO_CodingUnused) { // No compression allowed return OMX_ErrorUnsupportedSetting; } pPort->sVideoParam.xFramerate = pVideoPortFormat->xFramerate; pPort->sVideoParam.eCompressionFormat = pVideoPortFormat->eCompressionFormat; pPort->sVideoParam.eColorFormat = pVideoPortFormat->eColorFormat; break; case OMX_IndexParamOtherPortFormat: pOtherPortFormat = (OMX_OTHER_PARAM_PORTFORMATTYPE*)ComponentParameterStructure; portIndex = pOtherPortFormat->nPortIndex; err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pOtherPortFormat, sizeof(OMX_OTHER_PARAM_PORTFORMATTYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } if(portIndex != CLOCKPORT_INDEX) { return OMX_ErrorBadPortIndex; } pClockPort = (omx_base_clock_PortType *) omx_video_scheduler_component_Private->ports[portIndex]; pClockPort->sOtherParam.eFormat = pOtherPortFormat->eFormat; break; case OMX_IndexParamStandardComponentRole: pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)ComponentParameterStructure; if (omx_video_scheduler_component_Private->state != OMX_StateLoaded && omx_video_scheduler_component_Private->state != OMX_StateWaitForResources) { DEBUG(DEB_LEV_ERR, "In %s Incorrect State=%x lineno=%d\n",__func__,omx_video_scheduler_component_Private->state,__LINE__); return OMX_ErrorIncorrectStateOperation; } if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone) { break; } if (strcmp( (char*) pComponentRole->cRole, VIDEO_SCHEDULER_COMP_ROLE)) { return OMX_ErrorBadParameter; } break; default: /*Call the base component function*/ return omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure); } return err; }
OMX_ERRORTYPE omx_audioenc_component_SetParameter( OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure) { OMX_ERRORTYPE err = OMX_ErrorNone; OMX_AUDIO_PARAM_PORTFORMATTYPE *pAudioPortFormat; OMX_AUDIO_PARAM_PCMMODETYPE* pAudioPcmMode; OMX_AUDIO_PARAM_MP3TYPE * pAudioMp3; OMX_AUDIO_PARAM_AACPROFILETYPE *pAudioAac; //support for AAC format OMX_PARAM_COMPONENTROLETYPE * pComponentRole; OMX_AUDIO_PARAM_G726TYPE *pAudioG726; OMX_U32 portIndex; /* Check which structure we are being fed and make control its header */ OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent; omx_audioenc_component_PrivateType* omx_audioenc_component_Private = openmaxStandComp->pComponentPrivate; omx_base_audio_PortType *port; if (ComponentParameterStructure == NULL) { return OMX_ErrorBadParameter; } DEBUG(DEB_LEV_SIMPLE_SEQ, " Setting parameter %i\n", nParamIndex); switch(nParamIndex) { case OMX_IndexParamAudioPortFormat: pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure; portIndex = pAudioPortFormat->nPortIndex; /*Check Structure Header and verify component state*/ err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } if (portIndex <= 1) { port = (omx_base_audio_PortType *) omx_audioenc_component_Private->ports[portIndex]; memcpy(&port->sAudioParam,pAudioPortFormat,sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); } else { return OMX_ErrorBadPortIndex; } break; case OMX_IndexParamAudioPcm: pAudioPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*)ComponentParameterStructure; portIndex = pAudioPcmMode->nPortIndex; /*Check Structure Header and verify component state*/ err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } if(pAudioPcmMode->nPortIndex == 0) memcpy(&omx_audioenc_component_Private->pAudioPcmMode,pAudioPcmMode,sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)); else return OMX_ErrorBadPortIndex; break; case OMX_IndexParamAudioAac: pAudioAac = (OMX_AUDIO_PARAM_AACPROFILETYPE*) ComponentParameterStructure; portIndex = pAudioAac->nPortIndex; err = omx_base_component_ParameterSanityCheck(hComponent,portIndex,pAudioAac,sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } if (pAudioAac->nPortIndex == 1) { memcpy(&omx_audioenc_component_Private->pAudioAac,pAudioAac,sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE)); } else { return OMX_ErrorBadPortIndex; } break; case OMX_IndexParamAudioMp3: pAudioMp3 = (OMX_AUDIO_PARAM_MP3TYPE*) ComponentParameterStructure; portIndex = pAudioMp3->nPortIndex; err = omx_base_component_ParameterSanityCheck(hComponent,portIndex,pAudioMp3,sizeof(OMX_AUDIO_PARAM_MP3TYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } if (pAudioMp3->nPortIndex == 1) { memcpy(&omx_audioenc_component_Private->pAudioMp3,pAudioMp3,sizeof(OMX_AUDIO_PARAM_MP3TYPE)); } else { return OMX_ErrorBadPortIndex; } break; case OMX_IndexParamAudioG726: pAudioG726 = (OMX_AUDIO_PARAM_G726TYPE*) ComponentParameterStructure; portIndex = pAudioG726->nPortIndex; err = omx_base_component_ParameterSanityCheck(hComponent,portIndex,pAudioG726,sizeof(OMX_AUDIO_PARAM_G726TYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } if (pAudioG726->nPortIndex == 1) { memcpy(&omx_audioenc_component_Private->pAudioG726,pAudioG726,sizeof(OMX_AUDIO_PARAM_G726TYPE)); } else { return OMX_ErrorBadPortIndex; } break; case OMX_IndexParamStandardComponentRole: pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)ComponentParameterStructure; if (!strcmp((char*)pComponentRole->cRole, AUDIO_ENC_MP3_ROLE)) { omx_audioenc_component_Private->audio_coding_type = OMX_AUDIO_CodingMP3; } else if (!strcmp((char*)pComponentRole->cRole, AUDIO_ENC_AAC_ROLE)) { omx_audioenc_component_Private->audio_coding_type = OMX_AUDIO_CodingAAC; } else { return OMX_ErrorBadParameter; } omx_audioenc_component_SetInternalParameters(openmaxStandComp); break; default: /*Call the base component function*/ return omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure); } return err; }