libstagefrighthw has moved from hardware/samsung_slsi/exynos5
authorYunji Kim <yunji.kim@samsung.com>
Tue, 16 Oct 2012 04:39:41 +0000 (04:39 +0000)
committerHuisung Kang <hs1218.kang@samsung.com>
Sun, 28 Oct 2012 22:42:22 +0000 (07:42 +0900)
Change-Id: I99b7e8503719c50c08c52b46b924e434c4118b63
Signed-off-by: Yunji Kim <yunji.kim@samsung.com>
Android.mk
libstagefrighthw/Android.mk [new file with mode: 0644]
libstagefrighthw/Exynos_OMX_Plugin.cpp [new file with mode: 0644]
libstagefrighthw/Exynos_OMX_Plugin.h [new file with mode: 0644]

index c25647522ca231e0d3cf61c06f8952aede7521fc..457ef77ad94b60ea276c036f28be3f4d596941b6 100644 (file)
@@ -15,6 +15,7 @@
 #
 
 common_exynos_dirs := \
+       libstagefrighthw \
        libcsc \
        libv4l2 \
        libexynosutils
diff --git a/libstagefrighthw/Android.mk b/libstagefrighthw/Android.mk
new file mode 100644 (file)
index 0000000..a8af63c
--- /dev/null
@@ -0,0 +1,39 @@
+# Copyright (C) 2008 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+    Exynos_OMX_Plugin.cpp
+
+LOCAL_CFLAGS += $(PV_CFLAGS_MINUS_VISIBILITY)
+
+LOCAL_C_INCLUDES:= \
+      frameworks/native/include/media/hardware \
+      frameworks/native/include/media/openmax \
+      frameworks/native/include
+
+LOCAL_SHARED_LIBRARIES :=    \
+        libbinder            \
+        libutils             \
+        libcutils            \
+        libui                \
+        libdl                \
+        libstagefright_foundation
+
+LOCAL_MODULE := libstagefrighthw
+
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_SHARED_LIBRARY)
diff --git a/libstagefrighthw/Exynos_OMX_Plugin.cpp b/libstagefrighthw/Exynos_OMX_Plugin.cpp
new file mode 100644 (file)
index 0000000..7a9849e
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Exynos_OMX_Plugin.h"
+
+#include <dlfcn.h>
+
+#include <media/hardware/HardwareAPI.h>
+#include <media/stagefright/foundation/ADebug.h>
+
+namespace android {
+
+OMXPluginBase *createOMXPlugin() {
+    return new ExynosOMXPlugin;
+}
+
+ExynosOMXPlugin::ExynosOMXPlugin()
+    : mLibHandle(dlopen("libExynosOMX_Core.so", RTLD_NOW)),
+      mInit(NULL),
+      mDeinit(NULL),
+      mComponentNameEnum(NULL),
+      mGetHandle(NULL),
+      mFreeHandle(NULL),
+      mGetRolesOfComponentHandle(NULL) {
+    if (mLibHandle != NULL) {
+        mInit = (InitFunc)dlsym(mLibHandle, "Exynos_OMX_Init");
+        mDeinit = (DeinitFunc)dlsym(mLibHandle, "Exynos_OMX_Deinit");
+
+        mComponentNameEnum =
+            (ComponentNameEnumFunc)dlsym(mLibHandle, "Exynos_OMX_ComponentNameEnum");
+
+        mGetHandle = (GetHandleFunc)dlsym(mLibHandle, "Exynos_OMX_GetHandle");
+        mFreeHandle = (FreeHandleFunc)dlsym(mLibHandle, "Exynos_OMX_FreeHandle");
+
+        mGetRolesOfComponentHandle =
+            (GetRolesOfComponentFunc)dlsym(
+                    mLibHandle, "Exynos_OMX_GetRolesOfComponent");
+
+        (*mInit)();
+
+    }
+}
+
+ExynosOMXPlugin::~ExynosOMXPlugin() {
+    if (mLibHandle != NULL) {
+        (*mDeinit)();
+
+        dlclose(mLibHandle);
+        mLibHandle = NULL;
+    }
+}
+
+OMX_ERRORTYPE ExynosOMXPlugin::makeComponentInstance(
+        const char *name,
+        const OMX_CALLBACKTYPE *callbacks,
+        OMX_PTR appData,
+        OMX_COMPONENTTYPE **component) {
+    if (mLibHandle == NULL) {
+        return OMX_ErrorUndefined;
+    }
+
+    return (*mGetHandle)(
+            reinterpret_cast<OMX_HANDLETYPE *>(component),
+            const_cast<char *>(name),
+            appData, const_cast<OMX_CALLBACKTYPE *>(callbacks));
+}
+
+OMX_ERRORTYPE ExynosOMXPlugin::destroyComponentInstance(
+        OMX_COMPONENTTYPE *component) {
+    if (mLibHandle == NULL) {
+        return OMX_ErrorUndefined;
+    }
+
+    return (*mFreeHandle)(reinterpret_cast<OMX_HANDLETYPE *>(component));
+}
+
+OMX_ERRORTYPE ExynosOMXPlugin::enumerateComponents(
+        OMX_STRING name,
+        size_t size,
+        OMX_U32 index) {
+    if (mLibHandle == NULL) {
+        return OMX_ErrorUndefined;
+    }
+
+    return (*mComponentNameEnum)(name, size, index);
+}
+
+OMX_ERRORTYPE ExynosOMXPlugin::getRolesOfComponent(
+        const char *name,
+        Vector<String8> *roles) {
+    roles->clear();
+
+    if (mLibHandle == NULL) {
+        return OMX_ErrorUndefined;
+    }
+
+    OMX_U32 numRoles;
+    OMX_ERRORTYPE err = (*mGetRolesOfComponentHandle)(
+            const_cast<OMX_STRING>(name), &numRoles, NULL);
+
+    if (err != OMX_ErrorNone) {
+        return err;
+    }
+
+    if (numRoles > 0) {
+        OMX_U8 **array = new OMX_U8 *[numRoles];
+        for (OMX_U32 i = 0; i < numRoles; ++i) {
+            array[i] = new OMX_U8[OMX_MAX_STRINGNAME_SIZE];
+        }
+
+        OMX_U32 numRoles2;
+        err = (*mGetRolesOfComponentHandle)(
+                const_cast<OMX_STRING>(name), &numRoles2, array);
+
+        CHECK_EQ(err, OMX_ErrorNone);
+        CHECK_EQ(numRoles, numRoles2);
+
+        for (OMX_U32 i = 0; i < numRoles; ++i) {
+            String8 s((const char *)array[i]);
+            roles->push(s);
+
+            delete[] array[i];
+            array[i] = NULL;
+        }
+
+        delete[] array;
+        array = NULL;
+    }
+
+    return OMX_ErrorNone;
+}
+
+}  // namespace android
+
diff --git a/libstagefrighthw/Exynos_OMX_Plugin.h b/libstagefrighthw/Exynos_OMX_Plugin.h
new file mode 100644 (file)
index 0000000..3b4d8f0
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef Exynos_OMX_PLUGIN
+
+#define Exynos_OMX_PLUGIN
+
+#include <media/hardware/OMXPluginBase.h>
+
+namespace android {
+
+struct ExynosOMXPlugin : public OMXPluginBase {
+    ExynosOMXPlugin();
+    virtual ~ExynosOMXPlugin();
+
+    virtual OMX_ERRORTYPE makeComponentInstance(
+            const char *name,
+            const OMX_CALLBACKTYPE *callbacks,
+            OMX_PTR appData,
+            OMX_COMPONENTTYPE **component);
+
+    virtual OMX_ERRORTYPE destroyComponentInstance(
+            OMX_COMPONENTTYPE *component);
+
+    virtual OMX_ERRORTYPE enumerateComponents(
+            OMX_STRING name,
+            size_t size,
+            OMX_U32 index);
+
+    virtual OMX_ERRORTYPE getRolesOfComponent(
+            const char *name,
+            Vector<String8> *roles);
+
+private:
+    void *mLibHandle;
+
+    typedef OMX_ERRORTYPE (*InitFunc)();
+    typedef OMX_ERRORTYPE (*DeinitFunc)();
+    typedef OMX_ERRORTYPE (*ComponentNameEnumFunc)(
+            OMX_STRING, OMX_U32, OMX_U32);
+
+    typedef OMX_ERRORTYPE (*GetHandleFunc)(
+            OMX_HANDLETYPE *, OMX_STRING, OMX_PTR, OMX_CALLBACKTYPE *);
+
+    typedef OMX_ERRORTYPE (*FreeHandleFunc)(OMX_HANDLETYPE *);
+
+    typedef OMX_ERRORTYPE (*GetRolesOfComponentFunc)(
+            OMX_STRING, OMX_U32 *, OMX_U8 **);
+
+    InitFunc mInit;
+    DeinitFunc mDeinit;
+    ComponentNameEnumFunc mComponentNameEnum;
+    GetHandleFunc mGetHandle;
+    FreeHandleFunc mFreeHandle;
+    GetRolesOfComponentFunc mGetRolesOfComponentHandle;
+
+    ExynosOMXPlugin(const ExynosOMXPlugin &);
+    ExynosOMXPlugin &operator=(const ExynosOMXPlugin &);
+};
+
+}  // namespace android
+
+#endif  // Exynos_OMX_PLUGIN