Merge "Omx vts tests" into oc-dev

am: 2e2e255125

Change-Id: I47b2613f0cfaf1f237bbdc432262b46fc3de3b9f
This commit is contained in:
Zhuoyao Zhang 2017-06-08 16:28:23 +00:00 committed by android-build-merger
commit ca7c33143d
14 changed files with 788 additions and 736 deletions

View file

@ -87,13 +87,6 @@ Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
return status;
}
Return<android::hardware::media::omx::V1_0::Status> setRole(
sp<IOmxNode> omxNode, const char* role) {
OMX_PARAM_COMPONENTROLETYPE params;
strcpy((char*)params.cRole, role);
return setParam(omxNode, OMX_IndexParamStandardComponentRole, &params);
}
void enumerateProfile(sp<IOmxNode> omxNode, OMX_U32 portIndex,
std::vector<int32_t>* arrProfile) {
android::hardware::media::omx::V1_0::Status status;

View file

@ -30,9 +30,6 @@
Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding);
Return<android::hardware::media::omx::V1_0::Status> setRole(
sp<IOmxNode> omxNode, const char* role);
void enumerateProfile(sp<IOmxNode> omxNode, OMX_U32 portIndex,
std::vector<int32_t>* arrProfile);

View file

@ -36,6 +36,7 @@ using ::android::hardware::media::omx::V1_0::IOmxNode;
using ::android::hardware::media::omx::V1_0::Message;
using ::android::hardware::media::omx::V1_0::CodecBuffer;
using ::android::hardware::media::omx::V1_0::PortMode;
using ::android::hardware::media::omx::V1_0::Status;
using ::android::hidl::allocator::V1_0::IAllocator;
using ::android::hidl::memory::V1_0::IMemory;
using ::android::hidl::memory::V1_0::IMapper;
@ -51,6 +52,14 @@ using ::android::sp;
#include <media_hidl_test_common.h>
#include <memory>
// set component role
Return<android::hardware::media::omx::V1_0::Status> setRole(
sp<IOmxNode> omxNode, const char* role) {
OMX_PARAM_COMPONENTROLETYPE params;
strcpy((char*)params.cRole, role);
return setParam(omxNode, OMX_IndexParamStandardComponentRole, &params);
}
// allocate buffers needed on a component port
void allocatePortBuffers(sp<IOmxNode> omxNode,
android::Vector<BufferInfo>* buffArray,
@ -293,51 +302,59 @@ size_t getEmptyBufferID(android::Vector<BufferInfo>* buffArray) {
void dispatchOutputBuffer(sp<IOmxNode> omxNode,
android::Vector<BufferInfo>* buffArray,
size_t bufferIndex, PortMode portMode) {
if (portMode == PortMode::DYNAMIC_ANW_BUFFER) {
android::hardware::media::omx::V1_0::Status status;
CodecBuffer t = (*buffArray)[bufferIndex].omxBuffer;
t.type = CodecBuffer::Type::ANW_BUFFER;
native_handle_t* fenceNh = native_handle_create(0, 0);
ASSERT_NE(fenceNh, nullptr);
status = omxNode->fillBuffer((*buffArray)[bufferIndex].id, t, fenceNh);
native_handle_close(fenceNh);
native_handle_delete(fenceNh);
ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
buffArray->editItemAt(bufferIndex).owner = component;
} else {
android::hardware::media::omx::V1_0::Status status;
CodecBuffer t;
t.sharedMemory = android::hardware::hidl_memory();
t.nativeHandle = android::hardware::hidl_handle();
t.type = CodecBuffer::Type::PRESET;
t.attr.preset.rangeOffset = 0;
t.attr.preset.rangeLength = 0;
native_handle_t* fenceNh = native_handle_create(0, 0);
ASSERT_NE(fenceNh, nullptr);
status = omxNode->fillBuffer((*buffArray)[bufferIndex].id, t, fenceNh);
native_handle_close(fenceNh);
native_handle_delete(fenceNh);
ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
buffArray->editItemAt(bufferIndex).owner = component;
android::hardware::media::omx::V1_0::Status status;
CodecBuffer t;
native_handle_t* fenceNh = native_handle_create(0, 0);
ASSERT_NE(fenceNh, nullptr);
switch (portMode) {
case PortMode::DYNAMIC_ANW_BUFFER:
t = (*buffArray)[bufferIndex].omxBuffer;
t.type = CodecBuffer::Type::ANW_BUFFER;
status =
omxNode->fillBuffer((*buffArray)[bufferIndex].id, t, fenceNh);
break;
case PortMode::PRESET_SECURE_BUFFER:
case PortMode::PRESET_BYTE_BUFFER:
t.sharedMemory = android::hardware::hidl_memory();
t.nativeHandle = android::hardware::hidl_handle();
t.type = CodecBuffer::Type::PRESET;
t.attr.preset.rangeOffset = 0;
t.attr.preset.rangeLength = 0;
status =
omxNode->fillBuffer((*buffArray)[bufferIndex].id, t, fenceNh);
break;
default:
status = Status::NAME_NOT_FOUND;
}
native_handle_close(fenceNh);
native_handle_delete(fenceNh);
ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
buffArray->editItemAt(bufferIndex).owner = component;
}
// dispatch buffer to input port
void dispatchInputBuffer(sp<IOmxNode> omxNode,
android::Vector<BufferInfo>* buffArray,
size_t bufferIndex, int bytesCount, uint32_t flags,
uint64_t timestamp) {
uint64_t timestamp, PortMode portMode) {
android::hardware::media::omx::V1_0::Status status;
CodecBuffer t;
t.sharedMemory = android::hardware::hidl_memory();
t.nativeHandle = android::hardware::hidl_handle();
t.type = CodecBuffer::Type::PRESET;
t.attr.preset.rangeOffset = 0;
t.attr.preset.rangeLength = bytesCount;
native_handle_t* fenceNh = native_handle_create(0, 0);
ASSERT_NE(fenceNh, nullptr);
status = omxNode->emptyBuffer((*buffArray)[bufferIndex].id, t, flags,
timestamp, fenceNh);
switch (portMode) {
case PortMode::PRESET_SECURE_BUFFER:
case PortMode::PRESET_BYTE_BUFFER:
t.sharedMemory = android::hardware::hidl_memory();
t.nativeHandle = android::hardware::hidl_handle();
t.type = CodecBuffer::Type::PRESET;
t.attr.preset.rangeOffset = 0;
t.attr.preset.rangeLength = bytesCount;
status = omxNode->emptyBuffer((*buffArray)[bufferIndex].id, t,
flags, timestamp, fenceNh);
break;
default:
status = Status::NAME_NOT_FOUND;
}
native_handle_close(fenceNh);
native_handle_delete(fenceNh);
ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);

View file

@ -256,6 +256,9 @@ Return<android::hardware::media::omx::V1_0::Status> setPortConfig(
/*
* common functions declarations
*/
Return<android::hardware::media::omx::V1_0::Status> setRole(
sp<IOmxNode> omxNode, const char* role);
void allocatePortBuffers(sp<IOmxNode> omxNode,
android::Vector<BufferInfo>* buffArray,
OMX_U32 portIndex,
@ -288,7 +291,8 @@ void dispatchOutputBuffer(sp<IOmxNode> omxNode,
void dispatchInputBuffer(sp<IOmxNode> omxNode,
android::Vector<BufferInfo>* buffArray,
size_t bufferIndex, int bytesCount, uint32_t flags,
uint64_t timestamp);
uint64_t timestamp,
PortMode portMode = PortMode::PRESET_BYTE_BUFFER);
void flushPorts(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
android::Vector<BufferInfo>* iBuffer,

View file

@ -164,6 +164,14 @@ class ComponentHidlTest : public ::testing::VtsHalHidlTargetTestBase {
}
}
if (compClass == unknown_class) disableTest = true;
isSecure = false;
size_t suffixLen = strlen(".secure");
if (strlen(gEnv->getComponent().c_str()) >= suffixLen) {
isSecure =
!strcmp(gEnv->getComponent().c_str() +
strlen(gEnv->getComponent().c_str()) - suffixLen,
".secure");
}
if (disableTest) std::cerr << "[ ] Warning ! Test Disabled\n";
}
@ -186,6 +194,7 @@ class ComponentHidlTest : public ::testing::VtsHalHidlTargetTestBase {
sp<CodecObserver> observer;
sp<IOmxNode> omxNode;
standardCompClass compClass;
bool isSecure;
bool disableTest;
protected:
@ -197,6 +206,25 @@ 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;
pm[1] = PortMode::PRESET_BYTE_BUFFER;
if (isSecure) {
switch (compClass) {
case ComponentHidlTest::video_decoder:
pm[0] = PortMode::PRESET_SECURE_BUFFER;
break;
case ComponentHidlTest::video_encoder:
pm[1] = PortMode::PRESET_SECURE_BUFFER;
break;
default:
break;
}
}
return;
}
// get/set video component port format
Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
sp<IOmxNode> omxNode, OMX_U32 portIndex,
@ -304,14 +332,6 @@ Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
return status;
}
// set component role
Return<android::hardware::media::omx::V1_0::Status> setRole(
sp<IOmxNode> omxNode, const char* role) {
OMX_PARAM_COMPONENTROLETYPE params;
strcpy((char*)params.cRole, role);
return setParam(omxNode, OMX_IndexParamStandardComponentRole, &params);
}
// test dispatch message API call
TEST_F(ComponentHidlTest, dispatchMsg) {
description("test dispatch message API call");
@ -320,34 +340,21 @@ TEST_F(ComponentHidlTest, dispatchMsg) {
Message msgin, msgout;
msgin.type = Message::Type::EVENT;
// dispatch EOS event, normally this is by component when it receives a
// EOS flag
msgin.data.eventData.event = OMX_EventBufferFlag;
msgin.data.eventData.data1 = 0U;
msgin.data.eventData.data2 = (uint32_t)OMX_BUFFERFLAG_EOS;
msgin.data.eventData.event = OMX_EventError;
msgin.data.eventData.data1 = 0xdeaf;
msgin.data.eventData.data2 = 0xd00d;
msgin.data.eventData.data3 = 0x01ce;
msgin.data.eventData.data4 = 0xfa11;
status = omxNode->dispatchMessage(msgin);
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
status = observer->dequeueMessage(&msgout, DEFAULT_TIMEOUT);
ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
ASSERT_EQ(msgout.type, msgin.type);
ASSERT_EQ(msgout.data.eventData.event, msgin.data.eventData.event);
ASSERT_EQ(msgout.data.eventData.data1, msgin.data.eventData.data1);
ASSERT_EQ(msgout.data.eventData.data2, msgin.data.eventData.data2);
// dispatch dataspace changed event
msgin.data.eventData.event = OMX_EventDataSpaceChanged;
msgin.data.eventData.data1 = 281149440U; // V0_BT601_625;
msgin.data.eventData.data2 = 0x1111;
msgin.data.eventData.data3 = 0x24; // RAW_OPAQUE
status = omxNode->dispatchMessage(msgin);
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
status = observer->dequeueMessage(&msgout, DEFAULT_TIMEOUT);
ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
ASSERT_EQ(msgout.type, msgin.type);
ASSERT_EQ(msgout.data.eventData.event, msgin.data.eventData.event);
ASSERT_EQ(msgout.data.eventData.data1, msgin.data.eventData.data1);
ASSERT_EQ(msgout.data.eventData.data2, msgin.data.eventData.data2);
EXPECT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
EXPECT_EQ(msgout.type, msgin.type);
EXPECT_EQ(msgout.data.eventData.event, msgin.data.eventData.event);
EXPECT_EQ(msgout.data.eventData.data1, msgin.data.eventData.data1);
EXPECT_EQ(msgout.data.eventData.data2, msgin.data.eventData.data2);
EXPECT_EQ(msgout.data.eventData.data3, msgin.data.eventData.data3);
EXPECT_EQ(msgout.data.eventData.data4, msgin.data.eventData.data4);
}
// set component role
@ -464,116 +471,86 @@ TEST_F(ComponentHidlTest, SetDefaultPortParams) {
kPortIndexOutput = kPortIndexInput + 1;
}
// r/w default i/o port parameters
OMX_PARAM_PORTDEFINITIONTYPE iPortDef;
status = getPortParam(omxNode, OMX_IndexParamPortDefinition,
kPortIndexInput, &iPortDef);
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
if (status == android::hardware::media::omx::V1_0::Status::OK) {
EXPECT_EQ(iPortDef.eDir, OMX_DirInput);
EXPECT_EQ(iPortDef.bEnabled, OMX_TRUE);
EXPECT_EQ(iPortDef.bPopulated, OMX_FALSE);
EXPECT_GE(iPortDef.nBufferCountMin, 1U);
EXPECT_GE(iPortDef.nBufferCountActual, iPortDef.nBufferCountMin);
if (compClass == audio_encoder || compClass == audio_decoder) {
EXPECT_EQ(iPortDef.eDomain, OMX_PortDomainAudio);
if (compClass == audio_decoder) {
iPortDef.format.audio.bFlagErrorConcealment = OMX_TRUE;
status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
kPortIndexInput, &iPortDef);
for (size_t i = kPortIndexInput; i < kPortIndexOutput; i++) {
OMX_PARAM_PORTDEFINITIONTYPE portDef;
status =
getPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef);
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
if (status == android::hardware::media::omx::V1_0::Status::OK) {
EXPECT_EQ(portDef.eDir, i - kPortIndexInput); // OMX_DirInput
EXPECT_EQ(portDef.bEnabled, OMX_TRUE);
EXPECT_EQ(portDef.bPopulated, OMX_FALSE);
EXPECT_GE(portDef.nBufferCountMin, 1U);
EXPECT_GE(portDef.nBufferCountActual, portDef.nBufferCountMin);
if (compClass == audio_encoder || compClass == audio_decoder) {
EXPECT_EQ(portDef.eDomain, OMX_PortDomainAudio);
} else if (compClass == video_encoder ||
compClass == video_decoder) {
EXPECT_EQ(portDef.eDomain, OMX_PortDomainVideo);
}
} else if (compClass == video_encoder || compClass == video_decoder) {
EXPECT_EQ(iPortDef.eDomain, OMX_PortDomainVideo);
if (compClass == video_decoder) {
iPortDef.format.video.bFlagErrorConcealment = OMX_TRUE;
status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
kPortIndexInput, &iPortDef);
}
}
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
OMX_PARAM_PORTDEFINITIONTYPE dummy = iPortDef;
iPortDef.nBufferCountActual = iPortDef.nBufferCountMin - 1;
status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
kPortIndexInput, &iPortDef);
EXPECT_NE(status, ::android::hardware::media::omx::V1_0::Status::OK);
// Edit Read-Only fields.
iPortDef.eDir = OMX_DirOutput; // Read Only field
iPortDef.nBufferCountActual = dummy.nBufferCountActual << 1;
iPortDef.nBufferCountMin = dummy.nBufferCountMin
<< 1; // Read Only field
iPortDef.nBufferSize = dummy.nBufferSize << 1; // Read Only field
status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
kPortIndexInput, &iPortDef);
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
status = getPortParam(omxNode, OMX_IndexParamPortDefinition,
kPortIndexInput, &iPortDef);
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
EXPECT_EQ(iPortDef.nBufferCountActual, dummy.nBufferCountActual << 1);
if ((iPortDef.eDir != OMX_DirInput) ||
(iPortDef.nBufferCountMin != dummy.nBufferCountMin) ||
(iPortDef.nBufferSize != dummy.nBufferSize)) {
std::cerr << "[ ] Warning ! Component input port does not "
"preserve Read-Only fields \n";
}
}
OMX_PARAM_PORTDEFINITIONTYPE mirror = portDef;
OMX_PARAM_PORTDEFINITIONTYPE oPortDef;
status = getPortParam(omxNode, OMX_IndexParamPortDefinition,
kPortIndexOutput, &oPortDef);
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
EXPECT_EQ(oPortDef.eDir, OMX_DirOutput);
EXPECT_EQ(oPortDef.bEnabled, OMX_TRUE);
EXPECT_EQ(oPortDef.bPopulated, OMX_FALSE);
EXPECT_GE(oPortDef.nBufferCountMin, 1U);
EXPECT_GE(oPortDef.nBufferCountActual, oPortDef.nBufferCountMin);
if (compClass == audio_encoder || compClass == audio_decoder) {
EXPECT_EQ(oPortDef.eDomain, OMX_PortDomainAudio);
if (compClass == audio_encoder) {
oPortDef.format.audio.bFlagErrorConcealment = OMX_TRUE;
status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
kPortIndexOutput, &oPortDef);
// nBufferCountActual >= nBufferCountMin
portDef.nBufferCountActual = portDef.nBufferCountMin - 1;
status = setPortParam(omxNode, OMX_IndexParamPortDefinition, i,
&portDef);
EXPECT_NE(status,
::android::hardware::media::omx::V1_0::Status::OK);
// Edit Read-Only fields.
portDef = mirror;
portDef.eDir = static_cast<OMX_DIRTYPE>(RANDOM_INDEX);
setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef);
getPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef);
EXPECT_EQ(portDef.eDir, mirror.eDir);
setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &mirror);
portDef = mirror;
portDef.nBufferSize >>= 1;
setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef);
getPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef);
EXPECT_EQ(portDef.nBufferSize, mirror.nBufferSize);
setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &mirror);
portDef = mirror;
portDef.nBufferCountMin += 1;
setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef);
getPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef);
EXPECT_EQ(portDef.nBufferCountMin, mirror.nBufferCountMin);
setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &mirror);
portDef = mirror;
portDef.nBufferCountActual += 1;
status = setPortParam(omxNode, OMX_IndexParamPortDefinition, i,
&portDef);
if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
status = getPortParam(omxNode, OMX_IndexParamPortDefinition, i,
&portDef);
EXPECT_EQ(portDef.nBufferCountActual,
mirror.nBufferCountActual + 1);
}
} else if (compClass == video_encoder || compClass == video_decoder) {
EXPECT_EQ(oPortDef.eDomain, OMX_PortDomainVideo);
if (compClass == video_encoder) {
oPortDef.format.video.bFlagErrorConcealment = OMX_TRUE;
status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
kPortIndexOutput, &oPortDef);
portDef = mirror;
portDef.nBufferSize = mirror.nBufferSize << 1;
status = setPortParam(omxNode, OMX_IndexParamPortDefinition, i,
&portDef);
if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
status = getPortParam(omxNode, OMX_IndexParamPortDefinition, i,
&portDef);
if (portDef.nBufferSize != mirror.nBufferSize) {
std::cout
<< "[ ] Warning ! Component input port does "
"not preserve Read-Only fields \n";
}
}
}
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
OMX_PARAM_PORTDEFINITIONTYPE dummy = oPortDef;
oPortDef.nBufferCountActual = oPortDef.nBufferCountMin - 1;
status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
kPortIndexOutput, &oPortDef);
EXPECT_NE(status, ::android::hardware::media::omx::V1_0::Status::OK);
// Edit Read-Only fields.
oPortDef.eDir = OMX_DirInput; // Read Only field
oPortDef.nBufferCountActual = dummy.nBufferCountActual << 1;
oPortDef.nBufferCountMin = dummy.nBufferCountMin
<< 1; // Read Only field
oPortDef.nBufferSize = dummy.nBufferSize << 1; // Read Only field
status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
kPortIndexOutput, &oPortDef);
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
status = getPortParam(omxNode, OMX_IndexParamPortDefinition,
kPortIndexOutput, &oPortDef);
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
EXPECT_EQ(oPortDef.nBufferCountActual, dummy.nBufferCountActual << 1);
if ((oPortDef.eDir != OMX_DirOutput) ||
(oPortDef.nBufferCountMin != dummy.nBufferCountMin) ||
(oPortDef.nBufferSize != dummy.nBufferSize)) {
std::cerr << "[ ] Warning ! Component output port does "
"not preserve Read-Only fields \n";
}
}
}
// populate port test
TEST_F(ComponentHidlTest, PopulatePort) {
description("Verify bPopulated field of a component port");
if (disableTest) return;
if (disableTest || isSecure) return;
android::hardware::media::omx::V1_0::Status status;
OMX_U32 portBase = 0;
@ -664,21 +641,29 @@ TEST_F(ComponentHidlTest, Flush) {
android::Vector<BufferInfo> iBuffer, oBuffer;
// set port mode
PortMode portMode[2];
initPortMode(portMode, isSecure, compClass);
status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
// set state to idle
changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer,
kPortIndexInput, kPortIndexOutput);
kPortIndexInput, kPortIndexOutput, portMode);
// set state to executing
changeStateIdletoExecute(omxNode, observer);
// dispatch buffers
for (size_t i = 0; i < oBuffer.size(); i++) {
dispatchOutputBuffer(omxNode, &oBuffer, i);
dispatchOutputBuffer(omxNode, &oBuffer, i, portMode[1]);
}
// flush port
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
// dispatch buffers
for (size_t i = 0; i < iBuffer.size(); i++) {
dispatchInputBuffer(omxNode, &iBuffer, i, 0, 0, 0);
dispatchInputBuffer(omxNode, &iBuffer, i, 0, 0, 0, portMode[0]);
}
// flush ports
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
@ -714,14 +699,22 @@ TEST_F(ComponentHidlTest, StateTransitions) {
android::Vector<BufferInfo> iBuffer, oBuffer;
// set port mode
PortMode portMode[2];
initPortMode(portMode, isSecure, compClass);
status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
// set state to idle
changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer,
kPortIndexInput, kPortIndexOutput);
kPortIndexInput, kPortIndexOutput, portMode);
// set state to executing
changeStateIdletoExecute(omxNode, observer);
// dispatch buffers
for (size_t i = 0; i < oBuffer.size(); i++) {
dispatchOutputBuffer(omxNode, &oBuffer, i);
dispatchOutputBuffer(omxNode, &oBuffer, i, portMode[1]);
}
// set state to idle
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer);
@ -729,7 +722,7 @@ TEST_F(ComponentHidlTest, StateTransitions) {
changeStateIdletoExecute(omxNode, observer);
// dispatch buffers
for (size_t i = 0; i < iBuffer.size(); i++) {
dispatchInputBuffer(omxNode, &iBuffer, i, 0, 0, 0);
dispatchInputBuffer(omxNode, &iBuffer, i, 0, 0, 0, portMode[0]);
}
// set state to idle
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer);
@ -741,7 +734,7 @@ TEST_F(ComponentHidlTest, StateTransitions) {
// state transitions test - monkeying
TEST_F(ComponentHidlTest, StateTransitions_M) {
description("Test State Transitions monkeying");
if (disableTest) return;
if (disableTest || isSecure) return;
android::hardware::media::omx::V1_0::Status status;
uint32_t kPortIndexInput = 0, kPortIndexOutput = 1;
Message msg;
@ -878,9 +871,17 @@ TEST_F(ComponentHidlTest, PortEnableDisable_Idle) {
// Component State :: Idle
android::Vector<BufferInfo> pBuffer[2];
// set port mode
PortMode portMode[2];
initPortMode(portMode, isSecure, compClass);
status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
// set state to idle
changeStateLoadedtoIdle(omxNode, observer, &pBuffer[0], &pBuffer[1],
kPortIndexInput, kPortIndexOutput);
kPortIndexInput, kPortIndexOutput, portMode);
for (size_t i = portBase; i < portBase + 2; i++) {
status =
@ -929,7 +930,8 @@ TEST_F(ComponentHidlTest, PortEnableDisable_Idle) {
ASSERT_EQ(status,
android::hardware::media::omx::V1_0::Status::TIMED_OUT);
allocatePortBuffers(omxNode, &pBuffer[i - portBase], i);
allocatePortBuffers(omxNode, &pBuffer[i - portBase], i,
portMode[i - portBase]);
status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT,
&pBuffer[0], &pBuffer[1]);
ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
@ -973,16 +975,24 @@ TEST_F(ComponentHidlTest, PortEnableDisable_Execute) {
// Component State :: Idle
android::Vector<BufferInfo> pBuffer[2];
// set port mode
PortMode portMode[2];
initPortMode(portMode, isSecure, compClass);
status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
// set state to idle
changeStateLoadedtoIdle(omxNode, observer, &pBuffer[0], &pBuffer[1],
kPortIndexInput, kPortIndexOutput);
kPortIndexInput, kPortIndexOutput, portMode);
// set state to executing
changeStateIdletoExecute(omxNode, observer);
// dispatch buffers
for (size_t i = 0; i < pBuffer[1].size(); i++) {
dispatchOutputBuffer(omxNode, &pBuffer[1], i);
dispatchOutputBuffer(omxNode, &pBuffer[1], i, portMode[1]);
}
for (size_t i = portBase; i < portBase + 2; i++) {
@ -1035,7 +1045,8 @@ TEST_F(ComponentHidlTest, PortEnableDisable_Execute) {
ASSERT_EQ(status,
android::hardware::media::omx::V1_0::Status::TIMED_OUT);
allocatePortBuffers(omxNode, &pBuffer[i - portBase], i);
allocatePortBuffers(omxNode, &pBuffer[i - portBase], i,
portMode[i - portBase]);
status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT,
&pBuffer[0], &pBuffer[1]);
ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
@ -1060,7 +1071,7 @@ TEST_F(ComponentHidlTest, PortEnableDisable_Execute) {
TEST_F(ComponentHidlTest, PortEnableDisable_M) {
description(
"Test Port Enable and Disable Monkeying (Component State :: Loaded)");
if (disableTest) return;
if (disableTest || isSecure) return;
android::hardware::media::omx::V1_0::Status status;
OMX_U32 portBase = 0;
Message msg;

View file

@ -27,6 +27,8 @@ cc_test {
"libhwbinder",
"libnativehelper",
"libutils",
"android.hidl.allocator@1.0",
"android.hidl.memory@1.0",
"android.hardware.media.omx@1.0",
],
static_libs: ["VtsHalHidlTargetTestBase"],
@ -34,5 +36,9 @@ cc_test {
"-O0",
"-g",
],
include_dirs: [
"frameworks/native/include/media/openmax/",
"hardware/interfaces/media/omx/1.0/vts/functional/common",
],
}

View file

@ -17,21 +17,35 @@
#define LOG_TAG "media_omx_hidl_master_test"
#include <android-base/logging.h>
#include <VtsHalHidlTargetTestBase.h>
#include <android/hardware/media/omx/1.0/IOmx.h>
#include <android/hardware/media/omx/1.0/IOmxNode.h>
#include <android/hardware/media/omx/1.0/IOmxObserver.h>
#include <android/hardware/media/omx/1.0/IOmxStore.h>
#include <android/hardware/media/omx/1.0/types.h>
#include <getopt.h>
#include <log/log.h>
#include <android/hidl/allocator/1.0/IAllocator.h>
#include <android/hidl/memory/1.0/IMapper.h>
#include <android/hidl/memory/1.0/IMemory.h>
using ::android::hardware::media::omx::V1_0::IOmxStore;
using ::android::hardware::media::omx::V1_0::IOmx;
using ::android::hardware::media::omx::V1_0::IOmxObserver;
using ::android::hardware::media::omx::V1_0::IOmxNode;
using ::android::hardware::media::omx::V1_0::IOmxStore;
using ::android::hardware::media::omx::V1_0::Message;
using ::android::hardware::media::omx::V1_0::CodecBuffer;
using ::android::hardware::media::omx::V1_0::PortMode;
using ::android::hidl::allocator::V1_0::IAllocator;
using ::android::hidl::memory::V1_0::IMemory;
using ::android::hidl::memory::V1_0::IMapper;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;
#include <VtsHalHidlTargetTestBase.h>
#include <getopt.h>
#include <media_hidl_test_common.h>
// A class for test environment setup
class ComponentTestEnvironment : public ::testing::Environment {
public:
@ -127,8 +141,7 @@ TEST_F(MasterHidlTest, ListServiceAttr) {
attributes = _nl;
})
.isOk());
if (attributes.size() == 0)
std::cerr << "[ ] Warning ! Attribute list empty \n";
if (attributes.size() == 0) ALOGV("Warning, Attribute list empty");
}
// get node prefix
@ -137,8 +150,7 @@ TEST_F(MasterHidlTest, getNodePrefix) {
hidl_string prefix;
omxStore->getNodePrefix(
[&prefix](hidl_string const& _nl) { prefix = _nl; });
if (prefix.empty())
std::cerr << "[ ] Warning ! Node Prefix empty \n";
if (prefix.empty()) ALOGV("Warning, Node Prefix empty");
}
// list roles
@ -148,15 +160,15 @@ TEST_F(MasterHidlTest, ListRoles) {
omxStore->listRoles([&roleList](hidl_vec<IOmxStore::RoleInfo> const& _nl) {
roleList = _nl;
});
if (roleList.size() == 0)
std::cerr << "[ ] Warning ! RoleInfo list empty \n";
if (roleList.size() == 0) ALOGV("Warning, RoleInfo list empty");
}
// list components and roles
// list components and roles.
TEST_F(MasterHidlTest, ListNodes) {
description("enumerate component and roles");
android::hardware::media::omx::V1_0::Status status;
hidl_vec<IOmx::ComponentInfo> nodeList;
bool isPass = true;
EXPECT_TRUE(
omx->listNodes([&status, &nodeList](
android::hardware::media::omx::V1_0::Status _s,
@ -166,9 +178,36 @@ TEST_F(MasterHidlTest, ListNodes) {
})
.isOk());
if (nodeList.size() == 0)
std::cerr << "[ ] Warning ! ComponentInfo list empty \n";
else
displayComponentInfo(nodeList);
ALOGV("Warning, ComponentInfo list empty");
else {
// displayComponentInfo(nodeList);
for (size_t i = 0; i < nodeList.size(); i++) {
sp<CodecObserver> observer = nullptr;
sp<IOmxNode> omxNode = nullptr;
observer = new CodecObserver(nullptr);
ASSERT_NE(observer, nullptr);
EXPECT_TRUE(
omx->allocateNode(
nodeList[i].mName, observer,
[&](android::hardware::media::omx::V1_0::Status _s,
sp<IOmxNode> const& _nl) {
status = _s;
omxNode = _nl;
})
.isOk());
if (omxNode == nullptr) {
isPass = false;
std::cerr << "[ !OK ] " << nodeList[i].mName.c_str()
<< "\n";
} else {
EXPECT_TRUE((omxNode->freeNode()).isOk());
omxNode = nullptr;
// std::cout << "[ OK ] " << nodeList[i].mName.c_str() <<
// "\n";
}
}
}
EXPECT_TRUE(isPass);
}
int main(int argc, char** argv) {

View file

@ -209,10 +209,11 @@ class VideoDecHidlTest : public ::testing::VtsHalHidlTargetTestBase {
isSecure = false;
size_t suffixLen = strlen(".secure");
if (strlen(gEnv->getComponent().c_str()) >= suffixLen) {
isSecure =
!strcmp(gEnv->getComponent().c_str() +
strlen(gEnv->getComponent().c_str()) - suffixLen,
".secure");
}
isSecure = !strcmp(gEnv->getComponent().c_str() +
strlen(gEnv->getComponent().c_str()) - suffixLen,
".secure");
if (isSecure) disableTest = true;
if (disableTest) std::cout << "[ ] Warning ! Test Disabled\n";
}
@ -784,25 +785,15 @@ TEST_F(VideoDecHidlTest, DecodeTest) {
eleInfo.close();
// set port mode
if (isSecure) {
portMode[0] = PortMode::PRESET_SECURE_BUFFER;
portMode[1] = PortMode::DYNAMIC_ANW_BUFFER;
status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
portMode[0] = PortMode::PRESET_BYTE_BUFFER;
portMode[1] = PortMode::DYNAMIC_ANW_BUFFER;
status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
if (status != ::android::hardware::media::omx::V1_0::Status::OK) {
portMode[1] = PortMode::PRESET_BYTE_BUFFER;
status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
} else {
portMode[0] = PortMode::PRESET_BYTE_BUFFER;
portMode[1] = PortMode::DYNAMIC_ANW_BUFFER;
status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
if (status != ::android::hardware::media::omx::V1_0::Status::OK) {
portMode[1] = PortMode::PRESET_BYTE_BUFFER;
status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
ASSERT_EQ(status,
::android::hardware::media::omx::V1_0::Status::OK);
}
}
// set Port Params

View file

@ -221,10 +221,11 @@ class VideoEncHidlTest : public ::testing::VtsHalHidlTargetTestBase {
isSecure = false;
size_t suffixLen = strlen(".secure");
if (strlen(gEnv->getComponent().c_str()) >= suffixLen) {
isSecure =
!strcmp(gEnv->getComponent().c_str() +
strlen(gEnv->getComponent().c_str()) - suffixLen,
".secure");
}
isSecure = !strcmp(gEnv->getComponent().c_str() +
strlen(gEnv->getComponent().c_str()) - suffixLen,
".secure");
if (isSecure) disableTest = true;
if (disableTest) std::cerr << "[ ] Warning ! Test Disabled\n";
}
@ -1213,7 +1214,6 @@ TEST_F(VideoEncHidlTest, EncodeTest) {
// set port mode
PortMode portMode[2];
portMode[0] = portMode[1] = PortMode::PRESET_BYTE_BUFFER;
if (isSecure && prependSPSPPS) portMode[1] = PortMode::PRESET_SECURE_BUFFER;
status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);

View file

@ -114,13 +114,6 @@ Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
return status;
}
Return<android::hardware::media::omx::V1_0::Status> setRole(
sp<IOmxNode> omxNode, const char* role) {
OMX_PARAM_COMPONENTROLETYPE params;
strcpy((char*)params.cRole, role);
return setParam(omxNode, OMX_IndexParamStandardComponentRole, &params);
}
void enumerateProfileAndLevel(sp<IOmxNode> omxNode, OMX_U32 portIndex,
std::vector<int32_t>* arrProfile,
std::vector<int32_t>* arrLevel) {

View file

@ -31,9 +31,6 @@ Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat,
OMX_U32 xFramerate);
Return<android::hardware::media::omx::V1_0::Status> setRole(
sp<IOmxNode> omxNode, const char* role);
void enumerateProfileAndLevel(sp<IOmxNode> omxNode, OMX_U32 portIndex,
std::vector<int32_t>* arrProfile,
std::vector<int32_t>* arrLevel);

File diff suppressed because it is too large Load diff

Binary file not shown.