1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
#define LOG_TAG "omx_interface"
#include <utils/Log.h>
#include "pvlogger.h"
#include "pv_omxcore.h"
#include "omx_interface.h"
// this is the name of the original SO that contains your OMX core
#define OMX_CORE_LIBRARY "libOMX_Core.so"
class TIOMXInterface : public OMXInterface
{
public:
// Handle to the OMX core library
void* ipHandle;
~TIOMXInterface()
{
if ((NULL != ipHandle) && (0 != dlclose(ipHandle)))
{
// dlclose() returns non-zero value if close failed, check for errors
const char* pErr = dlerror();
if (NULL != pErr)
{
LOGE("TIOMXInterface: Error closing library: %s\n", pErr);
}
else
{
LOGE("OsclSharedLibrary::Close: Error closing library, no error reported");
}
}
ipHandle = NULL;
};
OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
{
// Make sure ipHandle is valid. If ipHandle is NULL, the dlopen
// call failed.
if (ipHandle && aInterfaceId == OMX_INTERFACE_ID)
{
LOGD("TIOMXInterface: library lookup success\n");
// the library lookup was successful
return this;
}
// the ID doesn't match
LOGE("TIOMXInterface: library lookup failed\n");
return NULL;
};
static TIOMXInterface* Instance()
{
LOGD("TIOMXInterface: creating interface\n");
return OSCL_NEW(TIOMXInterface, ());
};
bool UnloadWhenNotUsed(void)
{
// As of 9/22/08, the PV OMX core library can not be
// safely unloaded and reloaded when the proxy interface
// is enabled.
return false;
};
private:
TIOMXInterface()
{
LOGD("Calling DLOPEN on OMX_CORE_LIBRARY (%s)\n", OMX_CORE_LIBRARY);
ipHandle = dlopen(OMX_CORE_LIBRARY, RTLD_NOW);
if (NULL == ipHandle)
{
pOMX_Init = NULL;
pOMX_Deinit = NULL;
pOMX_ComponentNameEnum = NULL;
pOMX_GetHandle = NULL;
pOMX_FreeHandle = NULL;
pOMX_GetComponentsOfRole = NULL;
pOMX_GetRolesOfComponent = NULL;
pOMX_SetupTunnel = NULL;
pOMX_GetContentPipe = NULL;
// added extra method to enable config parsing without instantiating the component
pOMXConfigParser = NULL;
// check for errors
const char* pErr = dlerror();
if (NULL == pErr)
{
// No error reported, but no handle to the library
LOGE("OsclLib::LoadLibrary: Error opening "
"library (%s) but no error reported\n", OMX_CORE_LIBRARY);
}
else
{
// Error reported
LOGE("OsclLib::LoadLibrary: Error opening "
"library (%s): %s\n", OMX_CORE_LIBRARY, pErr);
}
}
else
{
LOGD("DLOPEN SUCCEEDED (%s)\n", OMX_CORE_LIBRARY);
// Lookup all the symbols in the OMX core
pOMX_Init = (tpOMX_Init)dlsym(ipHandle, "TIOMX_Init");
pOMX_Deinit = (tpOMX_Deinit)dlsym(ipHandle, "TIOMX_Deinit");
pOMX_ComponentNameEnum = (tpOMX_ComponentNameEnum)dlsym(ipHandle, "TIOMX_ComponentNameEnum");
pOMX_GetHandle = (tpOMX_GetHandle)dlsym(ipHandle, "TIOMX_GetHandle");
pOMX_FreeHandle = (tpOMX_FreeHandle)dlsym(ipHandle, "TIOMX_FreeHandle");
pOMX_GetComponentsOfRole = (tpOMX_GetComponentsOfRole)dlsym(ipHandle, "TIOMX_GetComponentsOfRole");
pOMX_GetRolesOfComponent = (tpOMX_GetRolesOfComponent)dlsym(ipHandle, "TIOMX_GetRolesOfComponent");
pOMX_SetupTunnel = (tpOMX_SetupTunnel)dlsym(ipHandle, "TIOMX_SetupTunnel");
pOMXConfigParser = (tpOMXConfigParser)dlsym(ipHandle, "TIOMXConfigParserRedirect");
pOMX_GetContentPipe = NULL; // (tpOMX_GetContentPipe)dlsym(ipHandle, "OMX_GetContentPipe");
}
};
};
// function to obtain the interface object from the shared library
extern "C"
{
OSCL_EXPORT_REF OsclAny* PVGetInterface()
{
return TIOMXInterface::Instance();
}
}
|