diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-07-08 01:04:02 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-07-08 01:04:02 +0000 |
commit | 6f6840a9c174a8a739ffccb49fe8be72bbc2476d (patch) | |
tree | d3c99a519f46ed2afa26c3a4cfc1d0a22db2defe | |
parent | 0c9240f7b6fc8b40881a33a5873fb22c9f6f0fa6 (diff) | |
parent | 99d23a09f13530ad56baba33caf8d72217b2f36a (diff) | |
download | platform_hardware_interfaces-6f6840a9c174a8a739ffccb49fe8be72bbc2476d.tar.gz platform_hardware_interfaces-6f6840a9c174a8a739ffccb49fe8be72bbc2476d.tar.bz2 platform_hardware_interfaces-6f6840a9c174a8a739ffccb49fe8be72bbc2476d.zip |
Merge "move duplicate code to common"
7 files changed, 120 insertions, 231 deletions
diff --git a/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.cpp b/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.cpp index 7240964ecb..4c68219b47 100644 --- a/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.cpp +++ b/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.cpp @@ -46,47 +46,6 @@ using ::android::sp; #include <media_hidl_test_common.h> #include <memory> -Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat( - sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding) { - OMX_U32 index = 0; - OMX_AUDIO_PARAM_PORTFORMATTYPE portFormat; - std::vector<OMX_AUDIO_CODINGTYPE> arrEncoding; - android::hardware::media::omx::V1_0::Status status; - - while (1) { - portFormat.nIndex = index; - status = getPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex, - &portFormat); - if (status != ::android::hardware::media::omx::V1_0::Status::OK) break; - arrEncoding.push_back(portFormat.eEncoding); - index++; - if (index == 512) { - // enumerated way too many formats, highly unusual for this to - // happen. - EXPECT_LE(index, 512U) - << "Expecting OMX_ErrorNoMore but not received"; - break; - } - } - if (!index) return status; - for (index = 0; index < arrEncoding.size(); index++) { - if (arrEncoding[index] == eEncoding) { - portFormat.eEncoding = arrEncoding[index]; - break; - } - } - if (index == arrEncoding.size()) { - ALOGE("setting default Port format %x", (int)arrEncoding[0]); - portFormat.eEncoding = arrEncoding[0]; - } - // In setParam call nIndex shall be ignored as per omx-il specification. - // see how this holds up by corrupting nIndex - portFormat.nIndex = RANDOM_INDEX; - status = setPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex, - &portFormat); - return status; -} - void enumerateProfile(sp<IOmxNode> omxNode, OMX_U32 portIndex, std::vector<int32_t>* arrProfile) { android::hardware::media::omx::V1_0::Status status; diff --git a/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.h b/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.h index 70142f2b05..b187d28415 100644 --- a/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.h +++ b/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.h @@ -20,16 +20,8 @@ #include <media_hidl_test_common.h> /* - * Random Index used for monkey testing while get/set parameters - */ -#define RANDOM_INDEX 1729 - -/* * Common audio utils */ -Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat( - sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding); - void enumerateProfile(sp<IOmxNode> omxNode, OMX_U32 portIndex, std::vector<int32_t>* arrProfile); diff --git a/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp b/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp index e81e6dd4d0..d30a75c406 100755 --- a/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp +++ b/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp @@ -60,6 +60,113 @@ Return<android::hardware::media::omx::V1_0::Status> setRole( return setParam(omxNode, OMX_IndexParamStandardComponentRole, ¶ms); } +// get/set video component port format +Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat( + sp<IOmxNode> omxNode, OMX_U32 portIndex, + OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat, + OMX_U32 xFramerate) { + OMX_U32 index = 0; + OMX_VIDEO_PARAM_PORTFORMATTYPE portFormat; + std::vector<OMX_COLOR_FORMATTYPE> arrColorFormat; + std::vector<OMX_VIDEO_CODINGTYPE> arrCompressionFormat; + android::hardware::media::omx::V1_0::Status status; + + while (1) { + portFormat.nIndex = index; + status = getPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex, + &portFormat); + if (status != ::android::hardware::media::omx::V1_0::Status::OK) break; + if (eCompressionFormat == OMX_VIDEO_CodingUnused) + arrColorFormat.push_back(portFormat.eColorFormat); + else + arrCompressionFormat.push_back(portFormat.eCompressionFormat); + index++; + if (index == 512) { + // enumerated way too many formats, highly unusual for this to + // happen. + EXPECT_LE(index, 512U) + << "Expecting OMX_ErrorNoMore but not received"; + break; + } + } + if (!index) return status; + if (eCompressionFormat == OMX_VIDEO_CodingUnused) { + for (index = 0; index < arrColorFormat.size(); index++) { + if (arrColorFormat[index] == eColorFormat) { + portFormat.eColorFormat = arrColorFormat[index]; + break; + } + } + if (index == arrColorFormat.size()) { + ALOGE("setting default color format %x", (int)arrColorFormat[0]); + portFormat.eColorFormat = arrColorFormat[0]; + } + portFormat.eCompressionFormat = OMX_VIDEO_CodingUnused; + } else { + for (index = 0; index < arrCompressionFormat.size(); index++) { + if (arrCompressionFormat[index] == eCompressionFormat) { + portFormat.eCompressionFormat = arrCompressionFormat[index]; + break; + } + } + if (index == arrCompressionFormat.size()) { + ALOGE("setting default compression format %x", + (int)arrCompressionFormat[0]); + portFormat.eCompressionFormat = arrCompressionFormat[0]; + } + portFormat.eColorFormat = OMX_COLOR_FormatUnused; + } + // In setParam call nIndex shall be ignored as per omx-il specification. + // see how this holds up by corrupting nIndex + portFormat.nIndex = RANDOM_INDEX; + portFormat.xFramerate = xFramerate; + status = setPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex, + &portFormat); + return status; +} + +// get/set audio component port format +Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat( + sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding) { + OMX_U32 index = 0; + OMX_AUDIO_PARAM_PORTFORMATTYPE portFormat; + std::vector<OMX_AUDIO_CODINGTYPE> arrEncoding; + android::hardware::media::omx::V1_0::Status status; + + while (1) { + portFormat.nIndex = index; + status = getPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex, + &portFormat); + if (status != ::android::hardware::media::omx::V1_0::Status::OK) break; + arrEncoding.push_back(portFormat.eEncoding); + index++; + if (index == 512) { + // enumerated way too many formats, highly unusual for this to + // happen. + EXPECT_LE(index, 512U) + << "Expecting OMX_ErrorNoMore but not received"; + break; + } + } + if (!index) return status; + for (index = 0; index < arrEncoding.size(); index++) { + if (arrEncoding[index] == eEncoding) { + portFormat.eEncoding = arrEncoding[index]; + break; + } + } + if (index == arrEncoding.size()) { + ALOGE("setting default Port format %x", (int)arrEncoding[0]); + portFormat.eEncoding = arrEncoding[0]; + } + // In setParam call nIndex shall be ignored as per omx-il specification. + // see how this holds up by corrupting nIndex + portFormat.nIndex = RANDOM_INDEX; + status = setPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex, + &portFormat); + return status; +} + // allocate buffers needed on a component port void allocatePortBuffers(sp<IOmxNode> omxNode, android::Vector<BufferInfo>* buffArray, diff --git a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h index d617e45e43..c0e03f63d6 100644 --- a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h +++ b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h @@ -36,6 +36,11 @@ #define DEFAULT_TIMEOUT 100000 #define TIMEOUT_COUNTER (10000000 / DEFAULT_TIMEOUT) +/* + * Random Index used for monkey testing while get/set parameters + */ +#define RANDOM_INDEX 1729 + enum bufferOwner { client, component, @@ -259,6 +264,14 @@ Return<android::hardware::media::omx::V1_0::Status> setPortConfig( Return<android::hardware::media::omx::V1_0::Status> setRole( sp<IOmxNode> omxNode, const char* role); +Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat( + sp<IOmxNode> omxNode, OMX_U32 portIndex, + OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat, + OMX_U32 xFramerate); + +Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat( + sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding); + void allocatePortBuffers(sp<IOmxNode> omxNode, android::Vector<BufferInfo>* buffArray, OMX_U32 portIndex, diff --git a/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp b/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp index 357c11e2b0..178db1538e 100644 --- a/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp +++ b/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp @@ -203,9 +203,6 @@ class ComponentHidlTest : public ::testing::VtsHalHidlTargetTestBase { } }; -// Random Index used for monkey testing while get/set parameters -#define RANDOM_INDEX 1729 - void initPortMode(PortMode* pm, bool isSecure, ComponentHidlTest::standardCompClass compClass) { pm[0] = PortMode::PRESET_BYTE_BUFFER; @@ -225,113 +222,6 @@ void initPortMode(PortMode* pm, bool isSecure, return; } -// get/set video component port format -Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat( - sp<IOmxNode> omxNode, OMX_U32 portIndex, - OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat, - OMX_U32 xFramerate) { - OMX_U32 index = 0; - OMX_VIDEO_PARAM_PORTFORMATTYPE portFormat; - std::vector<OMX_COLOR_FORMATTYPE> arrColorFormat; - std::vector<OMX_VIDEO_CODINGTYPE> arrCompressionFormat; - android::hardware::media::omx::V1_0::Status status; - - while (1) { - portFormat.nIndex = index; - status = getPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex, - &portFormat); - if (status != ::android::hardware::media::omx::V1_0::Status::OK) break; - if (eCompressionFormat == OMX_VIDEO_CodingUnused) - arrColorFormat.push_back(portFormat.eColorFormat); - else - arrCompressionFormat.push_back(portFormat.eCompressionFormat); - index++; - if (index == 512) { - // enumerated way too many formats, highly unusual for this to - // happen. - EXPECT_LE(index, 512U) - << "Expecting OMX_ErrorNoMore but not received"; - break; - } - } - if (!index) return status; - if (eCompressionFormat == OMX_VIDEO_CodingUnused) { - for (index = 0; index < arrColorFormat.size(); index++) { - if (arrColorFormat[index] == eColorFormat) { - portFormat.eColorFormat = arrColorFormat[index]; - break; - } - } - if (index == arrColorFormat.size()) { - ALOGE("setting default color format %x", (int)arrColorFormat[0]); - portFormat.eColorFormat = arrColorFormat[0]; - } - portFormat.eCompressionFormat = OMX_VIDEO_CodingUnused; - } else { - for (index = 0; index < arrCompressionFormat.size(); index++) { - if (arrCompressionFormat[index] == eCompressionFormat) { - portFormat.eCompressionFormat = arrCompressionFormat[index]; - break; - } - } - if (index == arrCompressionFormat.size()) { - ALOGE("setting default compression format %x", - (int)arrCompressionFormat[0]); - portFormat.eCompressionFormat = arrCompressionFormat[0]; - } - portFormat.eColorFormat = OMX_COLOR_FormatUnused; - } - // In setParam call nIndex shall be ignored as per omx-il specification. - // see how this holds up by corrupting nIndex - portFormat.nIndex = RANDOM_INDEX; - portFormat.xFramerate = xFramerate; - status = setPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex, - &portFormat); - return status; -} - -// get/set audio component port format -Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat( - sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding) { - OMX_U32 index = 0; - OMX_AUDIO_PARAM_PORTFORMATTYPE portFormat; - std::vector<OMX_AUDIO_CODINGTYPE> arrEncoding; - android::hardware::media::omx::V1_0::Status status; - - while (1) { - portFormat.nIndex = index; - status = getPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex, - &portFormat); - if (status != ::android::hardware::media::omx::V1_0::Status::OK) break; - arrEncoding.push_back(portFormat.eEncoding); - index++; - if (index == 512) { - // enumerated way too many formats, highly unusual for this to - // happen. - EXPECT_LE(index, 512U) - << "Expecting OMX_ErrorNoMore but not received"; - break; - } - } - if (!index) return status; - for (index = 0; index < arrEncoding.size(); index++) { - if (arrEncoding[index] == eEncoding) { - portFormat.eEncoding = arrEncoding[index]; - break; - } - } - if (index == arrEncoding.size()) { - ALOGE("setting default Port format %x", (int)arrEncoding[0]); - portFormat.eEncoding = arrEncoding[0]; - } - // In setParam call nIndex shall be ignored as per omx-il specification. - // see how this holds up by corrupting nIndex - portFormat.nIndex = RANDOM_INDEX; - status = setPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex, - &portFormat); - return status; -} - // test dispatch message API call TEST_F(ComponentHidlTest, dispatchMsg) { description("test dispatch message API call"); diff --git a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp index 77763d172c..91aecf22e6 100644 --- a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp +++ b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp @@ -52,68 +52,6 @@ using ::android::sp; #include <media_video_hidl_test_common.h> #include <memory> -Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat( - sp<IOmxNode> omxNode, OMX_U32 portIndex, - OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat, - OMX_U32 xFramerate) { - OMX_U32 index = 0; - OMX_VIDEO_PARAM_PORTFORMATTYPE portFormat; - std::vector<OMX_COLOR_FORMATTYPE> arrColorFormat; - std::vector<OMX_VIDEO_CODINGTYPE> arrCompressionFormat; - android::hardware::media::omx::V1_0::Status status; - - while (1) { - portFormat.nIndex = index; - status = getPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex, - &portFormat); - if (status != ::android::hardware::media::omx::V1_0::Status::OK) break; - if (eCompressionFormat == OMX_VIDEO_CodingUnused) - arrColorFormat.push_back(portFormat.eColorFormat); - else - arrCompressionFormat.push_back(portFormat.eCompressionFormat); - index++; - if (index == 512) { - // enumerated way too many formats, highly unusual for this to - // happen. - EXPECT_LE(index, 512U) - << "Expecting OMX_ErrorNoMore but not received"; - break; - } - } - if (!index) return status; - if (eCompressionFormat == OMX_VIDEO_CodingUnused) { - for (index = 0; index < arrColorFormat.size(); index++) { - if (arrColorFormat[index] == eColorFormat) { - portFormat.eColorFormat = arrColorFormat[index]; - break; - } - } - if (index == arrColorFormat.size()) { - ALOGE("setting default color format %x", (int)arrColorFormat[0]); - portFormat.eColorFormat = arrColorFormat[0]; - } - portFormat.eCompressionFormat = OMX_VIDEO_CodingUnused; - } else { - for (index = 0; index < arrCompressionFormat.size(); index++) { - if (arrCompressionFormat[index] == eCompressionFormat) { - portFormat.eCompressionFormat = arrCompressionFormat[index]; - break; - } - } - if (index == arrCompressionFormat.size()) { - ALOGE("setting default compression format %x", - (int)arrCompressionFormat[0]); - portFormat.eCompressionFormat = arrCompressionFormat[0]; - } - portFormat.eColorFormat = OMX_COLOR_FormatUnused; - } - portFormat.nIndex = 0; - portFormat.xFramerate = xFramerate; - status = setPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex, - &portFormat); - return status; -} - void enumerateProfileAndLevel(sp<IOmxNode> omxNode, OMX_U32 portIndex, std::vector<int32_t>* arrProfile, std::vector<int32_t>* arrLevel) { diff --git a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h index e4927792e3..e6a61d4a8f 100644 --- a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h +++ b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h @@ -17,20 +17,10 @@ #ifndef MEDIA_VIDEO_HIDL_TEST_COMMON_H #define MEDIA_VIDEO_HIDL_TEST_COMMON_H -/* - * Random Index used for monkey testing while get/set parameters - */ -#define RANDOM_INDEX 1729 /* * Common video utils */ - -Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat( - sp<IOmxNode> omxNode, OMX_U32 portIndex, - OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat, - OMX_U32 xFramerate); - void enumerateProfileAndLevel(sp<IOmxNode> omxNode, OMX_U32 portIndex, std::vector<int32_t>* arrProfile, std::vector<int32_t>* arrLevel); |