2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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 express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "Exynos_OMX_Plugin.h"
21 #include <media/hardware/HardwareAPI.h>
22 #include <media/stagefright/foundation/ADebug.h>
26 OMXPluginBase
*createOMXPlugin() {
27 return new ExynosOMXPlugin
;
30 ExynosOMXPlugin::ExynosOMXPlugin()
31 : mLibHandle(dlopen("libExynosOMX_Core.so", RTLD_NOW
)),
34 mComponentNameEnum(NULL
),
37 mGetRolesOfComponentHandle(NULL
) {
38 if (mLibHandle
!= NULL
) {
39 mInit
= (InitFunc
)dlsym(mLibHandle
, "Exynos_OMX_Init");
40 mDeinit
= (DeinitFunc
)dlsym(mLibHandle
, "Exynos_OMX_Deinit");
43 (ComponentNameEnumFunc
)dlsym(mLibHandle
, "Exynos_OMX_ComponentNameEnum");
45 mGetHandle
= (GetHandleFunc
)dlsym(mLibHandle
, "Exynos_OMX_GetHandle");
46 mFreeHandle
= (FreeHandleFunc
)dlsym(mLibHandle
, "Exynos_OMX_FreeHandle");
48 mGetRolesOfComponentHandle
=
49 (GetRolesOfComponentFunc
)dlsym(
50 mLibHandle
, "Exynos_OMX_GetRolesOfComponent");
57 ExynosOMXPlugin::~ExynosOMXPlugin() {
58 if (mLibHandle
!= NULL
) {
66 OMX_ERRORTYPE
ExynosOMXPlugin::makeComponentInstance(
68 const OMX_CALLBACKTYPE
*callbacks
,
70 OMX_COMPONENTTYPE
**component
) {
71 if (mLibHandle
== NULL
) {
72 return OMX_ErrorUndefined
;
76 reinterpret_cast<OMX_HANDLETYPE
*>(component
),
77 const_cast<char *>(name
),
78 appData
, const_cast<OMX_CALLBACKTYPE
*>(callbacks
));
81 OMX_ERRORTYPE
ExynosOMXPlugin::destroyComponentInstance(
82 OMX_COMPONENTTYPE
*component
) {
83 if (mLibHandle
== NULL
) {
84 return OMX_ErrorUndefined
;
87 return (*mFreeHandle
)(reinterpret_cast<OMX_HANDLETYPE
*>(component
));
90 OMX_ERRORTYPE
ExynosOMXPlugin::enumerateComponents(
94 if (mLibHandle
== NULL
) {
95 return OMX_ErrorUndefined
;
98 return (*mComponentNameEnum
)(name
, size
, index
);
101 OMX_ERRORTYPE
ExynosOMXPlugin::getRolesOfComponent(
103 Vector
<String8
> *roles
) {
106 if (mLibHandle
== NULL
) {
107 return OMX_ErrorUndefined
;
111 OMX_ERRORTYPE err
= (*mGetRolesOfComponentHandle
)(
112 const_cast<OMX_STRING
>(name
), &numRoles
, NULL
);
114 if (err
!= OMX_ErrorNone
) {
119 OMX_U8
**array
= new OMX_U8
*[numRoles
];
120 for (OMX_U32 i
= 0; i
< numRoles
; ++i
) {
121 array
[i
] = new OMX_U8
[OMX_MAX_STRINGNAME_SIZE
];
125 err
= (*mGetRolesOfComponentHandle
)(
126 const_cast<OMX_STRING
>(name
), &numRoles2
, array
);
128 CHECK_EQ(err
, OMX_ErrorNone
);
129 CHECK_EQ(numRoles
, numRoles2
);
131 for (OMX_U32 i
= 0; i
< numRoles
; ++i
) {
132 String8
s((const char *)array
[i
]);
143 return OMX_ErrorNone
;
146 } // namespace android