本文译自PV OpenCORE官方文档《OpenMAX Call Sequences: OHA2.1 rev.1Feb 25, 2009》。
将codec集成到PV OpenCORE多媒体框架的方法有几种:1)作为压缩多媒体输入输出(MIO)组件,2)作为节点(node),3)作为OpenMAX组件集成到OpenMAX codecs节点中。许多codecs,特别是包含硬件加速器的codes都执行OpenMAX IL接口,并且将OpenMAX接口当成最简单的集成方法。
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()
OMX_GetRolesOfComponent()
OMXCore Initialization
2)OMX Componentinstantiation, capabilities and port indices
After the OMX Core isinitialized, the next step is typically to instantiate a specific component andenumerate capabilities and port indices. The PV framework will:
l 利用OMX_GetHandle调用来实例化想要的OMX组件
l 利用OMX_GetParameter调用来获取OMX组件的能力和OMX组件上可用端口的数量
l 遍历可用的端口以查找输入端口的索引
l 遍历可用的端口以查找输出端口的索引
OMXComponent Instantiation through OMX_GetHandle
3)OMX componentinput and output buffer negotiation
Before any data can beexchanged, parameters for input and output buffers need to be negotiated. Toaccomplish this, the PV framework:
l 调用OMX_GetParameter来获取input port buffer参数
l 核实(verify) input buffer参数的有效性
l 调用OMX_SetParameter来设置input buffer参数
l 调用OMX_GetParameter来获取output port buffer参数
l 核实(verify) output buffer参数的有效性
l 调用OMX_SetParameter来设置output buffer参数
OMXComponent Buffer Negotiation
4)OMXTransition Loaded->Idel State
The buffer allocation ishandled as part of the allocation to the Idle state. During this transition, PVFramework:
l 调用OMX_SendCommand向OMX组件发送命令以改变组件状态(Loaded->Idel)
l 调用OMX_UseBuffer或OMX_AllocateBuffer向OMX组件发送命令。The call isused NumInputBuffer times for input port, and NumOutputBuffer for output port.
l 等待组件的EventHandler回调。这个callback通知框架组件的状态转换已经完成。
OMXComponent state transition from OMX_StateLoaded->OMX_StateIdle
5)Transition to“Executing”state and data exchange
The transition toexecuting starts the active processing of data. In this step, PV Framework:
l 调用OMX_SendCommand向OMX组件发送命令以改变组件状态(Idle->Executing)
l 等待EventHandler callback,组件的状态转换已完成
l 调用OMX_EmptyThisBuffer或OMX_FillThisBuffer向音频组件发送input或output buffers。组件利用适当的callback返回buffers。
OMXcomponent state transition from idle to execute and data exchange
6)Pausing
A common use-caseinvolves pausing and resuming. In this case, the PV framework:
l 调用OMX_SendCommand向OMX组件发送命令以改变组件状态(Executing->Pause)
l 等待EventHandler callback,组件的状态转换已完成
向OMX组件发送pause命令后,PV框架立即停止向OMX组件发送inpupt/output buffers。
In order to resume, thePV framework:
l 调用OMX_SendCommand向OMX组件发送命令以改变组件状态(Pause->Executing)
l 等待EventHandler callback,组件的状态转换已完成
当接到callback组件状态转换成Executing后,PV框架可以恢复向组件发送OMXinput/output buffers。
OMXcomponent state transition from execute to pause and back
7)Port flush(if applicable)
The port flush call istypically used with a decoder component during repositioning so that any queueddata is discarded. In this situation, the PV framework:
l 调用OMX_SendCommand向OMX组件发送命令flush所有ports。
l 等待两个来自组件input和output ports的EventHandler callback,组件已完成portsflushing。
当发送flush命令后,PV框架立刻停止向OMX组件发送input/output buffers。当收到第二个callback后,PV框架可以恢复向组件发送input/output buffers。
OMXcomponent port flush procedure
8)Stop/Transitionto “Idle” state
In order to stopprocessing, the PV framework:
l 调用OMX_SendCommand向OMX组件发送命令以改变组件的状态(Executing/Pause->Idle)
l 等待EventHandler callback,组件的状态转换已完成
当接收到Idle状态转换命令完成的callback时,PV框架认为所有的OMX输入buffers和输出buffers都已经从OMX组件返回。
OMXcomponent state transition from OMX_StateExecuting/Paused->OMX_StateIdle
9)OMX ComponentTransition from Idle->Loaded State and De-initialization
当结束与OMX组件的交互后,PV框架将:
l 调用OMX_SendCommand向OMX组件发送命令以改变组件的状态(Idle->Loaded)
l 发起一系列的OMX_FreeBuffer调用
l 等待EventHandler callback,组件的状态转换已完成
l 向OMX Core发起OMX_FreeHandle调用以释放组件的Handle
在发起状态转换命令之前,PV框架需要等待所有的输入输出buffers从OMX组件返回。
OMXcomponent state transition from OMX_StateIdle->OMX_StateLoaded
10) OMX CoreDe-initialization
PV框架简单地调用OMX_Deinit()。