From 1707a166395bcd9d38068297b12d354d1d1666d6 Mon Sep 17 00:00:00 2001 From: Vijay Venkatraman Date: Tue, 6 Dec 2016 17:26:49 -0800 Subject: Replacing LOCAL_COPY_HEADERS with LOCAL_EXPORT_C_INCLUDE_DIRS, for VNDK Moved arbitrator and omx_adaptor headers to exportable include/ dir. Added symlink at old location Bug: 33241851 Test: Add lib to LOCAL_EXPORT_SHARED_LIBRARIES Change-Id: Ibfc9fc2d5744ff555e23b835cc63d27dfbeeda3f --- media_resource_manager/Android.mk | 8 - media_resource_manager/arbitrator/Android.mk | 1 + .../arbitrator/MediaResourceArbitrator.h | 180 +-------------------- media_resource_manager/arbitrator/include | 1 + .../MediaResourceArbitrator.h | 179 ++++++++++++++++++++ .../include/media_resource_manager/OMX_adaptor.h | 117 ++++++++++++++ media_resource_manager/omx_adaptor/Android.mk | 1 + media_resource_manager/omx_adaptor/OMX_adaptor.h | 118 +------------- media_resource_manager/omx_adaptor/include | 1 + 9 files changed, 302 insertions(+), 304 deletions(-) mode change 100644 => 120000 media_resource_manager/arbitrator/MediaResourceArbitrator.h create mode 120000 media_resource_manager/arbitrator/include create mode 100644 media_resource_manager/include/media_resource_manager/MediaResourceArbitrator.h create mode 100644 media_resource_manager/include/media_resource_manager/OMX_adaptor.h mode change 100644 => 120000 media_resource_manager/omx_adaptor/OMX_adaptor.h create mode 120000 media_resource_manager/omx_adaptor/include (limited to 'media_resource_manager') diff --git a/media_resource_manager/Android.mk b/media_resource_manager/Android.mk index c577542..abed527 100644 --- a/media_resource_manager/Android.mk +++ b/media_resource_manager/Android.mk @@ -1,13 +1,5 @@ LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_COPY_HEADERS_TO := media_resource_manager -LOCAL_COPY_HEADERS := \ - arbitrator/MediaResourceArbitrator.h \ - omx_adaptor/OMX_adaptor.h - -include $(BUILD_COPY_HEADERS) include $(CLEAR_VARS) MEDIA_RESOURCE_MANAGER_ROOT := $(LOCAL_PATH) diff --git a/media_resource_manager/arbitrator/Android.mk b/media_resource_manager/arbitrator/Android.mk index 9de52a5..d665c24 100644 --- a/media_resource_manager/arbitrator/Android.mk +++ b/media_resource_manager/arbitrator/Android.mk @@ -16,6 +16,7 @@ LOCAL_C_INCLUDES := \ $(TARGET_OUT_HEADERS)/khronos/openmax \ $(call include-path-for, frameworks-native)/media/openmax +LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include LOCAL_MODULE_TAGS := optional LOCAL_MODULE := libmrm_arbitrator diff --git a/media_resource_manager/arbitrator/MediaResourceArbitrator.h b/media_resource_manager/arbitrator/MediaResourceArbitrator.h deleted file mode 100644 index abb7b1a..0000000 --- a/media_resource_manager/arbitrator/MediaResourceArbitrator.h +++ /dev/null @@ -1,179 +0,0 @@ -/* -* Copyright (c) 2015 Intel Corporation. All rights reserved. -* -* 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 MEDIA_RESOURCE_ARBITRATOR_H_ -#define MEDIA_RESOURCE_ARBITRATOR_H_ - -#include -#include -#include -#include - -#define MAX_BUFFER_SIZE (20 * 1024) - -using namespace android; - -// This error type keeps align with the OMX error type -typedef enum _ArbitratorErrorType { - ArbitratorErrorNone = 0, - - /** There were insufficient resources to perform the requested operation */ - ArbitratorErrorInsufficientResources = 0x80001000, - - /** There was an error, but the cause of the error could not be determined */ - ArbitratorErrorUndefined = 0x80001001 -} ArbitratorErrorType; - - -typedef enum _ResolutionType { - Resolution_CIF = 0, - Resolution_480, - Resolution_720, - Resolution_1080, - Resolution_2K, - Resolution_4K, - Resolution_MAX -} ResolutionType; - - -typedef enum _CodecType { - CODEC_TYPE_AVC = 0, - CODEC_TYPE_HEVC, - CODEC_TYPE_VP8, - CODEC_TYPE_VP9, - CODEC_TYPE_MPEG4, - CODEC_TYPE_MPEG2, - CODEC_TYPE_H263, - CODEC_TYPE_VC1, - CODEC_TYPE_WMV, - CODEC_TYPE_MAX -} CodecType; - - -typedef struct _CodecInfo { - CodecType codecType; - bool isEncoder; - bool isSecured; - ResolutionType resolution; - uint frameRate; -} CodecInfo; - - -typedef struct _CodecLimitInfo { - CodecInfo codecInfo; - int instanceLimit; -} CodecLimitInfo; - - -typedef struct _LivingDecodersTable { - Vector livingDecoders; - uint maxResolution; - uint maxFrameRate; -} LivingDecodersTable; - - -typedef struct _LivingEncodersTable { - Vector livingEncoders; - uint maxResolution; - uint maxFrameRate; -} LivingEncodersTable; - - -class MediaResourceArbitrator { -public: - MediaResourceArbitrator (); - ~MediaResourceArbitrator (); - - /* Initialize the arbitrator. - Parse the config XML file if given. */ - ArbitratorErrorType Config(const char* configFilePath); - - /* Check if the resource limitation is hit and - it is under full load status. In such status, there - is no room to instantiate codec anymore. */ - bool CheckIfFullLoad(bool isEncoder); - - /* Add codec in the pool. - Resolution and frame rate must be provided. - This is not necessarily be called when codec instance - is constructed when the resolution and frame rate are - not known yet. - This may be called when codec is configured, - for example in OMX set parameter, etc. - Return value is expected to be as one of: - ArbitratorErrorNone, - ArbitratorErrorInsufficientResources - */ - ArbitratorErrorType AddResource(/* in */ CodecType codecType, - /* in */ bool isEncoder, - /* in */ bool isSecured, - /* in */ ResolutionType resolution, - /* in */ uint frameRate); - - /* Remove codec in the pool.*/ - ArbitratorErrorType RemoveResource(CodecType codecType, - bool isEncoder, - bool isSecured, - ResolutionType resolution, - uint frameRate); - - uint GetLivingCodecsNum(void); - - // XML function - void ParseXMLFile(FILE* fp); - static void startElement(void *userData, const char *name, const char **atts); - static void endElement(void *userData, const char *name); - void getConfigData(const char *name, const char **atts); - -private: - // a global table stores all codec limit info - Vector mDecoderLimitInfos; - Vector mEncoderLimitInfos; - - // a global talbe stores all living codec info - LivingDecodersTable mLivingDecodersTable; - LivingEncodersTable mLivingEncodersTable; - - // arbitrator lock - pthread_mutex_t mArbitratorLock; - - // indicate whether it is under full load status - bool mIsEncoderUnderFullLoad; - bool mIsDecoderUnderFullLoad; - - KeyedVector mCodecNameTypeMap; - KeyedVector mResolutionNameTypeMap; - - static const int mBufSize = MAX_BUFFER_SIZE; - // indicate XML parser is parsing a codec tag - bool mIfParsingCodec; - CodecLimitInfo mParsingCodecLimitInfo; - - ArbitratorErrorType ArbitrateFullLoad(CodecInfo& codec); - - bool CheckCodecMatched(const CodecInfo& sourceCodec, - const CodecInfo& targetCodec); - - void SetupDefaultCodecLimitation(void); - void InitializeCodecNameTypeMap(); - void InitializeResolutionNameTypeMap(); - void DumpCodecTypeFromVector(void); - CodecType MapCodecTypeFromName(const char* name); - ResolutionType MapResolutionTypeFromName(const char* name); -}; - -#endif /* MEDIA_RESOURCE_ARBITRATOR_H_ */ diff --git a/media_resource_manager/arbitrator/MediaResourceArbitrator.h b/media_resource_manager/arbitrator/MediaResourceArbitrator.h new file mode 120000 index 0000000..ac6380d --- /dev/null +++ b/media_resource_manager/arbitrator/MediaResourceArbitrator.h @@ -0,0 +1 @@ +../include/media_resource_manager/MediaResourceArbitrator.h \ No newline at end of file diff --git a/media_resource_manager/arbitrator/include b/media_resource_manager/arbitrator/include new file mode 120000 index 0000000..3a1af68 --- /dev/null +++ b/media_resource_manager/arbitrator/include @@ -0,0 +1 @@ +../include/ \ No newline at end of file diff --git a/media_resource_manager/include/media_resource_manager/MediaResourceArbitrator.h b/media_resource_manager/include/media_resource_manager/MediaResourceArbitrator.h new file mode 100644 index 0000000..abb7b1a --- /dev/null +++ b/media_resource_manager/include/media_resource_manager/MediaResourceArbitrator.h @@ -0,0 +1,179 @@ +/* +* Copyright (c) 2015 Intel Corporation. All rights reserved. +* +* 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 MEDIA_RESOURCE_ARBITRATOR_H_ +#define MEDIA_RESOURCE_ARBITRATOR_H_ + +#include +#include +#include +#include + +#define MAX_BUFFER_SIZE (20 * 1024) + +using namespace android; + +// This error type keeps align with the OMX error type +typedef enum _ArbitratorErrorType { + ArbitratorErrorNone = 0, + + /** There were insufficient resources to perform the requested operation */ + ArbitratorErrorInsufficientResources = 0x80001000, + + /** There was an error, but the cause of the error could not be determined */ + ArbitratorErrorUndefined = 0x80001001 +} ArbitratorErrorType; + + +typedef enum _ResolutionType { + Resolution_CIF = 0, + Resolution_480, + Resolution_720, + Resolution_1080, + Resolution_2K, + Resolution_4K, + Resolution_MAX +} ResolutionType; + + +typedef enum _CodecType { + CODEC_TYPE_AVC = 0, + CODEC_TYPE_HEVC, + CODEC_TYPE_VP8, + CODEC_TYPE_VP9, + CODEC_TYPE_MPEG4, + CODEC_TYPE_MPEG2, + CODEC_TYPE_H263, + CODEC_TYPE_VC1, + CODEC_TYPE_WMV, + CODEC_TYPE_MAX +} CodecType; + + +typedef struct _CodecInfo { + CodecType codecType; + bool isEncoder; + bool isSecured; + ResolutionType resolution; + uint frameRate; +} CodecInfo; + + +typedef struct _CodecLimitInfo { + CodecInfo codecInfo; + int instanceLimit; +} CodecLimitInfo; + + +typedef struct _LivingDecodersTable { + Vector livingDecoders; + uint maxResolution; + uint maxFrameRate; +} LivingDecodersTable; + + +typedef struct _LivingEncodersTable { + Vector livingEncoders; + uint maxResolution; + uint maxFrameRate; +} LivingEncodersTable; + + +class MediaResourceArbitrator { +public: + MediaResourceArbitrator (); + ~MediaResourceArbitrator (); + + /* Initialize the arbitrator. + Parse the config XML file if given. */ + ArbitratorErrorType Config(const char* configFilePath); + + /* Check if the resource limitation is hit and + it is under full load status. In such status, there + is no room to instantiate codec anymore. */ + bool CheckIfFullLoad(bool isEncoder); + + /* Add codec in the pool. + Resolution and frame rate must be provided. + This is not necessarily be called when codec instance + is constructed when the resolution and frame rate are + not known yet. + This may be called when codec is configured, + for example in OMX set parameter, etc. + Return value is expected to be as one of: + ArbitratorErrorNone, + ArbitratorErrorInsufficientResources + */ + ArbitratorErrorType AddResource(/* in */ CodecType codecType, + /* in */ bool isEncoder, + /* in */ bool isSecured, + /* in */ ResolutionType resolution, + /* in */ uint frameRate); + + /* Remove codec in the pool.*/ + ArbitratorErrorType RemoveResource(CodecType codecType, + bool isEncoder, + bool isSecured, + ResolutionType resolution, + uint frameRate); + + uint GetLivingCodecsNum(void); + + // XML function + void ParseXMLFile(FILE* fp); + static void startElement(void *userData, const char *name, const char **atts); + static void endElement(void *userData, const char *name); + void getConfigData(const char *name, const char **atts); + +private: + // a global table stores all codec limit info + Vector mDecoderLimitInfos; + Vector mEncoderLimitInfos; + + // a global talbe stores all living codec info + LivingDecodersTable mLivingDecodersTable; + LivingEncodersTable mLivingEncodersTable; + + // arbitrator lock + pthread_mutex_t mArbitratorLock; + + // indicate whether it is under full load status + bool mIsEncoderUnderFullLoad; + bool mIsDecoderUnderFullLoad; + + KeyedVector mCodecNameTypeMap; + KeyedVector mResolutionNameTypeMap; + + static const int mBufSize = MAX_BUFFER_SIZE; + // indicate XML parser is parsing a codec tag + bool mIfParsingCodec; + CodecLimitInfo mParsingCodecLimitInfo; + + ArbitratorErrorType ArbitrateFullLoad(CodecInfo& codec); + + bool CheckCodecMatched(const CodecInfo& sourceCodec, + const CodecInfo& targetCodec); + + void SetupDefaultCodecLimitation(void); + void InitializeCodecNameTypeMap(); + void InitializeResolutionNameTypeMap(); + void DumpCodecTypeFromVector(void); + CodecType MapCodecTypeFromName(const char* name); + ResolutionType MapResolutionTypeFromName(const char* name); +}; + +#endif /* MEDIA_RESOURCE_ARBITRATOR_H_ */ diff --git a/media_resource_manager/include/media_resource_manager/OMX_adaptor.h b/media_resource_manager/include/media_resource_manager/OMX_adaptor.h new file mode 100644 index 0000000..145233d --- /dev/null +++ b/media_resource_manager/include/media_resource_manager/OMX_adaptor.h @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2015 Intel Corporation. All rights reserved. +* +* 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 OMX_WRAPPER_H_ +#define OMX_WRAPPER_H_ + +#include +#include +#include +#include +#include +#include +#include "MediaResourceArbitrator.h" + +using namespace android; + +typedef KeyedVector ComponentNameMap; +typedef KeyedVector ComponentFramerateMap; + +typedef struct _AdaptorCodecInfo { + CodecType codecType; + bool isEncoder; + bool isSecured; + ResolutionType resolution; + uint frameRate; +} AdaptorCodecInfo; + +typedef KeyedVector ComponentInfoMap; + +class MRM_OMX_Adaptor { +public: + // Returns the singleton instance + static MRM_OMX_Adaptor* getInstance(); + + ~MRM_OMX_Adaptor() { + if (sInstance) { + delete sInstance; + sInstance = NULL; + } + }; + + // create and configure the MRM arbitrator + OMX_ERRORTYPE MRM_OMX_Init(void); + + + // check with MRM arbitrator if codec resource + // is under full load status. + // this should be called before OMX_GetHandle + // return OMX_ErrorInsufficientResources if true. + OMX_ERRORTYPE MRM_OMX_CheckIfFullLoad(OMX_STRING cComponentName); + + + // Set component name and component handle + // keeps this mapping but not adds resource yet. + // this intends to be called after OMX_GetHandle + void MRM_OMX_SetComponent( + OMX_HANDLETYPE pComponentHandle, + OMX_STRING cComponentName); + + + // handle the index 'OMX_IndexParamPortDefinition' + // when codec is configured, with resolution and + // frame rate. this actually adds resource + // to the MRM arbitrator. + // return OMX_ErrorInsufficientResources if failed. + OMX_ERRORTYPE MRM_OMX_SetParameter( + OMX_HANDLETYPE hComponent, + OMX_INDEXTYPE nIndex, + OMX_PTR pComponentParameterStructure); + + + // check grahpic buffer resource + // return OMX_ErrorInsufficientResources if under full load status. + OMX_ERRORTYPE MRM_OMX_UseBuffer( + OMX_HANDLETYPE hComponent, + OMX_BUFFERHEADERTYPE **ppBufferHdr, + OMX_U32 nPortIndex, + OMX_PTR pAppPrivate, + OMX_U32 nSizeBytes, + OMX_U8 *pBuffer); + + + // Remove the component + OMX_ERRORTYPE MRM_OMX_RemoveComponent(OMX_HANDLETYPE pComponentHandle); + +private: + MRM_OMX_Adaptor() { mArbitrator = new MediaResourceArbitrator(); } + MRM_OMX_Adaptor& operator=(const MRM_OMX_Adaptor&); // Don't call me + MRM_OMX_Adaptor(const MRM_OMX_Adaptor&); // Don't call me + + + void ParseCodecInfoFromComponentName(const char* componentName, + AdaptorCodecInfo* codecInfo); + + MediaResourceArbitrator* mArbitrator; + static Mutex sLock; + static MRM_OMX_Adaptor* sInstance; + + ComponentNameMap mComponentNameMap; + ComponentFramerateMap mComponentFramerateMap; + ComponentInfoMap mComponentInfoMap; +}; +#endif /* OMX_WRAPPER_H_ */ diff --git a/media_resource_manager/omx_adaptor/Android.mk b/media_resource_manager/omx_adaptor/Android.mk index 1804ce1..63638db 100644 --- a/media_resource_manager/omx_adaptor/Android.mk +++ b/media_resource_manager/omx_adaptor/Android.mk @@ -12,6 +12,7 @@ LOCAL_SHARED_LIBRARIES := \ libdl \ libmrm_arbitrator \ +LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include LOCAL_C_INCLUDES := \ $(TARGET_OUT_HEADERS)/khronos/openmax \ diff --git a/media_resource_manager/omx_adaptor/OMX_adaptor.h b/media_resource_manager/omx_adaptor/OMX_adaptor.h deleted file mode 100644 index 145233d..0000000 --- a/media_resource_manager/omx_adaptor/OMX_adaptor.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -* Copyright (c) 2015 Intel Corporation. All rights reserved. -* -* 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 OMX_WRAPPER_H_ -#define OMX_WRAPPER_H_ - -#include -#include -#include -#include -#include -#include -#include "MediaResourceArbitrator.h" - -using namespace android; - -typedef KeyedVector ComponentNameMap; -typedef KeyedVector ComponentFramerateMap; - -typedef struct _AdaptorCodecInfo { - CodecType codecType; - bool isEncoder; - bool isSecured; - ResolutionType resolution; - uint frameRate; -} AdaptorCodecInfo; - -typedef KeyedVector ComponentInfoMap; - -class MRM_OMX_Adaptor { -public: - // Returns the singleton instance - static MRM_OMX_Adaptor* getInstance(); - - ~MRM_OMX_Adaptor() { - if (sInstance) { - delete sInstance; - sInstance = NULL; - } - }; - - // create and configure the MRM arbitrator - OMX_ERRORTYPE MRM_OMX_Init(void); - - - // check with MRM arbitrator if codec resource - // is under full load status. - // this should be called before OMX_GetHandle - // return OMX_ErrorInsufficientResources if true. - OMX_ERRORTYPE MRM_OMX_CheckIfFullLoad(OMX_STRING cComponentName); - - - // Set component name and component handle - // keeps this mapping but not adds resource yet. - // this intends to be called after OMX_GetHandle - void MRM_OMX_SetComponent( - OMX_HANDLETYPE pComponentHandle, - OMX_STRING cComponentName); - - - // handle the index 'OMX_IndexParamPortDefinition' - // when codec is configured, with resolution and - // frame rate. this actually adds resource - // to the MRM arbitrator. - // return OMX_ErrorInsufficientResources if failed. - OMX_ERRORTYPE MRM_OMX_SetParameter( - OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, - OMX_PTR pComponentParameterStructure); - - - // check grahpic buffer resource - // return OMX_ErrorInsufficientResources if under full load status. - OMX_ERRORTYPE MRM_OMX_UseBuffer( - OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE **ppBufferHdr, - OMX_U32 nPortIndex, - OMX_PTR pAppPrivate, - OMX_U32 nSizeBytes, - OMX_U8 *pBuffer); - - - // Remove the component - OMX_ERRORTYPE MRM_OMX_RemoveComponent(OMX_HANDLETYPE pComponentHandle); - -private: - MRM_OMX_Adaptor() { mArbitrator = new MediaResourceArbitrator(); } - MRM_OMX_Adaptor& operator=(const MRM_OMX_Adaptor&); // Don't call me - MRM_OMX_Adaptor(const MRM_OMX_Adaptor&); // Don't call me - - - void ParseCodecInfoFromComponentName(const char* componentName, - AdaptorCodecInfo* codecInfo); - - MediaResourceArbitrator* mArbitrator; - static Mutex sLock; - static MRM_OMX_Adaptor* sInstance; - - ComponentNameMap mComponentNameMap; - ComponentFramerateMap mComponentFramerateMap; - ComponentInfoMap mComponentInfoMap; -}; -#endif /* OMX_WRAPPER_H_ */ diff --git a/media_resource_manager/omx_adaptor/OMX_adaptor.h b/media_resource_manager/omx_adaptor/OMX_adaptor.h new file mode 120000 index 0000000..989467d --- /dev/null +++ b/media_resource_manager/omx_adaptor/OMX_adaptor.h @@ -0,0 +1 @@ +../include/media_resource_manager/OMX_adaptor.h \ No newline at end of file diff --git a/media_resource_manager/omx_adaptor/include b/media_resource_manager/omx_adaptor/include new file mode 120000 index 0000000..3a1af68 --- /dev/null +++ b/media_resource_manager/omx_adaptor/include @@ -0,0 +1 @@ +../include/ \ No newline at end of file -- cgit v1.2.3