OpenMax IL: component 概述

 OpenMax IL 有四個部分組成:        

 客戶端(Client)OpenMax IL的調用者

 組件(Component)OpenMax IL的單元,每一個組件實現一種功能

 端口(Port):組件的輸入輸出接口

 隧道化(Tunneled):讓兩個組件直接連接的方式

OpenMax IL 中重要的組成部分是componentcomponentOpenMax IL實現的核心內容,一個組件以輸入、輸出端口爲接口,端口可以被連接到另一個組件上。外部對組件可以發送命令,還進行設置/獲取參數、配置等內容。component的端口可以包含緩衝區(Buffer)的隊列。

OpenMAL IL的客戶端,通過調用四個OpenMAL IL組件,實現了一個功能。四個組件分別是Source組件、Host組件、Accelerator組件和Sink組件。Source組件只有一個輸出端口;Host組件有一個輸入端口和一個輸出端口;Accelerator組件具有一個輸入端口,調用了硬件的編解碼器,加速主要體現在這個環節上。Accelerator組件和Sink組件通過私有通訊方式在內部進行連接,沒有經過明確的組件端口。如下圖

 

組件的處理的核心內容是:通過輸入端口消耗Buffer,通過輸出端口填充Buffer,由此多組件相聯接可以構成流式的處理。

 

component state有如下,具體定義在OMX_Core.h

framework/base/include/media/libstagefright/openmax/OMX_Core.h

typedef enum OMX_STATETYPE

{

    OMX_StateInvalid,      /**< component has detected that it's internal data

                                structures are corrupted to the point that

                                it cannot determine it's state properly */

    OMX_StateLoaded,      /**< component has been loaded but has not completed

                                initialization.  The OMX_SetParameter macro

                                and the OMX_GetParameter macro are the only

                                valid macros allowed to be sent to the

                                component in this state. */

    OMX_StateIdle,        /**< component initialization has been completed

                                successfully and the component is ready to

                                to start. */

    OMX_StateExecuting,   /**< component has accepted the start command and

                                is processing data (if data is available) */

    OMX_StatePause,       /**< component has received pause command */

    OMX_StateWaitForResources, /**< component is waiting for resources, either after

                                preemption or before it gets the resources requested.

                                See specification for complete details. */

    OMX_StateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */

    OMX_StateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */

    OMX_StateMax = 0X7FFFFFFF

} OMX_STATETYPE;

 

componentLOADER狀態下,只能建立它本身一些屬性和配置信息,客戶端能做什麼呢?客戶端可以發*  SetParameters/GetParameters and SetConfig/GetConfig這些commandcomponent,以便以後component記錄下這些parameterconfiguration的變化。在IDLE狀態下,就可以分得buffer之類的資源,但是不能操作這些buffer直到component處於Executing狀態下。

component state 如何轉換呢?

一般change state可以通過OMX_SendCommand的方式通知給component,格式如下:

OMX_SendCommand(  hComponent, Cmd,mParam,pCmdData)

hComponent:執行該commandcomponent

Cmd:component執行的command        

mParam:執行command的一些參數值

如客戶端發給componentmOMX->sendCommand(mNode, OMX_CommandStateSet, OMX_StateIdle);

 

說到command 那就列舉下有哪些command吧:

coder在如下路徑

framework/base/include/media/libstagefright/openmax/OMX_Core.h

typedef enum OMX_COMMANDTYPE

{

    OMX_CommandStateSet,    /**< Change the component state */

    OMX_CommandFlush,       /**< Flush the data queue(s) of a component */

    OMX_CommandPortDisable, /**< Disable a port on a component. */

    OMX_CommandPortEnable,  /**< Enable a port on a component. */

    OMX_CommandMarkBuffer,  /**< Mark a component/buffer for observation */

    OMX_CommandKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */

    OMX_CommandVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */

    OMX_CommandMax = 0X7FFFFFFF

} OMX_COMMANDTYPE;

具體command如何傳到component,可以參考本博的OMXCodec與OMX事件處理流程

http://blog.csdn.net/tjy1985/article/details/7397752

 

發佈了32 篇原創文章 · 獲贊 59 · 訪問量 44萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章