Openmax 一些函数的简单介绍

OMX_Init()

没有什么好说的,初始化函数,一定要运行的.

 

OMX_GetHandle

得到某一个组件的句柄

OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle(
    OMX_OUT OMX_HANDLETYPE* pHandle,
    OMX_IN  OMX_STRING cComponentName,
    OMX_IN  OMX_PTR pAppData,
    OMX_IN  OMX_CALLBACKTYPE* pCallBacks);

 

OMX_GetExtensionIndex

除了标准OMX_INDEXTYPE中定义的以外,返回用户自定义的一些参数(第二个参数)对应的index(第三个参数,用在OMX_SetParameter...里面),用来configur或者parameter.

这些参数往往被定义在用户特殊的extension interface里面

 

#define OMX_GetExtensionIndex(                              /
        hComponent,                                         /
        cParameterName,                                     /
        pIndexType)                                         /
    ((OMX_COMPONENTTYPE*)hComponent)->GetExtensionIndex(    /
        hComponent,                                         /
        cParameterName,                                     /
        pIndexType)                     /* Macro End */

 

 

 

OMX_SetParameter

设定某个参数对应的值

#define OMX_SetParameter(                                   /
        hComponent,                                         /
        nParamIndex,                                        /
        pComponentParameterStructure)                        /
    ((OMX_COMPONENTTYPE*)hComponent)->SetParameter(         /
        hComponent,                                         /
        nParamIndex,                                        /
        pComponentParameterStructure)    /* Macro End */

 

 

 

OMX_SetConfig

设定某个config值

#define OMX_SetConfig(                                      /
        hComponent,                                         /
        nConfigIndex,                                       /
        pComponentConfigStructure)                           /
    ((OMX_COMPONENTTYPE*)hComponent)->SetConfig(            /
        hComponent,                                         /
        nConfigIndex,                                       /
        pComponentConfigStructure)       /* Macro End */

 

注意有时候,需要先停止某个组件(的某些端口),才能设置config 成功

 

OMX_SendCommand

 

一般的命令有:

OMX_CommandStateSet 、OMX_CommandFlush、OMX_CommandPortDisable" 、 "OMX_CommandPortEnable、CommandMarkBuffer

 

#define OMX_SendCommand(                                    /
         hComponent,                                        /
         Cmd,                                               /
         nParam,                                            /
         pCmdData)                                          /
     ((OMX_COMPONENTTYPE*)hComponent)->SendCommand(         /
         hComponent,                                        /
         Cmd,                                               /
         nParam,                                            /
         pCmdData)                          /* Macro End */

 

 例子:OMXSAFE(OMX_SendCommand(vrenderer, OMX_CommandPortEnable, 1, 0)); // 停下1对应的端口

 

OMX_SetupTunnel

将两个组件连接起来,实际会引起调用每个组件的ComponentTunnelRequest

 

OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_SetupTunnel(
    OMX_IN  OMX_HANDLETYPE hOutput,
    OMX_IN  OMX_U32 nPortOutput,
    OMX_IN  OMX_HANDLETYPE hInput,
    OMX_IN  OMX_U32 nPortInput);

 

例子:

OMXSAFE(OMX_SetupTunnel(reader,   0, vdecoder,  0)); // reader的0端口为出,vdecoder的0端口为入,连接成一个Tunnel

 

 

准备好后,就可以设置OMX_StateExecuting,来让这个流程活动起来了。

 

再以后,就可以通过OMX_StateIdle 来停下。

 

 

OMX_GetState

 

#define OMX_GetState(                                       /
        hComponent,                                         /
        pState)                                             /
    ((OMX_COMPONENTTYPE*)hComponent)->GetState(             /
        hComponent,                                         /
        pState)                         /* Macro End */

 

 

 

 

 一些新补充:

 

1:

OMX_PARAM_PORTDEFINITIONTYPE decOutputPortDef;

   INIT_PARAM(decOutputPortDef);
    decOutputPortDef.nPortIndex = 0;

    err = OMX_GetParameter(pCtx->hReaderComp,
                           OMX_IndexParamPortDefinition,
                           &decOutputPortDef); // 利用IndexParamPortDefinition来得到组件的输出端口的属性

 

    videoWidth = decOutputPortDef.format.video.nFrameWidth; 
    videoHeight = decOutputPortDef.format.video.nFrameHeight;

 

2:OMX_BUFFERHEADERTYPE *pOmxBufferHeader ;

// tell decoder output port that it will be using our buffer

        err = OMX_UseBuffer(hDecodeComp,
                            &pOmxBufferHeader,  //out
                            OMX_DECODE_OUTPUT_PORT,
                            NULL,
                            outSize,
                            (NvU8*)pOut);

 

 将分配好的pOut指针和他的大小outSize,配成一个OMX_BUF, 并给pOmxBufferHeader,这样就通过OMX_UseBuffer,来得到一个以后能给他用的Buffer,指针用我们分配的。

 

3:

 

 OMXErr = OMX_FillThisBuffer(hDecodeComp, pOmxBufferHeader);

 

让hDecodeComp将pOmxBufferHeader的数据准备好(就是输出数据),pOmxBufferHeader就是通过UseBuffer来组装的。

 

通过nFilledLen,可以得到具体数据填充情况。

如果OMX_FillThisBuffer是异步函数的话,那真正的返回是要靠:Callback_FillBufferDone 来设置真正数据ready信号

 

 

4:

 

 

 

 

 

 

 

你可能感兴趣的:(cmd,buffer,callback,interface,extension,output)