將codec集成到PV OpenCORE多媒體框架的方法有幾種:1)作為壓縮多媒體輸入輸出(MIO)組件,2)作為節(jié)點(node),3)作為OpenMAX組件集成到OpenMAX codecs節(jié)點中。許多codecs,特別是包含硬件加速器的codes都執(zhí)行OpenMAX IL接口,并且將OpenMAX接口當(dāng)成最簡單的集成方法。
OpenCORE與OMX core/component的交互
1) OMX core初始化
PlayerDriver::playerThread()
->OMX_MasterInit() (pv_omxmastercore.cpp)
->_Try_OMX_MasterInit(error, status, data)
->_OMX_MasterInit(data) 執(zhí)行所有的OpenMAX IL Core標(biāo)準(zhǔn)函數(shù)
->OMX_Init()
OMX_ComponentNameEnum()
l 利用OMX_GetHandle調(diào)用來實例化想要的OMX組件
l 利用OMX_GetParameter調(diào)用來獲取OMX組件的能力和OMX組件上可用端口的數(shù)量
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 調(diào)用OMX_GetParameter來獲取input port buffer參數(shù) l 核實(verify) input buffer參數(shù)的有效性 l 調(diào)用OMX_SetParameter來設(shè)置input buffer參數(shù) l 調(diào)用OMX_GetParameter來獲取output port buffer參數(shù) l 核實(verify) output buffer參數(shù)的有效性 The buffer allocation is handled as part of the allocation to the Idle state. During this transition, PV Framework: l 調(diào)用OMX_SendCommand向OMX組件發(fā)送命令以改變組件狀態(tài)(Loaded->Idel) l 調(diào)用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 調(diào)用OMX_SendCommand向OMX組件發(fā)送命令以改變組件狀態(tài)(Idle->Executing) l 等待EventHandler callback,組件的狀態(tài)轉(zhuǎn)換已完成 l 調(diào)用OMX_EmptyThisBuffer或OMX_FillThisBuffer向音頻組件發(fā)送input或output buffers。組件利用適當(dāng)?shù)?/span>callback返回buffers。 6) Pausing A common use-case involves pausing and resuming. In this case, the PV framework: l 調(diào)用OMX_SendCommand向OMX組件發(fā)送命令以改變組件狀態(tài)(Executing->Pause) l 等待EventHandler callback,組件的狀態(tài)轉(zhuǎn)換已完成 向OMX組件發(fā)送pause命令后,PV框架立即停止向OMX組件發(fā)送inpupt/output buffers。 l 調(diào)用OMX_SendCommand向OMX組件發(fā)送命令以改變組件狀態(tài)(Pause->Executing) l 等待EventHandler callback,組件的狀態(tài)轉(zhuǎn)換已完成 當(dāng)接到callback組件狀態(tài)轉(zhuǎn)換成Executing后,PV框架可以恢復(fù)向組件發(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 調(diào)用OMX_SendCommand向OMX組件發(fā)送命令flush所有ports。 l 等待兩個來自組件input和output ports的EventHandler callback,組件已完成ports flushing。 當(dāng)發(fā)送flush命令后,PV框架立刻停止向OMX組件發(fā)送input/output buffers。當(dāng)收到第二個callback后,PV框架可以恢復(fù)向組件發(fā)送input/output buffers。 OMX component port flush procedure 8) Stop/Transition to “Idle” state In order to stop processing, the PV framework: l 調(diào)用OMX_SendCommand向OMX組件發(fā)送命令以改變組件的狀態(tài)(Executing/Pause->Idle) l 等待EventHandler callback,組件的狀態(tài)轉(zhuǎn)換已完成 當(dāng)接收到Idle狀態(tài)轉(zhuǎn)換命令完成的callback時,PV框架認(rèn)為所有的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 當(dāng)結(jié)束與OMX組件的交互后,PV框架將: l 調(diào)用OMX_SendCommand向OMX組件發(fā)送命令以改變組件的狀態(tài)(Idle->Loaded) l 發(fā)起一系列的OMX_FreeBuffer調(diào)用 l 等待EventHandler callback,組件的狀態(tài)轉(zhuǎn)換已完成 l 向OMX Core發(fā)起OMX_FreeHandle調(diào)用以釋放組件的Handle 在發(fā)起狀態(tài)轉(zhuǎn)換命令之前,PV框架需要等待所有的輸入輸出buffers從OMX組件返回。 OMX component state transition from OMX_StateIdle->OMX_StateLoaded 10) OMX Core De-initialization PV框架簡單地調(diào)用OMX_Deinit()。