將codec集成到PV OpenCORE多媒體框架的方法有幾種:1)作為壓縮多媒體輸入輸出(MIO)組件,2)作為節點(diǎn)(node),3)作為OpenMAX組件集成到OpenMAX codecs節點(diǎn)中。許多codecs,特別是包含硬件加速器的codes都執行OpenMAX IL接口,并且將OpenMAX接口當成最簡(jiǎn)單的集成方法。
OpenCORE與OMX core/component的交互
1) OMX core初始化
PlayerDriver::playerThread()
->OMX_MasterInit() (pv_omxmastercore.cpp)
->_Try_OMX_MasterInit(error, status, data)
->_OMX_MasterInit(data) 執行所有的OpenMAX IL Core標準函數
->OMX_Init()
OMX_ComponentNameEnum()

l 利用OMX_GetHandle調用來(lái)實(shí)例化想要的OMX組件
l 利用OMX_GetParameter調用來(lái)獲取OMX組件的能力和OMX組件上可用端口的數量
l 遍歷可用的端口以查找輸入端口的索引
l 遍歷可用的端口以查找輸出端口的索引

OMX Component Instantiation through OMX_GetHandle
3) OMX component input and output buffer negotiation Before any data can be exchanged, parameters for input and output buffers need to be negotiated. To accomplish this, the PV framework: l 調用OMX_GetParameter來(lái)獲取input port buffer參數 l 核實(shí)(verify) input buffer參數的有效性 l 調用OMX_SetParameter來(lái)設置input buffer參數 l 調用OMX_GetParameter來(lái)獲取output port buffer參數 l 核實(shí)(verify) output buffer參數的有效性 The buffer allocation is handled as part of the allocation to the Idle state. During this transition, PV Framework: l 調用OMX_SendCommand向OMX組件發(fā)送命令以改變組件狀態(tài)(Loaded->Idel) l 調用OMX_UseBuffer或OMX_AllocateBuffer向OMX組件發(fā)送命令。The call is used NumInputBuffer times for input port, and NumOutputBuffer for output port. The transition to executing starts the active processing of data. In this step, PV Framework: l 調用OMX_SendCommand向OMX組件發(fā)送命令以改變組件狀態(tài)(Idle->Executing) l 等待EventHandler callback,組件的狀態(tài)轉換已完成 l 調用OMX_EmptyThisBuffer或OMX_FillThisBuffer向音頻組件發(fā)送input或output buffers。組件利用適當的callback返回buffers。 6) Pausing A common use-case involves pausing and resuming. In this case, the PV framework: l 調用OMX_SendCommand向OMX組件發(fā)送命令以改變組件狀態(tài)(Executing->Pause) l 等待EventHandler callback,組件的狀態(tài)轉換已完成 向OMX組件發(fā)送pause命令后,PV框架立即停止向OMX組件發(fā)送inpupt/output buffers。 l 調用OMX_SendCommand向OMX組件發(fā)送命令以改變組件狀態(tài)(Pause->Executing) l 等待EventHandler callback,組件的狀態(tài)轉換已完成 當接到callback組件狀態(tài)轉換成Executing后,PV框架可以恢復向組件發(fā)送OMX input/output buffers。 OMX component state transition from execute to pause and back 7) Port flush (if applicable) The port flush call is typically used with a decoder component during repositioning so that any queued data is discarded. In this situation, the PV framework: l 調用OMX_SendCommand向OMX組件發(fā)送命令flush所有ports。 l 等待兩個(gè)來(lái)自組件input和output ports的EventHandler callback,組件已完成ports flushing。 當發(fā)送flush命令后,PV框架立刻停止向OMX組件發(fā)送input/output buffers。當收到第二個(gè)callback后,PV框架可以恢復向組件發(fā)送input/output buffers。 OMX component port flush procedure 8) Stop/Transition to “Idle” state In order to stop processing, the PV framework: l 調用OMX_SendCommand向OMX組件發(fā)送命令以改變組件的狀態(tài)(Executing/Pause->Idle) l 等待EventHandler callback,組件的狀態(tài)轉換已完成 當接收到Idle狀態(tài)轉換命令完成的callback時(shí),PV框架認為所有的OMX輸入buffers和輸出buffers都已經(jīng)從OMX組件返回。 OMX component state transition from OMX_StateExecuting/Paused->OMX_StateIdle 9) OMX Component Transition from Idle->Loaded State and De-initialization 當結束與OMX組件的交互后,PV框架將: l 調用OMX_SendCommand向OMX組件發(fā)送命令以改變組件的狀態(tài)(Idle->Loaded) l 發(fā)起一系列的OMX_FreeBuffer調用 l 等待EventHandler callback,組件的狀態(tài)轉換已完成 l 向OMX Core發(fā)起OMX_FreeHandle調用以釋放組件的Handle 在發(fā)起狀態(tài)轉換命令之前,PV框架需要等待所有的輸入輸出buffers從OMX組件返回。 OMX component state transition from OMX_StateIdle->OMX_StateLoaded 10) OMX Core De-initialization PV框架簡(jiǎn)單地調用OMX_Deinit()。 






聯(lián)系客服