软解码节点的创建和调用

来源:互联网 发布:大数据 项目需求分析 编辑:程序博客网 时间:2024/06/01 09:42

  android多媒体框架中,SoftOMXPlugin用来添加和解码节点,用简单的创建流程说明:

1.struct SoftOMXPlugin:public OMXPluginBse{

    makeComponentInstance()

   {

    dlopen("libstagefright_soft_xxx");//必须按照此标准

    dlsym("SoftOMXComponent"); //此函数创建解码类

  }

};

2. OMXMaster.cpp:: addPlugin(new SoftOMXPlugin);//添加到mPluginByComponentName中

3. OMX.cpp::mMaster(new OMXMaster);

4. MediaPlayerService.cpp::getOMX(){ mOMX = new OMX; }

调用过程:

1. awesomeplayer.cpp::initVideoDecoder()

    {

        mVideoSource = OMXCodec::Create(,mClient.interface, ); // OMXClient mClient;

    }

2. class OMXClient{

public:

    status_t connect()

    {

        sp<IServiceManager> sm = defaultServiceManager();

        sp<IBiner> binder = sm->getService(String16("media.player"));

        sp<IMediaPlayerService> service = interface_caset<IMediaPlayerService>(binder);

        mOMX = service->getOMX();

    }

    sp<IOMX> interface(){ return mOMX; }

private:

    sp<IOMX> mOMX;

};

3. OMXCodec.cpp::create()

    {

        omx->allocateNode();

    }

4. OMX.cpp::allocateNode()

    {

        mMaster->makeComponentInstance(); //mMaster(new OMXMaster);

    }

5. OMXMaster.cpp::makeComponentInstance()

    {

        OMXPluginBase *plugin = mPluginByComponentName.valueAt(index);

        plugin->makeComponentInstance();//调用的是SoftOMXPlugin.cpp

    }

两个重要的基类OMXPluginBase.cpp(调用者)和SimpleSoftOMXComponent.cpp(解码节点)

其中struct SimpleSoftOMXComponent: public SoftOMXComponent

例如:

struct SoftFFmpegVideo: public SimpleSoftOMXComponent{

protected:

    virtual void onQueueFilled(OMX_U32 portIndex);

   xxxx

};

android::SoftOMXComponent *createSoftOMXComponent(const char *name, const OMX_CALLBACKTYPE *callbacks,

                      OMX_PTR appData, OMX_COMPONENTTYPE **component ){

            return new android::SoftFFmpegVideo(name, callbacks, appData, component);

} //实现上述类并被plugin调用

SoftFFmpegVideo.cpp如果想作为plugin添加到以上的流程中,需要编译成libstagefright_soft_ffmpegvdec.so
0 0