stagefright框架(二)- 和OpenMAX的運作

Stagefright的編解碼功能是利用OpenMAX框架,而且用的還是OpenCORE之OMX的實作,我們來看一下Stagefright和OMX是如何運作的。

(1) OMX_Init

OMXClient mClient;

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元件的指令也和OMX_SendCommand的call path一樣,請見下表:

OMXCodec
OMX
OMXNodeInstance
 
useBuffer
useBuffer (OMX_UseBuffer)
 
getParameter

getParameter (OMX_GetParameter)

 
fillBuffer

fillBuffer (OMX_FillThisBuffer)

 
emptyBuffer

emptyBuffer (OMX_EmptyThisBuffer)












stagefright框架(二)- 和OpenMAX的運作_第1张图片


 (4) Callback Functions

OMX_CALLBACKTYPE OMXNodeInstance::kCallbacks =
{
  &OnEvent, <--------------- omx_message::EVENT
  &OnEmptyBufferDone, <----- omx_message::EMPTY_BUFFER_DONE
  &OnFillBufferDone <------- omx_message::FILL_BUFFER_DONE
}

你可能感兴趣的:(android,stagefright,OpenCore,OpenMax)