这些都是标准OMX的接口头文件和数据类型,从最底层看起,能够更容易理解OMX得各种数据类型,抛砖引玉,希望大家多多谈论自己的经验!!
/platform/external/opencore/extern_libs_v2/khronos/openmax/include/OMX_Types.h
OMX_Types头文件包含使用原始类型的定义核心,应用程序和组件。如用在不同操作系统上此文件可能需要修改, "char"设置为8位,"short"设置为16位和 "long"设置为32位。
OMX_API
OMX_APIENTRY//平台相关
OMX_IN //确定一个OMX的函数输入输出。这也可用于指定一个指针指向一个输出输入参数。
OMX_OUT
OMX_INOUT
OMX_ALL// #define OMX_ALL 0xFFFFFFFF
# <project path="prebuilt" name="platform/prebuilt" />
//数据类型定义
typedef unsigned char OMX_U8
typedef signed char OMX_S8;
typedef unsigned short OMX_U16;
typedef signed short OMX_S16;
typedef unsigned long OMX_U32;
typedef signed long OMX_S32;
typedef unsigned long long OMX_U64;
typedef signed long long OMX_S64;
OMX_BOOL//在OMX core and components参数传递中的二值变量,32bit
typedef enum OMX_BOOL {
OMX_FALSE = 0,
OMX_TRUE = !OMX_FALSE,
OMX_BOOL_MAX = 0x7FFFFFFF
} OMX_BOOL;
OMX_PTR//用来在OMX applications and the OMX Core and components传递指针 32bit
typedef void* OMX_PTR;
OMX_STRING//用来在OMX applications and the OMX Core and components传递"C"类型字符串 32bit以/0结束,该指针字对齐,字符是字节对齐
typedef char* OMX_STRING;
OMX_BYTE//用来在OMX applications and the OMX Core and components传递数组如buffers
typedef unsigned char* OMX_BYTE;
OMX_UUIDTYPE//唯一标识符,保证每一个系统上运行的实例是独一无二的,由component生成
typedef unsigned char OMX_UUIDTYPE[128];
OMX_DIRTYPE//枚举用于表示一个端口是输入或一个输出端口。
typedef enum OMX_DIRTYPE
{
OMX_DirInput, /**< Port is an input port */
OMX_DirOutput, /**< Port is an output port */
OMX_DirMax = 0x7FFFFFFF
} OMX_DIRTYPE;
OMX_ENDIANTYPE
typedef enum OMX_ENDIANTYPE
{
OMX_EndianBig, /**< big endian */
OMX_EndianLittle, /**< little endian */
OMX_EndianMax = 0x7FFFFFFF
} OMX_ENDIANTYPE;
OMX_NUMERICALDATATYPE
typedef enum OMX_NUMERICALDATATYPE
{
OMX_NumericalDataSigned, /**< signed data */
OMX_NumericalDataUnsigned, /**< unsigned data */
OMX_NumercialDataMax = 0x7FFFFFFF
} OMX_NUMERICALDATATYPE;
OMX_BU32
/** Unsigned bounded value type */
typedef struct OMX_BU32 {
OMX_U32 nValue; /**< actual value */
OMX_U32 nMin; /**< minimum for value (i.e. nValue >= nMin) */
OMX_U32 nMax; /**< maximum for value (i.e. nValue <= nMax) */
} OMX_BU32;
/** Signed bounded value type */
typedef struct OMX_BS32 {
OMX_S32 nValue; /**< actual value */
OMX_S32 nMin; /**< minimum for value (i.e. nValue >= nMin) */
OMX_S32 nMax; /**< maximum for value (i.e. nValue <= nMax) */
} OMX_BS32;
OMX_TICKS//64bit
#define OMX_TICKS_PER_SECOND 1000000//时间滴答
typedef void* OMX_HANDLETYPE;//public interface for the OMX Handle
OMX_MARKTYPE//component 产生标志事件
typedef struct OMX_MARKTYPE
{
OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will
generate a mark event upon
processing the mark. */
OMX_PTR pMarkData; /**< Application specific data associated with
the mark sent on a mark event to disambiguate
this mark from others. */
} OMX_MARKTYPE;
OMX_NATIVE_DEVICETYPE//用来映射OMX video port给native使用
typedef void* OMX_NATIVE_DEVICETYPE;
typedef void* OMX_NATIVE_WINDOWTYPE;//用来映射OMX video port给window
OMX_VERSIONTYPE//版本
/platform/external/opencore/extern_libs_v2/khronos/openmax/include/OMX_Index.h
OMX_INDEXTYPE//枚举类型,当设计、获得参数或配置数据时用来选择一个结构体,每个entry对应一个特定结构体
当方法OMX_GetParameter, OMX_SetParameter, OMX_GetConfig or OMX_SetConfig 使用时,这个枚举的第二个参数用作entry
第三个entrt是结构体
OMX_SetConfig command would have OMX_IndexConfigCommonInputCrop
send a pointer to an initialized OMX_RECTTYPE structure as the
third parameter.
/platform/external/opencore/extern_libs_v2/khronos/openmax/include/OMX_Core.h
OMX_COMMANDTYPE//表示一个OMX_SendCommand的action
typedef enum OMX_COMMANDTYPE
{
OMX_CommandStateSet, /**< Change the component state */
OMX_CommandFlush, /**< Flush the data queue(s) of a component */
OMX_CommandPortDisable, /**< Disable a port on a component. */
OMX_CommandPortEnable, /**< Enable a port on a component. */
OMX_CommandMarkBuffer, /**< Mark a component/buffer for observation */
OMX_CommandKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_CommandVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_CommandMax = 0X7FFFFFFF
} OMX_COMMANDTYPE;
typedef enum OMX_STATETYPE
typedef enum OMX_ERRORTYPE
typedef OMX_ERRORTYPE (* OMX_COMPONENTINITTYPE)(OMX_IN OMX_HANDLETYPE hComponent);
typedef struct OMX_COMPONENTREGISTERTYPE
extern OMX_COMPONENTREGISTERTYPE OMX_ComponentRegistered[];
OMX_PRIORITYMGMTTYPE
1)OMX_Init
2)OMX_Deinit
3)OMX_GetHandle
4)OMX_FreeHandle
5)OMX_ComponentNameEnum
6)OMX_GetComponentsOfRole
7)OMX_GetRolesOfComponent
8)OMX_SetupTunnel
9)OMX_GetContentPipe
/platform/external/opencore/extern_libs_v2/khronos/openmax/include/OMX_audio.h
typedef enum OMX_AUDIO_CODINGTYPE//用于audio编码
typedef struct OMX_AUDIO_PORTDEFINITIONTYPE//
typedef struct OMX_AUDIO_PARAM_PORTFORMATTYPE //端口格式
/platform/external/opencore/codecs_v2/omx/omx_mastercore/include/omx_interface.h
/platform/external/opencore/codecs_v2/omx/omx_common/src/pv_omxcore.cpp
//属于OMX_core的9个方法
1)OMX_Init
2)OMX_Deinit
3)OMX_GetHandle
4)OMX_FreeHandle
5)OMX_ComponentNameEnum
6)OMX_GetComponentsOfRole
7)OMX_GetRolesOfComponent
8)OMX_SetupTunnel
9)OMX_GetContentPipe
The code for the OMX core wrapper interface template for this case is provided in:
.../codecs_v2/omx/omx_core_plugins/template/src
#ifndef PV_OMXCORE_H_INCLUDED
#define PV_OMXCORE_H_INCLUDED
#ifndef PV_OMXDEFS_H_INCLUDED
#include "pv_omxdefs.h"
#endif
#ifndef PV_OMX_QUEUE_H_INCLUDED
#include "pv_omx_queue.h"
#endif
#ifndef OMX_Types_h
#include "OMX_Types.h"
#endif
#ifndef OSCL_BASE_INCLUDED_H
#include "oscl_base.h" //OSCL操作系统兼容层
#endif
#ifndef OSCL_UUID_H_INCLUDED
#include "oscl_uuid.h"
#endif
#ifndef OMX_Core_h
#include "OMX_Core.h"
#endif
#ifndef OMX_Component_h
#include "OMX_Component.h"
#endif
#if PROXY_INTERFACE
#ifndef OMX_PROXY_INTERFACE_H_INCLUDED
#include "omx_proxy_interface.h"
#endif
#endif
#if USE_DYNAMIC_LOAD_OMX_COMPONENTS
#ifndef OSCL_SHARED_LIBRARY_H_INCLUDED
#include "oscl_shared_library.h"
#endif
#endif
#define MAX_ROLES_SUPPORTED 3
#ifdef __cplusplus
extern "C"
{
#endif
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_GetComponentsOfRole(
OMX_IN OMX_STRING role,
OMX_INOUT OMX_U32 *pNumComps,
OMX_INOUT OMX_U8 **compNames);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum(
OMX_OUT OMX_STRING cComponentName,
OMX_IN OMX_U32 nNameLength,
OMX_IN OMX_U32 nIndex);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle(OMX_OUT OMX_HANDLETYPE* pHandle,
OMX_IN OMX_STRING cComponentName,
OMX_IN OMX_PTR pAppData,
OMX_IN OMX_CALLBACKTYPE* pCallBacks);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_GetRolesOfComponent(
OMX_IN OMX_STRING compName,
OMX_INOUT OMX_U32* pNumRoles,
OMX_OUT OMX_U8** roles);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_SetupTunnel(
OMX_IN OMX_HANDLETYPE hOutput,
OMX_IN OMX_U32 nPortOutput,
OMX_IN OMX_HANDLETYPE hInput,
OMX_IN OMX_U32 nPortInput);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_GetContentPipe(
OMX_OUT OMX_HANDLETYPE *hPipe,
OMX_IN OMX_STRING szURI);
OSCL_IMPORT_REF OMX_BOOL OMXConfigParser(
OMX_PTR aInputParameters,
OMX_PTR aOutputParameters);
#ifdef __cplusplus
}
#endif
#if USE_DYNAMIC_LOAD_OMX_COMPONENTS
//Dynamic loading interface definitions
#define PV_OMX_SHARED_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x67)
#define PV_OMX_CREATE_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x68)
#define PV_OMX_DESTROY_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x69)
#define PV_OMX_AVCDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6a)
#define PV_OMX_M4VDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6b)
#define PV_OMX_H263DEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6c)
#define PV_OMX_WMVDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6d)
#define PV_OMX_AACDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6e)
#define PV_OMX_AMRDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6f)
#define PV_OMX_MP3DEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x70)
#define PV_OMX_WMADEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x71)
#define PV_OMX_AVCENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x72)
#define PV_OMX_M4VENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x73)
#define PV_OMX_H263ENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x74)
#define PV_OMX_AMRENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x75)
#define PV_OMX_AACENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x76)
#define PV_OMX_RVDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x77)
#define PV_OMX_RADEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x78)
#define OMX_MAX_LIB_PATH 256
class OmxSharedLibraryInterface
{
public:
virtual OsclAny *QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId) = 0;
};
#endif // USE_DYNAMIC_LOAD_OMX_COMPONENTS
// PV additions to OMX_EXTRADATATYPE enum
#define OMX_ExtraDataNALSizeArray 0x7F123321 // random value above 0x7F000000 (start of the unused range for vendors)
class ComponentRegistrationType
{
public:
// name of the component used as identifier
OMX_STRING ComponentName;
OMX_STRING RoleString[MAX_ROLES_SUPPORTED];
OMX_U32 NumberOfRolesSupported;
// pointer to factory function to be called when component needs to be instantiated
OMX_ERRORTYPE(*FunctionPtrCreateComponent)(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData,
OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
// pointer to function that destroys the component and its AO
OMX_ERRORTYPE(*FunctionPtrDestroyComponent)(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
//This function will return the role string
void GetRolesOfComponent(OMX_STRING* aRole_string)
{
for (OMX_U32 ii = 0; ii < NumberOfRolesSupported; ii++)
{
aRole_string[ii] = RoleString[ii];
}
}
// for dynamic loading
OMX_STRING SharedLibraryName;
OMX_PTR SharedLibraryPtr;
OMX_PTR SharedLibraryOsclUuid;
OMX_U32 SharedLibraryRefCounter;
};
typedef struct CoreDescriptorType
{
QueueType* pMessageQueue; // The output queue for the messages to be send to the components
} CoreDescriptorType;
/** This structure contains all the fields of a message handled by the core */
struct CoreMessage
{
OMX_COMPONENTTYPE* pComponent; /// A reference to the main structure that defines a component. It represents the target of the message
OMX_S32 MessageType; /// the flag that specifies if the message is a command, a warning or an error
OMX_S32 MessageParam1; /// the first field of the message. Its use is the same as specified for the command in OpenMAX spec
OMX_S32 MessageParam2; /// the second field of the message. Its use is the same as specified for the command in OpenMAX spec
OMX_PTR pCmdData; /// This pointer could contain some proprietary data not covered by the standard
};
typedef struct PV_OMXComponentCapabilityFlagsType
{
// OMX COMPONENT CAPABILITY RELATED MEMBERS
OMX_BOOL iIsOMXComponentMultiThreaded;
OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc;
OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc;
OMX_BOOL iOMXComponentSupportsMovableInputBuffers;
OMX_BOOL iOMXComponentSupportsPartialFrames;
OMX_BOOL iOMXComponentUsesNALStartCodes;
OMX_BOOL iOMXComponentCanHandleIncompleteFrames;
OMX_BOOL iOMXComponentUsesFullAVCFrames;
OMX_BOOL iOMXComponentUsesInterleaved2BNALSizes;
OMX_BOOL iOMXComponentUsesInterleaved4BNALSizes;
} PV_OMXComponentCapabilityFlagsType;
class OMXGlobalData
{
public:
OMXGlobalData()
: iInstanceCount(1),
iOsclInit(false),
iNumBaseInstance(0),
iComponentIndex(0)
{
for (OMX_S32 ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
{
ipInstantiatedComponentReg[ii] = NULL;
}
}
uint32 iInstanceCount;
bool iOsclInit; //did we do OsclInit in OMX_Init? if so we must cleanup in OMX_Deinit.
//Number of base instances
OMX_U32 iNumBaseInstance;
// Array to store component handles for future recognition of components etc.
OMX_HANDLETYPE iComponentHandle[MAX_INSTANTIATED_COMPONENTS];
OMX_U32 iComponentIndex;
// Array of supported component types (e.g. MP4, AVC, AAC, etc.)
// they need to be registered
// For each OMX Component type (e.g. Mp3, AVC, AAC) there is one entry in this table that contains info
// such as component type, factory, destructor functions, library name for dynamic loading etc.
// when the omx component is registered (at OMX_Init)
ComponentRegistrationType* ipRegTemplateList[MAX_SUPPORTED_COMPONENTS];
// Array of pointers - For each OMX component that gets instantiated - the pointer to its registry structure
// is saved here. This information is needed when the component is to be destroyed
ComponentRegistrationType* ipInstantiatedComponentReg[MAX_INSTANTIATED_COMPONENTS];
// array of function pointers. For each component, a destructor function is assigned
//OMX_ERRORTYPE(*ComponentDestructor[MAX_INSTANTIATED_COMPONENTS])(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
#if PROXY_INTERFACE
ProxyApplication_OMX* ipProxyTerm[MAX_INSTANTIATED_COMPONENTS];
#endif
};
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_MasterInit();
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_MasterDeinit();
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_MasterGetComponentsOfRole(
OMX_IN OMX_STRING role,
OMX_INOUT OMX_U32 *pNumComps,
OMX_INOUT OMX_U8 **compNames);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_MasterComponentNameEnum(
OMX_OUT OMX_STRING cComponentName,
OMX_IN OMX_U32 nNameLength,
OMX_IN OMX_U32 nIndex);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_MasterFreeHandle(OMX_IN OMX_HANDLETYPE hComponent);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_MasterGetHandle(OMX_OUT OMX_HANDLETYPE* pHandle,
OMX_IN OMX_STRING cComponentName,
OMX_IN OMX_PTR pAppData,
OMX_IN OMX_CALLBACKTYPE* pCallBacks);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_MasterGetRolesOfComponent(
OMX_IN OMX_STRING compName,
OMX_INOUT OMX_U32* pNumRoles,
OMX_OUT OMX_U8** roles);
OSCL_IMPORT_REF OMX_BOOL OMX_MasterConfigParser(
OMX_PTR aInputParameters,
OMX_PTR aOutputParameters);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_SetupTunnel(
OMX_IN OMX_HANDLETYPE hOutput,
OMX_IN OMX_U32 nPortOutput,
OMX_IN OMX_HANDLETYPE hInput,
OMX_IN OMX_U32 nPortInput);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_GetContentPipe(
OMX_OUT OMX_HANDLETYPE *hPipe,
OMX_IN OMX_STRING szURI);
/platform/external/opencore/extern_libs_v2/khronos/openmax/include/OMX_Types.h
OMX_Types头文件包含使用原始类型的定义核心,应用程序和组件。如用在不同操作系统上此文件可能需要修改, "char"设置为8位,"short"设置为16位和 "long"设置为32位。
OMX_API
OMX_APIENTRY//平台相关
OMX_IN //确定一个OMX的函数输入输出。这也可用于指定一个指针指向一个输出输入参数。
OMX_OUT
OMX_INOUT
OMX_ALL// #define OMX_ALL 0xFFFFFFFF
# <project path="prebuilt" name="platform/prebuilt" />
//数据类型定义
typedef unsigned char OMX_U8
typedef signed char OMX_S8;
typedef unsigned short OMX_U16;
typedef signed short OMX_S16;
typedef unsigned long OMX_U32;
typedef signed long OMX_S32;
typedef unsigned long long OMX_U64;
typedef signed long long OMX_S64;
OMX_BOOL//在OMX core and components参数传递中的二值变量,32bit
typedef enum OMX_BOOL {
OMX_FALSE = 0,
OMX_TRUE = !OMX_FALSE,
OMX_BOOL_MAX = 0x7FFFFFFF
} OMX_BOOL;
OMX_PTR//用来在OMX applications and the OMX Core and components传递指针 32bit
typedef void* OMX_PTR;
OMX_STRING//用来在OMX applications and the OMX Core and components传递"C"类型字符串 32bit以/0结束,该指针字对齐,字符是字节对齐
typedef char* OMX_STRING;
OMX_BYTE//用来在OMX applications and the OMX Core and components传递数组如buffers
typedef unsigned char* OMX_BYTE;
OMX_UUIDTYPE//唯一标识符,保证每一个系统上运行的实例是独一无二的,由component生成
typedef unsigned char OMX_UUIDTYPE[128];
OMX_DIRTYPE//枚举用于表示一个端口是输入或一个输出端口。
typedef enum OMX_DIRTYPE
{
OMX_DirInput, /**< Port is an input port */
OMX_DirOutput, /**< Port is an output port */
OMX_DirMax = 0x7FFFFFFF
} OMX_DIRTYPE;
OMX_ENDIANTYPE
typedef enum OMX_ENDIANTYPE
{
OMX_EndianBig, /**< big endian */
OMX_EndianLittle, /**< little endian */
OMX_EndianMax = 0x7FFFFFFF
} OMX_ENDIANTYPE;
OMX_NUMERICALDATATYPE
typedef enum OMX_NUMERICALDATATYPE
{
OMX_NumericalDataSigned, /**< signed data */
OMX_NumericalDataUnsigned, /**< unsigned data */
OMX_NumercialDataMax = 0x7FFFFFFF
} OMX_NUMERICALDATATYPE;
OMX_BU32
/** Unsigned bounded value type */
typedef struct OMX_BU32 {
OMX_U32 nValue; /**< actual value */
OMX_U32 nMin; /**< minimum for value (i.e. nValue >= nMin) */
OMX_U32 nMax; /**< maximum for value (i.e. nValue <= nMax) */
} OMX_BU32;
/** Signed bounded value type */
typedef struct OMX_BS32 {
OMX_S32 nValue; /**< actual value */
OMX_S32 nMin; /**< minimum for value (i.e. nValue >= nMin) */
OMX_S32 nMax; /**< maximum for value (i.e. nValue <= nMax) */
} OMX_BS32;
OMX_TICKS//64bit
#define OMX_TICKS_PER_SECOND 1000000//时间滴答
typedef void* OMX_HANDLETYPE;//public interface for the OMX Handle
OMX_MARKTYPE//component 产生标志事件
typedef struct OMX_MARKTYPE
{
OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will
generate a mark event upon
processing the mark. */
OMX_PTR pMarkData; /**< Application specific data associated with
the mark sent on a mark event to disambiguate
this mark from others. */
} OMX_MARKTYPE;
OMX_NATIVE_DEVICETYPE//用来映射OMX video port给native使用
typedef void* OMX_NATIVE_DEVICETYPE;
typedef void* OMX_NATIVE_WINDOWTYPE;//用来映射OMX video port给window
OMX_VERSIONTYPE//版本
/platform/external/opencore/extern_libs_v2/khronos/openmax/include/OMX_Index.h
OMX_INDEXTYPE//枚举类型,当设计、获得参数或配置数据时用来选择一个结构体,每个entry对应一个特定结构体
当方法OMX_GetParameter, OMX_SetParameter, OMX_GetConfig or OMX_SetConfig 使用时,这个枚举的第二个参数用作entry
第三个entrt是结构体
OMX_SetConfig command would have OMX_IndexConfigCommonInputCrop
send a pointer to an initialized OMX_RECTTYPE structure as the
third parameter.
/platform/external/opencore/extern_libs_v2/khronos/openmax/include/OMX_Core.h
OMX_COMMANDTYPE//表示一个OMX_SendCommand的action
typedef enum OMX_COMMANDTYPE
{
OMX_CommandStateSet, /**< Change the component state */
OMX_CommandFlush, /**< Flush the data queue(s) of a component */
OMX_CommandPortDisable, /**< Disable a port on a component. */
OMX_CommandPortEnable, /**< Enable a port on a component. */
OMX_CommandMarkBuffer, /**< Mark a component/buffer for observation */
OMX_CommandKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_CommandVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_CommandMax = 0X7FFFFFFF
} OMX_COMMANDTYPE;
typedef enum OMX_STATETYPE
typedef enum OMX_ERRORTYPE
typedef OMX_ERRORTYPE (* OMX_COMPONENTINITTYPE)(OMX_IN OMX_HANDLETYPE hComponent);
typedef struct OMX_COMPONENTREGISTERTYPE
extern OMX_COMPONENTREGISTERTYPE OMX_ComponentRegistered[];
OMX_PRIORITYMGMTTYPE
1)OMX_Init
2)OMX_Deinit
3)OMX_GetHandle
4)OMX_FreeHandle
5)OMX_ComponentNameEnum
6)OMX_GetComponentsOfRole
7)OMX_GetRolesOfComponent
8)OMX_SetupTunnel
9)OMX_GetContentPipe
/platform/external/opencore/extern_libs_v2/khronos/openmax/include/OMX_audio.h
typedef enum OMX_AUDIO_CODINGTYPE//用于audio编码
typedef struct OMX_AUDIO_PORTDEFINITIONTYPE//
typedef struct OMX_AUDIO_PARAM_PORTFORMATTYPE //端口格式
/platform/external/opencore/codecs_v2/omx/omx_mastercore/include/omx_interface.h
/platform/external/opencore/codecs_v2/omx/omx_common/src/pv_omxcore.cpp
//属于OMX_core的9个方法
1)OMX_Init
2)OMX_Deinit
3)OMX_GetHandle
4)OMX_FreeHandle
5)OMX_ComponentNameEnum
6)OMX_GetComponentsOfRole
7)OMX_GetRolesOfComponent
8)OMX_SetupTunnel
9)OMX_GetContentPipe
The code for the OMX core wrapper interface template for this case is provided in:
.../codecs_v2/omx/omx_core_plugins/template/src
#ifndef PV_OMXCORE_H_INCLUDED
#define PV_OMXCORE_H_INCLUDED
#ifndef PV_OMXDEFS_H_INCLUDED
#include "pv_omxdefs.h"
#endif
#ifndef PV_OMX_QUEUE_H_INCLUDED
#include "pv_omx_queue.h"
#endif
#ifndef OMX_Types_h
#include "OMX_Types.h"
#endif
#ifndef OSCL_BASE_INCLUDED_H
#include "oscl_base.h" //OSCL操作系统兼容层
#endif
#ifndef OSCL_UUID_H_INCLUDED
#include "oscl_uuid.h"
#endif
#ifndef OMX_Core_h
#include "OMX_Core.h"
#endif
#ifndef OMX_Component_h
#include "OMX_Component.h"
#endif
#if PROXY_INTERFACE
#ifndef OMX_PROXY_INTERFACE_H_INCLUDED
#include "omx_proxy_interface.h"
#endif
#endif
#if USE_DYNAMIC_LOAD_OMX_COMPONENTS
#ifndef OSCL_SHARED_LIBRARY_H_INCLUDED
#include "oscl_shared_library.h"
#endif
#endif
#define MAX_ROLES_SUPPORTED 3
#ifdef __cplusplus
extern "C"
{
#endif
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_GetComponentsOfRole(
OMX_IN OMX_STRING role,
OMX_INOUT OMX_U32 *pNumComps,
OMX_INOUT OMX_U8 **compNames);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum(
OMX_OUT OMX_STRING cComponentName,
OMX_IN OMX_U32 nNameLength,
OMX_IN OMX_U32 nIndex);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle(OMX_OUT OMX_HANDLETYPE* pHandle,
OMX_IN OMX_STRING cComponentName,
OMX_IN OMX_PTR pAppData,
OMX_IN OMX_CALLBACKTYPE* pCallBacks);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_GetRolesOfComponent(
OMX_IN OMX_STRING compName,
OMX_INOUT OMX_U32* pNumRoles,
OMX_OUT OMX_U8** roles);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_SetupTunnel(
OMX_IN OMX_HANDLETYPE hOutput,
OMX_IN OMX_U32 nPortOutput,
OMX_IN OMX_HANDLETYPE hInput,
OMX_IN OMX_U32 nPortInput);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_GetContentPipe(
OMX_OUT OMX_HANDLETYPE *hPipe,
OMX_IN OMX_STRING szURI);
OSCL_IMPORT_REF OMX_BOOL OMXConfigParser(
OMX_PTR aInputParameters,
OMX_PTR aOutputParameters);
#ifdef __cplusplus
}
#endif
#if USE_DYNAMIC_LOAD_OMX_COMPONENTS
//Dynamic loading interface definitions
#define PV_OMX_SHARED_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x67)
#define PV_OMX_CREATE_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x68)
#define PV_OMX_DESTROY_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x69)
#define PV_OMX_AVCDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6a)
#define PV_OMX_M4VDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6b)
#define PV_OMX_H263DEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6c)
#define PV_OMX_WMVDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6d)
#define PV_OMX_AACDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6e)
#define PV_OMX_AMRDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6f)
#define PV_OMX_MP3DEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x70)
#define PV_OMX_WMADEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x71)
#define PV_OMX_AVCENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x72)
#define PV_OMX_M4VENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x73)
#define PV_OMX_H263ENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x74)
#define PV_OMX_AMRENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x75)
#define PV_OMX_AACENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x76)
#define PV_OMX_RVDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x77)
#define PV_OMX_RADEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x78)
#define OMX_MAX_LIB_PATH 256
class OmxSharedLibraryInterface
{
public:
virtual OsclAny *QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId) = 0;
};
#endif // USE_DYNAMIC_LOAD_OMX_COMPONENTS
// PV additions to OMX_EXTRADATATYPE enum
#define OMX_ExtraDataNALSizeArray 0x7F123321 // random value above 0x7F000000 (start of the unused range for vendors)
class ComponentRegistrationType
{
public:
// name of the component used as identifier
OMX_STRING ComponentName;
OMX_STRING RoleString[MAX_ROLES_SUPPORTED];
OMX_U32 NumberOfRolesSupported;
// pointer to factory function to be called when component needs to be instantiated
OMX_ERRORTYPE(*FunctionPtrCreateComponent)(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData,
OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
// pointer to function that destroys the component and its AO
OMX_ERRORTYPE(*FunctionPtrDestroyComponent)(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
//This function will return the role string
void GetRolesOfComponent(OMX_STRING* aRole_string)
{
for (OMX_U32 ii = 0; ii < NumberOfRolesSupported; ii++)
{
aRole_string[ii] = RoleString[ii];
}
}
// for dynamic loading
OMX_STRING SharedLibraryName;
OMX_PTR SharedLibraryPtr;
OMX_PTR SharedLibraryOsclUuid;
OMX_U32 SharedLibraryRefCounter;
};
typedef struct CoreDescriptorType
{
QueueType* pMessageQueue; // The output queue for the messages to be send to the components
} CoreDescriptorType;
/** This structure contains all the fields of a message handled by the core */
struct CoreMessage
{
OMX_COMPONENTTYPE* pComponent; /// A reference to the main structure that defines a component. It represents the target of the message
OMX_S32 MessageType; /// the flag that specifies if the message is a command, a warning or an error
OMX_S32 MessageParam1; /// the first field of the message. Its use is the same as specified for the command in OpenMAX spec
OMX_S32 MessageParam2; /// the second field of the message. Its use is the same as specified for the command in OpenMAX spec
OMX_PTR pCmdData; /// This pointer could contain some proprietary data not covered by the standard
};
typedef struct PV_OMXComponentCapabilityFlagsType
{
// OMX COMPONENT CAPABILITY RELATED MEMBERS
OMX_BOOL iIsOMXComponentMultiThreaded;
OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc;
OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc;
OMX_BOOL iOMXComponentSupportsMovableInputBuffers;
OMX_BOOL iOMXComponentSupportsPartialFrames;
OMX_BOOL iOMXComponentUsesNALStartCodes;
OMX_BOOL iOMXComponentCanHandleIncompleteFrames;
OMX_BOOL iOMXComponentUsesFullAVCFrames;
OMX_BOOL iOMXComponentUsesInterleaved2BNALSizes;
OMX_BOOL iOMXComponentUsesInterleaved4BNALSizes;
} PV_OMXComponentCapabilityFlagsType;
class OMXGlobalData
{
public:
OMXGlobalData()
: iInstanceCount(1),
iOsclInit(false),
iNumBaseInstance(0),
iComponentIndex(0)
{
for (OMX_S32 ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
{
ipInstantiatedComponentReg[ii] = NULL;
}
}
uint32 iInstanceCount;
bool iOsclInit; //did we do OsclInit in OMX_Init? if so we must cleanup in OMX_Deinit.
//Number of base instances
OMX_U32 iNumBaseInstance;
// Array to store component handles for future recognition of components etc.
OMX_HANDLETYPE iComponentHandle[MAX_INSTANTIATED_COMPONENTS];
OMX_U32 iComponentIndex;
// Array of supported component types (e.g. MP4, AVC, AAC, etc.)
// they need to be registered
// For each OMX Component type (e.g. Mp3, AVC, AAC) there is one entry in this table that contains info
// such as component type, factory, destructor functions, library name for dynamic loading etc.
// when the omx component is registered (at OMX_Init)
ComponentRegistrationType* ipRegTemplateList[MAX_SUPPORTED_COMPONENTS];
// Array of pointers - For each OMX component that gets instantiated - the pointer to its registry structure
// is saved here. This information is needed when the component is to be destroyed
ComponentRegistrationType* ipInstantiatedComponentReg[MAX_INSTANTIATED_COMPONENTS];
// array of function pointers. For each component, a destructor function is assigned
//OMX_ERRORTYPE(*ComponentDestructor[MAX_INSTANTIATED_COMPONENTS])(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
#if PROXY_INTERFACE
ProxyApplication_OMX* ipProxyTerm[MAX_INSTANTIATED_COMPONENTS];
#endif
};
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_MasterInit();
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_MasterDeinit();
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_MasterGetComponentsOfRole(
OMX_IN OMX_STRING role,
OMX_INOUT OMX_U32 *pNumComps,
OMX_INOUT OMX_U8 **compNames);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_MasterComponentNameEnum(
OMX_OUT OMX_STRING cComponentName,
OMX_IN OMX_U32 nNameLength,
OMX_IN OMX_U32 nIndex);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_MasterFreeHandle(OMX_IN OMX_HANDLETYPE hComponent);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_MasterGetHandle(OMX_OUT OMX_HANDLETYPE* pHandle,
OMX_IN OMX_STRING cComponentName,
OMX_IN OMX_PTR pAppData,
OMX_IN OMX_CALLBACKTYPE* pCallBacks);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_MasterGetRolesOfComponent(
OMX_IN OMX_STRING compName,
OMX_INOUT OMX_U32* pNumRoles,
OMX_OUT OMX_U8** roles);
OSCL_IMPORT_REF OMX_BOOL OMX_MasterConfigParser(
OMX_PTR aInputParameters,
OMX_PTR aOutputParameters);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_SetupTunnel(
OMX_IN OMX_HANDLETYPE hOutput,
OMX_IN OMX_U32 nPortOutput,
OMX_IN OMX_HANDLETYPE hInput,
OMX_IN OMX_U32 nPortInput);
OSCL_IMPORT_REF OMX_ERRORTYPE OMX_GetContentPipe(
OMX_OUT OMX_HANDLETYPE *hPipe,
OMX_IN OMX_STRING szURI);