在Stagefright中的编解码功能还是利用openMAX框架,接下来分析一下在StageFright中OMX是如何运用的。
(1)OMX_Init openMAX的初始化。
AwesomePlayer::AwesomePlayer(){
mClient.connect();
}
status_t OMXClient::connect()
{
mOMX = service->getOMX();
}
sp<IOMX> MediaPlayerService::getOMX()
{
mOMX = new OMX;
}
OMX::OMX() : mMaster(new OMXMaster)
OMXMaster::OMXMaster()
{
addPlugin(new OMXPVCodecsPlugin);
}
OMXPVCodecsPlugin::OMXPVCodecsPlugin()
{
OMX_MasterInit();
}
OMX_ERRORTYPE OMX_MasterInit() <-- under OpenCORE
{
return OMX_Init();
}
(2)OMX_SendCommand
OMXCodec::function_name(){
mOMX->sendCommand(mNode, OMX_CommandStateSet, OMX_StateIdle);
}
status_t OMX::sendCommand(node, cmd, param)
{
return findInstance(node)->sendCommand(cmd, param);
}
status_t OMXNodeInstance::sendCommand(cmd, param)
{
OMX_SendCommand(mHandle, cmd, param, NULL);
}
(3)其他作用在OMX元件的指令
OMX | OMXNodeInstance | |
useBuffer | useBuffer (OMX_UseBuffer) | |
getParameter | getParameter (OMX_GetParameter) | |
fillBuffer | fillBuffer (OMX_FillThisBuffer) | |
emptyBuffer | emptyBuffer (OMX_EmptyThisBuffer |
(4) Callback Functions回调函数。
OMX_CALLBACKTYPE OMXNodeInstance::kCallbacks =
{
&OnEvent, <--------------- omx_message::EVENT
&OnEmptyBufferDone, <----- omx_message::EMPTY_BUFFER_DONE
&OnFillBufferDone <------- omx_message::FILL_BUFFER_DONE
}