Commit f399a08d authored by Martin Storsjö's avatar Martin Storsjö Committed by 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: default avatarJean-Baptiste Kempf <jb@videolan.org>
(cherry picked from commit e3e83295)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent d19a4357
...@@ -3,4 +3,4 @@ SOURCES_omxil = omxil.c utils.c omxil.h omxil_utils.h \ ...@@ -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 OMX_Audio.h OMX_Index.h OMX_Other.h OMX_Video.h ../h264_nal.h
CPPFLAGS_iomx = -DUSE_IOMX CPPFLAGS_iomx = -DUSE_IOMX
SOURCES_iomx = $(SOURCES_omxil) iomx.cpp iomx.h SOURCES_iomx = $(SOURCES_omxil)
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
#include <binder/MemoryDealer.h> #include <binder/MemoryDealer.h>
#include <OMX_Component.h> #include <OMX_Component.h>
#include "iomx.h"
using namespace android; using namespace android;
class IOMXContext { class IOMXContext {
...@@ -272,7 +270,7 @@ static OMX_ERRORTYPE iomx_set_config(OMX_HANDLETYPE component, OMX_INDEXTYPE ind ...@@ -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))); 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(); OMXNode* node = new OMXNode();
node->app_data = app_data; node->app_data = app_data;
...@@ -310,7 +308,7 @@ static OMX_ERRORTYPE iomx_get_handle(OMX_HANDLETYPE *handle_ptr, const char *com ...@@ -310,7 +308,7 @@ static OMX_ERRORTYPE iomx_get_handle(OMX_HANDLETYPE *handle_ptr, const char *com
return OMX_ErrorNone; 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; OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)handle)->pComponentPrivate;
ctx->iomx->freeNode( node->node ); ctx->iomx->freeNode( node->node );
...@@ -320,24 +318,28 @@ static OMX_ERRORTYPE iomx_free_handle(OMX_HANDLETYPE handle) ...@@ -320,24 +318,28 @@ static OMX_ERRORTYPE iomx_free_handle(OMX_HANDLETYPE handle)
return OMX_ErrorNone; return OMX_ErrorNone;
} }
static OMX_ERRORTYPE iomx_init() OMX_ERRORTYPE OMX_Init(void)
{ {
OMXClient client; OMXClient client;
if (client.connect() != OK) if (client.connect() != OK)
return OMX_ErrorUndefined; return OMX_ErrorUndefined;
if (!ctx)
ctx = new IOMXContext();
ctx->iomx = client.interface(); ctx->iomx = client.interface();
ctx->iomx->listNodes(&ctx->components); ctx->iomx->listNodes(&ctx->components);
return OMX_ErrorNone; return OMX_ErrorNone;
} }
static OMX_ERRORTYPE iomx_deinit() OMX_ERRORTYPE OMX_Deinit(void)
{ {
ctx->iomx = NULL; ctx->iomx = NULL;
delete ctx;
ctx = NULL;
return OMX_ErrorNone; 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()) if (index >= ctx->components.size())
return OMX_ErrorNoMore; return OMX_ErrorNoMore;
...@@ -349,7 +351,7 @@ static OMX_ERRORTYPE iomx_component_name_enum(OMX_STRING component_name, OMX_U32 ...@@ -349,7 +351,7 @@ static OMX_ERRORTYPE iomx_component_name_enum(OMX_STRING component_name, OMX_U32
return OMX_ErrorNone; 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++ ) { for( List<IOMX::ComponentInfo>::iterator it = ctx->components.begin(); it != ctx->components.end(); it++ ) {
if (!strcmp(component_name, it->mName.string())) { if (!strcmp(component_name, it->mName.string())) {
...@@ -371,34 +373,3 @@ static OMX_ERRORTYPE iomx_get_roles_of_component(OMX_STRING component_name, OMX_ ...@@ -371,34 +373,3 @@ static OMX_ERRORTYPE iomx_get_roles_of_component(OMX_STRING component_name, OMX_
return OMX_ErrorInvalidComponentName; 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;
}
/*****************************************************************************
* iomx.h: Interface for the IOMX OpenMAX wrapper
*****************************************************************************
* Copyright (C) 2011 VLC authors and VideoLAN
*
* Authors: Martin Storsjo <martin@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
...@@ -30,10 +30,10 @@ ...@@ -30,10 +30,10 @@
#include <dlfcn.h> #include <dlfcn.h>
#if defined(USE_IOMX) #if defined(USE_IOMX)
# include "iomx.h" /* On dll_open, just check that the OMX_Init symbol already is loaded */
# define dll_open(name) iomx_dlopen(name) # define dll_open(name) dlsym(RTLD_DEFAULT, "OMX_Init")
# define dll_close(handle) iomx_dlclose(handle) # define dll_close(handle) do { } while (0)
# define dlsym(handle, name) iomx_dlsym(handle, name) # define dlsym(handle, name) dlsym(RTLD_DEFAULT, name)
#else #else
# define dll_open(name) dlopen( name, RTLD_NOW ) # define dll_open(name) dlopen( name, RTLD_NOW )
# define dll_close(handle) dlclose(handle) # define dll_close(handle) dlclose(handle)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment