pv_omx_interface.cpp revision 83e8059707184ea765b91054daf3c07e304c4d0c
1/* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13 * express or implied.
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
17 */
18#include "pvlogger.h"
19
20#include "pv_omxcore.h"
21#include "omx_interface.h"
22
23class PVOMXInterface : public OMXInterface
24{
25    public:
26        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
27        {
28            if (aInterfaceId == OMX_INTERFACE_ID)
29            {
30                // the library lookup was successful
31                return this;
32            }
33            // the ID doesn't match
34            return NULL;
35        };
36
37        static PVOMXInterface* Instance()
38        {
39            return OSCL_NEW(PVOMXInterface, ());
40        };
41
42        bool UnloadWhenNotUsed(void)
43        {
44            // As of 9/22/08, the PV OMX core library can not be
45            // safely unloaded and reloaded when the proxy interface
46            // is enabled.
47            return false;
48        };
49
50    private:
51
52        PVOMXInterface()
53        {
54            // set the pointers to the omx core methods
55            pOMX_Init = OMX_Init;
56            pOMX_Deinit = OMX_Deinit;
57            pOMX_ComponentNameEnum = OMX_ComponentNameEnum;
58            pOMX_GetHandle = OMX_GetHandle;
59            pOMX_FreeHandle = OMX_FreeHandle;
60            pOMX_GetComponentsOfRole = OMX_GetComponentsOfRole;
61            pOMX_GetRolesOfComponent = OMX_GetRolesOfComponent;
62            pOMX_SetupTunnel = OMX_SetupTunnel;
63            pOMX_GetContentPipe = OMX_GetContentPipe;
64            //pOMXConfigParser = OMXConfigParser;
65        };
66
67};
68
69// function to obtain the interface object from the shared library
70extern "C"
71{
72    OSCL_EXPORT_REF OsclAny* PVGetInterface()
73    {
74        return PVOMXInterface::Instance();
75    }
76    OSCL_EXPORT_REF void PVReleaseInterface(void* aInterface)
77    {
78        PVOMXInterface* pInterface = (PVOMXInterface*)aInterface;
79        if (pInterface)
80        {
81            OSCL_DELETE(pInterface);
82        }
83    }
84
85}
86