[vlc-commits] omxil: Build the iomx wrapper code as a separate shared library

Martin Storsjö git at videolan.org
Mon Dec 19 02:20:28 CET 2011


vlc | branch: master | Martin Storsjö <martin at martin.st> | Fri Dec 16 23:47:03 2011 +0200| [e3e832956b5cb42297dfa33389a1228ee5b6ee61] | committer: Jean-Baptiste Kempf

omxil: Build the iomx wrapper code as a separate shared library

The separate shared library needs to be loaded into the process
before using the iomx module, preferrably by the java part
of the android application.

This allows building the iomx glue code for a number of different
ABI versions, and additionally avoids linking the main VLC
library to any private symbols that might make it unloadable.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e3e832956b5cb42297dfa33389a1228ee5b6ee61
---

 modules/codec/omxil/Modules.am |    2 +-
 modules/codec/omxil/iomx.cpp   |   49 ++++++++-------------------------------
 modules/codec/omxil/iomx.h     |   33 ---------------------------
 modules/codec/omxil/omxil.c    |    8 +++---
 4 files changed, 15 insertions(+), 77 deletions(-)

diff --git a/modules/codec/omxil/Modules.am b/modules/codec/omxil/Modules.am
index 8e1695c..a33b2e7 100644
--- a/modules/codec/omxil/Modules.am
+++ b/modules/codec/omxil/Modules.am
@@ -3,4 +3,4 @@ SOURCES_omxil = omxil.c utils.c omxil.h omxil_utils.h \
         OMX_Audio.h OMX_Index.h OMX_Other.h OMX_Video.h ../h264_nal.h
 
 CPPFLAGS_iomx = -DUSE_IOMX
-SOURCES_iomx = $(SOURCES_omxil) iomx.cpp iomx.h
+SOURCES_iomx = $(SOURCES_omxil)
diff --git a/modules/codec/omxil/iomx.cpp b/modules/codec/omxil/iomx.cpp
index 1d52ad8..ccc4abb 100644
--- a/modules/codec/omxil/iomx.cpp
+++ b/modules/codec/omxil/iomx.cpp
@@ -29,8 +29,6 @@
 #include <binder/MemoryDealer.h>
 #include <OMX_Component.h>
 
-#include "iomx.h"
-
 using namespace android;
 
 class IOMXContext {
@@ -272,7 +270,7 @@ static OMX_ERRORTYPE iomx_set_config(OMX_HANDLETYPE component, OMX_INDEXTYPE ind
     return get_error(ctx->iomx->setConfig(node->node, index, param, sizeof(OMX_BOOL)));
 }
 
-static OMX_ERRORTYPE iomx_get_handle(OMX_HANDLETYPE *handle_ptr, const char *component_name, OMX_PTR app_data, const OMX_CALLBACKTYPE *callbacks)
+OMX_ERRORTYPE OMX_GetHandle(OMX_HANDLETYPE *handle_ptr, OMX_STRING component_name, OMX_PTR app_data, OMX_CALLBACKTYPE *callbacks)
 {
     OMXNode* node = new OMXNode();
     node->app_data = app_data;
@@ -310,7 +308,7 @@ static OMX_ERRORTYPE iomx_get_handle(OMX_HANDLETYPE *handle_ptr, const char *com
     return OMX_ErrorNone;
 }
 
-static OMX_ERRORTYPE iomx_free_handle(OMX_HANDLETYPE handle)
+OMX_ERRORTYPE OMX_FreeHandle(OMX_HANDLETYPE handle)
 {
     OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)handle)->pComponentPrivate;
     ctx->iomx->freeNode( node->node );
@@ -320,24 +318,28 @@ static OMX_ERRORTYPE iomx_free_handle(OMX_HANDLETYPE handle)
     return OMX_ErrorNone;
 }
 
-static OMX_ERRORTYPE iomx_init()
+OMX_ERRORTYPE OMX_Init(void)
 {
     OMXClient client;
     if (client.connect() != OK)
         return OMX_ErrorUndefined;
 
+    if (!ctx)
+        ctx = new IOMXContext();
     ctx->iomx = client.interface();
     ctx->iomx->listNodes(&ctx->components);
     return OMX_ErrorNone;
 }
 
-static OMX_ERRORTYPE iomx_deinit()
+OMX_ERRORTYPE OMX_Deinit(void)
 {
     ctx->iomx = NULL;
+    delete ctx;
+    ctx = NULL;
     return OMX_ErrorNone;
 }
 
-static OMX_ERRORTYPE iomx_component_name_enum(OMX_STRING component_name, OMX_U32 name_length, OMX_U32 index)
+OMX_ERRORTYPE OMX_ComponentNameEnum(OMX_STRING component_name, OMX_U32 name_length, OMX_U32 index)
 {
     if (index >= ctx->components.size())
         return OMX_ErrorNoMore;
@@ -349,7 +351,7 @@ static OMX_ERRORTYPE iomx_component_name_enum(OMX_STRING component_name, OMX_U32
     return OMX_ErrorNone;
 }
 
-static OMX_ERRORTYPE iomx_get_roles_of_component(OMX_STRING component_name, OMX_U32 *num_roles, OMX_U8 **roles)
+OMX_ERRORTYPE OMX_GetRolesOfComponent(OMX_STRING component_name, OMX_U32 *num_roles, OMX_U8 **roles)
 {
     for( List<IOMX::ComponentInfo>::iterator it = ctx->components.begin(); it != ctx->components.end(); it++ ) {
         if (!strcmp(component_name, it->mName.string())) {
@@ -371,34 +373,3 @@ static OMX_ERRORTYPE iomx_get_roles_of_component(OMX_STRING component_name, OMX_
     return OMX_ErrorInvalidComponentName;
 }
 
-void* iomx_dlopen(const char *)
-{
-    if (!ctx)
-        ctx = new IOMXContext();
-    return ctx;
-}
-
-void iomx_dlclose(void *handle)
-{
-    IOMXContext *ctx = (IOMXContext*) handle;
-    delete ctx;
-    ::ctx = NULL;
-}
-
-void *iomx_dlsym(void *, const char *name)
-{
-    if (!strcmp(name, "OMX_Init"))
-        return (void*) iomx_init;
-    if (!strcmp(name, "OMX_Deinit"))
-        return (void*) iomx_deinit;
-    if (!strcmp(name, "OMX_GetHandle"))
-        return (void*) iomx_get_handle;
-    if (!strcmp(name, "OMX_FreeHandle"))
-        return (void*) iomx_free_handle;
-    if (!strcmp(name, "OMX_ComponentNameEnum"))
-        return (void*) iomx_component_name_enum;
-    if (!strcmp(name, "OMX_GetRolesOfComponent"))
-        return (void*) iomx_get_roles_of_component;
-    return NULL;
-}
-
diff --git a/modules/codec/omxil/iomx.h b/modules/codec/omxil/iomx.h
deleted file mode 100644
index 453f817..0000000
--- a/modules/codec/omxil/iomx.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*****************************************************************************
- * iomx.h: Interface for the IOMX OpenMAX wrapper
- *****************************************************************************
- * Copyright (C) 2011 VLC authors and VideoLAN
- *
- * Authors: Martin Storsjo <martin at martin.st>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void* iomx_dlopen(const char *name);
-void iomx_dlclose(void *handle);
-void* iomx_dlsym(void *handle, const char *name);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index a5344c8..d46bb31 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -30,10 +30,10 @@
 
 #include <dlfcn.h>
 #if defined(USE_IOMX)
-# include "iomx.h"
-# define dll_open(name) iomx_dlopen(name)
-# define dll_close(handle) iomx_dlclose(handle)
-# define dlsym(handle, name) iomx_dlsym(handle, name)
+/* On dll_open, just check that the OMX_Init symbol already is loaded */
+# define dll_open(name) dlsym(RTLD_DEFAULT, "OMX_Init")
+# define dll_close(handle) do { } while (0)
+# define dlsym(handle, name) dlsym(RTLD_DEFAULT, name)
 #else
 # define dll_open(name) dlopen( name, RTLD_NOW )
 # define dll_close(handle) dlclose(handle)



More information about the vlc-commits mailing list