`
isiqi
  • 浏览: 16483200 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

Android opencore 2.02 howto

阅读更多

Android opencore 2.02 howto

How to intergrate a new library into OpenCore
1. Create a new UUID
In ANDROID_DIR/external/opencore/codecs_v2/omx/omx_common/include/pv_omxcore.h
#if USE_DYNAMIC_LOAD_OMX_COMPONENTS
#define PV_OMX_MP3DEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x
70)
#define PV_OMX_AACENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x76)
2. Add in your decoder library and interface head file
In fold ANDROID_DIR/external/opencore/codecs_v2/, create a new directory and put your decoder files in. Here we take the mp3 decoder as an example.The mp3 decoder is put in the fold audio/mp3/dec/ and the head file will be used by us are:(you can get this in Android.mk)
LOCAL_COPY_HEADERS := \
include/pvmp3_decoder.h \
include/pvmp3decoder_api.h \
include/pvmp3_audio_type_defs.h
The decoder library will be compiled to be a static library named libpvmp3.a
3. Intergrate the decoder library into openmax in opencore
Create a new directory in codecs_v2/omx. Here we take the mp3 decoder as an example. The mp3 omx component is placed in the fold omx/omx_mp3/. From the Android.mk file you can know the most imp

ortant files are:
LOCAL_SRC_FILES := \
src/mp3_dec.cpp \
src/omx_mp3_component.cpp \
src/mp3_timestamp.cpp
LOCAL_COPY_HEADERS := \
include/mp3_dec.h \
include/omx_mp3_component.h \
include/mp3_timestamp.h
We can get a snap from the head files. In the file mp3_dec.h, a new class named Mp3Decoder will be created to use the mp3 decoder.
CPvMP3_Decoder* iAudioMp3Decoder; // defined in pvmp3_decoder.h
tPVMP3DecoderExternal* iMP3DecExt; //defined in pvmp3decoder_api.h
Some import interfaces will be created here:
Mp3Decoder();
OMX_BOOL Mp3DecInit(OMX_AUDIO_CONFIG_EQUALIZERTYPE* aEqualizerType);
void Mp3DecDeinit();
Int Mp3DecodeAudio(OMX_S16* aOutBuff,
OMX_U32* aOutputLength, OMX_U8** aInputBuf,
OMX_U32* aInBufSize,
OMX_S32* aFrameCount,
OMX_AUDIO_PARAM_PCMMODETYPE* aAudioPcmParam,
OMX_AUDIO_PARAM_MP3TYPE* aAudioMp3Param,
OMX_BOOL aMarkerFlag,
OMX_BOOL* aResizeFlag);
void ResetDecoder(); // for repositioning
If your decoder is an audio decoder you should create a class which inherits from OmxComponentAudio. If your decoder is a video decoder you should create a class which inherits from OmxComponentVideo.
The OmxComponetAudio class:
class OmxComponentAudio : public OmxComponentBase
{
public:
OmxComponentAudio();
virtual ~OmxComponentAudio() {}
OMX_ERRORTYPE GetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex,
OMX_INOUT OMX_PTR ComponentParameterStructure);
OMX_ERRORTYPE SetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex,
OMX_IN OMX_PTR ComponentParameterStructure);
virtual void UpdateAACPlusFlag(OMX_BOOL aAacPlusFlag)
{
OSCL_UNUSED_ARG(aAacPlusFlag);
}
};
The OmxComponentVideo class:
class OmxComponentVideo : public OmxComponentBase
{
public:
OmxComponentVideo();
virtual ~OmxComponentVideo() {}
OMX_ERRORTYPE GetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex,
OMX_INOUT OMX_PTR ComponentParameterStructure);
OMX_ERRORTYPE SetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex,
OMX_IN OMX_PTR ComponentParameterStructure);
};
In the base class OmxComponentBase you can see there are 5 pure virtual interfaces:
virtual OMX_ERRORTYPE GetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex,
OMX_INOUT OMX_PTR ComponentParameterStructure) = 0;
virtual OMX_ERRORTYPE SetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex,
OMX_IN OMX_PTR ComponentParameterStructure) = 0;
virtual void ProcessData() = 0;
virtual OMX_ERRORTYPE ComponentInit() = 0;
virtual OMX_ERRORTYPE ComponentDeInit() = 0;
So these interfaces must have a definition in derived components. The first two will be derived in OmxComponent Audio and OmxComponentVideo. So our component must define the left 3 functions.
And here in our mp3 componet(named OpenmaxMp3AO in the file omx_mp3_component.h)
OpenmaxMp3AO();
~OpenmaxMp3AO();
OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy);
OMX_ERRORTYPE DestroyComponent();
OMX_ERRORTYPE ComponentInit();
OMX_ERRORTYPE ComponentDeInit();
static void ComponentGetRolesOfComponent(OMX_STRING* aRoleString);
void ProcessData();
void SyncWithInputTimestamp();
void ProcessInBufferFlag();
void ResetComponent();
OMX_ERRORTYPE GetConfig(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_INOUT OMX_PTR pComponentConfigStructure);
And we will use the Mp3Decoder to implement the component OpenmaxMp3AO
Mp3Decoder* ipMp3Dec;
Sometimes we need a timestamp
Mp3TimeStampCalc iCurrentFrameTS;
In omx_mp3_component.cpp we can know the Mp3OmxSharedLibraryInterface will be implemented as a singleton because we need mp3 deocoder at time. And here the UUID will be used to judge whether this library is the right.
OsclAny *QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId)
{
if (PV_OMX_MP3DEC_UUID == aOmxTypeId)
{
if (PV_OMX_CREATE_INTERFACE == aInterfaceId)
{
return ((OsclAny*)(&Mp3OmxComponentFactory));
}
else if (PV_OMX_DESTROY_INTERFACE == aInterfaceId)
{
return ((OsclAny*)(&Mp3OmxComponentDestructor));
}
}
return NULL;
};
OsclAny *SharedLibraryLookup(const OsclUuid& aInterfaceId)
{
if (aInterfaceId == PV_OMX_SHARED_INTERFACE)
{
return OSCL_STATIC_CAST(OmxSharedLibraryInterface*, this);
}
return NULL;
};
Finally after we finished all the source code we will get a new component library,here the mp3 component will be compiled to be library named libomx_mp3_component_lib.so
4. Compile the two libs to be the shared lib
In build_config/opencore_dynamic/Android_omx_mp3dec_sharedlibrary.mk, we will compile the mp3 decoder lib and the mp3 component lib to libomx_mp3dec_sharedlibrary.so
LOCAL_WHOLE_STATIC_LIBRARIES := \
libomx_mp3_component_lib \
libpvmp3
LOCAL_MODULE := libomx_mp3dec_sharedlibrary
…..
include $(PV_TOP)/codecs_v2/omx/omx_mp3/Android.mk
include $(PV_TOP)/codecs_v2/audio/mp3/dec/Android.mk
5. Regist the shared lib in soure code
In codecs_v2/omx/omx_common/src/pv_omxregistry.cpp
#if (REGISTER_OMX_MP3_COMPONENT) || (USE_DYNAMIC_LOAD_OMX_COMPONENTS)
/////////////////////////////////////////////////////////////////////////////
OMX_ERRORTYPE Mp3Register()
{
….
pCRT->SharedLibraryName = (OMX_STRING)"libomx_mp3dec_sharedlibrary.so";
….
OSCL_PLACEMENT_NEW(temp, PV_OMX_MP3DEC_UUID);
And this function Mp3Register will be called in omx_common/src/pv_omxcore.cpp
OSCL_EXPORT_REF OMX_ERRORTYPE OMX_Init()
{

if (status == OMX_ErrorNone)
{
_Try_OMX_Init(error, status);

}
...
}
static void _Try_OMX_Init(int32& aError, OMX_ERRORTYPE& aStatus)
{
OSCL_TRY(aError, aStatus = _OMX_Init(););
}
tatic OMX_ERRORTYPE _OMX_Init()
{
….
Status = Mp3Register();

}
6. At last we need to finish the PVOMXInterface in pv_omx_interface.cpp
Because the PV OpenCORE framework is utilizing dynamic loading and linking to handle
potentially multiple OMX cores simultaneously, the OMX core libraries must be built as shared
objects .
There are currently two different build methods to include the PV OMX core wrapper into the final
shared object library (.so):
6.1 If your opencore shared library and the opencore wrapper library are build seperately:
we need to modify the file omx_core_plugins/template/src/pv_omx_interface.cpp.
#define OMX_CORE_LIBRARY "libOmxCore.so" →
needs to be substituted with the following line that contains the name of the pre-built shared
library that contains OMX core methods (but does not contain OMX core wrapper):
#define OMX_CORE_LIBRAY “ “lib_prebuilt_omxcore_no_wrapper.so”
As part of dynamic loading process, the OMX core wrapper for this case must open “lib_prebuilt
omxcore_no_wrapper.so” library and link to the OMX core methods in this library explicitly (using
dlopen & dlsym calls).
In pv_omx_interface.cpp:
pOMX_Init = (tpOMX_Init)dlsym(ipHandle, "OMX_Init");
...
The provider of the final OMX core library must ensure that makefiles that create the final OMX
library (“lib_omxcore_plus_wrapper.so”) include the OMX core library wrapper as well. The
purpose of OMX core library wrapper is to provide the PV OpenCORE framework with common
APIs to dynamically load and communicate with OMX core plugins.
6.2 OMX core methods and the OMX core wrapper interface can be built simultaneously:
The code for the OMX core wrapper interface for this case is provided in: .../codecs_v2/omx/omx_sharedlibrary/interface/src
This code needs to be copied to an appropriate place in the directory structure of vendor's code
that will enable the creation of “lib_omxcore_and_simultaneous_wrapper.so”
In pv_omx_interface.cpp:
pOMX_Init = OMX_Init;
...
reference :http://blog.163.com/xxw8393/blog/static/3725683420096232521743/

分享到:
评论

相关推荐

    opencore-amr-android, android中的opencore amr编解码器.zip

    opencore-amr-android, android中的opencore amr编解码器 opencore-amr-android一种带有解释功能的opencore amr编解码器及其封装amr音频文件的。中文文档请移步 README_CN QQ部落帮助: 453503476背景opencore 是...

    android opencore

    在Android系统中,OpenCore是一个重要的组件,主要负责多媒体处理,特别是视频播放功能。这个"android opencore"涉及到的核心知识点主要包括以下几个方面: 1. **OpenCore简介**:OpenCore是Apple开发的一个开源...

    Android Opencore OpenMAX学习

    在Android系统中,OpenCore和OpenMAX是两个重要的多媒体处理框架,它们对于音频、视频的解码、编码以及播放有着至关重要的作用。本篇文章将深入探讨这两个组件,并结合实际的开发经验,帮助你理解它们的工作原理和...

    Android的多媒体框架OpenCore介绍

    Android的多媒体框架OpenCore是Android系统中的核心组件之一,用于处理多媒体内容的播放和录制。OpenCore最初由PacketVideo公司开发,后来成为Android系统的一部分。本文将深入探讨OpenCore的结构、功能及其与...

    android opencore源码文件

    Android OpenCore源码是Android操作系统中的一个关键组件,主要负责多媒体处理和播放功能。OpenCore是一个开源的多媒体框架,它在Android系统中扮演着至关重要的角色,为应用程序提供音频、视频编码、解码以及流媒体...

    android中的opencore介绍

    标题 "android中的opencore介绍" 指涉的是Android操作系统中的OpenCore组件,这是一个多媒体框架,用于处理音频和视频编码、解码以及播放。OpenCore是Android早期版本中的核心部分,它为Android设备提供了多媒体内容...

    OpenCore Configurator 2.67.1.0-OpenCore 0.9.1 supported

    OpenCore Configurator 2.67.1.0 是一个专为OpenCore引导加载器配置而设计的强大工具,尤其在黑苹果(Black Apple,即在非Apple硬件上安装 macOS)社区中广泛应用。这个版本更新主要增加了对OpenCore 0.9.1的支持,...

    opencore官方文档中文版

    《OpenCore 官方文档中文版》是针对OpenCore这一开源项目的重要参考资料,它深入剖析了OpenCore的代码结构和实现的功能,对于Android开发者以及对音视频处理技术感兴趣的人来说,是一份不可多得的学习资源。OpenCore...

    OpenCore-Legacy-Patcher

    OpenCore Legacy Patcher是一款专为macOS用户设计的工具,主要功能是帮助用户在不支持最新OpenCore启动加载器的老式Mac系统上安装和运行较新的macOS版本。OpenCore作为替代传统 Clover 引导加载器的选择,以其高度可...

    OpenCore Configurator.app-0.6.3.zip

    OpenCore Configurator.app-0.6.3.zip 是一个用于配置OpenCore启动加载器的工具,适用于OpenCore 0.6.3版本。OpenCore是苹果MacOS系统中广泛使用的替代Clover的引导加载程序,它允许用户在非苹果硬件上安装和运行...

    OpenCore Configurator [OpenCore 0.7.0 supported Version 2.40.0.1]

    OpenCore Configurator是一款专为macOS系统设计的配置工具,主要用来帮助用户更方便地管理和配置OpenCore引导加载器。OpenCore是当前苹果Mac平台上广泛使用的替代Clover的引导加载程序,它支持最新的macOS系统,并且...

    OpenCore-0.7.6

    OpenCore 是一个现代的引导加载器,用于在MacOS系统上实现启动自定义硬件或进行系统升级。OpenCore 0.7.6 版本是该软件的一个特定迭代,提供了许多改进和修复,以增强其稳定性和兼容性。在这个版本中,我们可以期待...

    OpenCore-0.7.3-RELEASE.zip

    OpenCore是一款广受欢迎的Mac电脑启动管理器,其最新版本为OpenCore 0.7.3 RELEASE。这个压缩包文件“OpenCore-0.7.3-RELEASE.zip”包含了使用和配置OpenCore所需的关键组件,使得用户能够自定义和优化他们的Mac电脑...

    黑苹果使用OpenCore安装黑苹果

    3. **OpenCore配置**:从GitHub或其他可靠源下载OpenCore的最新版本,并将其解压到你的启动驱动器的EFI分区。OpenCore的配置文件`config.plist`是关键,需要根据你的硬件进行调整。 4. **BIOS/UEFI设置**:进入主板...

    OpenCore-0.6.8-RELEASE.zip

    OpenCore 是一款开源的启动加载器,主要用于macOS系统,特别是在非Apple硬件上安装和运行macOS,也就是我们常说的“黑苹果”(Hackintosh)系统。OpenCore 0.6.8-RELEASE 是该软件的一个版本,它提供了一种灵活且强大...

    OpenCore-Patcher-GUI.app.zip v0.6.7 版本

    OpenCore Patcher GUI是专为Mac用户设计的一款实用工具,主要目标是帮助那些拥有较旧型号Mac的用户能够顺利升级到最新的MacOS操作系统。在OpenCore Patcher图形界面程序的帮助下,用户无需深入复杂的命令行操作,就...

    OpenCore-Mod-0.6.9-DEBUG.zip

    OpenCore是一款先进的Mac OS(X)启动加载器,它在苹果硬件和macOS系统之间起到了桥梁的作用,使得用户能够自定义启动过程,优化性能,并支持多种安装选项。OpenCore的出现,部分取代了早期的Clover引导,提供了更现代...

    Android的多媒体框架OpenCore介绍.pdf

    Android的多媒体框架OpenCore是Android系统中用于处理多媒体内容的核心组件,它提供了全面的多媒体播放和录制功能。OpenCore最初由PacketVideo公司开发,后来成为Android系统的一部分。在Android开发者社区中,...

    OpenCore_v0.7.7_RELEASE 黑果OC引导

    OpenCore是苹果社区中广泛使用的引导加载器,特别是在安装和运行macOS系统于非Apple硬件,也就是所谓的“黑果”(Hackintosh)上。OpenCore_v0.7.7_RELEASE代表了OpenCore的一个稳定版本,这通常是开发者推荐用于...

Global site tag (gtag.js) - Google Analytics