OpenMax Componet 类的继承关系

OpenCORE里继承一个新的codec时,需要用到OpenMAX接口规范对该codec进行封装,即要定义一个用于封装的类(wrapper),实现OpenMAX规定的集中核心方法(omx core methods)。若该codec是一个音频解码器,则该类继承OmxComponentAudio类;若是视频解码器,则继承OmxComponentVideo类。而OmxComponentAudioOmxComponentVideo类都是继承了OmxComponentBase类;OmxComponentBase类又继承自OsclActiveObject类。

 

为了深入点理解每OMX Component每个接口(core methods)具体要实现些什么功能,我们逐一深入这些相关的类的定义中。

 

1OsclActiveObject

该类的定义在.../opencore/oscl/oscl/osclproc/src/oscl_scheduler_ao.h文件中。看给类的注释:

 

 

即该类是用于执行(或运行)对象的用户基础类,该运行对象没有计时器。 这个正在运行的对象(AO)可以在多个线程间被使用,如在一个线程中的请求可以在另一个线程中完成。

 

OsclActiveObject类又继承自两个类:HeapBasePVActiveBase类,其中类HeapBase是用于基础的堆操作,如分配、释放内存等。类PVActiveBase主要是跟线程相关的(PV Scheduler internal AO base class)

 

OsclActiveObject类主要是定义了对象运行的相关操作,如优先级、对象状态等。

 

2OmxComponentBase

其中一些接口涉及到proxy(代理??),不知道具体什么差别!!!

 

……

 

……

接着是最重要的部分,

 

        

        //Pure virtual functions, definition to be written in derived class

        

        virtual OMX_ERRORTYPE GetParameter(

            OMX_IN  OMX_HANDLETYPE hComponent,

            OMX_IN  OMX_INDEXTYPE nParamIndex,

            OMX_INOUT OMX_PTR ComponentParameterStructure) = 0;

 

        virtual OMX_ERRORTYPE SetParameter(

            OMX_IN  OMX_HANDLETYPE hComponent,

            OMX_IN  OMX_INDEXTYPE nParamIndex,

            OMX_IN  OMX_PTR ComponentParameterStructure) = 0;

 

        virtual OSCL_IMPORT_REF OMX_ERRORTYPE GetConfig(

            OMX_IN  OMX_HANDLETYPE hComponent,

            OMX_IN  OMX_INDEXTYPE nIndex,

            OMX_INOUT OMX_PTR pComponentConfigStructure);

 

        //Making Setconfig as virtual function to be implemented in respective component class

// 在各个派生的component中各自实现该函数

        virtual OSCL_IMPORT_REF OMX_ERRORTYPE SetConfig(

            OMX_IN  OMX_HANDLETYPE hComponent,

            OMX_IN  OMX_INDEXTYPE nIndex,

            OMX_IN  OMX_PTR pComponentConfigStructure);

 

……

 

        

 

        //Pure virtual function called from base, must have a definition in derived components

        //virtual void Decode() = 0;

        

        virtual void ProcessData() = 0;

……

     

        virtual OMX_ERRORTYPE ComponentInit() = 0;

        virtual OMX_ERRORTYPE ComponentDeInit() = 0;

……

 

这些接口是每一个OMX component都必须实现的函数(core methods),其中最重要的5种方法:

(1) ComponentInit()

(2) ComponentDeinit()

(3) GetParameter()

(4) SetParameter()

(5) ProcessData()

 

3OmxComponentAudio

每个音频解码器组件都必须继承的类,其中GetParameter()SetParameter()方法在该类中实现,其余方法在最终派生的component类中实现。

 

class OmxComponentAudio : public OmxComponentBase

{

    public:

        OSCL_IMPORT_REF OmxComponentAudio();

        OSCL_IMPORT_REF virtual ~OmxComponentAudio();

 

        OSCL_IMPORT_REF OMX_ERRORTYPE GetParameter(

            OMX_IN  OMX_HANDLETYPE hComponent,

            OMX_IN  OMX_INDEXTYPE nParamIndex,

            OMX_INOUT OMX_PTR ComponentParameterStructure);

 

        OSCL_IMPORT_REF OMX_ERRORTYPE SetParameter(

            OMX_IN  OMX_HANDLETYPE hComponent,

            OMX_IN  OMX_INDEXTYPE nParamIndex,

            OMX_IN  OMX_PTR ComponentParameterStructure);

 

        virtual void UpdateAACPlusFlag(OMX_BOOL aAacPlusFlag)

        {

            OSCL_UNUSED_ARG(aAacPlusFlag);

        }

 

        OSCL_IMPORT_REF virtual void CalculateBufferParameters(OMX_U32 PortIndex);

};

 

注意:

OmxComponentBase类继承来的其他虚函数,如ComponentInit(), ComponentDeinit(), ProcessData()等在这还没有具体实现。

 

【进一步分析GetParameter()SetParameter()函数!!!!】

 

4OmxComponentVideo

 

class OmxComponentVideo : public OmxComponentBase

{

    public:

        OSCL_IMPORT_REF OmxComponentVideo();

        OSCL_IMPORT_REF virtual ~OmxComponentVideo();

 

        OSCL_IMPORT_REF OMX_ERRORTYPE GetParameter(

            OMX_IN  OMX_HANDLETYPE hComponent,

            OMX_IN  OMX_INDEXTYPE nParamIndex,

            OMX_INOUT OMX_PTR ComponentParameterStructure);

 

        OSCL_IMPORT_REF OMX_ERRORTYPE SetParameter(

            OMX_IN  OMX_HANDLETYPE hComponent,

            OMX_IN  OMX_INDEXTYPE nParamIndex,

            OMX_IN  OMX_PTR ComponentParameterStructure);

 

        OSCL_IMPORT_REF virtual void CalculateBufferParameters(OMX_U32 PortIndex);

};

 

OmxComponentVideo类中也是把从OmxComponentBase类中继承来的虚函数GetParameter()SetParameter()函数做了实现。

 

5OpenmaxMp3AO

该类是对MP3解码器按照openmax接口规范进行封装的类,以便作为一个音频解码的component集成进opencore框架中。

 

 

class OpenmaxMp3AO : public OmxComponentAudio

{

    public:

 

        OpenmaxMp3AO();

        ~OpenmaxMp3AO();

 

        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy);

        OMX_ERRORTYPE DestroyComponent();

 

        OMX_ERRORTYPE ComponentInit(); // 继承自OmxComponentAudio

        OMX_ERRORTYPE ComponentDeInit(); // 继承自OmxComponentAudio

 

        void ProcessData(); // 继承自OmxComponentAudio

        void SyncWithInputTimestamp(); // 继承自OmxComponentAudio

        void ProcessInBufferFlag(); // 继承自OmxComponentBase

 

        void ResetComponent(); // 继承自OmxComponentBase

        OMX_ERRORTYPE GetConfig( // 覆盖掉OmxComponentAudio中的实现

            OMX_IN  OMX_HANDLETYPE hComponent,

            OMX_IN  OMX_INDEXTYPE nIndex,

            OMX_INOUT OMX_PTR pComponentConfigStructure);

 

    private:

 

        void CheckForSilenceInsertion();

        void DoSilenceInsertion();

 

        Mp3Decoder*      ipMp3Dec; // 看具体实现!!!

        Mp3TimeStampCalc iCurrentFrameTS;

};

 

 

6OpenmaxAvcAO

该类是对H264解码器按照openmax接口规范进行封装的类,以便作为一个视频解码的component集成进opencore框架中。

 

class OpenmaxAvcAO : public OmxComponentVideo

{

    public:

        OpenmaxAvcAO();

        ~OpenmaxAvcAO();

 

        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy);

        OMX_ERRORTYPE DestroyComponent();

 

        OMX_ERRORTYPE ComponentInit();

        OMX_ERRORTYPE ComponentDeInit();

 

        void ComponentBufferMgmtWithoutMarker();

        OMX_BOOL ParseFullAVCFramesIntoNALs(OMX_BUFFERHEADERTYPE* aInputBuffer);

        void ProcessData();

        void DecodeWithoutMarker();

        void DecodeWithMarker();

        void ResetComponent();

        void ReleaseReferenceBuffers();

 

 

        OMX_ERRORTYPE GetConfig( // 覆盖继承类中的实现

            OMX_IN  OMX_HANDLETYPE hComponent,

            OMX_IN  OMX_INDEXTYPE nIndex,

            OMX_INOUT OMX_PTR pComponentConfigStructure);

 

        OMX_BOOL DetectStartCodeLength(OMX_U8* aBitstream,

                                       OMX_U8** aNalUnit,

                                       OMX_U32 aBufSize,

                                       OMX_U32* aSCSize);

 

        // ipOutputBuffer is fed to the decoder which may keep it as a reference

        // The decoder "spits" out another output buffer for rendering

        OMX_BUFFERHEADERTYPE *ipOutputBufferForRendering;

 

    private:

        AvcDecoder_OMX* ipAvcDec;

        OMX_BOOL        iDecodeReturn;

        OMX_BOOL        iFlushOutputStatus;

 

        // variables for "frame" mode i.e. iOMXComponentNeedsFullAVCFrames is turned on

        OMX_U32 iNALSizeArray[MAX_NAL_PER_FRAME]; // 100 should be more than enough NALs per frame

        OMX_U32 iNALStartCodeSizeArray[MAX_NAL_PER_FRAME]; // 100 should be more than enough NALs per frame

        OMX_U32 iCurrNAL;

        OMX_U32 iNumNALs;

        OMX_U32 iNALOffset;

        OMX_U32 iSizeOfNALSize;

};


你可能感兴趣的:(框架,import,wrapper,Codec)