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
19/* Contains changes by Wind River Systems, 2009-2010 */
20
21#include "pvlogger.h"
22
23#include "pv_omxcore.h"
24#include "omx_interface.h"
25#include "intel_omx_config_parser.h"
26
27
28
29class PVOMXInterface : public OMXInterface
30{
31    public:
32        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
33        {
34            if (aInterfaceId == OMX_INTERFACE_ID)
35            {
36                // the library lookup was successful
37                return this;
38            }
39            // the ID doesn't match
40            return NULL;
41        };
42
43        static PVOMXInterface* Instance()
44        {
45            return OSCL_NEW(PVOMXInterface, ());
46        };
47
48        bool UnloadWhenNotUsed(void)
49        {
50            // As of 9/22/08, the PV OMX core library can not be
51            // safely unloaded and reloaded when the proxy interface
52            // is enabled.
53            return false;
54        };
55
56    private:
57
58        PVOMXInterface()
59        {
60            // set the pointers to the omx core methods
61            pOMX_Init = OMX_Init;
62            pOMX_Deinit = OMX_Deinit;
63            pOMX_ComponentNameEnum = OMX_ComponentNameEnum;
64            pOMX_GetHandle = OMX_GetHandle;
65            pOMX_FreeHandle = OMX_FreeHandle;
66            pOMX_GetComponentsOfRole = OMX_GetComponentsOfRole;
67            pOMX_GetRolesOfComponent = OMX_GetRolesOfComponent;
68            pOMX_GetContentPipe = OMX_GetContentPipe;
69            pOMXConfigParser = Intel_OMXConfigParser;
70        };
71
72};
73
74// function to obtain the interface object from the shared library
75extern "C"
76{
77    OSCL_EXPORT_REF OsclAny* PVGetInterface()
78    {
79        return PVOMXInterface::Instance();
80    }
81    OSCL_EXPORT_REF void PVReleaseInterface(void* interface)
82    {
83        PVOMXInterface* pInterface = (PVOMXInterface*)interface;
84        if (pInterface)
85        {
86            OSCL_DELETE(pInterface);
87        }
88    }
89}
90