stagefright 架构分析(八) 如何获取ComponentHandle,plugin与omx_core桥接

本文详细介绍了在Stagefright框架中,Plugin如何加载libOmxCore.so并调用其函数,特别是如何通过OMX_GetHandle获取ComponentHandle。内容包括libOmxCore.so的编译、Plugin调用流程、OMX_COMPONENTTYPE接口的实现,以及ComponentHandle的获取和根据ComponentName查找对应handle的过程。
摘要由CSDN通过智能技术生成

目前基于高通的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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值