mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Merge "move duplicate code to common"
This commit is contained in:
committed by
Android (Google) Code Review
commit
6f6840a9c1
@@ -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;
|
||||
|
||||
@@ -19,17 +19,9 @@
|
||||
|
||||
#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);
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user