目前基于高通的code分析:
1. 引入libOmxCore.so
根据stagefright 架构分析(七) 动态加载libstagefrighthw.so中的描述
Plugin会加载libOmxCore.so,并调用相应的functions
OMX_Init
OMX_Deinit
OMX_ComponentNameEnum
OMX_GetHandle
OMX_FreeHandle
OMX_GetRolesOfComponent
2. libOmxCore.so 编译内容
LOCAL_SRC_FILES := src/common/omx_core_cmp.cpp
LOCAL_SRC_FILES += src/common/qc_omx_core.c
LOCAL_SRC_FILES += src/$(MM_CORE_TARGET)/qc_registry_table_android.c
3. Plugin调用functions
调用的functions在qc_omx_core.c实现QComOMXPlugin中通过dlsym得到的函数指针,是在qc_omx_core.c中实现的。
例如 mInit = (InitFunc)dlsym(mLibHandle, "OMX_Init");
(*mInit)();
最终调用的是
OMX_API OMX_ERRORTYPE OMX_APIENTRY
OMX_Init()
{
DEBUG_PRINT("OMXCORE API - OMX_Init \n");
/* Nothing to do here ; shared objects shall be loaded at the get handle method */
return OMX_ErrorNone;
}
4. OMX_COMPONENTTYPE interface
component interface在omx_core_cmp.cpp中实现:
具体看这个函数,就容易理解了
void * qc_omx_create_component_wrapper(OMX_PTR obj_ptr)
{
qc_omx_component *pThis = (qc_omx_component *)obj_ptr;
OMX_COMPONENTTYPE* component = &(pThis->m_cmp);
memset(&pThis->m_cmp,0,sizeof(OMX_COMPONENTTYPE));
component->nSize = sizeof(OMX_COMPONENTTYPE);
component->nVersion.nVersion = OMX_SPEC_VERSION;
component->pApplicationPrivate = 0;
component->pComponentPrivate = obj_ptr;
component->AllocateBuffer = &qc_omx_component_allocate_buffer;
component->FreeBuffer = &qc_omx_component_free_buffer;
component->GetParameter = &qc_omx_component_get_parameter;
component->SetParameter = &qc_omx_component_set_parameter;
component->SendCommand = &qc_omx_component_send_command;
component->FillThisBuffer = &qc_omx_component_fill_this_buffer;
component->EmptyThisBuffer = &qc_omx_component_empty_this_buffer;
component->GetState = &qc_omx_component_get_state;
component->GetComponentVersion = &qc_omx_component_get_version;
component->GetConfig = &qc_omx_component_get_config;
component->SetConfig = &qc_omx_component_set_config;
component->GetExtensi