move duplicate code to common
Test: make vts -j99 BUILD_GOOGLE_VTS=true TARGET_PRODUCT=aosp_arm64 \
&& vts-tradefed run commandAndExit vts \
--skip-all-system-status-check --primary-abi-only \
--skip-preconditions --module VtsHalMediaOmxV1_0Test -l INFO
Bug: 62894603
Change-Id: I4f9bec22c6437935f49603f11d27642ef2135382
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 7240964..4c68219 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 @@
#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 70142f2..b187d28 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 e81e6dd..d30a75c 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 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 d617e45..c0e03f6 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> 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 357c11e..178db15 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 @@
}
};
-// 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 @@
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 77763d1..91aecf2 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 @@
#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 e492779..e6a61d4 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);