diff options
Diffstat (limited to 'media/omx/1.0')
18 files changed, 1616 insertions, 1070 deletions
diff --git a/media/omx/1.0/IOmxStore.hal b/media/omx/1.0/IOmxStore.hal index a224b0e1..3ec05357 100644 --- a/media/omx/1.0/IOmxStore.hal +++ b/media/omx/1.0/IOmxStore.hal | |||
@@ -39,7 +39,7 @@ interface IOmxStore { | |||
39 | * string: arbitrary string | 39 | * string: arbitrary string |
40 | * size: <num>x<num> | 40 | * size: <num>x<num> |
41 | * ratio: <num>:<num> | 41 | * ratio: <num>:<num> |
42 | * range<type>: <type>-<type> | 42 | * range<type>: <type> | <type>-<type> |
43 | * list<type>: <type> | <type>,<list<type>> | 43 | * list<type>: <type> | <type>,<list<type>> |
44 | */ | 44 | */ |
45 | struct Attribute { | 45 | struct Attribute { |
@@ -97,7 +97,7 @@ interface IOmxStore { | |||
97 | * | 97 | * |
98 | * Required node attributes for video nodes that are required by Android to | 98 | * Required node attributes for video nodes that are required by Android to |
99 | * describe measured values for this device: | 99 | * describe measured values for this device: |
100 | * key: 'measured-frame-rate-<width>-<height>-range', | 100 | * key: 'measured-frame-rate-<width>x<height>-range', |
101 | * value-type: range<num>; where width: num, height: num | 101 | * value-type: range<num>; where width: num, height: num |
102 | * | 102 | * |
103 | * Optional node attributes for decoders to describe supported values: | 103 | * Optional node attributes for decoders to describe supported values: |
@@ -111,7 +111,7 @@ interface IOmxStore { | |||
111 | * Optional node attributes for encoders to describe supported values: | 111 | * Optional node attributes for encoders to describe supported values: |
112 | * key: 'complexity-default', value-type: num | 112 | * key: 'complexity-default', value-type: num |
113 | * key: 'complexity-range', value-type: range<num> | 113 | * key: 'complexity-range', value-type: range<num> |
114 | * key: 'feature-bitrate-control', value-type: list<enum<VBR,CBR,CQ>> | 114 | * key: 'feature-bitrate-modes', value-type: list<enum<VBR,CBR,CQ>> |
115 | * key: 'feature-intra-refresh', value-type: enum<0,1> | 115 | * key: 'feature-intra-refresh', value-type: enum<0,1> |
116 | * key: 'quality-default', value-type: num | 116 | * key: 'quality-default', value-type: num |
117 | * key: 'quality-range', value-type: range<num> | 117 | * key: 'quality-range', value-type: range<num> |
diff --git a/media/omx/1.0/vts/functional/audio/Android.bp b/media/omx/1.0/vts/functional/audio/Android.bp index 66fd20be..f517fa1d 100644 --- a/media/omx/1.0/vts/functional/audio/Android.bp +++ b/media/omx/1.0/vts/functional/audio/Android.bp | |||
@@ -16,65 +16,19 @@ | |||
16 | 16 | ||
17 | cc_test { | 17 | cc_test { |
18 | name: "VtsHalMediaOmxV1_0TargetAudioEncTest", | 18 | name: "VtsHalMediaOmxV1_0TargetAudioEncTest", |
19 | defaults: ["hidl_defaults"], | 19 | defaults: ["VtsHalMediaOmxV1_0Defaults"], |
20 | srcs: ["VtsHalMediaOmxV1_0TargetAudioEncTest.cpp", | 20 | srcs: [ |
21 | "media_audio_hidl_test_common.cpp"], | 21 | "VtsHalMediaOmxV1_0TargetAudioEncTest.cpp", |
22 | shared_libs: [ | 22 | "media_audio_hidl_test_common.cpp" |
23 | "libbase", | ||
24 | "liblog", | ||
25 | "libcutils", | ||
26 | "libhidlbase", | ||
27 | "libhidlmemory", | ||
28 | "libhidltransport", | ||
29 | "libhwbinder", | ||
30 | "libnativehelper", | ||
31 | "libutils", | ||
32 | "libstagefright_foundation", | ||
33 | "android.hidl.allocator@1.0", | ||
34 | "android.hidl.memory@1.0", | ||
35 | "android.hardware.media.omx@1.0", | ||
36 | ], | ||
37 | static_libs: ["VtsHalHidlTargetTestBase", | ||
38 | "VtsHalMediaOmxV1_0CommonUtil"], | ||
39 | cflags: [ | ||
40 | "-O0", | ||
41 | "-g", | ||
42 | ], | ||
43 | include_dirs: [ | ||
44 | "frameworks/native/include/media/openmax/", | ||
45 | "hardware/interfaces/media/omx/1.0/vts/functional/common", | ||
46 | ], | 23 | ], |
47 | } | 24 | } |
48 | 25 | ||
49 | cc_test { | 26 | cc_test { |
50 | name: "VtsHalMediaOmxV1_0TargetAudioDecTest", | 27 | name: "VtsHalMediaOmxV1_0TargetAudioDecTest", |
51 | defaults: ["hidl_defaults"], | 28 | defaults: ["VtsHalMediaOmxV1_0Defaults"], |
52 | srcs: ["VtsHalMediaOmxV1_0TargetAudioDecTest.cpp", | 29 | srcs: [ |
53 | "media_audio_hidl_test_common.cpp"], | 30 | "VtsHalMediaOmxV1_0TargetAudioDecTest.cpp", |
54 | shared_libs: [ | 31 | "media_audio_hidl_test_common.cpp" |
55 | "libbase", | ||
56 | "liblog", | ||
57 | "libcutils", | ||
58 | "libhidlbase", | ||
59 | "libhidlmemory", | ||
60 | "libhidltransport", | ||
61 | "libhwbinder", | ||
62 | "libnativehelper", | ||
63 | "libutils", | ||
64 | "libstagefright_foundation", | ||
65 | "android.hidl.allocator@1.0", | ||
66 | "android.hidl.memory@1.0", | ||
67 | "android.hardware.media.omx@1.0", | ||
68 | ], | ||
69 | static_libs: ["VtsHalHidlTargetTestBase", | ||
70 | "VtsHalMediaOmxV1_0CommonUtil"], | ||
71 | cflags: [ | ||
72 | "-O0", | ||
73 | "-g", | ||
74 | ], | ||
75 | include_dirs: [ | ||
76 | "frameworks/native/include/media/openmax/", | ||
77 | "hardware/interfaces/media/omx/1.0/vts/functional/common", | ||
78 | ], | 32 | ], |
79 | } | 33 | } |
80 | 34 | ||
diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp index 336cab48..38cdcd65 100644 --- a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp +++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp | |||
@@ -15,6 +15,10 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #define LOG_TAG "media_omx_hidl_audio_dec_test" | 17 | #define LOG_TAG "media_omx_hidl_audio_dec_test" |
18 | #ifdef __LP64__ | ||
19 | #define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS | ||
20 | #endif | ||
21 | |||
18 | #include <android-base/logging.h> | 22 | #include <android-base/logging.h> |
19 | 23 | ||
20 | #include <android/hardware/media/omx/1.0/IOmx.h> | 24 | #include <android/hardware/media/omx/1.0/IOmx.h> |
@@ -161,6 +165,7 @@ class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
161 | this->omxNode = _nl; | 165 | this->omxNode = _nl; |
162 | }) | 166 | }) |
163 | .isOk()); | 167 | .isOk()); |
168 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
164 | ASSERT_NE(omxNode, nullptr); | 169 | ASSERT_NE(omxNode, nullptr); |
165 | ASSERT_NE(gEnv->getRole().empty(), true) << "Invalid Component Role"; | 170 | ASSERT_NE(gEnv->getRole().empty(), true) << "Invalid Component Role"; |
166 | struct StringToName { | 171 | struct StringToName { |
@@ -171,7 +176,7 @@ class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
171 | {"mp3", mp3}, {"amrnb", amrnb}, {"amrwb", amrwb}, | 176 | {"mp3", mp3}, {"amrnb", amrnb}, {"amrwb", amrwb}, |
172 | {"aac", aac}, {"vorbis", vorbis}, {"opus", opus}, | 177 | {"aac", aac}, {"vorbis", vorbis}, {"opus", opus}, |
173 | {"pcm", pcm}, {"g711alaw", g711alaw}, {"g711mlaw", g711mlaw}, | 178 | {"pcm", pcm}, {"g711alaw", g711alaw}, {"g711mlaw", g711mlaw}, |
174 | {"gsm", gsm}, {"raw", raw}, | 179 | {"gsm", gsm}, {"raw", raw}, {"flac", flac}, |
175 | }; | 180 | }; |
176 | const size_t kNumStringToName = | 181 | const size_t kNumStringToName = |
177 | sizeof(kStringToName) / sizeof(kStringToName[0]); | 182 | sizeof(kStringToName) / sizeof(kStringToName[0]); |
@@ -204,6 +209,7 @@ class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
204 | {g711mlaw, OMX_AUDIO_CodingG711}, | 209 | {g711mlaw, OMX_AUDIO_CodingG711}, |
205 | {gsm, OMX_AUDIO_CodingGSMFR}, | 210 | {gsm, OMX_AUDIO_CodingGSMFR}, |
206 | {raw, OMX_AUDIO_CodingPCM}, | 211 | {raw, OMX_AUDIO_CodingPCM}, |
212 | {flac, OMX_AUDIO_CodingFLAC}, | ||
207 | }; | 213 | }; |
208 | static const size_t kNumCompToCoding = | 214 | static const size_t kNumCompToCoding = |
209 | sizeof(kCompToCoding) / sizeof(kCompToCoding[0]); | 215 | sizeof(kCompToCoding) / sizeof(kCompToCoding[0]); |
@@ -219,11 +225,15 @@ class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
219 | framesReceived = 0; | 225 | framesReceived = 0; |
220 | timestampUs = 0; | 226 | timestampUs = 0; |
221 | timestampDevTest = false; | 227 | timestampDevTest = false; |
222 | if (disableTest) std::cerr << "[ ] Warning ! Test Disabled\n"; | 228 | if (disableTest) std::cout << "[ WARN ] Test Disabled \n"; |
223 | } | 229 | } |
224 | 230 | ||
225 | virtual void TearDown() override { | 231 | virtual void TearDown() override { |
226 | if (omxNode != nullptr) { | 232 | if (omxNode != nullptr) { |
233 | // If you have encountered a fatal failure, it is possible that | ||
234 | // freeNode() will not go through. Instead of hanging the app. | ||
235 | // let it pass through and report errors | ||
236 | if (::testing::Test::HasFatalFailure()) return; | ||
227 | EXPECT_TRUE((omxNode->freeNode()).isOk()); | 237 | EXPECT_TRUE((omxNode->freeNode()).isOk()); |
228 | omxNode = nullptr; | 238 | omxNode = nullptr; |
229 | } | 239 | } |
@@ -263,9 +273,8 @@ class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
263 | EXPECT_EQ(tsHit, true) | 273 | EXPECT_EQ(tsHit, true) |
264 | << "TimeStamp not recognized"; | 274 | << "TimeStamp not recognized"; |
265 | } else { | 275 | } else { |
266 | std::cerr | 276 | std::cout << "[ INFO ] Received non-zero " |
267 | << "[ ] Warning ! Received non-zero " | 277 | "output / TimeStamp not recognized \n"; |
268 | "output / TimeStamp not recognized \n"; | ||
269 | } | 278 | } |
270 | } | 279 | } |
271 | } | 280 | } |
@@ -301,6 +310,7 @@ class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
301 | g711mlaw, | 310 | g711mlaw, |
302 | gsm, | 311 | gsm, |
303 | raw, | 312 | raw, |
313 | flac, | ||
304 | unknown_comp, | 314 | unknown_comp, |
305 | }; | 315 | }; |
306 | 316 | ||
@@ -418,6 +428,9 @@ void getInputChannelInfo(sp<IOmxNode> omxNode, OMX_U32 kPortIndexInput, | |||
418 | ASSERT_EQ(status, | 428 | ASSERT_EQ(status, |
419 | ::android::hardware::media::omx::V1_0::Status::OK); | 429 | ::android::hardware::media::omx::V1_0::Status::OK); |
420 | *nChannels = param.nChannels; | 430 | *nChannels = param.nChannels; |
431 | // NOTE: For amrnb sample rate is 8k and amrwb sample rate is 16k. | ||
432 | // There is no nSampleRate field in OMX_AUDIO_PARAM_AMRTYPE. Just | ||
433 | // return 8k to avoid returning uninit variable. | ||
421 | *nSampleRate = 8000; | 434 | *nSampleRate = 8000; |
422 | break; | 435 | break; |
423 | } | 436 | } |
@@ -431,6 +444,16 @@ void getInputChannelInfo(sp<IOmxNode> omxNode, OMX_U32 kPortIndexInput, | |||
431 | *nSampleRate = param.nSampleRate; | 444 | *nSampleRate = param.nSampleRate; |
432 | break; | 445 | break; |
433 | } | 446 | } |
447 | case OMX_AUDIO_CodingFLAC: { | ||
448 | OMX_AUDIO_PARAM_FLACTYPE param; | ||
449 | status = getPortParam(omxNode, OMX_IndexParamAudioFlac, | ||
450 | kPortIndexInput, ¶m); | ||
451 | ASSERT_EQ(status, | ||
452 | ::android::hardware::media::omx::V1_0::Status::OK); | ||
453 | *nChannels = param.nChannels; | ||
454 | *nSampleRate = param.nSampleRate; | ||
455 | break; | ||
456 | } | ||
434 | default: | 457 | default: |
435 | ASSERT_TRUE(false); | 458 | ASSERT_TRUE(false); |
436 | break; | 459 | break; |
@@ -472,6 +495,9 @@ void GetURLForComponent(AudioDecHidlTest::standardComp comp, char* mURL, | |||
472 | "bbb_gsm_1ch_8khz_13kbps.info"}, | 495 | "bbb_gsm_1ch_8khz_13kbps.info"}, |
473 | {AudioDecHidlTest::standardComp::raw, "bbb_raw_1ch_8khz_s32le.raw", | 496 | {AudioDecHidlTest::standardComp::raw, "bbb_raw_1ch_8khz_s32le.raw", |
474 | "bbb_raw_1ch_8khz_s32le.info"}, | 497 | "bbb_raw_1ch_8khz_s32le.info"}, |
498 | {AudioDecHidlTest::standardComp::flac, | ||
499 | "bbb_flac_stereo_680kbps_48000hz.flac", | ||
500 | "bbb_flac_stereo_680kbps_48000hz.info"}, | ||
475 | }; | 501 | }; |
476 | 502 | ||
477 | for (size_t i = 0; i < sizeof(kCompToURL) / sizeof(kCompToURL[0]); ++i) { | 503 | for (size_t i = 0; i < sizeof(kCompToURL) / sizeof(kCompToURL[0]); ++i) { |
@@ -530,13 +556,13 @@ void portReconfiguration(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
530 | // set Port Params | 556 | // set Port Params |
531 | int32_t nChannels; | 557 | int32_t nChannels; |
532 | int32_t nSampleRate; | 558 | int32_t nSampleRate; |
533 | getInputChannelInfo(omxNode, kPortIndexInput, eEncoding, &nChannels, | 559 | ASSERT_NO_FATAL_FAILURE(getInputChannelInfo( |
534 | &nSampleRate); | 560 | omxNode, kPortIndexInput, eEncoding, &nChannels, &nSampleRate)); |
535 | // Configure output port | 561 | // Configure output port |
536 | // SPECIAL CASE: Soft Vorbis, Opus and Raw Decoders do not offer way | 562 | // SPECIAL CASE: Soft Vorbis, Opus and Raw Decoders do not offer way |
537 | // to | 563 | // to configure output PCM port. The port undergoes auto |
538 | // configure output PCM port. The port undergoes auto configuration | 564 | // configuration internally basing on parsed elementary stream |
539 | // internally basing on parsed elementary stream information. | 565 | // information. |
540 | if (comp != AudioDecHidlTest::standardComp::vorbis && | 566 | if (comp != AudioDecHidlTest::standardComp::vorbis && |
541 | comp != AudioDecHidlTest::standardComp::opus && | 567 | comp != AudioDecHidlTest::standardComp::opus && |
542 | comp != AudioDecHidlTest::standardComp::raw) { | 568 | comp != AudioDecHidlTest::standardComp::raw) { |
@@ -545,9 +571,8 @@ void portReconfiguration(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
545 | nSampleRate); | 571 | nSampleRate); |
546 | } | 572 | } |
547 | 573 | ||
548 | // If you can disable a port, then you should be able to | 574 | // If you can disable a port, then you should be able to enable it |
549 | // enable | 575 | // as well |
550 | // it as well | ||
551 | status = omxNode->sendCommand( | 576 | status = omxNode->sendCommand( |
552 | toRawCommandType(OMX_CommandPortEnable), kPortIndexOutput); | 577 | toRawCommandType(OMX_CommandPortEnable), kPortIndexOutput); |
553 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | 578 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); |
@@ -558,7 +583,8 @@ void portReconfiguration(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
558 | ASSERT_EQ(status, | 583 | ASSERT_EQ(status, |
559 | android::hardware::media::omx::V1_0::Status::TIMED_OUT); | 584 | android::hardware::media::omx::V1_0::Status::TIMED_OUT); |
560 | 585 | ||
561 | allocatePortBuffers(omxNode, oBuffer, kPortIndexOutput); | 586 | ASSERT_NO_FATAL_FAILURE( |
587 | allocatePortBuffers(omxNode, oBuffer, kPortIndexOutput)); | ||
562 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, | 588 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, |
563 | oBuffer); | 589 | oBuffer); |
564 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | 590 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); |
@@ -568,14 +594,14 @@ void portReconfiguration(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
568 | 594 | ||
569 | // dispatch output buffers | 595 | // dispatch output buffers |
570 | for (size_t i = 0; i < oBuffer->size(); i++) { | 596 | for (size_t i = 0; i < oBuffer->size(); i++) { |
571 | dispatchOutputBuffer(omxNode, oBuffer, i); | 597 | ASSERT_NO_FATAL_FAILURE( |
598 | dispatchOutputBuffer(omxNode, oBuffer, i)); | ||
572 | } | 599 | } |
573 | } else { | 600 | } else { |
574 | ASSERT_TRUE(false); | 601 | ASSERT_TRUE(false); |
575 | } | 602 | } |
576 | } else { | 603 | } else { |
577 | EXPECT_TRUE(false); | 604 | ASSERT_TRUE(false); |
578 | return; | ||
579 | } | 605 | } |
580 | } | 606 | } |
581 | 607 | ||
@@ -588,18 +614,19 @@ void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
588 | AudioDecHidlTest::standardComp comp) { | 614 | AudioDecHidlTest::standardComp comp) { |
589 | android::hardware::media::omx::V1_0::Status status; | 615 | android::hardware::media::omx::V1_0::Status status; |
590 | Message msg; | 616 | Message msg; |
591 | int timeOut = TIMEOUT_COUNTER; | 617 | int timeOut = TIMEOUT_COUNTER_Q; |
592 | 618 | ||
593 | while (timeOut--) { | 619 | while (timeOut--) { |
594 | size_t i = 0; | 620 | size_t i = 0; |
595 | status = | 621 | status = |
596 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); | 622 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); |
597 | if (status == android::hardware::media::omx::V1_0::Status::OK) { | 623 | if (status == android::hardware::media::omx::V1_0::Status::OK) { |
598 | EXPECT_EQ(msg.type, Message::Type::EVENT); | 624 | ASSERT_EQ(msg.type, Message::Type::EVENT); |
599 | packedArgs audioArgs = {eEncoding, comp}; | 625 | packedArgs audioArgs = {eEncoding, comp}; |
600 | portReconfiguration(omxNode, observer, iBuffer, oBuffer, | 626 | ASSERT_NO_FATAL_FAILURE( |
601 | kPortIndexInput, kPortIndexOutput, msg, | 627 | portReconfiguration(omxNode, observer, iBuffer, oBuffer, |
602 | PortMode::PRESET_BYTE_BUFFER, &audioArgs); | 628 | kPortIndexInput, kPortIndexOutput, msg, |
629 | PortMode::PRESET_BYTE_BUFFER, &audioArgs)); | ||
603 | } | 630 | } |
604 | // status == TIMED_OUT, it could be due to process time being large | 631 | // status == TIMED_OUT, it could be due to process time being large |
605 | // than DEFAULT_TIMEOUT or component needs output buffers to start | 632 | // than DEFAULT_TIMEOUT or component needs output buffers to start |
@@ -612,9 +639,10 @@ void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
612 | // Dispatch an output buffer assuming outQueue.empty() is true | 639 | // Dispatch an output buffer assuming outQueue.empty() is true |
613 | size_t index; | 640 | size_t index; |
614 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { | 641 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { |
615 | dispatchOutputBuffer(omxNode, oBuffer, index); | 642 | ASSERT_NO_FATAL_FAILURE( |
643 | dispatchOutputBuffer(omxNode, oBuffer, index)); | ||
644 | timeOut = TIMEOUT_COUNTER_Q; | ||
616 | } | 645 | } |
617 | timeOut--; | ||
618 | } | 646 | } |
619 | } | 647 | } |
620 | 648 | ||
@@ -628,51 +656,29 @@ void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
628 | AudioDecHidlTest::standardComp comp, bool signalEOS = true) { | 656 | AudioDecHidlTest::standardComp comp, bool signalEOS = true) { |
629 | android::hardware::media::omx::V1_0::Status status; | 657 | android::hardware::media::omx::V1_0::Status status; |
630 | Message msg; | 658 | Message msg; |
631 | 659 | size_t index; | |
632 | // dispatch output buffers | ||
633 | for (size_t i = 0; i < oBuffer->size(); i++) { | ||
634 | dispatchOutputBuffer(omxNode, oBuffer, i); | ||
635 | } | ||
636 | // dispatch input buffers | ||
637 | uint32_t flags = 0; | 660 | uint32_t flags = 0; |
638 | int frameID = offset; | 661 | int frameID = offset; |
639 | for (size_t i = 0; (i < iBuffer->size()) && (frameID < (int)Info->size()) && | 662 | int timeOut = TIMEOUT_COUNTER_Q; |
640 | (frameID < (offset + range)); | 663 | bool iQueued, oQueued; |
641 | i++) { | ||
642 | char* ipBuffer = static_cast<char*>( | ||
643 | static_cast<void*>((*iBuffer)[i].mMemory->getPointer())); | ||
644 | ASSERT_LE((*Info)[frameID].bytesCount, | ||
645 | static_cast<int>((*iBuffer)[i].mMemory->getSize())); | ||
646 | eleStream.read(ipBuffer, (*Info)[frameID].bytesCount); | ||
647 | ASSERT_EQ(eleStream.gcount(), (*Info)[frameID].bytesCount); | ||
648 | flags = (*Info)[frameID].flags; | ||
649 | if (signalEOS && ((frameID == (int)Info->size() - 1) || | ||
650 | (frameID == (offset + range - 1)))) | ||
651 | flags |= OMX_BUFFERFLAG_EOS; | ||
652 | dispatchInputBuffer(omxNode, iBuffer, i, (*Info)[frameID].bytesCount, | ||
653 | flags, (*Info)[frameID].timestamp); | ||
654 | frameID++; | ||
655 | } | ||
656 | 664 | ||
657 | int timeOut = TIMEOUT_COUNTER; | ||
658 | bool stall = false; | ||
659 | while (1) { | 665 | while (1) { |
666 | iQueued = oQueued = false; | ||
660 | status = | 667 | status = |
661 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); | 668 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); |
662 | |||
663 | // Port Reconfiguration | 669 | // Port Reconfiguration |
664 | if (status == android::hardware::media::omx::V1_0::Status::OK && | 670 | if (status == android::hardware::media::omx::V1_0::Status::OK && |
665 | msg.type == Message::Type::EVENT) { | 671 | msg.type == Message::Type::EVENT) { |
666 | packedArgs audioArgs = {eEncoding, comp}; | 672 | packedArgs audioArgs = {eEncoding, comp}; |
667 | portReconfiguration(omxNode, observer, iBuffer, oBuffer, | 673 | ASSERT_NO_FATAL_FAILURE( |
668 | kPortIndexInput, kPortIndexOutput, msg, | 674 | portReconfiguration(omxNode, observer, iBuffer, oBuffer, |
669 | PortMode::PRESET_BYTE_BUFFER, &audioArgs); | 675 | kPortIndexInput, kPortIndexOutput, msg, |
676 | PortMode::PRESET_BYTE_BUFFER, &audioArgs)); | ||
670 | } | 677 | } |
671 | 678 | ||
672 | if (frameID == (int)Info->size() || frameID == (offset + range)) break; | 679 | if (frameID == (int)Info->size() || frameID == (offset + range)) break; |
673 | 680 | ||
674 | // Dispatch input buffer | 681 | // Dispatch input buffer |
675 | size_t index = 0; | ||
676 | if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) { | 682 | if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) { |
677 | char* ipBuffer = static_cast<char*>( | 683 | char* ipBuffer = static_cast<char*>( |
678 | static_cast<void*>((*iBuffer)[index].mMemory->getPointer())); | 684 | static_cast<void*>((*iBuffer)[index].mMemory->getPointer())); |
@@ -681,28 +687,33 @@ void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
681 | eleStream.read(ipBuffer, (*Info)[frameID].bytesCount); | 687 | eleStream.read(ipBuffer, (*Info)[frameID].bytesCount); |
682 | ASSERT_EQ(eleStream.gcount(), (*Info)[frameID].bytesCount); | 688 | ASSERT_EQ(eleStream.gcount(), (*Info)[frameID].bytesCount); |
683 | flags = (*Info)[frameID].flags; | 689 | flags = (*Info)[frameID].flags; |
690 | // Indicate to omx core that the buffer contains a full frame worth | ||
691 | // of data | ||
692 | flags |= OMX_BUFFERFLAG_ENDOFFRAME; | ||
693 | // Indicate the omx core that this is the last buffer it needs to | ||
694 | // process | ||
684 | if (signalEOS && ((frameID == (int)Info->size() - 1) || | 695 | if (signalEOS && ((frameID == (int)Info->size() - 1) || |
685 | (frameID == (offset + range - 1)))) | 696 | (frameID == (offset + range - 1)))) |
686 | flags |= OMX_BUFFERFLAG_EOS; | 697 | flags |= OMX_BUFFERFLAG_EOS; |
687 | dispatchInputBuffer(omxNode, iBuffer, index, | 698 | ASSERT_NO_FATAL_FAILURE(dispatchInputBuffer( |
688 | (*Info)[frameID].bytesCount, flags, | 699 | omxNode, iBuffer, index, (*Info)[frameID].bytesCount, flags, |
689 | (*Info)[frameID].timestamp); | 700 | (*Info)[frameID].timestamp)); |
690 | frameID++; | 701 | frameID++; |
691 | stall = false; | 702 | iQueued = true; |
692 | } else | 703 | } |
693 | stall = true; | 704 | // Dispatch output buffer |
694 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { | 705 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { |
695 | dispatchOutputBuffer(omxNode, oBuffer, index); | 706 | ASSERT_NO_FATAL_FAILURE( |
696 | stall = false; | 707 | dispatchOutputBuffer(omxNode, oBuffer, index)); |
697 | } else | 708 | oQueued = true; |
698 | stall = true; | 709 | } |
699 | if (stall) | 710 | // Reset Counters when either input or output buffer is dispatched |
700 | timeOut--; | 711 | if (iQueued || oQueued) |
712 | timeOut = TIMEOUT_COUNTER_Q; | ||
701 | else | 713 | else |
702 | timeOut = TIMEOUT_COUNTER; | 714 | timeOut--; |
703 | if (timeOut == 0) { | 715 | if (timeOut == 0) { |
704 | EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite"; | 716 | ASSERT_TRUE(false) << "Wait on Input/Output is found indefinite"; |
705 | break; | ||
706 | } | 717 | } |
707 | } | 718 | } |
708 | } | 719 | } |
@@ -717,7 +728,7 @@ TEST_F(AudioDecHidlTest, SetRole) { | |||
717 | } | 728 | } |
718 | 729 | ||
719 | // port format enumeration | 730 | // port format enumeration |
720 | TEST_F(AudioDecHidlTest, DISABLED_EnumeratePortFormat) { | 731 | TEST_F(AudioDecHidlTest, EnumeratePortFormat) { |
721 | description("Test Component on Mandatory Port Parameters (Port Format)"); | 732 | description("Test Component on Mandatory Port Parameters (Port Format)"); |
722 | if (disableTest) return; | 733 | if (disableTest) return; |
723 | android::hardware::media::omx::V1_0::Status status; | 734 | android::hardware::media::omx::V1_0::Status status; |
@@ -766,13 +777,13 @@ TEST_F(AudioDecHidlTest, DecodeTest) { | |||
766 | int bytesCount = 0; | 777 | int bytesCount = 0; |
767 | uint32_t flags = 0; | 778 | uint32_t flags = 0; |
768 | uint32_t timestamp = 0; | 779 | uint32_t timestamp = 0; |
769 | timestampDevTest = true; | 780 | timestampDevTest = false; |
770 | while (1) { | 781 | while (1) { |
771 | if (!(eleInfo >> bytesCount)) break; | 782 | if (!(eleInfo >> bytesCount)) break; |
772 | eleInfo >> flags; | 783 | eleInfo >> flags; |
773 | eleInfo >> timestamp; | 784 | eleInfo >> timestamp; |
774 | Info.push_back({bytesCount, flags, timestamp}); | 785 | Info.push_back({bytesCount, flags, timestamp}); |
775 | if (flags != OMX_BUFFERFLAG_CODECCONFIG) | 786 | if (timestampDevTest && (flags != OMX_BUFFERFLAG_CODECCONFIG)) |
776 | timestampUslist.push_back(timestamp); | 787 | timestampUslist.push_back(timestamp); |
777 | } | 788 | } |
778 | eleInfo.close(); | 789 | eleInfo.close(); |
@@ -784,8 +795,8 @@ TEST_F(AudioDecHidlTest, DecodeTest) { | |||
784 | setDefaultPortParam(omxNode, kPortIndexInput, eEncoding, 1, 8000, | 795 | setDefaultPortParam(omxNode, kPortIndexInput, eEncoding, 1, 8000, |
785 | OMX_AUDIO_PCMModeLinear, OMX_NumericalDataSigned, | 796 | OMX_AUDIO_PCMModeLinear, OMX_NumericalDataSigned, |
786 | 32); | 797 | 32); |
787 | getInputChannelInfo(omxNode, kPortIndexInput, eEncoding, &nChannels, | 798 | ASSERT_NO_FATAL_FAILURE(getInputChannelInfo( |
788 | &nSampleRate); | 799 | omxNode, kPortIndexInput, eEncoding, &nChannels, &nSampleRate)); |
789 | // Configure output port | 800 | // Configure output port |
790 | // SPECIAL CASE: Soft Vorbis, Opus and Raw Decoders do not offer way to | 801 | // SPECIAL CASE: Soft Vorbis, Opus and Raw Decoders do not offer way to |
791 | // configure output PCM port. The port undergoes auto configuration | 802 | // configure output PCM port. The port undergoes auto configuration |
@@ -798,36 +809,37 @@ TEST_F(AudioDecHidlTest, DecodeTest) { | |||
798 | android::Vector<BufferInfo> iBuffer, oBuffer; | 809 | android::Vector<BufferInfo> iBuffer, oBuffer; |
799 | 810 | ||
800 | // set state to idle | 811 | // set state to idle |
801 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 812 | ASSERT_NO_FATAL_FAILURE(changeStateLoadedtoIdle(omxNode, observer, &iBuffer, |
802 | kPortIndexInput, kPortIndexOutput); | 813 | &oBuffer, kPortIndexInput, |
814 | kPortIndexOutput)); | ||
803 | // set state to executing | 815 | // set state to executing |
804 | changeStateIdletoExecute(omxNode, observer); | 816 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
805 | // Port Reconfiguration | 817 | // Port Reconfiguration |
806 | eleStream.open(mURL, std::ifstream::binary); | 818 | eleStream.open(mURL, std::ifstream::binary); |
807 | ASSERT_EQ(eleStream.is_open(), true); | 819 | ASSERT_EQ(eleStream.is_open(), true); |
808 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, eEncoding, | 820 | ASSERT_NO_FATAL_FAILURE(decodeNFrames( |
809 | kPortIndexInput, kPortIndexOutput, eleStream, &Info, 0, | 821 | omxNode, observer, &iBuffer, &oBuffer, eEncoding, kPortIndexInput, |
810 | (int)Info.size(), compName); | 822 | kPortIndexOutput, eleStream, &Info, 0, (int)Info.size(), compName)); |
811 | eleStream.close(); | 823 | eleStream.close(); |
812 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding, | 824 | ASSERT_NO_FATAL_FAILURE( |
813 | kPortIndexInput, kPortIndexOutput, compName); | 825 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding, |
826 | kPortIndexInput, kPortIndexOutput, compName)); | ||
814 | packedArgs audioArgs = {eEncoding, compName}; | 827 | packedArgs audioArgs = {eEncoding, compName}; |
815 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, nullptr, | 828 | ASSERT_NO_FATAL_FAILURE(testEOS( |
816 | portReconfiguration, kPortIndexInput, kPortIndexOutput, &audioArgs); | 829 | omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, nullptr, |
817 | EXPECT_EQ(timestampUslist.empty(), true); | 830 | portReconfiguration, kPortIndexInput, kPortIndexOutput, &audioArgs)); |
831 | if (timestampDevTest) EXPECT_EQ(timestampUslist.empty(), true); | ||
818 | // set state to idle | 832 | // set state to idle |
819 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 833 | ASSERT_NO_FATAL_FAILURE( |
834 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
820 | // set state to executing | 835 | // set state to executing |
821 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 836 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
822 | kPortIndexInput, kPortIndexOutput); | 837 | &oBuffer, kPortIndexInput, |
838 | kPortIndexOutput)); | ||
823 | } | 839 | } |
824 | 840 | ||
825 | // end of sequence test | 841 | // end of sequence test |
826 | // SPECIAL CASE; Sending Empty input EOS buffer is not supported across all | 842 | TEST_F(AudioDecHidlTest, EOSTest_M) { |
827 | // components. For instance soft vorbis and soft opus expects CSD buffers at | ||
828 | // the start. Disabling this test for now. We shall revisit this at a later | ||
829 | // stage | ||
830 | TEST_F(AudioDecHidlTest, DISABLED_EOSTest_M) { | ||
831 | description("Test end of stream monkeying"); | 843 | description("Test end of stream monkeying"); |
832 | if (disableTest) return; | 844 | if (disableTest) return; |
833 | android::hardware::media::omx::V1_0::Status status; | 845 | android::hardware::media::omx::V1_0::Status status; |
@@ -849,8 +861,8 @@ TEST_F(AudioDecHidlTest, DISABLED_EOSTest_M) { | |||
849 | setDefaultPortParam(omxNode, kPortIndexInput, eEncoding, 1, 8000, | 861 | setDefaultPortParam(omxNode, kPortIndexInput, eEncoding, 1, 8000, |
850 | OMX_AUDIO_PCMModeLinear, OMX_NumericalDataSigned, | 862 | OMX_AUDIO_PCMModeLinear, OMX_NumericalDataSigned, |
851 | 32); | 863 | 32); |
852 | getInputChannelInfo(omxNode, kPortIndexInput, eEncoding, &nChannels, | 864 | ASSERT_NO_FATAL_FAILURE(getInputChannelInfo( |
853 | &nSampleRate); | 865 | omxNode, kPortIndexInput, eEncoding, &nChannels, &nSampleRate)); |
854 | // Configure output port | 866 | // Configure output port |
855 | // SPECIAL CASE: Soft Vorbis, Opus and Raw Decoders do not offer way to | 867 | // SPECIAL CASE: Soft Vorbis, Opus and Raw Decoders do not offer way to |
856 | // configure output PCM port. The port undergoes auto configuration | 868 | // configure output PCM port. The port undergoes auto configuration |
@@ -863,26 +875,31 @@ TEST_F(AudioDecHidlTest, DISABLED_EOSTest_M) { | |||
863 | android::Vector<BufferInfo> iBuffer, oBuffer; | 875 | android::Vector<BufferInfo> iBuffer, oBuffer; |
864 | 876 | ||
865 | // set state to idle | 877 | // set state to idle |
866 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 878 | ASSERT_NO_FATAL_FAILURE(changeStateLoadedtoIdle(omxNode, observer, &iBuffer, |
867 | kPortIndexInput, kPortIndexOutput); | 879 | &oBuffer, kPortIndexInput, |
880 | kPortIndexOutput)); | ||
868 | // set state to executing | 881 | // set state to executing |
869 | changeStateIdletoExecute(omxNode, observer); | 882 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
870 | 883 | ||
871 | // request EOS at the start | 884 | // request EOS at the start |
872 | packedArgs audioArgs = {eEncoding, compName}; | 885 | packedArgs audioArgs = {eEncoding, compName}; |
873 | testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, nullptr, | 886 | ASSERT_NO_FATAL_FAILURE(testEOS( |
874 | portReconfiguration, kPortIndexInput, kPortIndexOutput, &audioArgs); | 887 | omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, nullptr, |
875 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 888 | portReconfiguration, kPortIndexInput, kPortIndexOutput, &audioArgs)); |
876 | kPortIndexOutput); | 889 | ASSERT_NO_FATAL_FAILURE(flushPorts(omxNode, observer, &iBuffer, &oBuffer, |
890 | kPortIndexInput, kPortIndexOutput)); | ||
877 | EXPECT_GE(framesReceived, 0U); | 891 | EXPECT_GE(framesReceived, 0U); |
878 | framesReceived = 0; | 892 | framesReceived = 0; |
879 | timestampUs = 0; | 893 | timestampUs = 0; |
880 | 894 | ||
881 | // set state to idle | 895 | // set state to idle |
882 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 896 | ASSERT_NO_FATAL_FAILURE( |
897 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
898 | |||
883 | // set state to executing | 899 | // set state to executing |
884 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 900 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
885 | kPortIndexInput, kPortIndexOutput); | 901 | &oBuffer, kPortIndexInput, |
902 | kPortIndexOutput)); | ||
886 | } | 903 | } |
887 | 904 | ||
888 | // end of sequence test | 905 | // end of sequence test |
@@ -928,8 +945,8 @@ TEST_F(AudioDecHidlTest, ThumbnailTest) { | |||
928 | setDefaultPortParam(omxNode, kPortIndexInput, eEncoding, 1, 8000, | 945 | setDefaultPortParam(omxNode, kPortIndexInput, eEncoding, 1, 8000, |
929 | OMX_AUDIO_PCMModeLinear, OMX_NumericalDataSigned, | 946 | OMX_AUDIO_PCMModeLinear, OMX_NumericalDataSigned, |
930 | 32); | 947 | 32); |
931 | getInputChannelInfo(omxNode, kPortIndexInput, eEncoding, &nChannels, | 948 | ASSERT_NO_FATAL_FAILURE(getInputChannelInfo( |
932 | &nSampleRate); | 949 | omxNode, kPortIndexInput, eEncoding, &nChannels, &nSampleRate)); |
933 | // Configure output port | 950 | // Configure output port |
934 | // SPECIAL CASE: Soft Vorbis, Opus and Raw Decoders do not offer way to | 951 | // SPECIAL CASE: Soft Vorbis, Opus and Raw Decoders do not offer way to |
935 | // configure output PCM port. The port undergoes auto configuration | 952 | // configure output PCM port. The port undergoes auto configuration |
@@ -942,10 +959,11 @@ TEST_F(AudioDecHidlTest, ThumbnailTest) { | |||
942 | android::Vector<BufferInfo> iBuffer, oBuffer; | 959 | android::Vector<BufferInfo> iBuffer, oBuffer; |
943 | 960 | ||
944 | // set state to idle | 961 | // set state to idle |
945 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 962 | ASSERT_NO_FATAL_FAILURE(changeStateLoadedtoIdle(omxNode, observer, &iBuffer, |
946 | kPortIndexInput, kPortIndexOutput); | 963 | &oBuffer, kPortIndexInput, |
964 | kPortIndexOutput)); | ||
947 | // set state to executing | 965 | // set state to executing |
948 | changeStateIdletoExecute(omxNode, observer); | 966 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
949 | 967 | ||
950 | // request EOS for thumbnail | 968 | // request EOS for thumbnail |
951 | // signal EOS flag with last frame | 969 | // signal EOS flag with last frame |
@@ -953,17 +971,19 @@ TEST_F(AudioDecHidlTest, ThumbnailTest) { | |||
953 | while (!(Info[i].flags & OMX_BUFFERFLAG_SYNCFRAME)) i++; | 971 | while (!(Info[i].flags & OMX_BUFFERFLAG_SYNCFRAME)) i++; |
954 | eleStream.open(mURL, std::ifstream::binary); | 972 | eleStream.open(mURL, std::ifstream::binary); |
955 | ASSERT_EQ(eleStream.is_open(), true); | 973 | ASSERT_EQ(eleStream.is_open(), true); |
956 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, eEncoding, | 974 | ASSERT_NO_FATAL_FAILURE(decodeNFrames( |
957 | kPortIndexInput, kPortIndexOutput, eleStream, &Info, 0, i + 1, | 975 | omxNode, observer, &iBuffer, &oBuffer, eEncoding, kPortIndexInput, |
958 | compName); | 976 | kPortIndexOutput, eleStream, &Info, 0, i + 1, compName)); |
959 | eleStream.close(); | 977 | eleStream.close(); |
960 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding, | 978 | ASSERT_NO_FATAL_FAILURE( |
961 | kPortIndexInput, kPortIndexOutput, compName); | 979 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding, |
980 | kPortIndexInput, kPortIndexOutput, compName)); | ||
962 | packedArgs audioArgs = {eEncoding, compName}; | 981 | packedArgs audioArgs = {eEncoding, compName}; |
963 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, nullptr, | 982 | ASSERT_NO_FATAL_FAILURE(testEOS( |
964 | portReconfiguration, kPortIndexInput, kPortIndexOutput, &audioArgs); | 983 | omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, nullptr, |
965 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 984 | portReconfiguration, kPortIndexInput, kPortIndexOutput, &audioArgs)); |
966 | kPortIndexOutput); | 985 | ASSERT_NO_FATAL_FAILURE(flushPorts(omxNode, observer, &iBuffer, &oBuffer, |
986 | kPortIndexInput, kPortIndexOutput)); | ||
967 | EXPECT_GE(framesReceived, 1U); | 987 | EXPECT_GE(framesReceived, 1U); |
968 | framesReceived = 0; | 988 | framesReceived = 0; |
969 | timestampUs = 0; | 989 | timestampUs = 0; |
@@ -971,25 +991,29 @@ TEST_F(AudioDecHidlTest, ThumbnailTest) { | |||
971 | // signal EOS flag after last frame | 991 | // signal EOS flag after last frame |
972 | eleStream.open(mURL, std::ifstream::binary); | 992 | eleStream.open(mURL, std::ifstream::binary); |
973 | ASSERT_EQ(eleStream.is_open(), true); | 993 | ASSERT_EQ(eleStream.is_open(), true); |
974 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, eEncoding, | 994 | ASSERT_NO_FATAL_FAILURE(decodeNFrames( |
975 | kPortIndexInput, kPortIndexOutput, eleStream, &Info, 0, i + 1, | 995 | omxNode, observer, &iBuffer, &oBuffer, eEncoding, kPortIndexInput, |
976 | compName, false); | 996 | kPortIndexOutput, eleStream, &Info, 0, i + 1, compName, false)); |
977 | eleStream.close(); | 997 | eleStream.close(); |
978 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding, | 998 | ASSERT_NO_FATAL_FAILURE( |
979 | kPortIndexInput, kPortIndexOutput, compName); | 999 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding, |
980 | testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, nullptr, | 1000 | kPortIndexInput, kPortIndexOutput, compName)); |
981 | portReconfiguration, kPortIndexInput, kPortIndexOutput, &audioArgs); | 1001 | ASSERT_NO_FATAL_FAILURE(testEOS( |
982 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1002 | omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, nullptr, |
983 | kPortIndexOutput); | 1003 | portReconfiguration, kPortIndexInput, kPortIndexOutput, &audioArgs)); |
1004 | ASSERT_NO_FATAL_FAILURE(flushPorts(omxNode, observer, &iBuffer, &oBuffer, | ||
1005 | kPortIndexInput, kPortIndexOutput)); | ||
984 | EXPECT_GE(framesReceived, 1U); | 1006 | EXPECT_GE(framesReceived, 1U); |
985 | framesReceived = 0; | 1007 | framesReceived = 0; |
986 | timestampUs = 0; | 1008 | timestampUs = 0; |
987 | 1009 | ||
988 | // set state to idle | 1010 | // set state to idle |
989 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1011 | ASSERT_NO_FATAL_FAILURE( |
1012 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
990 | // set state to executing | 1013 | // set state to executing |
991 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1014 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
992 | kPortIndexInput, kPortIndexOutput); | 1015 | &oBuffer, kPortIndexInput, |
1016 | kPortIndexOutput)); | ||
993 | } | 1017 | } |
994 | 1018 | ||
995 | // end of sequence test | 1019 | // end of sequence test |
@@ -1035,8 +1059,8 @@ TEST_F(AudioDecHidlTest, SimpleEOSTest) { | |||
1035 | setDefaultPortParam(omxNode, kPortIndexInput, eEncoding, 1, 8000, | 1059 | setDefaultPortParam(omxNode, kPortIndexInput, eEncoding, 1, 8000, |
1036 | OMX_AUDIO_PCMModeLinear, OMX_NumericalDataSigned, | 1060 | OMX_AUDIO_PCMModeLinear, OMX_NumericalDataSigned, |
1037 | 32); | 1061 | 32); |
1038 | getInputChannelInfo(omxNode, kPortIndexInput, eEncoding, &nChannels, | 1062 | ASSERT_NO_FATAL_FAILURE(getInputChannelInfo( |
1039 | &nSampleRate); | 1063 | omxNode, kPortIndexInput, eEncoding, &nChannels, &nSampleRate)); |
1040 | // Configure output port | 1064 | // Configure output port |
1041 | // SPECIAL CASE: Soft Vorbis, Opus and Raw Decoders do not offer way to | 1065 | // SPECIAL CASE: Soft Vorbis, Opus and Raw Decoders do not offer way to |
1042 | // configure output PCM port. The port undergoes auto configuration | 1066 | // configure output PCM port. The port undergoes auto configuration |
@@ -1049,33 +1073,39 @@ TEST_F(AudioDecHidlTest, SimpleEOSTest) { | |||
1049 | android::Vector<BufferInfo> iBuffer, oBuffer; | 1073 | android::Vector<BufferInfo> iBuffer, oBuffer; |
1050 | 1074 | ||
1051 | // set state to idle | 1075 | // set state to idle |
1052 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 1076 | ASSERT_NO_FATAL_FAILURE(changeStateLoadedtoIdle(omxNode, observer, &iBuffer, |
1053 | kPortIndexInput, kPortIndexOutput); | 1077 | &oBuffer, kPortIndexInput, |
1078 | kPortIndexOutput)); | ||
1054 | // set state to executing | 1079 | // set state to executing |
1055 | changeStateIdletoExecute(omxNode, observer); | 1080 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
1056 | 1081 | ||
1057 | // request EOS at the end | 1082 | // request EOS at the end |
1058 | eleStream.open(mURL, std::ifstream::binary); | 1083 | eleStream.open(mURL, std::ifstream::binary); |
1059 | ASSERT_EQ(eleStream.is_open(), true); | 1084 | ASSERT_EQ(eleStream.is_open(), true); |
1060 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, eEncoding, | 1085 | ASSERT_NO_FATAL_FAILURE(decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, |
1061 | kPortIndexInput, kPortIndexOutput, eleStream, &Info, 0, | 1086 | eEncoding, kPortIndexInput, |
1062 | (int)Info.size(), compName, false); | 1087 | kPortIndexOutput, eleStream, &Info, 0, |
1088 | (int)Info.size(), compName, false)); | ||
1063 | eleStream.close(); | 1089 | eleStream.close(); |
1064 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding, | 1090 | ASSERT_NO_FATAL_FAILURE( |
1065 | kPortIndexInput, kPortIndexOutput, compName); | 1091 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding, |
1092 | kPortIndexInput, kPortIndexOutput, compName)); | ||
1066 | packedArgs audioArgs = {eEncoding, compName}; | 1093 | packedArgs audioArgs = {eEncoding, compName}; |
1067 | testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, nullptr, | 1094 | ASSERT_NO_FATAL_FAILURE(testEOS( |
1068 | portReconfiguration, kPortIndexInput, kPortIndexOutput, &audioArgs); | 1095 | omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, nullptr, |
1069 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1096 | portReconfiguration, kPortIndexInput, kPortIndexOutput, &audioArgs)); |
1070 | kPortIndexOutput); | 1097 | ASSERT_NO_FATAL_FAILURE(flushPorts(omxNode, observer, &iBuffer, &oBuffer, |
1098 | kPortIndexInput, kPortIndexOutput)); | ||
1071 | framesReceived = 0; | 1099 | framesReceived = 0; |
1072 | timestampUs = 0; | 1100 | timestampUs = 0; |
1073 | 1101 | ||
1074 | // set state to idle | 1102 | // set state to idle |
1075 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1103 | ASSERT_NO_FATAL_FAILURE( |
1104 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
1076 | // set state to executing | 1105 | // set state to executing |
1077 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1106 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
1078 | kPortIndexInput, kPortIndexOutput); | 1107 | &oBuffer, kPortIndexInput, |
1108 | kPortIndexOutput)); | ||
1079 | } | 1109 | } |
1080 | 1110 | ||
1081 | // test input/output port flush | 1111 | // test input/output port flush |
@@ -1121,8 +1151,8 @@ TEST_F(AudioDecHidlTest, FlushTest) { | |||
1121 | setDefaultPortParam(omxNode, kPortIndexInput, eEncoding, 1, 8000, | 1151 | setDefaultPortParam(omxNode, kPortIndexInput, eEncoding, 1, 8000, |
1122 | OMX_AUDIO_PCMModeLinear, OMX_NumericalDataSigned, | 1152 | OMX_AUDIO_PCMModeLinear, OMX_NumericalDataSigned, |
1123 | 32); | 1153 | 32); |
1124 | getInputChannelInfo(omxNode, kPortIndexInput, eEncoding, &nChannels, | 1154 | ASSERT_NO_FATAL_FAILURE(getInputChannelInfo( |
1125 | &nSampleRate); | 1155 | omxNode, kPortIndexInput, eEncoding, &nChannels, &nSampleRate)); |
1126 | // Configure output port | 1156 | // Configure output port |
1127 | // SPECIAL CASE: Soft Vorbis, Opus and Raw Decoders do not offer way to | 1157 | // SPECIAL CASE: Soft Vorbis, Opus and Raw Decoders do not offer way to |
1128 | // configure output PCM port. The port undergoes auto configuration | 1158 | // configure output PCM port. The port undergoes auto configuration |
@@ -1135,10 +1165,11 @@ TEST_F(AudioDecHidlTest, FlushTest) { | |||
1135 | android::Vector<BufferInfo> iBuffer, oBuffer; | 1165 | android::Vector<BufferInfo> iBuffer, oBuffer; |
1136 | 1166 | ||
1137 | // set state to idle | 1167 | // set state to idle |
1138 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 1168 | ASSERT_NO_FATAL_FAILURE(changeStateLoadedtoIdle(omxNode, observer, &iBuffer, |
1139 | kPortIndexInput, kPortIndexOutput); | 1169 | &oBuffer, kPortIndexInput, |
1170 | kPortIndexOutput)); | ||
1140 | // set state to executing | 1171 | // set state to executing |
1141 | changeStateIdletoExecute(omxNode, observer); | 1172 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
1142 | 1173 | ||
1143 | // Decode 128 frames and flush. here 128 is chosen to ensure there is a key | 1174 | // Decode 128 frames and flush. here 128 is chosen to ensure there is a key |
1144 | // frame after this so that the below section can be convered for all | 1175 | // frame after this so that the below section can be convered for all |
@@ -1146,12 +1177,11 @@ TEST_F(AudioDecHidlTest, FlushTest) { | |||
1146 | int nFrames = 128; | 1177 | int nFrames = 128; |
1147 | eleStream.open(mURL, std::ifstream::binary); | 1178 | eleStream.open(mURL, std::ifstream::binary); |
1148 | ASSERT_EQ(eleStream.is_open(), true); | 1179 | ASSERT_EQ(eleStream.is_open(), true); |
1149 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, eEncoding, | 1180 | ASSERT_NO_FATAL_FAILURE(decodeNFrames( |
1150 | kPortIndexInput, kPortIndexOutput, eleStream, &Info, 0, | 1181 | omxNode, observer, &iBuffer, &oBuffer, eEncoding, kPortIndexInput, |
1151 | nFrames, compName, false); | 1182 | kPortIndexOutput, eleStream, &Info, 0, nFrames, compName, false)); |
1152 | // Note: Assumes 200 ms is enough to end any decode call that started | 1183 | ASSERT_NO_FATAL_FAILURE(flushPorts(omxNode, observer, &iBuffer, &oBuffer, |
1153 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1184 | kPortIndexInput, kPortIndexOutput)); |
1154 | kPortIndexOutput, 200000); | ||
1155 | framesReceived = 0; | 1185 | framesReceived = 0; |
1156 | 1186 | ||
1157 | // Seek to next key frame and start decoding till the end | 1187 | // Seek to next key frame and start decoding till the end |
@@ -1168,20 +1198,22 @@ TEST_F(AudioDecHidlTest, FlushTest) { | |||
1168 | index++; | 1198 | index++; |
1169 | } | 1199 | } |
1170 | if (keyFrame) { | 1200 | if (keyFrame) { |
1171 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, eEncoding, | 1201 | ASSERT_NO_FATAL_FAILURE( |
1172 | kPortIndexInput, kPortIndexOutput, eleStream, &Info, | 1202 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, eEncoding, |
1173 | index, Info.size() - index, compName, false); | 1203 | kPortIndexInput, kPortIndexOutput, eleStream, &Info, |
1204 | index, Info.size() - index, compName, false)); | ||
1174 | } | 1205 | } |
1175 | // Note: Assumes 200 ms is enough to end any decode call that started | 1206 | ASSERT_NO_FATAL_FAILURE(flushPorts(omxNode, observer, &iBuffer, &oBuffer, |
1176 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1207 | kPortIndexInput, kPortIndexOutput)); |
1177 | kPortIndexOutput, 200000); | ||
1178 | framesReceived = 0; | 1208 | framesReceived = 0; |
1179 | 1209 | ||
1180 | // set state to idle | 1210 | // set state to idle |
1181 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1211 | ASSERT_NO_FATAL_FAILURE( |
1212 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
1182 | // set state to executing | 1213 | // set state to executing |
1183 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1214 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
1184 | kPortIndexInput, kPortIndexOutput); | 1215 | &oBuffer, kPortIndexInput, |
1216 | kPortIndexOutput)); | ||
1185 | } | 1217 | } |
1186 | 1218 | ||
1187 | int main(int argc, char** argv) { | 1219 | int main(int argc, char** argv) { |
diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp index ae79e826..953dc750 100644 --- a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp +++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp | |||
@@ -15,6 +15,10 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #define LOG_TAG "media_omx_hidl_audio_enc_test" | 17 | #define LOG_TAG "media_omx_hidl_audio_enc_test" |
18 | #ifdef __LP64__ | ||
19 | #define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS | ||
20 | #endif | ||
21 | |||
18 | #include <android-base/logging.h> | 22 | #include <android-base/logging.h> |
19 | 23 | ||
20 | #include <android/hardware/media/omx/1.0/IOmx.h> | 24 | #include <android/hardware/media/omx/1.0/IOmx.h> |
@@ -161,6 +165,7 @@ class AudioEncHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
161 | this->omxNode = _nl; | 165 | this->omxNode = _nl; |
162 | }) | 166 | }) |
163 | .isOk()); | 167 | .isOk()); |
168 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
164 | ASSERT_NE(omxNode, nullptr); | 169 | ASSERT_NE(omxNode, nullptr); |
165 | ASSERT_NE(gEnv->getRole().empty(), true) << "Invalid Component Role"; | 170 | ASSERT_NE(gEnv->getRole().empty(), true) << "Invalid Component Role"; |
166 | struct StringToName { | 171 | struct StringToName { |
@@ -206,11 +211,15 @@ class AudioEncHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
206 | } | 211 | } |
207 | if (i == kNumCompToCoding) disableTest = true; | 212 | if (i == kNumCompToCoding) disableTest = true; |
208 | eosFlag = false; | 213 | eosFlag = false; |
209 | if (disableTest) std::cerr << "[ ] Warning ! Test Disabled\n"; | 214 | if (disableTest) std::cout << "[ WARN ] Test Disabled \n"; |
210 | } | 215 | } |
211 | 216 | ||
212 | virtual void TearDown() override { | 217 | virtual void TearDown() override { |
213 | if (omxNode != nullptr) { | 218 | if (omxNode != nullptr) { |
219 | // If you have encountered a fatal failure, it is possible that | ||
220 | // freeNode() will not go through. Instead of hanging the app. | ||
221 | // let it pass through and report errors | ||
222 | if (::testing::Test::HasFatalFailure()) return; | ||
214 | EXPECT_TRUE((omxNode->freeNode()).isOk()); | 223 | EXPECT_TRUE((omxNode->freeNode()).isOk()); |
215 | omxNode = nullptr; | 224 | omxNode = nullptr; |
216 | } | 225 | } |
@@ -342,13 +351,13 @@ void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
342 | android::Vector<BufferInfo>* oBuffer) { | 351 | android::Vector<BufferInfo>* oBuffer) { |
343 | android::hardware::media::omx::V1_0::Status status; | 352 | android::hardware::media::omx::V1_0::Status status; |
344 | Message msg; | 353 | Message msg; |
345 | int timeOut = TIMEOUT_COUNTER; | 354 | int timeOut = TIMEOUT_COUNTER_Q; |
346 | 355 | ||
347 | while (timeOut--) { | 356 | while (timeOut--) { |
348 | size_t i = 0; | 357 | size_t i = 0; |
349 | status = | 358 | status = |
350 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); | 359 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); |
351 | EXPECT_EQ(status, | 360 | ASSERT_EQ(status, |
352 | android::hardware::media::omx::V1_0::Status::TIMED_OUT); | 361 | android::hardware::media::omx::V1_0::Status::TIMED_OUT); |
353 | // status == TIMED_OUT, it could be due to process time being large | 362 | // status == TIMED_OUT, it could be due to process time being large |
354 | // than DEFAULT_TIMEOUT or component needs output buffers to start | 363 | // than DEFAULT_TIMEOUT or component needs output buffers to start |
@@ -361,9 +370,10 @@ void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
361 | // Dispatch an output buffer assuming outQueue.empty() is true | 370 | // Dispatch an output buffer assuming outQueue.empty() is true |
362 | size_t index; | 371 | size_t index; |
363 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { | 372 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { |
364 | dispatchOutputBuffer(omxNode, oBuffer, index); | 373 | ASSERT_NO_FATAL_FAILURE( |
374 | dispatchOutputBuffer(omxNode, oBuffer, index)); | ||
375 | timeOut = TIMEOUT_COUNTER_Q; | ||
365 | } | 376 | } |
366 | timeOut--; | ||
367 | } | 377 | } |
368 | } | 378 | } |
369 | 379 | ||
@@ -376,43 +386,25 @@ void encodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
376 | bool signalEOS = true) { | 386 | bool signalEOS = true) { |
377 | android::hardware::media::omx::V1_0::Status status; | 387 | android::hardware::media::omx::V1_0::Status status; |
378 | Message msg; | 388 | Message msg; |
379 | 389 | size_t index; | |
380 | // dispatch output buffers | ||
381 | for (size_t i = 0; i < oBuffer->size(); i++) { | ||
382 | dispatchOutputBuffer(omxNode, oBuffer, i); | ||
383 | } | ||
384 | // dispatch input buffers | ||
385 | int bytesCount = samplesPerFrame * nChannels * 2; | 390 | int bytesCount = samplesPerFrame * nChannels * 2; |
386 | int32_t timestampIncr = | 391 | int32_t timestampIncr = |
387 | (int)(((float)samplesPerFrame / nSampleRate) * 1000000); | 392 | (int)(((float)samplesPerFrame / nSampleRate) * 1000000); |
388 | uint64_t timestamp = 0; | 393 | uint64_t timestamp = 0; |
389 | uint32_t flags = 0; | 394 | uint32_t flags = 0; |
390 | for (size_t i = 0; i < iBuffer->size() && nFrames != 0; i++) { | 395 | int timeOut = TIMEOUT_COUNTER_Q; |
391 | char* ipBuffer = static_cast<char*>( | 396 | bool iQueued, oQueued; |
392 | static_cast<void*>((*iBuffer)[i].mMemory->getPointer())); | ||
393 | ASSERT_LE(bytesCount, | ||
394 | static_cast<int>((*iBuffer)[i].mMemory->getSize())); | ||
395 | eleStream.read(ipBuffer, bytesCount); | ||
396 | if (eleStream.gcount() != bytesCount) break; | ||
397 | if (signalEOS && (nFrames == 1)) flags = OMX_BUFFERFLAG_EOS; | ||
398 | dispatchInputBuffer(omxNode, iBuffer, i, bytesCount, flags, timestamp); | ||
399 | timestamp += timestampIncr; | ||
400 | nFrames--; | ||
401 | } | ||
402 | 397 | ||
403 | int timeOut = TIMEOUT_COUNTER; | ||
404 | bool stall = false; | ||
405 | while (1) { | 398 | while (1) { |
399 | iQueued = oQueued = false; | ||
406 | status = | 400 | status = |
407 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); | 401 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); |
408 | |||
409 | if (status == android::hardware::media::omx::V1_0::Status::OK) | 402 | if (status == android::hardware::media::omx::V1_0::Status::OK) |
410 | ASSERT_TRUE(false); | 403 | ASSERT_TRUE(false); |
411 | 404 | ||
412 | if (nFrames == 0) break; | 405 | if (nFrames == 0) break; |
413 | 406 | ||
414 | // Dispatch input buffer | 407 | // Dispatch input buffer |
415 | size_t index = 0; | ||
416 | if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) { | 408 | if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) { |
417 | char* ipBuffer = static_cast<char*>( | 409 | char* ipBuffer = static_cast<char*>( |
418 | static_cast<void*>((*iBuffer)[index].mMemory->getPointer())); | 410 | static_cast<void*>((*iBuffer)[index].mMemory->getPointer())); |
@@ -420,27 +412,27 @@ void encodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
420 | static_cast<int>((*iBuffer)[index].mMemory->getSize())); | 412 | static_cast<int>((*iBuffer)[index].mMemory->getSize())); |
421 | eleStream.read(ipBuffer, bytesCount); | 413 | eleStream.read(ipBuffer, bytesCount); |
422 | if (eleStream.gcount() != bytesCount) break; | 414 | if (eleStream.gcount() != bytesCount) break; |
423 | if (signalEOS && (nFrames == 1)) flags = OMX_BUFFERFLAG_EOS; | 415 | flags = OMX_BUFFERFLAG_ENDOFFRAME; |
424 | dispatchInputBuffer(omxNode, iBuffer, index, bytesCount, flags, | 416 | if (signalEOS && (nFrames == 1)) flags |= OMX_BUFFERFLAG_EOS; |
425 | timestamp); | 417 | ASSERT_NO_FATAL_FAILURE(dispatchInputBuffer( |
418 | omxNode, iBuffer, index, bytesCount, flags, timestamp)); | ||
426 | timestamp += timestampIncr; | 419 | timestamp += timestampIncr; |
427 | nFrames--; | 420 | nFrames--; |
428 | stall = false; | 421 | iQueued = true; |
429 | } else | 422 | } |
430 | stall = true; | ||
431 | // Dispatch output buffer | 423 | // Dispatch output buffer |
432 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { | 424 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { |
433 | dispatchOutputBuffer(omxNode, oBuffer, index); | 425 | ASSERT_NO_FATAL_FAILURE( |
434 | stall = false; | 426 | dispatchOutputBuffer(omxNode, oBuffer, index)); |
435 | } else | 427 | oQueued = true; |
436 | stall = true; | 428 | } |
437 | if (stall) | 429 | // Reset Counters when either input or output buffer is dispatched |
438 | timeOut--; | 430 | if (iQueued || oQueued) |
431 | timeOut = TIMEOUT_COUNTER_Q; | ||
439 | else | 432 | else |
440 | timeOut = TIMEOUT_COUNTER; | 433 | timeOut--; |
441 | if (timeOut == 0) { | 434 | if (timeOut == 0) { |
442 | EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite"; | 435 | ASSERT_TRUE(false) << "Wait on Input/Output is found indefinite"; |
443 | break; | ||
444 | } | 436 | } |
445 | } | 437 | } |
446 | } | 438 | } |
@@ -455,7 +447,7 @@ TEST_F(AudioEncHidlTest, SetRole) { | |||
455 | } | 447 | } |
456 | 448 | ||
457 | // port format enumeration | 449 | // port format enumeration |
458 | TEST_F(AudioEncHidlTest, DISABLED_EnumeratePortFormat) { | 450 | TEST_F(AudioEncHidlTest, EnumeratePortFormat) { |
459 | description("Test Component on Mandatory Port Parameters (Port Format)"); | 451 | description("Test Component on Mandatory Port Parameters (Port Format)"); |
460 | if (disableTest) return; | 452 | if (disableTest) return; |
461 | android::hardware::media::omx::V1_0::Status status; | 453 | android::hardware::media::omx::V1_0::Status status; |
@@ -531,31 +523,39 @@ TEST_F(AudioEncHidlTest, SimpleEncodeTest) { | |||
531 | } | 523 | } |
532 | setupPCMPort(omxNode, kPortIndexInput, nChannels, OMX_NumericalDataSigned, | 524 | setupPCMPort(omxNode, kPortIndexInput, nChannels, OMX_NumericalDataSigned, |
533 | 16, nSampleRate, OMX_AUDIO_PCMModeLinear); | 525 | 16, nSampleRate, OMX_AUDIO_PCMModeLinear); |
526 | |||
534 | // Configure output port | 527 | // Configure output port |
535 | setDefaultPortParam(omxNode, kPortIndexOutput, eEncoding, compName, | 528 | ASSERT_NO_FATAL_FAILURE(setDefaultPortParam(omxNode, kPortIndexOutput, |
536 | nChannels, nSampleRate, nBitRate); | 529 | eEncoding, compName, nChannels, |
530 | nSampleRate, nBitRate)); | ||
537 | 531 | ||
538 | android::Vector<BufferInfo> iBuffer, oBuffer; | 532 | android::Vector<BufferInfo> iBuffer, oBuffer; |
539 | 533 | ||
540 | // set state to idle | 534 | // set state to idle |
541 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 535 | ASSERT_NO_FATAL_FAILURE(changeStateLoadedtoIdle(omxNode, observer, &iBuffer, |
542 | kPortIndexInput, kPortIndexOutput); | 536 | &oBuffer, kPortIndexInput, |
537 | kPortIndexOutput)); | ||
543 | // set state to executing | 538 | // set state to executing |
544 | changeStateIdletoExecute(omxNode, observer); | 539 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
545 | 540 | ||
546 | eleStream.open(mURL, std::ifstream::binary); | 541 | eleStream.open(mURL, std::ifstream::binary); |
547 | ASSERT_EQ(eleStream.is_open(), true); | 542 | ASSERT_EQ(eleStream.is_open(), true); |
548 | encodeNFrames(omxNode, observer, &iBuffer, &oBuffer, 128, samplesPerFrame, | 543 | ASSERT_NO_FATAL_FAILURE(encodeNFrames(omxNode, observer, &iBuffer, &oBuffer, |
549 | nChannels, nSampleRate, eleStream); | 544 | 128, samplesPerFrame, nChannels, |
545 | nSampleRate, eleStream)); | ||
550 | eleStream.close(); | 546 | eleStream.close(); |
551 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer); | ||
552 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag); | ||
553 | 547 | ||
548 | ASSERT_NO_FATAL_FAILURE( | ||
549 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer)); | ||
550 | ASSERT_NO_FATAL_FAILURE( | ||
551 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag)); | ||
554 | // set state to idle | 552 | // set state to idle |
555 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 553 | ASSERT_NO_FATAL_FAILURE( |
554 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
556 | // set state to executing | 555 | // set state to executing |
557 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 556 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
558 | kPortIndexInput, kPortIndexOutput); | 557 | &oBuffer, kPortIndexInput, |
558 | kPortIndexOutput)); | ||
559 | } | 559 | } |
560 | 560 | ||
561 | int main(int argc, char** argv) { | 561 | int main(int argc, char** argv) { |
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 4c68219b..9500094d 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 | |||
@@ -15,6 +15,10 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #define LOG_TAG "media_omx_hidl_audio_test_common" | 17 | #define LOG_TAG "media_omx_hidl_audio_test_common" |
18 | #ifdef __LP64__ | ||
19 | #define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS | ||
20 | #endif | ||
21 | |||
18 | #include <android-base/logging.h> | 22 | #include <android-base/logging.h> |
19 | 23 | ||
20 | #include <android/hardware/media/omx/1.0/IOmx.h> | 24 | #include <android/hardware/media/omx/1.0/IOmx.h> |
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 08b3d9cd..b187d284 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,11 +20,6 @@ | |||
20 | #include <media_hidl_test_common.h> | 20 | #include <media_hidl_test_common.h> |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * Random Index used for monkey testing while get/set parameters | ||
24 | */ | ||
25 | #define RANDOM_INDEX 1729 | ||
26 | |||
27 | /* | ||
28 | * Common audio utils | 23 | * Common audio utils |
29 | */ | 24 | */ |
30 | void enumerateProfile(sp<IOmxNode> omxNode, OMX_U32 portIndex, | 25 | void enumerateProfile(sp<IOmxNode> omxNode, OMX_U32 portIndex, |
diff --git a/media/omx/1.0/vts/functional/common/Android.bp b/media/omx/1.0/vts/functional/common/Android.bp index 93251fe8..cdc52fb4 100755..100644 --- a/media/omx/1.0/vts/functional/common/Android.bp +++ b/media/omx/1.0/vts/functional/common/Android.bp | |||
@@ -16,18 +16,43 @@ | |||
16 | 16 | ||
17 | cc_library_static { | 17 | cc_library_static { |
18 | name: "VtsHalMediaOmxV1_0CommonUtil", | 18 | name: "VtsHalMediaOmxV1_0CommonUtil", |
19 | defaults: ["hidl_defaults"], | ||
20 | srcs: ["media_hidl_test_common.cpp"], | 19 | srcs: ["media_hidl_test_common.cpp"], |
21 | shared_libs: [ | 20 | |
22 | "liblog", | 21 | header_libs: ["media_plugin_headers"], |
22 | export_header_lib_headers: ["media_plugin_headers"], | ||
23 | export_include_dirs: ["."], | ||
24 | |||
25 | static_libs: [ | ||
26 | "VtsHalHidlTargetTestBase", | ||
23 | "libhidlmemory", | 27 | "libhidlmemory", |
24 | "android.hidl.allocator@1.0", | 28 | "android.hidl.allocator@1.0", |
25 | "android.hidl.memory@1.0", | 29 | "android.hidl.memory@1.0", |
26 | "android.hardware.media.omx@1.0", | 30 | "android.hardware.media.omx@1.0", |
31 | "android.hardware.graphics.allocator@2.0", | ||
27 | ], | 32 | ], |
28 | static_libs: ["VtsHalHidlTargetTestBase"], | 33 | } |
29 | cflags: [ "-O0", "-g", ], | 34 | |
30 | include_dirs: [ | 35 | cc_defaults { |
31 | "frameworks/native/include/media/openmax/", | 36 | name: "VtsHalMediaOmxV1_0Defaults", |
37 | defaults: ["VtsHalTargetTestDefaults"], | ||
38 | |||
39 | // Link to these statically as they are not guaranteed to be on the device. | ||
40 | static_libs: [ | ||
41 | "VtsHalMediaOmxV1_0CommonUtil", | ||
42 | "android.hardware.graphics.allocator@2.0", | ||
43 | "android.hardware.graphics.mapper@2.0", | ||
44 | "android.hardware.graphics.bufferqueue@1.0", | ||
45 | "android.hardware.graphics.common@1.0", | ||
46 | "android.hardware.media.omx@1.0", | ||
47 | "android.hardware.media@1.0", | ||
48 | "android.hidl.allocator@1.0", | ||
49 | "android.hidl.memory@1.0", | ||
50 | "libhidlmemory", | ||
51 | "libnativehelper", | ||
52 | ], | ||
53 | |||
54 | // TODO(b/64437680): Assume these libs are always available on the device. | ||
55 | shared_libs: [ | ||
56 | "libstagefright_foundation", | ||
32 | ], | 57 | ], |
33 | } | 58 | } |
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 1f67e2b6..34a96a0c 100755..100644 --- 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 | |||
@@ -15,13 +15,15 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #define LOG_TAG "media_omx_hidl_video_test_common" | 17 | #define LOG_TAG "media_omx_hidl_video_test_common" |
18 | |||
19 | #ifdef __LP64__ | 18 | #ifdef __LP64__ |
20 | #define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS | 19 | #define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS |
21 | #endif | 20 | #endif |
22 | 21 | ||
23 | #include <android-base/logging.h> | 22 | #include <android-base/logging.h> |
24 | 23 | ||
24 | #include <android/hardware/graphics/allocator/2.0/IAllocator.h> | ||
25 | #include <android/hardware/graphics/mapper/2.0/IMapper.h> | ||
26 | #include <android/hardware/graphics/mapper/2.0/types.h> | ||
25 | #include <android/hardware/media/omx/1.0/IOmx.h> | 27 | #include <android/hardware/media/omx/1.0/IOmx.h> |
26 | #include <android/hardware/media/omx/1.0/IOmxNode.h> | 28 | #include <android/hardware/media/omx/1.0/IOmxNode.h> |
27 | #include <android/hardware/media/omx/1.0/IOmxObserver.h> | 29 | #include <android/hardware/media/omx/1.0/IOmxObserver.h> |
@@ -29,7 +31,10 @@ | |||
29 | #include <android/hidl/allocator/1.0/IAllocator.h> | 31 | #include <android/hidl/allocator/1.0/IAllocator.h> |
30 | #include <android/hidl/memory/1.0/IMapper.h> | 32 | #include <android/hidl/memory/1.0/IMapper.h> |
31 | #include <android/hidl/memory/1.0/IMemory.h> | 33 | #include <android/hidl/memory/1.0/IMemory.h> |
34 | #include <cutils/atomic.h> | ||
32 | 35 | ||
36 | using ::android::hardware::graphics::common::V1_0::BufferUsage; | ||
37 | using ::android::hardware::graphics::common::V1_0::PixelFormat; | ||
33 | using ::android::hardware::media::omx::V1_0::IOmx; | 38 | using ::android::hardware::media::omx::V1_0::IOmx; |
34 | using ::android::hardware::media::omx::V1_0::IOmxObserver; | 39 | using ::android::hardware::media::omx::V1_0::IOmxObserver; |
35 | using ::android::hardware::media::omx::V1_0::IOmxNode; | 40 | using ::android::hardware::media::omx::V1_0::IOmxNode; |
@@ -186,10 +191,157 @@ Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat( | |||
186 | return status; | 191 | return status; |
187 | } | 192 | } |
188 | 193 | ||
194 | void allocateGraphicBuffers(sp<IOmxNode> omxNode, OMX_U32 portIndex, | ||
195 | BufferInfo* buffer, uint32_t nFrameWidth, | ||
196 | uint32_t nFrameHeight, int32_t* nStride, | ||
197 | int format) { | ||
198 | android::hardware::media::omx::V1_0::Status status; | ||
199 | sp<android::hardware::graphics::allocator::V2_0::IAllocator> allocator = | ||
200 | android::hardware::graphics::allocator::V2_0::IAllocator::getService(); | ||
201 | ASSERT_NE(nullptr, allocator.get()); | ||
202 | |||
203 | sp<android::hardware::graphics::mapper::V2_0::IMapper> mapper = | ||
204 | android::hardware::graphics::mapper::V2_0::IMapper::getService(); | ||
205 | ASSERT_NE(mapper.get(), nullptr); | ||
206 | |||
207 | android::hardware::graphics::mapper::V2_0::IMapper::BufferDescriptorInfo | ||
208 | descriptorInfo; | ||
209 | uint32_t usage; | ||
210 | |||
211 | descriptorInfo.width = nFrameWidth; | ||
212 | descriptorInfo.height = nFrameHeight; | ||
213 | descriptorInfo.layerCount = 1; | ||
214 | descriptorInfo.format = static_cast<PixelFormat>(format); | ||
215 | descriptorInfo.usage = static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN); | ||
216 | omxNode->getGraphicBufferUsage( | ||
217 | portIndex, | ||
218 | [&status, &usage](android::hardware::media::omx::V1_0::Status _s, | ||
219 | uint32_t _n1) { | ||
220 | status = _s; | ||
221 | usage = _n1; | ||
222 | }); | ||
223 | if (status == android::hardware::media::omx::V1_0::Status::OK) { | ||
224 | descriptorInfo.usage |= usage; | ||
225 | } | ||
226 | |||
227 | ::android::hardware::hidl_vec<uint32_t> descriptor; | ||
228 | android::hardware::graphics::mapper::V2_0::Error error; | ||
229 | mapper->createDescriptor( | ||
230 | descriptorInfo, [&error, &descriptor]( | ||
231 | android::hardware::graphics::mapper::V2_0::Error _s, | ||
232 | ::android::hardware::hidl_vec<uint32_t> _n1) { | ||
233 | error = _s; | ||
234 | descriptor = _n1; | ||
235 | }); | ||
236 | ASSERT_EQ(error, android::hardware::graphics::mapper::V2_0::Error::NONE); | ||
237 | |||
238 | static volatile int32_t nextId = 0; | ||
239 | uint64_t id = static_cast<uint64_t>(getpid()) << 32; | ||
240 | allocator->allocate( | ||
241 | descriptor, 1, | ||
242 | [&](android::hardware::graphics::mapper::V2_0::Error _s, uint32_t _n1, | ||
243 | const ::android::hardware::hidl_vec< | ||
244 | ::android::hardware::hidl_handle>& _n2) { | ||
245 | ASSERT_EQ(android::hardware::graphics::mapper::V2_0::Error::NONE, | ||
246 | _s); | ||
247 | *nStride = _n1; | ||
248 | buffer->omxBuffer.nativeHandle = _n2[0]; | ||
249 | buffer->omxBuffer.attr.anwBuffer.width = nFrameWidth; | ||
250 | buffer->omxBuffer.attr.anwBuffer.height = nFrameHeight; | ||
251 | buffer->omxBuffer.attr.anwBuffer.stride = _n1; | ||
252 | buffer->omxBuffer.attr.anwBuffer.format = descriptorInfo.format; | ||
253 | buffer->omxBuffer.attr.anwBuffer.usage = descriptorInfo.usage; | ||
254 | buffer->omxBuffer.attr.anwBuffer.layerCount = | ||
255 | descriptorInfo.layerCount; | ||
256 | buffer->omxBuffer.attr.anwBuffer.id = | ||
257 | id | static_cast<uint32_t>(android_atomic_inc(&nextId)); | ||
258 | }); | ||
259 | } | ||
260 | |||
261 | // allocate buffers needed on a component port | ||
262 | void allocateBuffer(sp<IOmxNode> omxNode, BufferInfo* buffer, OMX_U32 portIndex, | ||
263 | OMX_U32 nBufferSize, PortMode portMode) { | ||
264 | android::hardware::media::omx::V1_0::Status status; | ||
265 | |||
266 | if (portMode == PortMode::PRESET_SECURE_BUFFER) { | ||
267 | buffer->owner = client; | ||
268 | buffer->omxBuffer.type = CodecBuffer::Type::NATIVE_HANDLE; | ||
269 | omxNode->allocateSecureBuffer( | ||
270 | portIndex, nBufferSize, | ||
271 | [&status, &buffer]( | ||
272 | android::hardware::media::omx::V1_0::Status _s, uint32_t id, | ||
273 | ::android::hardware::hidl_handle const& nativeHandle) { | ||
274 | status = _s; | ||
275 | buffer->id = id; | ||
276 | buffer->omxBuffer.nativeHandle = nativeHandle; | ||
277 | }); | ||
278 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
279 | } else if (portMode == PortMode::PRESET_BYTE_BUFFER || | ||
280 | portMode == PortMode::DYNAMIC_ANW_BUFFER) { | ||
281 | sp<IAllocator> allocator = IAllocator::getService("ashmem"); | ||
282 | ASSERT_NE(allocator.get(), nullptr); | ||
283 | |||
284 | buffer->owner = client; | ||
285 | buffer->omxBuffer.type = CodecBuffer::Type::SHARED_MEM; | ||
286 | buffer->omxBuffer.attr.preset.rangeOffset = 0; | ||
287 | buffer->omxBuffer.attr.preset.rangeLength = 0; | ||
288 | bool success = false; | ||
289 | if (portMode != PortMode::PRESET_BYTE_BUFFER) { | ||
290 | nBufferSize = sizeof(android::VideoNativeMetadata); | ||
291 | } | ||
292 | allocator->allocate( | ||
293 | nBufferSize, | ||
294 | [&success, &buffer](bool _s, | ||
295 | ::android::hardware::hidl_memory const& mem) { | ||
296 | success = _s; | ||
297 | buffer->omxBuffer.sharedMemory = mem; | ||
298 | }); | ||
299 | ASSERT_EQ(success, true); | ||
300 | ASSERT_EQ(buffer->omxBuffer.sharedMemory.size(), nBufferSize); | ||
301 | buffer->mMemory = mapMemory(buffer->omxBuffer.sharedMemory); | ||
302 | ASSERT_NE(buffer->mMemory, nullptr); | ||
303 | if (portMode == PortMode::DYNAMIC_ANW_BUFFER) { | ||
304 | android::VideoNativeMetadata* metaData = | ||
305 | static_cast<android::VideoNativeMetadata*>( | ||
306 | static_cast<void*>(buffer->mMemory->getPointer())); | ||
307 | metaData->nFenceFd = -1; | ||
308 | buffer->slot = -1; | ||
309 | } | ||
310 | omxNode->useBuffer( | ||
311 | portIndex, buffer->omxBuffer, | ||
312 | [&status, &buffer](android::hardware::media::omx::V1_0::Status _s, | ||
313 | uint32_t id) { | ||
314 | status = _s; | ||
315 | buffer->id = id; | ||
316 | }); | ||
317 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
318 | } else if (portMode == PortMode::PRESET_ANW_BUFFER) { | ||
319 | OMX_PARAM_PORTDEFINITIONTYPE portDef; | ||
320 | status = getPortParam(omxNode, OMX_IndexParamPortDefinition, portIndex, | ||
321 | &portDef); | ||
322 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
323 | int32_t nStride; | ||
324 | buffer->owner = client; | ||
325 | buffer->omxBuffer.type = CodecBuffer::Type::ANW_BUFFER; | ||
326 | ASSERT_NO_FATAL_FAILURE(allocateGraphicBuffers( | ||
327 | omxNode, portIndex, buffer, portDef.format.video.nFrameWidth, | ||
328 | portDef.format.video.nFrameHeight, &nStride, | ||
329 | portDef.format.video.eColorFormat)); | ||
330 | omxNode->useBuffer( | ||
331 | portIndex, buffer->omxBuffer, | ||
332 | [&status, &buffer](android::hardware::media::omx::V1_0::Status _s, | ||
333 | uint32_t id) { | ||
334 | status = _s; | ||
335 | buffer->id = id; | ||
336 | }); | ||
337 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
338 | } | ||
339 | } | ||
340 | |||
189 | // allocate buffers needed on a component port | 341 | // allocate buffers needed on a component port |
190 | void allocatePortBuffers(sp<IOmxNode> omxNode, | 342 | void allocatePortBuffers(sp<IOmxNode> omxNode, |
191 | android::Vector<BufferInfo>* buffArray, | 343 | android::Vector<BufferInfo>* buffArray, |
192 | OMX_U32 portIndex, PortMode portMode) { | 344 | OMX_U32 portIndex, PortMode portMode, bool allocGrap) { |
193 | android::hardware::media::omx::V1_0::Status status; | 345 | android::hardware::media::omx::V1_0::Status status; |
194 | OMX_PARAM_PORTDEFINITIONTYPE portDef; | 346 | OMX_PARAM_PORTDEFINITIONTYPE portDef; |
195 | 347 | ||
@@ -199,70 +351,18 @@ void allocatePortBuffers(sp<IOmxNode> omxNode, | |||
199 | &portDef); | 351 | &portDef); |
200 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 352 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
201 | 353 | ||
202 | if (portMode == PortMode::PRESET_SECURE_BUFFER) { | 354 | for (size_t i = 0; i < portDef.nBufferCountActual; i++) { |
203 | for (size_t i = 0; i < portDef.nBufferCountActual; i++) { | 355 | BufferInfo buffer; |
204 | BufferInfo buffer; | 356 | ASSERT_NO_FATAL_FAILURE(allocateBuffer(omxNode, &buffer, portIndex, |
205 | buffer.owner = client; | 357 | portDef.nBufferSize, portMode)); |
206 | buffer.omxBuffer.type = CodecBuffer::Type::NATIVE_HANDLE; | 358 | if (allocGrap && portMode == PortMode::DYNAMIC_ANW_BUFFER) { |
207 | omxNode->allocateSecureBuffer( | 359 | int32_t nStride; |
208 | portIndex, portDef.nBufferSize, | 360 | ASSERT_NO_FATAL_FAILURE(allocateGraphicBuffers( |
209 | [&status, &buffer]( | 361 | omxNode, portIndex, &buffer, portDef.format.video.nFrameWidth, |
210 | android::hardware::media::omx::V1_0::Status _s, uint32_t id, | 362 | portDef.format.video.nFrameHeight, &nStride, |
211 | ::android::hardware::hidl_handle const& nativeHandle) { | 363 | portDef.format.video.eColorFormat)); |
212 | status = _s; | ||
213 | buffer.id = id; | ||
214 | buffer.omxBuffer.nativeHandle = nativeHandle; | ||
215 | }); | ||
216 | buffArray->push(buffer); | ||
217 | ASSERT_EQ(status, | ||
218 | ::android::hardware::media::omx::V1_0::Status::OK); | ||
219 | } | ||
220 | } else if (portMode == PortMode::PRESET_BYTE_BUFFER || | ||
221 | portMode == PortMode::DYNAMIC_ANW_BUFFER) { | ||
222 | sp<IAllocator> allocator = IAllocator::getService("ashmem"); | ||
223 | EXPECT_NE(allocator.get(), nullptr); | ||
224 | |||
225 | for (size_t i = 0; i < portDef.nBufferCountActual; i++) { | ||
226 | BufferInfo buffer; | ||
227 | buffer.owner = client; | ||
228 | buffer.omxBuffer.type = CodecBuffer::Type::SHARED_MEM; | ||
229 | buffer.omxBuffer.attr.preset.rangeOffset = 0; | ||
230 | buffer.omxBuffer.attr.preset.rangeLength = 0; | ||
231 | bool success = false; | ||
232 | if (portMode != PortMode::PRESET_BYTE_BUFFER) { | ||
233 | portDef.nBufferSize = sizeof(android::VideoNativeMetadata); | ||
234 | } | ||
235 | allocator->allocate( | ||
236 | portDef.nBufferSize, | ||
237 | [&success, &buffer]( | ||
238 | bool _s, ::android::hardware::hidl_memory const& mem) { | ||
239 | success = _s; | ||
240 | buffer.omxBuffer.sharedMemory = mem; | ||
241 | }); | ||
242 | ASSERT_EQ(success, true); | ||
243 | ASSERT_EQ(buffer.omxBuffer.sharedMemory.size(), | ||
244 | portDef.nBufferSize); | ||
245 | buffer.mMemory = mapMemory(buffer.omxBuffer.sharedMemory); | ||
246 | ASSERT_NE(buffer.mMemory, nullptr); | ||
247 | if (portMode == PortMode::DYNAMIC_ANW_BUFFER) { | ||
248 | android::VideoNativeMetadata* metaData = | ||
249 | static_cast<android::VideoNativeMetadata*>( | ||
250 | static_cast<void*>(buffer.mMemory->getPointer())); | ||
251 | metaData->nFenceFd = -1; | ||
252 | buffer.slot = -1; | ||
253 | } | ||
254 | omxNode->useBuffer( | ||
255 | portIndex, buffer.omxBuffer, | ||
256 | [&status, &buffer]( | ||
257 | android::hardware::media::omx::V1_0::Status _s, | ||
258 | uint32_t id) { | ||
259 | status = _s; | ||
260 | buffer.id = id; | ||
261 | }); | ||
262 | buffArray->push(buffer); | ||
263 | ASSERT_EQ(status, | ||
264 | ::android::hardware::media::omx::V1_0::Status::OK); | ||
265 | } | 364 | } |
365 | buffArray->push(buffer); | ||
266 | } | 366 | } |
267 | } | 367 | } |
268 | 368 | ||
@@ -273,7 +373,7 @@ void changeStateLoadedtoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
273 | android::Vector<BufferInfo>* iBuffer, | 373 | android::Vector<BufferInfo>* iBuffer, |
274 | android::Vector<BufferInfo>* oBuffer, | 374 | android::Vector<BufferInfo>* oBuffer, |
275 | OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput, | 375 | OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput, |
276 | PortMode* portMode) { | 376 | PortMode* portMode, bool allocGrap) { |
277 | android::hardware::media::omx::V1_0::Status status; | 377 | android::hardware::media::omx::V1_0::Status status; |
278 | Message msg; | 378 | Message msg; |
279 | PortMode defaultPortMode[2], *pm; | 379 | PortMode defaultPortMode[2], *pm; |
@@ -292,14 +392,16 @@ void changeStateLoadedtoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
292 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT); | 392 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT); |
293 | 393 | ||
294 | // allocate buffers on input port | 394 | // allocate buffers on input port |
295 | allocatePortBuffers(omxNode, iBuffer, kPortIndexInput, pm[0]); | 395 | ASSERT_NO_FATAL_FAILURE(allocatePortBuffers( |
396 | omxNode, iBuffer, kPortIndexInput, pm[0], allocGrap)); | ||
296 | 397 | ||
297 | // Dont switch states until the ports are populated | 398 | // Dont switch states until the ports are populated |
298 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); | 399 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); |
299 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT); | 400 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT); |
300 | 401 | ||
301 | // allocate buffers on output port | 402 | // allocate buffers on output port |
302 | allocatePortBuffers(omxNode, oBuffer, kPortIndexOutput, pm[1]); | 403 | ASSERT_NO_FATAL_FAILURE(allocatePortBuffers( |
404 | omxNode, oBuffer, kPortIndexOutput, pm[1], allocGrap)); | ||
303 | 405 | ||
304 | // As the ports are populated, check if the state transition is complete | 406 | // As the ports are populated, check if the state transition is complete |
305 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); | 407 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); |
@@ -439,6 +541,7 @@ void dispatchOutputBuffer(sp<IOmxNode> omxNode, | |||
439 | status = | 541 | status = |
440 | omxNode->fillBuffer((*buffArray)[bufferIndex].id, t, fenceNh); | 542 | omxNode->fillBuffer((*buffArray)[bufferIndex].id, t, fenceNh); |
441 | break; | 543 | break; |
544 | case PortMode::PRESET_ANW_BUFFER: | ||
442 | case PortMode::PRESET_SECURE_BUFFER: | 545 | case PortMode::PRESET_SECURE_BUFFER: |
443 | case PortMode::PRESET_BYTE_BUFFER: | 546 | case PortMode::PRESET_BYTE_BUFFER: |
444 | t.sharedMemory = android::hardware::hidl_memory(); | 547 | t.sharedMemory = android::hardware::hidl_memory(); |
@@ -545,43 +648,45 @@ void testEOS(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
545 | if (signalEOS) { | 648 | if (signalEOS) { |
546 | if ((i = getEmptyBufferID(iBuffer)) < iBuffer->size()) { | 649 | if ((i = getEmptyBufferID(iBuffer)) < iBuffer->size()) { |
547 | // signal an empty buffer with flag set to EOS | 650 | // signal an empty buffer with flag set to EOS |
548 | dispatchInputBuffer(omxNode, iBuffer, i, 0, OMX_BUFFERFLAG_EOS, 0); | 651 | ASSERT_NO_FATAL_FAILURE(dispatchInputBuffer(omxNode, iBuffer, i, 0, |
652 | OMX_BUFFERFLAG_EOS, 0)); | ||
549 | } else { | 653 | } else { |
550 | ASSERT_TRUE(false); | 654 | ASSERT_TRUE(false); |
551 | } | 655 | } |
552 | } | 656 | } |
553 | 657 | ||
554 | int timeOut = TIMEOUT_COUNTER; | 658 | int timeOut = TIMEOUT_COUNTER_PE; |
555 | while (timeOut--) { | 659 | while (timeOut--) { |
556 | // Dispatch all client owned output buffers to recover remaining frames | 660 | // Dispatch all client owned output buffers to recover remaining frames |
557 | while (1) { | 661 | while (1) { |
558 | if ((i = getEmptyBufferID(oBuffer)) < oBuffer->size()) { | 662 | if ((i = getEmptyBufferID(oBuffer)) < oBuffer->size()) { |
559 | dispatchOutputBuffer(omxNode, oBuffer, i, pm[1]); | 663 | ASSERT_NO_FATAL_FAILURE( |
664 | dispatchOutputBuffer(omxNode, oBuffer, i, pm[1])); | ||
560 | // if dispatch is successful, perhaps there is a latency | 665 | // if dispatch is successful, perhaps there is a latency |
561 | // in the component. Dont be in a haste to leave. reset timeout | 666 | // in the component. Dont be in a haste to leave. reset timeout |
562 | // counter | 667 | // counter |
563 | timeOut = TIMEOUT_COUNTER; | 668 | timeOut = TIMEOUT_COUNTER_PE; |
564 | } else { | 669 | } else { |
565 | break; | 670 | break; |
566 | } | 671 | } |
567 | } | 672 | } |
568 | 673 | ||
569 | Message msg; | 674 | Message msg; |
570 | status = | 675 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_PE, iBuffer, |
571 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); | 676 | oBuffer); |
572 | if (status == android::hardware::media::omx::V1_0::Status::OK) { | 677 | if (status == android::hardware::media::omx::V1_0::Status::OK) { |
573 | if (msg.data.eventData.event == OMX_EventPortSettingsChanged) { | 678 | if (msg.data.eventData.event == OMX_EventPortSettingsChanged) { |
574 | if (fptr) { | 679 | if (fptr) { |
575 | (*fptr)(omxNode, observer, iBuffer, oBuffer, | 680 | ASSERT_NO_FATAL_FAILURE((*fptr)( |
576 | kPortIndexInput, kPortIndexOutput, msg, pm[1], | 681 | omxNode, observer, iBuffer, oBuffer, kPortIndexInput, |
577 | args); | 682 | kPortIndexOutput, msg, pm[1], args)); |
578 | } else { | 683 | } else { |
579 | // something unexpected happened | 684 | // something unexpected happened |
580 | EXPECT_TRUE(false); | 685 | ASSERT_TRUE(false); |
581 | } | 686 | } |
582 | } else { | 687 | } else { |
583 | // something unexpected happened | 688 | // something unexpected happened |
584 | EXPECT_TRUE(false); | 689 | ASSERT_TRUE(false); |
585 | } | 690 | } |
586 | } | 691 | } |
587 | if (eosFlag == true) break; | 692 | if (eosFlag == true) break; |
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 0adea14e..bec733dc 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 | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright 2016, The Android Open Source Project | 2 | * Copyright 2017, The Android Open Source Project |
3 | * | 3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
@@ -33,8 +33,21 @@ | |||
33 | #include <media/openmax/OMX_AudioExt.h> | 33 | #include <media/openmax/OMX_AudioExt.h> |
34 | #include <media/openmax/OMX_VideoExt.h> | 34 | #include <media/openmax/OMX_VideoExt.h> |
35 | 35 | ||
36 | /* TIME OUTS (Wait time in dequeueMessage()) */ | ||
37 | |||
38 | /* As component is switching states (loaded<->idle<->execute), dequeueMessage() | ||
39 | * expects the events to be received within this duration */ | ||
36 | #define DEFAULT_TIMEOUT 100000 | 40 | #define DEFAULT_TIMEOUT 100000 |
37 | #define TIMEOUT_COUNTER (10000000 / DEFAULT_TIMEOUT) | 41 | /* Time interval between successive Input/Output enqueues */ |
42 | #define DEFAULT_TIMEOUT_Q 2000 | ||
43 | /* While the component is amidst a process call, asynchronous commands like | ||
44 | * flush, change states can get delayed (at max by process call time). Instead | ||
45 | * of waiting on DEFAULT_TIMEOUT, we give an additional leeway. */ | ||
46 | #define DEFAULT_TIMEOUT_PE 500000 | ||
47 | |||
48 | /* Breakout Timeout :: 5 sec*/ | ||
49 | #define TIMEOUT_COUNTER_Q (5000000 / DEFAULT_TIMEOUT_Q) | ||
50 | #define TIMEOUT_COUNTER_PE (5000000 / DEFAULT_TIMEOUT_PE) | ||
38 | 51 | ||
39 | /* | 52 | /* |
40 | * Random Index used for monkey testing while get/set parameters | 53 | * Random Index used for monkey testing while get/set parameters |
@@ -120,13 +133,15 @@ struct CodecObserver : public IOmxObserver { | |||
120 | if (it->type == | 133 | if (it->type == |
121 | android::hardware::media::omx::V1_0::Message::Type::EVENT) { | 134 | android::hardware::media::omx::V1_0::Message::Type::EVENT) { |
122 | *msg = *it; | 135 | *msg = *it; |
123 | msgQueue.erase(it); | 136 | if (callBack) callBack(*it, nullptr); |
137 | it = msgQueue.erase(it); | ||
124 | // OMX_EventBufferFlag event is sent when the component has | 138 | // OMX_EventBufferFlag event is sent when the component has |
125 | // processed a buffer with its EOS flag set. This event is | 139 | // processed a buffer with its EOS flag set. This event is |
126 | // not sent by soft omx components. Vendor components can | 140 | // not sent by soft omx components. Vendor components can |
127 | // send this. From IOMX point of view, we will ignore this | 141 | // send this. From IOMX point of view, we will ignore this |
128 | // event. | 142 | // event. |
129 | if (msg->data.eventData.event == OMX_EventBufferFlag) break; | 143 | if (msg->data.eventData.event == OMX_EventBufferFlag) |
144 | continue; | ||
130 | return ::android::hardware::media::omx::V1_0::Status::OK; | 145 | return ::android::hardware::media::omx::V1_0::Status::OK; |
131 | } else if (it->type == android::hardware::media::omx::V1_0:: | 146 | } else if (it->type == android::hardware::media::omx::V1_0:: |
132 | Message::Type::FILL_BUFFER_DONE) { | 147 | Message::Type::FILL_BUFFER_DONE) { |
@@ -137,7 +152,7 @@ struct CodecObserver : public IOmxObserver { | |||
137 | it->data.bufferData.buffer) { | 152 | it->data.bufferData.buffer) { |
138 | if (callBack) callBack(*it, &(*oBuffers)[i]); | 153 | if (callBack) callBack(*it, &(*oBuffers)[i]); |
139 | oBuffers->editItemAt(i).owner = client; | 154 | oBuffers->editItemAt(i).owner = client; |
140 | msgQueue.erase(it); | 155 | it = msgQueue.erase(it); |
141 | break; | 156 | break; |
142 | } | 157 | } |
143 | } | 158 | } |
@@ -152,24 +167,22 @@ struct CodecObserver : public IOmxObserver { | |||
152 | it->data.bufferData.buffer) { | 167 | it->data.bufferData.buffer) { |
153 | if (callBack) callBack(*it, &(*iBuffers)[i]); | 168 | if (callBack) callBack(*it, &(*iBuffers)[i]); |
154 | iBuffers->editItemAt(i).owner = client; | 169 | iBuffers->editItemAt(i).owner = client; |
155 | msgQueue.erase(it); | 170 | it = msgQueue.erase(it); |
156 | break; | 171 | break; |
157 | } | 172 | } |
158 | } | 173 | } |
159 | EXPECT_LE(i, iBuffers->size()); | 174 | EXPECT_LE(i, iBuffers->size()); |
160 | } | 175 | } |
176 | } else { | ||
177 | EXPECT_TRUE(false) << "Received unexpected message"; | ||
178 | ++it; | ||
161 | } | 179 | } |
162 | ++it; | ||
163 | } | 180 | } |
164 | if (finishBy - android::ALooper::GetNowUs() < 0) | 181 | int64_t delayUs = finishBy - android::ALooper::GetNowUs(); |
165 | return toStatus(android::TIMED_OUT); | 182 | if (delayUs < 0) return toStatus(android::TIMED_OUT); |
166 | android::status_t err = | 183 | (timeoutUs < 0) |
167 | (timeoutUs < 0) | 184 | ? msgCondition.wait(msgLock) |
168 | ? msgCondition.wait(msgLock) | 185 | : msgCondition.waitRelative(msgLock, delayUs * 1000ll); |
169 | : msgCondition.waitRelative( | ||
170 | msgLock, | ||
171 | (finishBy - android::ALooper::GetNowUs()) * 1000ll); | ||
172 | if (err == android::TIMED_OUT) return toStatus(err); | ||
173 | } | 186 | } |
174 | } | 187 | } |
175 | 188 | ||
@@ -284,16 +297,21 @@ Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat( | |||
284 | Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat( | 297 | Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat( |
285 | sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding); | 298 | sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding); |
286 | 299 | ||
300 | void allocateBuffer(sp<IOmxNode> omxNode, BufferInfo* buffer, OMX_U32 portIndex, | ||
301 | OMX_U32 nBufferSize, PortMode portMode); | ||
302 | |||
287 | void allocatePortBuffers(sp<IOmxNode> omxNode, | 303 | void allocatePortBuffers(sp<IOmxNode> omxNode, |
288 | android::Vector<BufferInfo>* buffArray, | 304 | android::Vector<BufferInfo>* buffArray, |
289 | OMX_U32 portIndex, | 305 | OMX_U32 portIndex, |
290 | PortMode portMode = PortMode::PRESET_BYTE_BUFFER); | 306 | PortMode portMode = PortMode::PRESET_BYTE_BUFFER, |
307 | bool allocGrap = false); | ||
291 | 308 | ||
292 | void changeStateLoadedtoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | 309 | void changeStateLoadedtoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer, |
293 | android::Vector<BufferInfo>* iBuffer, | 310 | android::Vector<BufferInfo>* iBuffer, |
294 | android::Vector<BufferInfo>* oBuffer, | 311 | android::Vector<BufferInfo>* oBuffer, |
295 | OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput, | 312 | OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput, |
296 | PortMode* portMode = nullptr); | 313 | PortMode* portMode = nullptr, |
314 | bool allocGrap = false); | ||
297 | 315 | ||
298 | void changeStateIdletoLoaded(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | 316 | void changeStateIdletoLoaded(sp<IOmxNode> omxNode, sp<CodecObserver> observer, |
299 | android::Vector<BufferInfo>* iBuffer, | 317 | android::Vector<BufferInfo>* iBuffer, |
@@ -322,7 +340,8 @@ void dispatchInputBuffer(sp<IOmxNode> omxNode, | |||
322 | void flushPorts(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | 340 | void flushPorts(sp<IOmxNode> omxNode, sp<CodecObserver> observer, |
323 | android::Vector<BufferInfo>* iBuffer, | 341 | android::Vector<BufferInfo>* iBuffer, |
324 | android::Vector<BufferInfo>* oBuffer, OMX_U32 kPortIndexInput, | 342 | android::Vector<BufferInfo>* oBuffer, OMX_U32 kPortIndexInput, |
325 | OMX_U32 kPortIndexOutput, int64_t timeoutUs = DEFAULT_TIMEOUT); | 343 | OMX_U32 kPortIndexOutput, |
344 | int64_t timeoutUs = DEFAULT_TIMEOUT_PE); | ||
326 | 345 | ||
327 | typedef void (*portreconfig)(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | 346 | typedef void (*portreconfig)(sp<IOmxNode> omxNode, sp<CodecObserver> observer, |
328 | android::Vector<BufferInfo>* iBuffer, | 347 | android::Vector<BufferInfo>* iBuffer, |
diff --git a/media/omx/1.0/vts/functional/component/Android.bp b/media/omx/1.0/vts/functional/component/Android.bp index fd3210fb..f76b6e94 100644 --- a/media/omx/1.0/vts/functional/component/Android.bp +++ b/media/omx/1.0/vts/functional/component/Android.bp | |||
@@ -16,32 +16,7 @@ | |||
16 | 16 | ||
17 | cc_test { | 17 | cc_test { |
18 | name: "VtsHalMediaOmxV1_0TargetComponentTest", | 18 | name: "VtsHalMediaOmxV1_0TargetComponentTest", |
19 | defaults: ["hidl_defaults"], | 19 | defaults: ["VtsHalMediaOmxV1_0Defaults"], |
20 | srcs: ["VtsHalMediaOmxV1_0TargetComponentTest.cpp"], | 20 | srcs: ["VtsHalMediaOmxV1_0TargetComponentTest.cpp"], |
21 | shared_libs: [ | ||
22 | "libbase", | ||
23 | "liblog", | ||
24 | "libcutils", | ||
25 | "libhidlbase", | ||
26 | "libhidlmemory", | ||
27 | "libhidltransport", | ||
28 | "libhwbinder", | ||
29 | "libnativehelper", | ||
30 | "libutils", | ||
31 | "libstagefright_foundation", | ||
32 | "android.hidl.allocator@1.0", | ||
33 | "android.hidl.memory@1.0", | ||
34 | "android.hardware.media.omx@1.0", | ||
35 | ], | ||
36 | static_libs: ["VtsHalHidlTargetTestBase", | ||
37 | "VtsHalMediaOmxV1_0CommonUtil"], | ||
38 | cflags: [ | ||
39 | "-O0", | ||
40 | "-g", | ||
41 | ], | ||
42 | include_dirs: [ | ||
43 | "frameworks/native/include/media/openmax/", | ||
44 | "hardware/interfaces/media/omx/1.0/vts/functional/common", | ||
45 | ], | ||
46 | } | 21 | } |
47 | 22 | ||
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 2d91e827..d66136d2 100644 --- a/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp +++ b/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp | |||
@@ -15,6 +15,10 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #define LOG_TAG "media_omx_hidl_component_test" | 17 | #define LOG_TAG "media_omx_hidl_component_test" |
18 | #ifdef __LP64__ | ||
19 | #define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS | ||
20 | #endif | ||
21 | |||
18 | #include <android-base/logging.h> | 22 | #include <android-base/logging.h> |
19 | 23 | ||
20 | #include <android/hardware/media/omx/1.0/IOmx.h> | 24 | #include <android/hardware/media/omx/1.0/IOmx.h> |
@@ -145,6 +149,7 @@ class ComponentHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
145 | this->omxNode = _nl; | 149 | this->omxNode = _nl; |
146 | }) | 150 | }) |
147 | .isOk()); | 151 | .isOk()); |
152 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | ||
148 | ASSERT_NE(omxNode, nullptr); | 153 | ASSERT_NE(omxNode, nullptr); |
149 | ASSERT_NE(gEnv->getRole().empty(), true) << "Invalid Component Role"; | 154 | ASSERT_NE(gEnv->getRole().empty(), true) << "Invalid Component Role"; |
150 | struct StringToClass { | 155 | struct StringToClass { |
@@ -181,11 +186,15 @@ class ComponentHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
181 | strlen(gEnv->getComponent().c_str()) - suffixLen, | 186 | strlen(gEnv->getComponent().c_str()) - suffixLen, |
182 | ".secure"); | 187 | ".secure"); |
183 | } | 188 | } |
184 | if (disableTest) std::cerr << "[ ] Warning ! Test Disabled\n"; | 189 | if (disableTest) std::cout << "[ WARN ] Test Disabled \n"; |
185 | } | 190 | } |
186 | 191 | ||
187 | virtual void TearDown() override { | 192 | virtual void TearDown() override { |
188 | if (omxNode != nullptr) { | 193 | if (omxNode != nullptr) { |
194 | // If you have encountered a fatal failure, it is possible that | ||
195 | // freeNode() will not go through. Instead of hanging the app. | ||
196 | // let it pass through and report errors | ||
197 | if (::testing::Test::HasFatalFailure()) return; | ||
189 | EXPECT_TRUE((omxNode->freeNode()).isOk()); | 198 | EXPECT_TRUE((omxNode->freeNode()).isOk()); |
190 | omxNode = nullptr; | 199 | omxNode = nullptr; |
191 | } | 200 | } |
@@ -213,9 +222,6 @@ class ComponentHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
213 | } | 222 | } |
214 | }; | 223 | }; |
215 | 224 | ||
216 | // Random Index used for monkey testing while get/set parameters | ||
217 | #define RANDOM_INDEX 1729 | ||
218 | |||
219 | void initPortMode(PortMode* pm, bool isSecure, | 225 | void initPortMode(PortMode* pm, bool isSecure, |
220 | ComponentHidlTest::standardCompClass compClass) { | 226 | ComponentHidlTest::standardCompClass compClass) { |
221 | pm[0] = PortMode::PRESET_BYTE_BUFFER; | 227 | pm[0] = PortMode::PRESET_BYTE_BUFFER; |
@@ -232,7 +238,6 @@ void initPortMode(PortMode* pm, bool isSecure, | |||
232 | break; | 238 | break; |
233 | } | 239 | } |
234 | } | 240 | } |
235 | return; | ||
236 | } | 241 | } |
237 | 242 | ||
238 | // test dispatch message API call | 243 | // test dispatch message API call |
@@ -293,7 +298,7 @@ TEST_F(ComponentHidlTest, DISABLED_GetPortIndices) { | |||
293 | } | 298 | } |
294 | 299 | ||
295 | // port format enumeration | 300 | // port format enumeration |
296 | TEST_F(ComponentHidlTest, DISABLED_EnumeratePortFormat) { | 301 | TEST_F(ComponentHidlTest, EnumeratePortFormat) { |
297 | description("Test Component on Mandatory Port Parameters (Port Format)"); | 302 | description("Test Component on Mandatory Port Parameters (Port Format)"); |
298 | if (disableTest) return; | 303 | if (disableTest) return; |
299 | android::hardware::media::omx::V1_0::Status status; | 304 | android::hardware::media::omx::V1_0::Status status; |
@@ -374,7 +379,7 @@ TEST_F(ComponentHidlTest, DISABLED_SetDefaultPortParams) { | |||
374 | kPortIndexOutput = kPortIndexInput + 1; | 379 | kPortIndexOutput = kPortIndexInput + 1; |
375 | } | 380 | } |
376 | 381 | ||
377 | for (size_t i = kPortIndexInput; i < kPortIndexOutput; i++) { | 382 | for (size_t i = kPortIndexInput; i <= kPortIndexOutput; i++) { |
378 | OMX_PARAM_PORTDEFINITIONTYPE portDef; | 383 | OMX_PARAM_PORTDEFINITIONTYPE portDef; |
379 | status = | 384 | status = |
380 | getPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); | 385 | getPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); |
@@ -400,28 +405,31 @@ TEST_F(ComponentHidlTest, DISABLED_SetDefaultPortParams) { | |||
400 | EXPECT_NE(status, | 405 | EXPECT_NE(status, |
401 | ::android::hardware::media::omx::V1_0::Status::OK); | 406 | ::android::hardware::media::omx::V1_0::Status::OK); |
402 | 407 | ||
403 | // Edit Read-Only fields. | 408 | // Port Direction - Read Only |
404 | portDef = mirror; | 409 | portDef = mirror; |
405 | portDef.eDir = static_cast<OMX_DIRTYPE>(RANDOM_INDEX); | 410 | portDef.eDir = static_cast<OMX_DIRTYPE>(RANDOM_INDEX); |
406 | setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); | 411 | setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); |
407 | getPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); | 412 | getPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); |
413 | if (portDef.eDir != mirror.eDir) { | ||
414 | std::cerr << "[ ERROR ] port direction has to be read only " | ||
415 | "but is changeable \n"; | ||
416 | } | ||
408 | EXPECT_EQ(portDef.eDir, mirror.eDir); | 417 | EXPECT_EQ(portDef.eDir, mirror.eDir); |
409 | setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &mirror); | 418 | setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &mirror); |
410 | 419 | ||
411 | portDef = mirror; | 420 | // Port Min BufferCount - Read Only |
412 | portDef.nBufferSize >>= 1; | ||
413 | setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); | ||
414 | getPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); | ||
415 | EXPECT_EQ(portDef.nBufferSize, mirror.nBufferSize); | ||
416 | setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &mirror); | ||
417 | |||
418 | portDef = mirror; | 421 | portDef = mirror; |
419 | portDef.nBufferCountMin += 1; | 422 | portDef.nBufferCountMin += 1; |
420 | setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); | 423 | setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); |
421 | getPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); | 424 | getPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); |
425 | if (portDef.nBufferCountMin != mirror.nBufferCountMin) { | ||
426 | std::cerr << "[ ERROR ] port Min BufferCount has to be " | ||
427 | "read only but is changeable \n"; | ||
428 | } | ||
422 | EXPECT_EQ(portDef.nBufferCountMin, mirror.nBufferCountMin); | 429 | EXPECT_EQ(portDef.nBufferCountMin, mirror.nBufferCountMin); |
423 | setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &mirror); | 430 | setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &mirror); |
424 | 431 | ||
432 | // Port Actual BufferCount | ||
425 | portDef = mirror; | 433 | portDef = mirror; |
426 | portDef.nBufferCountActual += 1; | 434 | portDef.nBufferCountActual += 1; |
427 | status = setPortParam(omxNode, OMX_IndexParamPortDefinition, i, | 435 | status = setPortParam(omxNode, OMX_IndexParamPortDefinition, i, |
@@ -432,20 +440,49 @@ TEST_F(ComponentHidlTest, DISABLED_SetDefaultPortParams) { | |||
432 | EXPECT_EQ(portDef.nBufferCountActual, | 440 | EXPECT_EQ(portDef.nBufferCountActual, |
433 | mirror.nBufferCountActual + 1); | 441 | mirror.nBufferCountActual + 1); |
434 | } | 442 | } |
443 | setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &mirror); | ||
435 | 444 | ||
445 | // Port BufferSize is although read only as per OMX-IL 1.2, android | ||
446 | // doesnt abide by this. | ||
447 | // Decrease buffer size | ||
436 | portDef = mirror; | 448 | portDef = mirror; |
437 | portDef.nBufferSize = mirror.nBufferSize << 1; | 449 | OMX_U32 nBufferSize = portDef.nBufferSize >> 1; |
438 | status = setPortParam(omxNode, OMX_IndexParamPortDefinition, i, | 450 | if (nBufferSize != 0) { |
439 | &portDef); | 451 | if (!strncmp(gEnv->getComponent().c_str(), "OMX.google.", 11)) { |
440 | if (status == ::android::hardware::media::omx::V1_0::Status::OK) { | 452 | portDef.nBufferSize = nBufferSize; |
441 | status = getPortParam(omxNode, OMX_IndexParamPortDefinition, i, | 453 | } else { |
442 | &portDef); | 454 | // Probable alignment requirements of vendor component |
443 | if (portDef.nBufferSize != mirror.nBufferSize) { | 455 | portDef.nBufferSize = ALIGN_POWER_OF_TWO(nBufferSize, 12); |
444 | std::cout | 456 | nBufferSize = portDef.nBufferSize; |
445 | << "[ ] Warning ! Component input port does " | ||
446 | "not preserve Read-Only fields \n"; | ||
447 | } | 457 | } |
458 | } else { | ||
459 | ASSERT_TRUE(false) << "Unexpected buffer size"; | ||
448 | } | 460 | } |
461 | setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); | ||
462 | getPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); | ||
463 | // SPECIAL CASE: For video decoder, allow configuration of input | ||
464 | // buffer size even if it is less than minimum requirement and | ||
465 | // similarly for encoder allow configuration of output port buffer | ||
466 | // size. | ||
467 | if ((compClass == video_encoder && i == kPortIndexOutput) || | ||
468 | (compClass == video_decoder && i == kPortIndexInput)) { | ||
469 | double dev = (portDef.nBufferSize / (double)nBufferSize); | ||
470 | dev -= 1; | ||
471 | if (dev < 0 || dev > 0.1) { | ||
472 | std::cerr << "[ ERROR ] port buffer size deviation " | ||
473 | "larger than expected \n"; | ||
474 | } | ||
475 | } else { | ||
476 | EXPECT_EQ(portDef.nBufferSize, mirror.nBufferSize); | ||
477 | } | ||
478 | setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &mirror); | ||
479 | |||
480 | // Increase buffer size | ||
481 | portDef = mirror; | ||
482 | portDef.nBufferSize = mirror.nBufferSize << 1; | ||
483 | setPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); | ||
484 | getPortParam(omxNode, OMX_IndexParamPortDefinition, i, &portDef); | ||
485 | EXPECT_EQ(portDef.nBufferSize, (mirror.nBufferSize << 1)); | ||
449 | } | 486 | } |
450 | } | 487 | } |
451 | } | 488 | } |
@@ -470,8 +507,10 @@ TEST_F(ComponentHidlTest, DISABLED_PopulatePort) { | |||
470 | portBase = params.nStartPortNumber; | 507 | portBase = params.nStartPortNumber; |
471 | } | 508 | } |
472 | 509 | ||
473 | sp<IAllocator> allocator = IAllocator::getService("ashmem"); | 510 | // set state to idle |
474 | EXPECT_NE(allocator.get(), nullptr); | 511 | status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet), |
512 | OMX_StateIdle); | ||
513 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | ||
475 | 514 | ||
476 | OMX_PARAM_PORTDEFINITIONTYPE portDef; | 515 | OMX_PARAM_PORTDEFINITIONTYPE portDef; |
477 | status = | 516 | status = |
@@ -485,30 +524,10 @@ TEST_F(ComponentHidlTest, DISABLED_PopulatePort) { | |||
485 | 524 | ||
486 | for (size_t i = 0; i < portDef.nBufferCountActual; i++) { | 525 | for (size_t i = 0; i < portDef.nBufferCountActual; i++) { |
487 | BufferInfo buffer; | 526 | BufferInfo buffer; |
488 | buffer.owner = client; | 527 | ASSERT_NO_FATAL_FAILURE(allocateBuffer(omxNode, &buffer, portBase, |
489 | buffer.omxBuffer.type = CodecBuffer::Type::SHARED_MEM; | 528 | nBufferSize, |
490 | buffer.omxBuffer.attr.preset.rangeOffset = 0; | 529 | PortMode::PRESET_BYTE_BUFFER)); |
491 | buffer.omxBuffer.attr.preset.rangeLength = 0; | ||
492 | bool success = false; | ||
493 | allocator->allocate( | ||
494 | nBufferSize, | ||
495 | [&success, &buffer](bool _s, | ||
496 | ::android::hardware::hidl_memory const& mem) { | ||
497 | success = _s; | ||
498 | buffer.omxBuffer.sharedMemory = mem; | ||
499 | }); | ||
500 | ASSERT_EQ(success, true); | ||
501 | ASSERT_EQ(buffer.omxBuffer.sharedMemory.size(), nBufferSize); | ||
502 | |||
503 | omxNode->useBuffer( | ||
504 | portBase, buffer.omxBuffer, | ||
505 | [&status, &buffer](android::hardware::media::omx::V1_0::Status _s, | ||
506 | uint32_t id) { | ||
507 | status = _s; | ||
508 | buffer.id = id; | ||
509 | }); | ||
510 | pBuffer.push(buffer); | 530 | pBuffer.push(buffer); |
511 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
512 | } | 531 | } |
513 | 532 | ||
514 | status = | 533 | status = |
@@ -548,44 +567,52 @@ TEST_F(ComponentHidlTest, Flush) { | |||
548 | PortMode portMode[2]; | 567 | PortMode portMode[2]; |
549 | initPortMode(portMode, isSecure, compClass); | 568 | initPortMode(portMode, isSecure, compClass); |
550 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | 569 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); |
551 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 570 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
552 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | 571 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); |
553 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 572 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
554 | 573 | ||
555 | // set state to idle | 574 | // set state to idle |
556 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 575 | ASSERT_NO_FATAL_FAILURE( |
557 | kPortIndexInput, kPortIndexOutput, portMode); | 576 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, |
577 | kPortIndexInput, kPortIndexOutput, portMode)); | ||
558 | // set state to executing | 578 | // set state to executing |
559 | changeStateIdletoExecute(omxNode, observer); | 579 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
560 | // dispatch buffers | 580 | // dispatch buffers |
561 | for (size_t i = 0; i < oBuffer.size(); i++) { | 581 | for (size_t i = 0; i < oBuffer.size(); i++) { |
562 | dispatchOutputBuffer(omxNode, &oBuffer, i, portMode[1]); | 582 | ASSERT_NO_FATAL_FAILURE( |
583 | dispatchOutputBuffer(omxNode, &oBuffer, i, portMode[1])); | ||
563 | } | 584 | } |
564 | // flush port | 585 | // flush port |
565 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 586 | ASSERT_NO_FATAL_FAILURE(flushPorts(omxNode, observer, &iBuffer, &oBuffer, |
566 | kPortIndexOutput); | 587 | kPortIndexInput, kPortIndexOutput)); |
588 | #if 0 | ||
567 | // TODO: Sending empty input buffers is slightly tricky. | 589 | // TODO: Sending empty input buffers is slightly tricky. |
568 | // Components sometimes process input buffers even when output buffers are | 590 | // Components sometimes process input buffers even when output buffers are |
569 | // not dispatched. For instance Parsing sequence header does not require | 591 | // not dispatched. For instance Parsing sequence header does not require |
570 | // output buffers. In such instances sending 0 size input buffers might | 592 | // output buffers. In such instances sending 0 size input buffers might |
571 | // make component to send error events. so lets skip this aspect of testing. | 593 | // make component to send error events. so lets skip this aspect of testing. |
572 | // dispatch buffers | 594 | // dispatch buffers |
573 | // for (size_t i = 0; i < iBuffer.size(); i++) { | 595 | for (size_t i = 0; i < iBuffer.size(); i++) { |
574 | // dispatchInputBuffer(omxNode, &iBuffer, i, 0, 0, 0, portMode[0]); | 596 | ASSERT_NO_FATAL_FAILURE( |
575 | // } | 597 | dispatchInputBuffer(omxNode, &iBuffer, i, 0, 0, 0, portMode[0])); |
576 | // // flush ports | 598 | } |
577 | // flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 599 | // flush ports |
578 | // kPortIndexOutput); | 600 | ASSERT_NO_FATAL_FAILURE(flushPorts(omxNode, observer, &iBuffer, &oBuffer, |
601 | kPortIndexInput, kPortIndexOutput)); | ||
602 | #endif | ||
603 | |||
579 | // set state to idle | 604 | // set state to idle |
580 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 605 | ASSERT_NO_FATAL_FAILURE( |
606 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
581 | // set state to loaded | 607 | // set state to loaded |
582 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 608 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
583 | kPortIndexInput, kPortIndexOutput); | 609 | &oBuffer, kPortIndexInput, |
610 | kPortIndexOutput)); | ||
584 | } | 611 | } |
585 | 612 | ||
586 | // state transitions test | 613 | // Flush test - monkeying |
587 | TEST_F(ComponentHidlTest, StateTransitions) { | 614 | TEST_F(ComponentHidlTest, Flush_M) { |
588 | description("Test State Transitions Loaded<->Idle<->Execute"); | 615 | description("Test Flush monkeying"); |
589 | if (disableTest) return; | 616 | if (disableTest) return; |
590 | android::hardware::media::omx::V1_0::Status status; | 617 | android::hardware::media::omx::V1_0::Status status; |
591 | uint32_t kPortIndexInput = 0, kPortIndexOutput = 1; | 618 | uint32_t kPortIndexInput = 0, kPortIndexOutput = 1; |
@@ -611,33 +638,267 @@ TEST_F(ComponentHidlTest, StateTransitions) { | |||
611 | PortMode portMode[2]; | 638 | PortMode portMode[2]; |
612 | initPortMode(portMode, isSecure, compClass); | 639 | initPortMode(portMode, isSecure, compClass); |
613 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | 640 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); |
641 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
642 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
643 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
644 | |||
645 | // // Flush all ports ; receive error OMX_ErrorIncorrectStateOperation | ||
646 | // status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush), | ||
647 | // OMX_ALL); | ||
648 | // ASSERT_NE(status, android::hardware::media::omx::V1_0::Status::OK); | ||
649 | |||
650 | // set state to idle | ||
651 | ASSERT_NO_FATAL_FAILURE( | ||
652 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | ||
653 | kPortIndexInput, kPortIndexOutput, portMode)); | ||
654 | |||
655 | // // Flush all ports ; receive error OMX_ErrorIncorrectStateOperation | ||
656 | // status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush), | ||
657 | // OMX_ALL); | ||
658 | // ASSERT_NE(status, android::hardware::media::omx::V1_0::Status::OK); | ||
659 | |||
660 | // set state to executing | ||
661 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); | ||
662 | |||
663 | // dispatch buffers | ||
664 | for (size_t i = 0; i < oBuffer.size(); i++) { | ||
665 | ASSERT_NO_FATAL_FAILURE( | ||
666 | dispatchOutputBuffer(omxNode, &oBuffer, i, portMode[1])); | ||
667 | } | ||
668 | |||
669 | // // flush invalid port, expecting OMX_ErrorBadPortIndex | ||
670 | // status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush), | ||
671 | // RANDOM_INDEX); | ||
672 | // ASSERT_NE(status, android::hardware::media::omx::V1_0::Status::OK); | ||
673 | |||
674 | // Flush all ports | ||
675 | status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush), OMX_ALL); | ||
676 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | ||
677 | |||
678 | for (int j = 0; j < 2; j++) { | ||
679 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_PE, &iBuffer, | ||
680 | &oBuffer); | ||
681 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | ||
682 | ASSERT_EQ(msg.type, Message::Type::EVENT); | ||
683 | ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete); | ||
684 | ASSERT_EQ(msg.data.eventData.data1, OMX_CommandFlush); | ||
685 | if (msg.data.eventData.data2 == kPortIndexInput) { | ||
686 | // test if client got all its buffers back | ||
687 | for (size_t i = 0; i < iBuffer.size(); ++i) { | ||
688 | EXPECT_EQ(iBuffer[i].owner, client); | ||
689 | } | ||
690 | } else if (msg.data.eventData.data2 == kPortIndexOutput) { | ||
691 | // test if client got all its buffers back | ||
692 | for (size_t i = 0; i < oBuffer.size(); ++i) { | ||
693 | EXPECT_EQ(oBuffer[i].owner, client); | ||
694 | } | ||
695 | } else { | ||
696 | EXPECT_TRUE(false) << "Bad port Index"; | ||
697 | } | ||
698 | } | ||
699 | |||
700 | // SPECIAL CASE: When OMX_ALL is used as argument, Android OMX Core sends | ||
701 | // an additional flush event with argument OMX_ALL. This we believe is | ||
702 | // not recognized by OMX-IL Spec. So read this event and ignore it | ||
703 | status = | ||
704 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_PE, &iBuffer, &oBuffer); | ||
705 | if (status == android::hardware::media::omx::V1_0::Status::OK) { | ||
706 | ASSERT_EQ(msg.type, Message::Type::EVENT); | ||
707 | ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete); | ||
708 | ASSERT_EQ(msg.data.eventData.data1, OMX_CommandFlush); | ||
709 | ASSERT_EQ(msg.data.eventData.data2, OMX_ALL); | ||
710 | } | ||
711 | |||
712 | // set state to idle | ||
713 | ASSERT_NO_FATAL_FAILURE( | ||
714 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
715 | // set state to loaded | ||
716 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, | ||
717 | &oBuffer, kPortIndexInput, | ||
718 | kPortIndexOutput)); | ||
719 | } | ||
720 | |||
721 | // test port mode configuration when the component is in various states | ||
722 | TEST_F(ComponentHidlTest, PortModeConfig) { | ||
723 | description("Test Port Mode Configuration"); | ||
724 | if (disableTest) return; | ||
725 | android::hardware::media::omx::V1_0::Status status; | ||
726 | uint32_t kPortIndexInput = 0, kPortIndexOutput = 1; | ||
727 | Message msg; | ||
728 | |||
729 | status = setRole(omxNode, gEnv->getRole().c_str()); | ||
730 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
731 | OMX_PORT_PARAM_TYPE params; | ||
732 | if (compClass == audio_decoder || compClass == audio_encoder) { | ||
733 | status = getParam(omxNode, OMX_IndexParamAudioInit, ¶ms); | ||
734 | } else { | ||
735 | status = getParam(omxNode, OMX_IndexParamVideoInit, ¶ms); | ||
736 | } | ||
737 | if (status == ::android::hardware::media::omx::V1_0::Status::OK) { | ||
738 | ASSERT_EQ(params.nPorts, 2U); | ||
739 | kPortIndexInput = params.nStartPortNumber; | ||
740 | kPortIndexOutput = kPortIndexInput + 1; | ||
741 | } | ||
742 | |||
743 | android::Vector<BufferInfo> iBuffer, oBuffer; | ||
744 | |||
745 | // set port mode | ||
746 | PortMode portMode[2]; | ||
747 | initPortMode(portMode, isSecure, compClass); | ||
748 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
749 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
750 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
751 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
752 | |||
753 | // set state to idle | ||
754 | ASSERT_NO_FATAL_FAILURE( | ||
755 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | ||
756 | kPortIndexInput, kPortIndexOutput, portMode)); | ||
757 | // Only Allow Port Mode configuration in loaded state | ||
758 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
759 | EXPECT_NE(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
760 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
761 | EXPECT_NE(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
762 | |||
763 | // set state to executing | ||
764 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); | ||
765 | // Only Allow Port Mode configuration in loaded state | ||
766 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
767 | EXPECT_NE(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
768 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
769 | EXPECT_NE(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
770 | |||
771 | // set state to idle | ||
772 | ASSERT_NO_FATAL_FAILURE( | ||
773 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
774 | // set state to loaded | ||
775 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, | ||
776 | &oBuffer, kPortIndexInput, | ||
777 | kPortIndexOutput)); | ||
778 | |||
779 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
614 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 780 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
615 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | 781 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); |
616 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 782 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
783 | } | ||
784 | |||
785 | // state transitions test | ||
786 | TEST_F(ComponentHidlTest, StateTransitions) { | ||
787 | description("Test State Transitions Loaded<->Idle<->Execute"); | ||
788 | if (disableTest) return; | ||
789 | android::hardware::media::omx::V1_0::Status status; | ||
790 | uint32_t kPortIndexInput = 0, kPortIndexOutput = 1; | ||
791 | OMX_U32 portBase = 0; | ||
792 | Message msg; | ||
793 | status = setRole(omxNode, gEnv->getRole().c_str()); | ||
794 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
795 | OMX_PORT_PARAM_TYPE params; | ||
796 | if (compClass == audio_decoder || compClass == audio_encoder) { | ||
797 | status = getParam(omxNode, OMX_IndexParamAudioInit, ¶ms); | ||
798 | } else { | ||
799 | status = getParam(omxNode, OMX_IndexParamVideoInit, ¶ms); | ||
800 | } | ||
801 | if (status == ::android::hardware::media::omx::V1_0::Status::OK) { | ||
802 | ASSERT_EQ(params.nPorts, 2U); | ||
803 | portBase = params.nStartPortNumber; | ||
804 | } | ||
805 | kPortIndexInput = portBase; | ||
806 | kPortIndexOutput = portBase + 1; | ||
807 | |||
808 | android::Vector<BufferInfo> pBuffer[2]; | ||
809 | |||
810 | // set port mode | ||
811 | PortMode portMode[2]; | ||
812 | initPortMode(portMode, isSecure, compClass); | ||
813 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
814 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
815 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
816 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
817 | |||
818 | // set state to idle | ||
819 | status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet), | ||
820 | OMX_StateIdle); | ||
821 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | ||
822 | |||
823 | for (size_t j = portBase; j < portBase + 2; j++) { | ||
824 | pBuffer[j - portBase].clear(); | ||
617 | 825 | ||
826 | OMX_PARAM_PORTDEFINITIONTYPE def; | ||
827 | status = getPortParam(omxNode, OMX_IndexParamPortDefinition, j, &def); | ||
828 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
829 | |||
830 | for (size_t i = 0; i < def.nBufferCountActual; i++) { | ||
831 | // Dont switch states until the ports are populated | ||
832 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, | ||
833 | &pBuffer[0], &pBuffer[1]); | ||
834 | ASSERT_EQ(status, | ||
835 | android::hardware::media::omx::V1_0::Status::TIMED_OUT); | ||
836 | |||
837 | BufferInfo buffer; | ||
838 | ASSERT_NO_FATAL_FAILURE(allocateBuffer( | ||
839 | omxNode, &buffer, j, def.nBufferSize, portMode[j - portBase])); | ||
840 | pBuffer[j - portBase].push(buffer); | ||
841 | } | ||
842 | } | ||
843 | |||
844 | // As the ports are populated, check if the state transition is complete | ||
845 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, &pBuffer[0], | ||
846 | &pBuffer[1]); | ||
847 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | ||
848 | ASSERT_EQ(msg.type, Message::Type::EVENT); | ||
849 | ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete); | ||
850 | ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet); | ||
851 | ASSERT_EQ(msg.data.eventData.data2, OMX_StateIdle); | ||
852 | |||
853 | // set state to executing | ||
854 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); | ||
855 | // dispatch buffers | ||
856 | for (size_t i = 0; i < pBuffer[1].size(); i++) { | ||
857 | ASSERT_NO_FATAL_FAILURE( | ||
858 | dispatchOutputBuffer(omxNode, &pBuffer[1], i, portMode[1])); | ||
859 | } | ||
618 | // set state to idle | 860 | // set state to idle |
619 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 861 | ASSERT_NO_FATAL_FAILURE( |
620 | kPortIndexInput, kPortIndexOutput, portMode); | 862 | changeStateExecutetoIdle(omxNode, observer, &pBuffer[0], &pBuffer[1])); |
863 | #if 0 | ||
621 | // set state to executing | 864 | // set state to executing |
622 | changeStateIdletoExecute(omxNode, observer); | 865 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
866 | // TODO: Sending empty input buffers is slightly tricky. | ||
623 | // dispatch buffers | 867 | // dispatch buffers |
624 | for (size_t i = 0; i < oBuffer.size(); i++) { | 868 | for (size_t i = 0; i < pBuffer[0].size(); i++) { |
625 | dispatchOutputBuffer(omxNode, &oBuffer, i, portMode[1]); | 869 | ASSERT_NO_FATAL_FAILURE( |
870 | dispatchInputBuffer(omxNode, &pBuffer[0], i, 0, 0, 0, portMode[0])); | ||
626 | } | 871 | } |
627 | // set state to idle | 872 | // set state to idle |
628 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 873 | ASSERT_NO_FATAL_FAILURE( |
629 | // // set state to executing | 874 | changeStateExecutetoIdle(omxNode, observer, &pBuffer[0], &pBuffer[1])); |
630 | // changeStateIdletoExecute(omxNode, observer); | 875 | #endif |
631 | // // TODO: Sending empty input buffers is slightly tricky. | 876 | |
632 | // // dispatch buffers | ||
633 | // for (size_t i = 0; i < iBuffer.size(); i++) { | ||
634 | // dispatchInputBuffer(omxNode, &iBuffer, i, 0, 0, 0, portMode[0]); | ||
635 | // } | ||
636 | // // set state to idle | ||
637 | // changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | ||
638 | // set state to loaded | 877 | // set state to loaded |
639 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 878 | status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet), |
640 | kPortIndexInput, kPortIndexOutput); | 879 | OMX_StateLoaded); |
880 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | ||
881 | |||
882 | for (size_t j = portBase; j < portBase + 2; j++) { | ||
883 | for (size_t i = 0; i < pBuffer[j].size(); ++i) { | ||
884 | // Dont switch states until the ports are populated | ||
885 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, | ||
886 | &pBuffer[0], &pBuffer[1]); | ||
887 | ASSERT_EQ(status, | ||
888 | android::hardware::media::omx::V1_0::Status::TIMED_OUT); | ||
889 | |||
890 | status = omxNode->freeBuffer(j, pBuffer[j][i].id); | ||
891 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | ||
892 | } | ||
893 | } | ||
894 | |||
895 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, &pBuffer[0], | ||
896 | &pBuffer[1]); | ||
897 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | ||
898 | ASSERT_EQ(msg.type, Message::Type::EVENT); | ||
899 | ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete); | ||
900 | ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet); | ||
901 | ASSERT_EQ(msg.data.eventData.data2, OMX_StateLoaded); | ||
641 | } | 902 | } |
642 | 903 | ||
643 | // state transitions test - monkeying | 904 | // state transitions test - monkeying |
@@ -675,8 +936,9 @@ TEST_F(ComponentHidlTest, DISABLED_StateTransitions_M) { | |||
675 | EXPECT_NE(status, android::hardware::media::omx::V1_0::Status::OK); | 936 | EXPECT_NE(status, android::hardware::media::omx::V1_0::Status::OK); |
676 | 937 | ||
677 | // set state to idle | 938 | // set state to idle |
678 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 939 | ASSERT_NO_FATAL_FAILURE(changeStateLoadedtoIdle(omxNode, observer, &iBuffer, |
679 | kPortIndexInput, kPortIndexOutput); | 940 | &oBuffer, kPortIndexInput, |
941 | kPortIndexOutput)); | ||
680 | 942 | ||
681 | // set state to idle ; receive error OMX_ErrorSameState | 943 | // set state to idle ; receive error OMX_ErrorSameState |
682 | status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet), | 944 | status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet), |
@@ -684,7 +946,7 @@ TEST_F(ComponentHidlTest, DISABLED_StateTransitions_M) { | |||
684 | EXPECT_NE(status, android::hardware::media::omx::V1_0::Status::OK); | 946 | EXPECT_NE(status, android::hardware::media::omx::V1_0::Status::OK); |
685 | 947 | ||
686 | // set state to executing | 948 | // set state to executing |
687 | changeStateIdletoExecute(omxNode, observer); | 949 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
688 | 950 | ||
689 | // set state to executing ; receive error OMX_ErrorSameState | 951 | // set state to executing ; receive error OMX_ErrorSameState |
690 | status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet), | 952 | status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet), |
@@ -696,12 +958,13 @@ TEST_F(ComponentHidlTest, DISABLED_StateTransitions_M) { | |||
696 | OMX_StateLoaded); | 958 | OMX_StateLoaded); |
697 | EXPECT_NE(status, android::hardware::media::omx::V1_0::Status::OK); | 959 | EXPECT_NE(status, android::hardware::media::omx::V1_0::Status::OK); |
698 | 960 | ||
699 | // set state to Idle | 961 | // set state to idle |
700 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 962 | ASSERT_NO_FATAL_FAILURE( |
701 | 963 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | |
702 | // set state to Loaded | 964 | // set state to loaded |
703 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 965 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
704 | kPortIndexInput, kPortIndexOutput); | 966 | &oBuffer, kPortIndexInput, |
967 | kPortIndexOutput)); | ||
705 | } | 968 | } |
706 | 969 | ||
707 | // port enable disable test | 970 | // port enable disable test |
@@ -784,14 +1047,14 @@ TEST_F(ComponentHidlTest, PortEnableDisable_Idle) { | |||
784 | PortMode portMode[2]; | 1047 | PortMode portMode[2]; |
785 | initPortMode(portMode, isSecure, compClass); | 1048 | initPortMode(portMode, isSecure, compClass); |
786 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | 1049 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); |
787 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1050 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
788 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | 1051 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); |
789 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1052 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
790 | 1053 | ||
791 | // set state to idle | 1054 | // set state to idle |
792 | changeStateLoadedtoIdle(omxNode, observer, &pBuffer[0], &pBuffer[1], | 1055 | ASSERT_NO_FATAL_FAILURE( |
793 | kPortIndexInput, kPortIndexOutput, portMode); | 1056 | changeStateLoadedtoIdle(omxNode, observer, &pBuffer[0], &pBuffer[1], |
794 | 1057 | kPortIndexInput, kPortIndexOutput, portMode)); | |
795 | for (size_t i = portBase; i < portBase + 2; i++) { | 1058 | for (size_t i = portBase; i < portBase + 2; i++) { |
796 | status = | 1059 | status = |
797 | omxNode->sendCommand(toRawCommandType(OMX_CommandPortDisable), i); | 1060 | omxNode->sendCommand(toRawCommandType(OMX_CommandPortDisable), i); |
@@ -839,8 +1102,8 @@ TEST_F(ComponentHidlTest, PortEnableDisable_Idle) { | |||
839 | ASSERT_EQ(status, | 1102 | ASSERT_EQ(status, |
840 | android::hardware::media::omx::V1_0::Status::TIMED_OUT); | 1103 | android::hardware::media::omx::V1_0::Status::TIMED_OUT); |
841 | 1104 | ||
842 | allocatePortBuffers(omxNode, &pBuffer[i - portBase], i, | 1105 | ASSERT_NO_FATAL_FAILURE(allocatePortBuffers( |
843 | portMode[i - portBase]); | 1106 | omxNode, &pBuffer[i - portBase], i, portMode[i - portBase])); |
844 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, | 1107 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, |
845 | &pBuffer[0], &pBuffer[1]); | 1108 | &pBuffer[0], &pBuffer[1]); |
846 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | 1109 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); |
@@ -854,8 +1117,9 @@ TEST_F(ComponentHidlTest, PortEnableDisable_Idle) { | |||
854 | } | 1117 | } |
855 | 1118 | ||
856 | // set state to Loaded | 1119 | // set state to Loaded |
857 | changeStateIdletoLoaded(omxNode, observer, &pBuffer[0], &pBuffer[1], | 1120 | ASSERT_NO_FATAL_FAILURE( |
858 | kPortIndexInput, kPortIndexOutput); | 1121 | changeStateIdletoLoaded(omxNode, observer, &pBuffer[0], &pBuffer[1], |
1122 | kPortIndexInput, kPortIndexOutput)); | ||
859 | } | 1123 | } |
860 | 1124 | ||
861 | // port enable disable test | 1125 | // port enable disable test |
@@ -888,20 +1152,20 @@ TEST_F(ComponentHidlTest, PortEnableDisable_Execute) { | |||
888 | PortMode portMode[2]; | 1152 | PortMode portMode[2]; |
889 | initPortMode(portMode, isSecure, compClass); | 1153 | initPortMode(portMode, isSecure, compClass); |
890 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | 1154 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); |
891 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1155 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
892 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | 1156 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); |
893 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1157 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
894 | 1158 | ||
895 | // set state to idle | 1159 | // set state to idle |
896 | changeStateLoadedtoIdle(omxNode, observer, &pBuffer[0], &pBuffer[1], | 1160 | ASSERT_NO_FATAL_FAILURE( |
897 | kPortIndexInput, kPortIndexOutput, portMode); | 1161 | changeStateLoadedtoIdle(omxNode, observer, &pBuffer[0], &pBuffer[1], |
898 | 1162 | kPortIndexInput, kPortIndexOutput, portMode)); | |
899 | // set state to executing | 1163 | // set state to executing |
900 | changeStateIdletoExecute(omxNode, observer); | 1164 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
901 | |||
902 | // dispatch buffers | 1165 | // dispatch buffers |
903 | for (size_t i = 0; i < pBuffer[1].size(); i++) { | 1166 | for (size_t i = 0; i < pBuffer[1].size(); i++) { |
904 | dispatchOutputBuffer(omxNode, &pBuffer[1], i, portMode[1]); | 1167 | ASSERT_NO_FATAL_FAILURE( |
1168 | dispatchOutputBuffer(omxNode, &pBuffer[1], i, portMode[1])); | ||
905 | } | 1169 | } |
906 | 1170 | ||
907 | for (size_t i = portBase; i < portBase + 2; i++) { | 1171 | for (size_t i = portBase; i < portBase + 2; i++) { |
@@ -954,8 +1218,8 @@ TEST_F(ComponentHidlTest, PortEnableDisable_Execute) { | |||
954 | ASSERT_EQ(status, | 1218 | ASSERT_EQ(status, |
955 | android::hardware::media::omx::V1_0::Status::TIMED_OUT); | 1219 | android::hardware::media::omx::V1_0::Status::TIMED_OUT); |
956 | 1220 | ||
957 | allocatePortBuffers(omxNode, &pBuffer[i - portBase], i, | 1221 | ASSERT_NO_FATAL_FAILURE(allocatePortBuffers( |
958 | portMode[i - portBase]); | 1222 | omxNode, &pBuffer[i - portBase], i, portMode[i - portBase])); |
959 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, | 1223 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, |
960 | &pBuffer[0], &pBuffer[1]); | 1224 | &pBuffer[0], &pBuffer[1]); |
961 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | 1225 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); |
@@ -968,12 +1232,13 @@ TEST_F(ComponentHidlTest, PortEnableDisable_Execute) { | |||
968 | } | 1232 | } |
969 | } | 1233 | } |
970 | 1234 | ||
971 | // set state to Idle | 1235 | // set state to idle |
972 | changeStateExecutetoIdle(omxNode, observer, &pBuffer[0], &pBuffer[1]); | 1236 | ASSERT_NO_FATAL_FAILURE( |
973 | 1237 | changeStateExecutetoIdle(omxNode, observer, &pBuffer[0], &pBuffer[1])); | |
974 | // set state to Loaded | 1238 | // set state to loaded |
975 | changeStateIdletoLoaded(omxNode, observer, &pBuffer[0], &pBuffer[1], | 1239 | ASSERT_NO_FATAL_FAILURE( |
976 | kPortIndexInput, kPortIndexOutput); | 1240 | changeStateIdletoLoaded(omxNode, observer, &pBuffer[0], &pBuffer[1], |
1241 | kPortIndexInput, kPortIndexOutput)); | ||
977 | } | 1242 | } |
978 | 1243 | ||
979 | // port enable disable test - monkeying | 1244 | // port enable disable test - monkeying |
diff --git a/media/omx/1.0/vts/functional/master/Android.bp b/media/omx/1.0/vts/functional/master/Android.bp index e24b79b8..4a45e692 100644 --- a/media/omx/1.0/vts/functional/master/Android.bp +++ b/media/omx/1.0/vts/functional/master/Android.bp | |||
@@ -16,29 +16,7 @@ | |||
16 | 16 | ||
17 | cc_test { | 17 | cc_test { |
18 | name: "VtsHalMediaOmxV1_0TargetMasterTest", | 18 | name: "VtsHalMediaOmxV1_0TargetMasterTest", |
19 | defaults: ["hidl_defaults"], | 19 | defaults: ["VtsHalMediaOmxV1_0Defaults"], |
20 | srcs: ["VtsHalMediaOmxV1_0TargetMasterTest.cpp"], | 20 | srcs: ["VtsHalMediaOmxV1_0TargetMasterTest.cpp"], |
21 | shared_libs: [ | ||
22 | "libbase", | ||
23 | "liblog", | ||
24 | "libcutils", | ||
25 | "libhidlbase", | ||
26 | "libhidltransport", | ||
27 | "libhwbinder", | ||
28 | "libnativehelper", | ||
29 | "libutils", | ||
30 | "android.hidl.allocator@1.0", | ||
31 | "android.hidl.memory@1.0", | ||
32 | "android.hardware.media.omx@1.0", | ||
33 | ], | ||
34 | static_libs: ["VtsHalHidlTargetTestBase"], | ||
35 | cflags: [ | ||
36 | "-O0", | ||
37 | "-g", | ||
38 | ], | ||
39 | include_dirs: [ | ||
40 | "frameworks/native/include/media/openmax/", | ||
41 | "hardware/interfaces/media/omx/1.0/vts/functional/common", | ||
42 | ], | ||
43 | } | 21 | } |
44 | 22 | ||
diff --git a/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp b/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp index e8f5f77d..5a31d691 100644 --- a/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp +++ b/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp | |||
@@ -15,6 +15,10 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #define LOG_TAG "media_omx_hidl_master_test" | 17 | #define LOG_TAG "media_omx_hidl_master_test" |
18 | #ifdef __LP64__ | ||
19 | #define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS | ||
20 | #endif | ||
21 | |||
18 | #include <android-base/logging.h> | 22 | #include <android-base/logging.h> |
19 | 23 | ||
20 | #include <android/hardware/media/omx/1.0/IOmx.h> | 24 | #include <android/hardware/media/omx/1.0/IOmx.h> |
@@ -146,6 +150,7 @@ TEST_F(MasterHidlTest, ListServiceAttr) { | |||
146 | attributes = _nl; | 150 | attributes = _nl; |
147 | }) | 151 | }) |
148 | .isOk()); | 152 | .isOk()); |
153 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | ||
149 | if (attributes.size() == 0) ALOGV("Warning, Attribute list empty"); | 154 | if (attributes.size() == 0) ALOGV("Warning, Attribute list empty"); |
150 | } | 155 | } |
151 | 156 | ||
@@ -182,6 +187,7 @@ TEST_F(MasterHidlTest, ListNodes) { | |||
182 | nodeList = _nl; | 187 | nodeList = _nl; |
183 | }) | 188 | }) |
184 | .isOk()); | 189 | .isOk()); |
190 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | ||
185 | if (nodeList.size() == 0) | 191 | if (nodeList.size() == 0) |
186 | ALOGV("Warning, ComponentInfo list empty"); | 192 | ALOGV("Warning, ComponentInfo list empty"); |
187 | else { | 193 | else { |
@@ -200,6 +206,7 @@ TEST_F(MasterHidlTest, ListNodes) { | |||
200 | omxNode = _nl; | 206 | omxNode = _nl; |
201 | }) | 207 | }) |
202 | .isOk()); | 208 | .isOk()); |
209 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | ||
203 | if (omxNode == nullptr) { | 210 | if (omxNode == nullptr) { |
204 | isPass = false; | 211 | isPass = false; |
205 | std::cerr << "[ !OK ] " << nodeList[i].mName.c_str() | 212 | std::cerr << "[ !OK ] " << nodeList[i].mName.c_str() |
diff --git a/media/omx/1.0/vts/functional/video/Android.bp b/media/omx/1.0/vts/functional/video/Android.bp index 4e94f3b3..f0da2b39 100644 --- a/media/omx/1.0/vts/functional/video/Android.bp +++ b/media/omx/1.0/vts/functional/video/Android.bp | |||
@@ -16,70 +16,21 @@ | |||
16 | 16 | ||
17 | cc_test { | 17 | cc_test { |
18 | name: "VtsHalMediaOmxV1_0TargetVideoDecTest", | 18 | name: "VtsHalMediaOmxV1_0TargetVideoDecTest", |
19 | defaults: ["hidl_defaults"], | 19 | defaults: ["VtsHalMediaOmxV1_0Defaults"], |
20 | srcs: ["VtsHalMediaOmxV1_0TargetVideoDecTest.cpp", | 20 | srcs: [ |
21 | "media_video_hidl_test_common.cpp"], | 21 | "VtsHalMediaOmxV1_0TargetVideoDecTest.cpp", |
22 | shared_libs: [ | 22 | "media_video_hidl_test_common.cpp" |
23 | "libbase", | ||
24 | "liblog", | ||
25 | "libcutils", | ||
26 | "libhidlbase", | ||
27 | "libhidlmemory", | ||
28 | "libhidltransport", | ||
29 | "libhwbinder", | ||
30 | "libnativehelper", | ||
31 | "libutils", | ||
32 | "libstagefright_foundation", | ||
33 | "android.hidl.allocator@1.0", | ||
34 | "android.hidl.memory@1.0", | ||
35 | "android.hardware.media.omx@1.0", | ||
36 | "android.hardware.graphics.allocator@2.0", | ||
37 | "android.hardware.graphics.mapper@2.0", | ||
38 | "android.hardware.graphics.common@1.0", | ||
39 | ], | ||
40 | static_libs: ["VtsHalHidlTargetTestBase", | ||
41 | "VtsHalMediaOmxV1_0CommonUtil"], | ||
42 | cflags: [ | ||
43 | "-O0", | ||
44 | "-g", | ||
45 | ], | ||
46 | include_dirs: [ | ||
47 | "frameworks/native/include/media/openmax/", | ||
48 | "hardware/interfaces/media/omx/1.0/vts/functional/common", | ||
49 | ], | 23 | ], |
50 | } | 24 | } |
51 | 25 | ||
52 | cc_test { | 26 | cc_test { |
53 | name: "VtsHalMediaOmxV1_0TargetVideoEncTest", | 27 | name: "VtsHalMediaOmxV1_0TargetVideoEncTest", |
54 | defaults: ["hidl_defaults"], | 28 | defaults: ["VtsHalMediaOmxV1_0Defaults"], |
55 | srcs: ["VtsHalMediaOmxV1_0TargetVideoEncTest.cpp", | 29 | srcs: [ |
56 | "media_video_hidl_test_common.cpp"], | 30 | "VtsHalMediaOmxV1_0TargetVideoEncTest.cpp", |
57 | shared_libs: [ | 31 | "media_video_hidl_test_common.cpp" |
58 | "libbase", | ||
59 | "liblog", | ||
60 | "libcutils", | ||
61 | "libhidlbase", | ||
62 | "libhidlmemory", | ||
63 | "libhidltransport", | ||
64 | "libhwbinder", | ||
65 | "libnativehelper", | ||
66 | "libnativewindow", | ||
67 | "libutils", | ||
68 | "libstagefright_foundation", | ||
69 | "android.hidl.allocator@1.0", | ||
70 | "android.hidl.memory@1.0", | ||
71 | "android.hardware.media.omx@1.0", | ||
72 | "android.hardware.graphics.bufferqueue@1.0", | ||
73 | "android.hardware.graphics.mapper@2.0", | ||
74 | ], | 32 | ], |
75 | static_libs: ["VtsHalHidlTargetTestBase", | 33 | static_libs: [ |
76 | "VtsHalMediaOmxV1_0CommonUtil"], | 34 | "libnativewindow", |
77 | cflags: [ | ||
78 | "-O0", | ||
79 | "-g", | ||
80 | ], | ||
81 | include_dirs: [ | ||
82 | "frameworks/native/include/media/openmax/", | ||
83 | "hardware/interfaces/media/omx/1.0/vts/functional/common", | ||
84 | ], | 35 | ], |
85 | } | 36 | } |
diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp index 438dd707..9b74a339 100644 --- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp +++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp | |||
@@ -15,11 +15,12 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #define LOG_TAG "media_omx_hidl_video_dec_test" | 17 | #define LOG_TAG "media_omx_hidl_video_dec_test" |
18 | #ifdef __LP64__ | ||
19 | #define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS | ||
20 | #endif | ||
21 | |||
18 | #include <android-base/logging.h> | 22 | #include <android-base/logging.h> |
19 | 23 | ||
20 | #include <android/hardware/graphics/allocator/2.0/IAllocator.h> | ||
21 | #include <android/hardware/graphics/mapper/2.0/IMapper.h> | ||
22 | #include <android/hardware/graphics/mapper/2.0/types.h> | ||
23 | #include <android/hardware/media/omx/1.0/IOmx.h> | 24 | #include <android/hardware/media/omx/1.0/IOmx.h> |
24 | #include <android/hardware/media/omx/1.0/IOmxNode.h> | 25 | #include <android/hardware/media/omx/1.0/IOmxNode.h> |
25 | #include <android/hardware/media/omx/1.0/IOmxObserver.h> | 26 | #include <android/hardware/media/omx/1.0/IOmxObserver.h> |
@@ -28,8 +29,6 @@ | |||
28 | #include <android/hidl/memory/1.0/IMapper.h> | 29 | #include <android/hidl/memory/1.0/IMapper.h> |
29 | #include <android/hidl/memory/1.0/IMemory.h> | 30 | #include <android/hidl/memory/1.0/IMemory.h> |
30 | 31 | ||
31 | using ::android::hardware::graphics::common::V1_0::BufferUsage; | ||
32 | using ::android::hardware::graphics::common::V1_0::PixelFormat; | ||
33 | using ::android::hardware::media::omx::V1_0::IOmx; | 32 | using ::android::hardware::media::omx::V1_0::IOmx; |
34 | using ::android::hardware::media::omx::V1_0::IOmxObserver; | 33 | using ::android::hardware::media::omx::V1_0::IOmxObserver; |
35 | using ::android::hardware::media::omx::V1_0::IOmxNode; | 34 | using ::android::hardware::media::omx::V1_0::IOmxNode; |
@@ -47,6 +46,7 @@ using ::android::sp; | |||
47 | 46 | ||
48 | #include <VtsHalHidlTargetTestBase.h> | 47 | #include <VtsHalHidlTargetTestBase.h> |
49 | #include <getopt.h> | 48 | #include <getopt.h> |
49 | #include <media/hardware/HardwareAPI.h> | ||
50 | #include <media_hidl_test_common.h> | 50 | #include <media_hidl_test_common.h> |
51 | #include <media_video_hidl_test_common.h> | 51 | #include <media_video_hidl_test_common.h> |
52 | #include <fstream> | 52 | #include <fstream> |
@@ -166,6 +166,7 @@ class VideoDecHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
166 | this->omxNode = _nl; | 166 | this->omxNode = _nl; |
167 | }) | 167 | }) |
168 | .isOk()); | 168 | .isOk()); |
169 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
169 | ASSERT_NE(omxNode, nullptr); | 170 | ASSERT_NE(omxNode, nullptr); |
170 | ASSERT_NE(gEnv->getRole().empty(), true) << "Invalid Component Role"; | 171 | ASSERT_NE(gEnv->getRole().empty(), true) << "Invalid Component Role"; |
171 | struct StringToName { | 172 | struct StringToName { |
@@ -217,6 +218,7 @@ class VideoDecHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
217 | timestampUs = 0; | 218 | timestampUs = 0; |
218 | timestampDevTest = false; | 219 | timestampDevTest = false; |
219 | isSecure = false; | 220 | isSecure = false; |
221 | portSettingsChange = false; | ||
220 | size_t suffixLen = strlen(".secure"); | 222 | size_t suffixLen = strlen(".secure"); |
221 | if (strlen(gEnv->getComponent().c_str()) >= suffixLen) { | 223 | if (strlen(gEnv->getComponent().c_str()) >= suffixLen) { |
222 | isSecure = | 224 | isSecure = |
@@ -225,11 +227,15 @@ class VideoDecHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
225 | ".secure"); | 227 | ".secure"); |
226 | } | 228 | } |
227 | if (isSecure) disableTest = true; | 229 | if (isSecure) disableTest = true; |
228 | if (disableTest) std::cout << "[ ] Warning ! Test Disabled\n"; | 230 | if (disableTest) std::cout << "[ WARN ] Test Disabled \n"; |
229 | } | 231 | } |
230 | 232 | ||
231 | virtual void TearDown() override { | 233 | virtual void TearDown() override { |
232 | if (omxNode != nullptr) { | 234 | if (omxNode != nullptr) { |
235 | // If you have encountered a fatal failure, it is possible that | ||
236 | // freeNode() will not go through. Instead of hanging the app. | ||
237 | // let it pass through and report errors | ||
238 | if (::testing::Test::HasFatalFailure()) return; | ||
233 | EXPECT_TRUE((omxNode->freeNode()).isOk()); | 239 | EXPECT_TRUE((omxNode->freeNode()).isOk()); |
234 | omxNode = nullptr; | 240 | omxNode = nullptr; |
235 | } | 241 | } |
@@ -269,9 +275,8 @@ class VideoDecHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
269 | EXPECT_EQ(tsHit, true) | 275 | EXPECT_EQ(tsHit, true) |
270 | << "TimeStamp not recognized"; | 276 | << "TimeStamp not recognized"; |
271 | } else { | 277 | } else { |
272 | std::cout | 278 | std::cout << "[ INFO ] Received non-zero " |
273 | << "[ ] Warning ! Received non-zero " | 279 | "output / TimeStamp not recognized \n"; |
274 | "output / TimeStamp not recognized \n"; | ||
275 | } | 280 | } |
276 | } | 281 | } |
277 | } | 282 | } |
@@ -293,6 +298,13 @@ class VideoDecHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
293 | } | 298 | } |
294 | #endif | 299 | #endif |
295 | } | 300 | } |
301 | } else if (msg.type == Message::Type::EVENT) { | ||
302 | if (msg.data.eventData.event == OMX_EventPortSettingsChanged) { | ||
303 | if ((msg.data.eventData.data2 == OMX_IndexParamPortDefinition || | ||
304 | msg.data.eventData.data2 == 0)) { | ||
305 | portSettingsChange = true; | ||
306 | } | ||
307 | } | ||
296 | } | 308 | } |
297 | } | 309 | } |
298 | 310 | ||
@@ -320,6 +332,7 @@ class VideoDecHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
320 | ::android::List<uint64_t> timestampUslist; | 332 | ::android::List<uint64_t> timestampUslist; |
321 | bool timestampDevTest; | 333 | bool timestampDevTest; |
322 | bool isSecure; | 334 | bool isSecure; |
335 | bool portSettingsChange; | ||
323 | 336 | ||
324 | protected: | 337 | protected: |
325 | static void description(const std::string& description) { | 338 | static void description(const std::string& description) { |
@@ -367,119 +380,61 @@ void getInputChannelInfo(sp<IOmxNode> omxNode, OMX_U32 kPortIndexInput, | |||
367 | } | 380 | } |
368 | } | 381 | } |
369 | 382 | ||
383 | // number of elementary streams per component | ||
384 | #define STREAM_COUNT 2 | ||
370 | // LookUpTable of clips and metadata for component testing | 385 | // LookUpTable of clips and metadata for component testing |
371 | void GetURLForComponent(VideoDecHidlTest::standardComp comp, char* mURL, | 386 | void GetURLForComponent(VideoDecHidlTest::standardComp comp, char* mURL, |
372 | char* info) { | 387 | char* info, size_t streamIndex = 1) { |
373 | struct CompToURL { | 388 | struct CompToURL { |
374 | VideoDecHidlTest::standardComp comp; | 389 | VideoDecHidlTest::standardComp comp; |
375 | const char* mURL; | 390 | const char mURL[STREAM_COUNT][512]; |
376 | const char* info; | 391 | const char info[STREAM_COUNT][512]; |
377 | }; | 392 | }; |
393 | ASSERT_TRUE(streamIndex < STREAM_COUNT); | ||
394 | |||
378 | static const CompToURL kCompToURL[] = { | 395 | static const CompToURL kCompToURL[] = { |
379 | {VideoDecHidlTest::standardComp::avc, | 396 | {VideoDecHidlTest::standardComp::avc, |
380 | "bbb_avc_1920x1080_5000kbps_30fps.h264", | 397 | {"bbb_avc_176x144_300kbps_60fps.h264", |
381 | "bbb_avc_1920x1080_5000kbps_30fps.info"}, | 398 | "bbb_avc_1920x1080_5000kbps_30fps.h264"}, |
399 | {"bbb_avc_176x144_300kbps_60fps.info", | ||
400 | "bbb_avc_1920x1080_5000kbps_30fps.info"}}, | ||
382 | {VideoDecHidlTest::standardComp::hevc, | 401 | {VideoDecHidlTest::standardComp::hevc, |
383 | "bbb_hevc_640x360_1600kbps_30fps.hevc", | 402 | {"bbb_hevc_176x144_176kbps_60fps.hevc", |
384 | "bbb_hevc_640x360_1600kbps_30fps.info"}, | 403 | "bbb_hevc_640x360_1600kbps_30fps.hevc"}, |
404 | {"bbb_hevc_176x144_176kbps_60fps.info", | ||
405 | "bbb_hevc_640x360_1600kbps_30fps.info"}}, | ||
385 | {VideoDecHidlTest::standardComp::mpeg2, | 406 | {VideoDecHidlTest::standardComp::mpeg2, |
386 | "bbb_mpeg2_176x144_105kbps_25fps.m2v", | 407 | {"bbb_mpeg2_176x144_105kbps_25fps.m2v", |
387 | "bbb_mpeg2_176x144_105kbps_25fps.info"}, | 408 | "bbb_mpeg2_352x288_1mbps_60fps.m2v"}, |
409 | {"bbb_mpeg2_176x144_105kbps_25fps.info", | ||
410 | "bbb_mpeg2_352x288_1mbps_60fps.info"}}, | ||
388 | {VideoDecHidlTest::standardComp::h263, | 411 | {VideoDecHidlTest::standardComp::h263, |
389 | "bbb_h263_352x288_300kbps_12fps.h263", | 412 | {"", "bbb_h263_352x288_300kbps_12fps.h263"}, |
390 | "bbb_h263_352x288_300kbps_12fps.info"}, | 413 | {"", "bbb_h263_352x288_300kbps_12fps.info"}}, |
391 | {VideoDecHidlTest::standardComp::mpeg4, | 414 | {VideoDecHidlTest::standardComp::mpeg4, |
392 | "bbb_mpeg4_1280x720_1000kbps_25fps.m4v", | 415 | {"", "bbb_mpeg4_1280x720_1000kbps_25fps.m4v"}, |
393 | "bbb_mpeg4_1280x720_1000kbps_25fps.info"}, | 416 | {"", "bbb_mpeg4_1280x720_1000kbps_25fps.info"}}, |
394 | {VideoDecHidlTest::standardComp::vp8, "bbb_vp8_640x360_2mbps_30fps.vp8", | 417 | {VideoDecHidlTest::standardComp::vp8, |
395 | "bbb_vp8_640x360_2mbps_30fps.info"}, | 418 | {"bbb_vp8_176x144_240kbps_60fps.vp8", |
419 | "bbb_vp8_640x360_2mbps_30fps.vp8"}, | ||
420 | {"bbb_vp8_176x144_240kbps_60fps.info", | ||
421 | "bbb_vp8_640x360_2mbps_30fps.info"}}, | ||
396 | {VideoDecHidlTest::standardComp::vp9, | 422 | {VideoDecHidlTest::standardComp::vp9, |
397 | "bbb_vp9_640x360_1600kbps_30fps.vp9", | 423 | {"bbb_vp9_176x144_285kbps_60fps.vp9", |
398 | "bbb_vp9_640x360_1600kbps_30fps.info"}, | 424 | "bbb_vp9_640x360_1600kbps_30fps.vp9"}, |
425 | {"bbb_vp9_176x144_285kbps_60fps.info", | ||
426 | "bbb_vp9_640x360_1600kbps_30fps.info"}}, | ||
399 | }; | 427 | }; |
400 | 428 | ||
401 | for (size_t i = 0; i < sizeof(kCompToURL) / sizeof(kCompToURL[0]); ++i) { | 429 | for (size_t i = 0; i < sizeof(kCompToURL) / sizeof(kCompToURL[0]); ++i) { |
402 | if (kCompToURL[i].comp == comp) { | 430 | if (kCompToURL[i].comp == comp) { |
403 | strcat(mURL, kCompToURL[i].mURL); | 431 | strcat(mURL, kCompToURL[i].mURL[streamIndex]); |
404 | strcat(info, kCompToURL[i].info); | 432 | strcat(info, kCompToURL[i].info[streamIndex]); |
405 | return; | 433 | return; |
406 | } | 434 | } |
407 | } | 435 | } |
408 | } | 436 | } |
409 | 437 | ||
410 | void allocateGraphicBuffers(sp<IOmxNode> omxNode, OMX_U32 portIndex, | ||
411 | android::Vector<BufferInfo>* buffArray, | ||
412 | uint32_t nFrameWidth, uint32_t nFrameHeight, | ||
413 | int32_t* nStride, uint32_t count) { | ||
414 | android::hardware::media::omx::V1_0::Status status; | ||
415 | sp<android::hardware::graphics::allocator::V2_0::IAllocator> allocator = | ||
416 | android::hardware::graphics::allocator::V2_0::IAllocator::getService(); | ||
417 | ASSERT_NE(nullptr, allocator.get()); | ||
418 | |||
419 | sp<android::hardware::graphics::mapper::V2_0::IMapper> mapper = | ||
420 | android::hardware::graphics::mapper::V2_0::IMapper::getService(); | ||
421 | ASSERT_NE(mapper.get(), nullptr); | ||
422 | |||
423 | android::hardware::graphics::mapper::V2_0::IMapper::BufferDescriptorInfo | ||
424 | descriptorInfo; | ||
425 | uint32_t usage; | ||
426 | |||
427 | descriptorInfo.width = nFrameWidth; | ||
428 | descriptorInfo.height = nFrameHeight; | ||
429 | descriptorInfo.layerCount = 1; | ||
430 | descriptorInfo.format = PixelFormat::RGBA_8888; | ||
431 | descriptorInfo.usage = static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN); | ||
432 | omxNode->getGraphicBufferUsage( | ||
433 | portIndex, | ||
434 | [&status, &usage](android::hardware::media::omx::V1_0::Status _s, | ||
435 | uint32_t _n1) { | ||
436 | status = _s; | ||
437 | usage = _n1; | ||
438 | }); | ||
439 | if (status == android::hardware::media::omx::V1_0::Status::OK) { | ||
440 | descriptorInfo.usage |= usage; | ||
441 | } | ||
442 | |||
443 | ::android::hardware::hidl_vec<uint32_t> descriptor; | ||
444 | android::hardware::graphics::mapper::V2_0::Error error; | ||
445 | mapper->createDescriptor( | ||
446 | descriptorInfo, [&error, &descriptor]( | ||
447 | android::hardware::graphics::mapper::V2_0::Error _s, | ||
448 | ::android::hardware::hidl_vec<uint32_t> _n1) { | ||
449 | error = _s; | ||
450 | descriptor = _n1; | ||
451 | }); | ||
452 | EXPECT_EQ(error, android::hardware::graphics::mapper::V2_0::Error::NONE); | ||
453 | |||
454 | EXPECT_EQ(buffArray->size(), count); | ||
455 | allocator->allocate( | ||
456 | descriptor, count, | ||
457 | [&](android::hardware::graphics::mapper::V2_0::Error _s, uint32_t _n1, | ||
458 | const ::android::hardware::hidl_vec< | ||
459 | ::android::hardware::hidl_handle>& _n2) { | ||
460 | ASSERT_EQ(android::hardware::graphics::mapper::V2_0::Error::NONE, | ||
461 | _s); | ||
462 | *nStride = _n1; | ||
463 | ASSERT_EQ(count, _n2.size()); | ||
464 | for (uint32_t i = 0; i < count; i++) { | ||
465 | buffArray->editItemAt(i).omxBuffer.nativeHandle = _n2[i]; | ||
466 | buffArray->editItemAt(i).omxBuffer.attr.anwBuffer.width = | ||
467 | nFrameWidth; | ||
468 | buffArray->editItemAt(i).omxBuffer.attr.anwBuffer.height = | ||
469 | nFrameHeight; | ||
470 | buffArray->editItemAt(i).omxBuffer.attr.anwBuffer.stride = _n1; | ||
471 | buffArray->editItemAt(i).omxBuffer.attr.anwBuffer.format = | ||
472 | descriptorInfo.format; | ||
473 | buffArray->editItemAt(i).omxBuffer.attr.anwBuffer.usage = | ||
474 | descriptorInfo.usage; | ||
475 | buffArray->editItemAt(i).omxBuffer.attr.anwBuffer.layerCount = | ||
476 | descriptorInfo.layerCount; | ||
477 | buffArray->editItemAt(i).omxBuffer.attr.anwBuffer.id = | ||
478 | (*buffArray)[i].id; | ||
479 | } | ||
480 | }); | ||
481 | } | ||
482 | |||
483 | // port settings reconfiguration during runtime. reconfigures frame dimensions | 438 | // port settings reconfiguration during runtime. reconfigures frame dimensions |
484 | void portReconfiguration(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | 439 | void portReconfiguration(sp<IOmxNode> omxNode, sp<CodecObserver> observer, |
485 | android::Vector<BufferInfo>* iBuffer, | 440 | android::Vector<BufferInfo>* iBuffer, |
@@ -493,6 +448,21 @@ void portReconfiguration(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
493 | ASSERT_EQ(msg.data.eventData.data1, kPortIndexOutput); | 448 | ASSERT_EQ(msg.data.eventData.data1, kPortIndexOutput); |
494 | if (msg.data.eventData.data2 == OMX_IndexParamPortDefinition || | 449 | if (msg.data.eventData.data2 == OMX_IndexParamPortDefinition || |
495 | msg.data.eventData.data2 == 0) { | 450 | msg.data.eventData.data2 == 0) { |
451 | // Components can send various kinds of port settings changed events | ||
452 | // all at once. Before committing to a full port reconfiguration, | ||
453 | // defer any events waiting in the queue to be addressed to a later | ||
454 | // point. | ||
455 | android::List<Message> msgQueueDefer; | ||
456 | while (1) { | ||
457 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, | ||
458 | iBuffer, oBuffer); | ||
459 | if (status != | ||
460 | android::hardware::media::omx::V1_0::Status::TIMED_OUT) { | ||
461 | msgQueueDefer.push_back(msg); | ||
462 | continue; | ||
463 | } else | ||
464 | break; | ||
465 | } | ||
496 | status = omxNode->sendCommand( | 466 | status = omxNode->sendCommand( |
497 | toRawCommandType(OMX_CommandPortDisable), kPortIndexOutput); | 467 | toRawCommandType(OMX_CommandPortDisable), kPortIndexOutput); |
498 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); | 468 | ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK); |
@@ -521,17 +491,19 @@ void portReconfiguration(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
521 | 491 | ||
522 | // set Port Params | 492 | // set Port Params |
523 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | 493 | uint32_t nFrameWidth, nFrameHeight, xFramerate; |
524 | OMX_COLOR_FORMATTYPE eColorFormat = | ||
525 | OMX_COLOR_FormatYUV420Planar; | ||
526 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, | 494 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, |
527 | &nFrameHeight, &xFramerate); | 495 | &nFrameHeight, &xFramerate); |
496 | // get configured color format | ||
497 | OMX_PARAM_PORTDEFINITIONTYPE portDef; | ||
498 | status = getPortParam(omxNode, OMX_IndexParamPortDefinition, | ||
499 | kPortIndexOutput, &portDef); | ||
528 | setDefaultPortParam(omxNode, kPortIndexOutput, | 500 | setDefaultPortParam(omxNode, kPortIndexOutput, |
529 | OMX_VIDEO_CodingUnused, eColorFormat, | 501 | OMX_VIDEO_CodingUnused, |
502 | portDef.format.video.eColorFormat, | ||
530 | nFrameWidth, nFrameHeight, 0, xFramerate); | 503 | nFrameWidth, nFrameHeight, 0, xFramerate); |
531 | 504 | ||
532 | // If you can disable a port, then you should be able to | 505 | // If you can disable a port, then you should be able to |
533 | // enable | 506 | // enable it as well |
534 | // it as well | ||
535 | status = omxNode->sendCommand( | 507 | status = omxNode->sendCommand( |
536 | toRawCommandType(OMX_CommandPortEnable), kPortIndexOutput); | 508 | toRawCommandType(OMX_CommandPortEnable), kPortIndexOutput); |
537 | ASSERT_EQ(status, | 509 | ASSERT_EQ(status, |
@@ -544,22 +516,8 @@ void portReconfiguration(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
544 | status, | 516 | status, |
545 | android::hardware::media::omx::V1_0::Status::TIMED_OUT); | 517 | android::hardware::media::omx::V1_0::Status::TIMED_OUT); |
546 | 518 | ||
547 | allocatePortBuffers(omxNode, oBuffer, kPortIndexOutput, | 519 | ASSERT_NO_FATAL_FAILURE(allocatePortBuffers( |
548 | oPortMode); | 520 | omxNode, oBuffer, kPortIndexOutput, oPortMode, true)); |
549 | if (oPortMode != PortMode::PRESET_BYTE_BUFFER) { | ||
550 | OMX_PARAM_PORTDEFINITIONTYPE portDef; | ||
551 | |||
552 | status = getPortParam(omxNode, OMX_IndexParamPortDefinition, | ||
553 | kPortIndexOutput, &portDef); | ||
554 | ASSERT_EQ( | ||
555 | status, | ||
556 | ::android::hardware::media::omx::V1_0::Status::OK); | ||
557 | allocateGraphicBuffers(omxNode, kPortIndexOutput, oBuffer, | ||
558 | portDef.format.video.nFrameWidth, | ||
559 | portDef.format.video.nFrameHeight, | ||
560 | &portDef.format.video.nStride, | ||
561 | portDef.nBufferCountActual); | ||
562 | } | ||
563 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, | 521 | status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, |
564 | iBuffer, oBuffer); | 522 | iBuffer, oBuffer); |
565 | ASSERT_EQ(status, | 523 | ASSERT_EQ(status, |
@@ -568,25 +526,36 @@ void portReconfiguration(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
568 | ASSERT_EQ(msg.data.eventData.data1, OMX_CommandPortEnable); | 526 | ASSERT_EQ(msg.data.eventData.data1, OMX_CommandPortEnable); |
569 | ASSERT_EQ(msg.data.eventData.data2, kPortIndexOutput); | 527 | ASSERT_EQ(msg.data.eventData.data2, kPortIndexOutput); |
570 | 528 | ||
529 | // Push back deferred messages to the list | ||
530 | android::List<Message>::iterator it = msgQueueDefer.begin(); | ||
531 | while (it != msgQueueDefer.end()) { | ||
532 | status = omxNode->dispatchMessage(*it); | ||
533 | ASSERT_EQ( | ||
534 | status, | ||
535 | ::android::hardware::media::omx::V1_0::Status::OK); | ||
536 | it++; | ||
537 | } | ||
538 | |||
571 | // dispatch output buffers | 539 | // dispatch output buffers |
572 | for (size_t i = 0; i < oBuffer->size(); i++) { | 540 | for (size_t i = 0; i < oBuffer->size(); i++) { |
573 | dispatchOutputBuffer(omxNode, oBuffer, i, oPortMode); | 541 | ASSERT_NO_FATAL_FAILURE( |
542 | dispatchOutputBuffer(omxNode, oBuffer, i, oPortMode)); | ||
574 | } | 543 | } |
575 | } else { | 544 | } else { |
576 | ASSERT_TRUE(false); | 545 | ASSERT_TRUE(false); |
577 | } | 546 | } |
578 | } else if (msg.data.eventData.data2 == | 547 | } else if (msg.data.eventData.data2 == |
579 | OMX_IndexConfigCommonOutputCrop) { | 548 | OMX_IndexConfigCommonOutputCrop) { |
580 | std::cout << "[ ] Warning ! OMX_EventPortSettingsChanged/ " | 549 | std::cout << "[ INFO ] OMX_EventPortSettingsChanged/ " |
581 | "OMX_IndexConfigCommonOutputCrop not handled \n"; | 550 | "OMX_IndexConfigCommonOutputCrop not handled \n"; |
582 | } else if (msg.data.eventData.data2 == OMX_IndexVendorStartUnused + 3) { | 551 | } else if (msg.data.eventData.data2 == OMX_IndexVendorStartUnused + 3) { |
583 | std::cout << "[ ] Warning ! OMX_EventPortSettingsChanged/ " | 552 | std::cout << "[ INFO ] OMX_EventPortSettingsChanged/ " |
584 | "kDescribeColorAspectsIndex not handled \n"; | 553 | "kDescribeColorAspectsIndex not handled \n"; |
585 | } | 554 | } |
586 | } else if (msg.data.eventData.event == OMX_EventError) { | 555 | } else if (msg.data.eventData.event == OMX_EventError) { |
587 | std::cout << "[ ] Warning ! OMX_EventError/ " | 556 | std::cerr << "[ ERROR ] OMX_EventError/ " |
588 | "Decode Frame Call might be failed \n"; | 557 | "Decode Frame Call might be failed \n"; |
589 | return; | 558 | ASSERT_TRUE(false); |
590 | } else { | 559 | } else { |
591 | // something unexpected happened | 560 | // something unexpected happened |
592 | ASSERT_TRUE(false); | 561 | ASSERT_TRUE(false); |
@@ -601,17 +570,17 @@ void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
601 | PortMode oPortMode) { | 570 | PortMode oPortMode) { |
602 | android::hardware::media::omx::V1_0::Status status; | 571 | android::hardware::media::omx::V1_0::Status status; |
603 | Message msg; | 572 | Message msg; |
604 | int timeOut = TIMEOUT_COUNTER; | 573 | int timeOut = TIMEOUT_COUNTER_Q; |
605 | 574 | ||
606 | while (timeOut--) { | 575 | while (timeOut--) { |
607 | size_t i = 0; | 576 | size_t i = 0; |
608 | status = | 577 | status = |
609 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); | 578 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); |
610 | if (status == android::hardware::media::omx::V1_0::Status::OK) { | 579 | if (status == android::hardware::media::omx::V1_0::Status::OK) { |
611 | EXPECT_EQ(msg.type, Message::Type::EVENT); | 580 | ASSERT_EQ(msg.type, Message::Type::EVENT); |
612 | portReconfiguration(omxNode, observer, iBuffer, oBuffer, | 581 | ASSERT_NO_FATAL_FAILURE(portReconfiguration( |
613 | kPortIndexInput, kPortIndexOutput, msg, | 582 | omxNode, observer, iBuffer, oBuffer, kPortIndexInput, |
614 | oPortMode, nullptr); | 583 | kPortIndexOutput, msg, oPortMode, nullptr)); |
615 | } | 584 | } |
616 | // status == TIMED_OUT, it could be due to process time being large | 585 | // status == TIMED_OUT, it could be due to process time being large |
617 | // than DEFAULT_TIMEOUT or component needs output buffers to start | 586 | // than DEFAULT_TIMEOUT or component needs output buffers to start |
@@ -624,9 +593,10 @@ void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
624 | // Dispatch an output buffer assuming outQueue.empty() is true | 593 | // Dispatch an output buffer assuming outQueue.empty() is true |
625 | size_t index; | 594 | size_t index; |
626 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { | 595 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { |
627 | dispatchOutputBuffer(omxNode, oBuffer, index, oPortMode); | 596 | ASSERT_NO_FATAL_FAILURE( |
597 | dispatchOutputBuffer(omxNode, oBuffer, index, oPortMode)); | ||
598 | timeOut = TIMEOUT_COUNTER_Q; | ||
628 | } | 599 | } |
629 | timeOut--; | ||
630 | } | 600 | } |
631 | } | 601 | } |
632 | 602 | ||
@@ -640,50 +610,27 @@ void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
640 | bool signalEOS = true) { | 610 | bool signalEOS = true) { |
641 | android::hardware::media::omx::V1_0::Status status; | 611 | android::hardware::media::omx::V1_0::Status status; |
642 | Message msg; | 612 | Message msg; |
643 | 613 | size_t index; | |
644 | // dispatch output buffers | ||
645 | for (size_t i = 0; i < oBuffer->size(); i++) { | ||
646 | dispatchOutputBuffer(omxNode, oBuffer, i, oPortMode); | ||
647 | } | ||
648 | // dispatch input buffers | ||
649 | uint32_t flags = 0; | 614 | uint32_t flags = 0; |
650 | int frameID = offset; | 615 | int frameID = offset; |
651 | for (size_t i = 0; (i < iBuffer->size()) && (frameID < (int)Info->size()) && | 616 | int timeOut = TIMEOUT_COUNTER_Q; |
652 | (frameID < (offset + range)); | 617 | bool iQueued, oQueued; |
653 | i++) { | ||
654 | char* ipBuffer = static_cast<char*>( | ||
655 | static_cast<void*>((*iBuffer)[i].mMemory->getPointer())); | ||
656 | ASSERT_LE((*Info)[frameID].bytesCount, | ||
657 | static_cast<int>((*iBuffer)[i].mMemory->getSize())); | ||
658 | eleStream.read(ipBuffer, (*Info)[frameID].bytesCount); | ||
659 | ASSERT_EQ(eleStream.gcount(), (*Info)[frameID].bytesCount); | ||
660 | flags = (*Info)[frameID].flags; | ||
661 | if (signalEOS && ((frameID == (int)Info->size() - 1) || | ||
662 | (frameID == (offset + range - 1)))) | ||
663 | flags |= OMX_BUFFERFLAG_EOS; | ||
664 | dispatchInputBuffer(omxNode, iBuffer, i, (*Info)[frameID].bytesCount, | ||
665 | flags, (*Info)[frameID].timestamp); | ||
666 | frameID++; | ||
667 | } | ||
668 | 618 | ||
669 | int timeOut = TIMEOUT_COUNTER; | ||
670 | bool stall = false; | ||
671 | while (1) { | 619 | while (1) { |
620 | iQueued = oQueued = false; | ||
672 | status = | 621 | status = |
673 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); | 622 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); |
674 | |||
675 | // Port Reconfiguration | 623 | // Port Reconfiguration |
676 | if (status == android::hardware::media::omx::V1_0::Status::OK && | 624 | if (status == android::hardware::media::omx::V1_0::Status::OK && |
677 | msg.type == Message::Type::EVENT) { | 625 | msg.type == Message::Type::EVENT) { |
678 | portReconfiguration(omxNode, observer, iBuffer, oBuffer, | 626 | ASSERT_NO_FATAL_FAILURE(portReconfiguration( |
679 | kPortIndexInput, kPortIndexOutput, msg, | 627 | omxNode, observer, iBuffer, oBuffer, kPortIndexInput, |
680 | oPortMode, nullptr); | 628 | kPortIndexOutput, msg, oPortMode, nullptr)); |
681 | } | 629 | } |
682 | 630 | ||
683 | if (frameID == (int)Info->size() || frameID == (offset + range)) break; | 631 | if (frameID == (int)Info->size() || frameID == (offset + range)) break; |
684 | 632 | ||
685 | // Dispatch input buffer | 633 | // Dispatch input buffer |
686 | size_t index = 0; | ||
687 | if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) { | 634 | if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) { |
688 | char* ipBuffer = static_cast<char*>( | 635 | char* ipBuffer = static_cast<char*>( |
689 | static_cast<void*>((*iBuffer)[index].mMemory->getPointer())); | 636 | static_cast<void*>((*iBuffer)[index].mMemory->getPointer())); |
@@ -692,29 +639,146 @@ void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
692 | eleStream.read(ipBuffer, (*Info)[frameID].bytesCount); | 639 | eleStream.read(ipBuffer, (*Info)[frameID].bytesCount); |
693 | ASSERT_EQ(eleStream.gcount(), (*Info)[frameID].bytesCount); | 640 | ASSERT_EQ(eleStream.gcount(), (*Info)[frameID].bytesCount); |
694 | flags = (*Info)[frameID].flags; | 641 | flags = (*Info)[frameID].flags; |
642 | // Indicate to omx core that the buffer contains a full frame worth | ||
643 | // of data | ||
644 | flags |= OMX_BUFFERFLAG_ENDOFFRAME; | ||
645 | // Indicate the omx core that this is the last buffer it needs to | ||
646 | // process | ||
695 | if (signalEOS && ((frameID == (int)Info->size() - 1) || | 647 | if (signalEOS && ((frameID == (int)Info->size() - 1) || |
696 | (frameID == (offset + range - 1)))) | 648 | (frameID == (offset + range - 1)))) |
697 | flags |= OMX_BUFFERFLAG_EOS; | 649 | flags |= OMX_BUFFERFLAG_EOS; |
698 | dispatchInputBuffer(omxNode, iBuffer, index, | 650 | ASSERT_NO_FATAL_FAILURE(dispatchInputBuffer( |
699 | (*Info)[frameID].bytesCount, flags, | 651 | omxNode, iBuffer, index, (*Info)[frameID].bytesCount, flags, |
700 | (*Info)[frameID].timestamp); | 652 | (*Info)[frameID].timestamp)); |
701 | frameID++; | 653 | frameID++; |
702 | stall = false; | 654 | iQueued = true; |
703 | } else | 655 | } |
704 | stall = true; | 656 | // Dispatch output buffer |
705 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { | 657 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { |
706 | dispatchOutputBuffer(omxNode, oBuffer, index, oPortMode); | 658 | ASSERT_NO_FATAL_FAILURE( |
707 | stall = false; | 659 | dispatchOutputBuffer(omxNode, oBuffer, index, oPortMode)); |
708 | } else | 660 | oQueued = true; |
709 | stall = true; | 661 | } |
710 | if (stall) | 662 | // Reset Counters when either input or output buffer is dispatched |
711 | timeOut--; | 663 | if (iQueued || oQueued) |
664 | timeOut = TIMEOUT_COUNTER_Q; | ||
712 | else | 665 | else |
713 | timeOut = TIMEOUT_COUNTER; | 666 | timeOut--; |
714 | if (timeOut == 0) { | 667 | if (timeOut == 0) { |
715 | EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite"; | 668 | ASSERT_TRUE(false) << "Wait on Input/Output is found indefinite"; |
669 | } | ||
670 | } | ||
671 | } | ||
672 | |||
673 | // DescribeColorFormatParams Copy Constructor (Borrowed from OMXUtils.cpp) | ||
674 | android::DescribeColorFormatParams::DescribeColorFormatParams( | ||
675 | const android::DescribeColorFormat2Params& params) { | ||
676 | eColorFormat = params.eColorFormat; | ||
677 | nFrameWidth = params.nFrameWidth; | ||
678 | nFrameHeight = params.nFrameHeight; | ||
679 | nStride = params.nStride; | ||
680 | nSliceHeight = params.nSliceHeight; | ||
681 | bUsingNativeBuffers = params.bUsingNativeBuffers; | ||
682 | }; | ||
683 | |||
684 | bool isColorFormatFlexibleYUV(sp<IOmxNode> omxNode, | ||
685 | OMX_COLOR_FORMATTYPE eColorFormat) { | ||
686 | android::hardware::media::omx::V1_0::Status status; | ||
687 | unsigned int index = OMX_IndexMax, index2 = OMX_IndexMax; | ||
688 | omxNode->getExtensionIndex( | ||
689 | "OMX.google.android.index.describeColorFormat", | ||
690 | [&index](android::hardware::media::omx::V1_0::Status _s, | ||
691 | unsigned int _nl) { | ||
692 | if (_s == ::android::hardware::media::omx::V1_0::Status::OK) | ||
693 | index = _nl; | ||
694 | }); | ||
695 | omxNode->getExtensionIndex( | ||
696 | "OMX.google.android.index.describeColorFormat2", | ||
697 | [&index2](android::hardware::media::omx::V1_0::Status _s, | ||
698 | unsigned int _nl) { | ||
699 | if (_s == ::android::hardware::media::omx::V1_0::Status::OK) | ||
700 | index2 = _nl; | ||
701 | }); | ||
702 | |||
703 | android::DescribeColorFormat2Params describeParams; | ||
704 | describeParams.eColorFormat = eColorFormat; | ||
705 | describeParams.nFrameWidth = 128; | ||
706 | describeParams.nFrameHeight = 128; | ||
707 | describeParams.nStride = 128; | ||
708 | describeParams.nSliceHeight = 128; | ||
709 | describeParams.bUsingNativeBuffers = OMX_FALSE; | ||
710 | if (index != OMX_IndexMax) { | ||
711 | android::DescribeColorFormatParams describeParamsV1(describeParams); | ||
712 | status = getParam(omxNode, static_cast<OMX_INDEXTYPE>(index), | ||
713 | &describeParamsV1); | ||
714 | if (status == ::android::hardware::media::omx::V1_0::Status::OK) { | ||
715 | android::MediaImage& img = describeParamsV1.sMediaImage; | ||
716 | if (img.mType == android::MediaImage::MEDIA_IMAGE_TYPE_YUV) { | ||
717 | if (img.mNumPlanes == 3 && | ||
718 | img.mPlane[img.Y].mHorizSubsampling == 1 && | ||
719 | img.mPlane[img.Y].mVertSubsampling == 1) { | ||
720 | if (img.mPlane[img.U].mHorizSubsampling == 2 && | ||
721 | img.mPlane[img.U].mVertSubsampling == 2 && | ||
722 | img.mPlane[img.V].mHorizSubsampling == 2 && | ||
723 | img.mPlane[img.V].mVertSubsampling == 2) { | ||
724 | if (img.mBitDepth <= 8) { | ||
725 | return true; | ||
726 | } | ||
727 | } | ||
728 | } | ||
729 | } | ||
730 | } | ||
731 | } else if (index2 != OMX_IndexMax) { | ||
732 | status = getParam(omxNode, static_cast<OMX_INDEXTYPE>(index2), | ||
733 | &describeParams); | ||
734 | android::MediaImage2& img = describeParams.sMediaImage; | ||
735 | if (img.mType == android::MediaImage2::MEDIA_IMAGE_TYPE_YUV) { | ||
736 | if (img.mNumPlanes == 3 && | ||
737 | img.mPlane[img.Y].mHorizSubsampling == 1 && | ||
738 | img.mPlane[img.Y].mVertSubsampling == 1) { | ||
739 | if (img.mPlane[img.U].mHorizSubsampling == 2 && | ||
740 | img.mPlane[img.U].mVertSubsampling == 2 && | ||
741 | img.mPlane[img.V].mHorizSubsampling == 2 && | ||
742 | img.mPlane[img.V].mVertSubsampling == 2) { | ||
743 | if (img.mBitDepth <= 8) { | ||
744 | return true; | ||
745 | } | ||
746 | } | ||
747 | } | ||
748 | } | ||
749 | } | ||
750 | return false; | ||
751 | } | ||
752 | |||
753 | // get default color format for output port | ||
754 | void getDefaultColorFormat(sp<IOmxNode> omxNode, OMX_U32 kPortIndexOutput, | ||
755 | PortMode oPortMode, | ||
756 | OMX_COLOR_FORMATTYPE* eColorFormat) { | ||
757 | android::hardware::media::omx::V1_0::Status status; | ||
758 | OMX_VIDEO_PARAM_PORTFORMATTYPE portFormat; | ||
759 | *eColorFormat = OMX_COLOR_FormatUnused; | ||
760 | portFormat.nIndex = 0; | ||
761 | while (portFormat.nIndex < 512) { | ||
762 | status = getPortParam(omxNode, OMX_IndexParamVideoPortFormat, | ||
763 | kPortIndexOutput, &portFormat); | ||
764 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) break; | ||
765 | EXPECT_EQ(portFormat.eCompressionFormat, OMX_VIDEO_CodingUnused); | ||
766 | if (oPortMode != PortMode::PRESET_BYTE_BUFFER) { | ||
767 | *eColorFormat = portFormat.eColorFormat; | ||
768 | break; | ||
769 | } | ||
770 | if (isColorFormatFlexibleYUV(omxNode, portFormat.eColorFormat)) { | ||
771 | *eColorFormat = portFormat.eColorFormat; | ||
772 | break; | ||
773 | } | ||
774 | if (OMX_COLOR_FormatYUV420SemiPlanar == portFormat.eColorFormat || | ||
775 | OMX_COLOR_FormatYUV420Planar == portFormat.eColorFormat || | ||
776 | OMX_COLOR_FormatYUV420PackedPlanar == portFormat.eColorFormat || | ||
777 | OMX_COLOR_FormatYUV420PackedSemiPlanar == portFormat.eColorFormat) { | ||
778 | *eColorFormat = portFormat.eColorFormat; | ||
716 | break; | 779 | break; |
717 | } | 780 | } |
781 | portFormat.nIndex++; | ||
718 | } | 782 | } |
719 | } | 783 | } |
720 | 784 | ||
@@ -788,7 +852,7 @@ TEST_F(VideoDecHidlTest, DecodeTest) { | |||
788 | eleInfo >> flags; | 852 | eleInfo >> flags; |
789 | eleInfo >> timestamp; | 853 | eleInfo >> timestamp; |
790 | Info.push_back({bytesCount, flags, timestamp}); | 854 | Info.push_back({bytesCount, flags, timestamp}); |
791 | if (flags != OMX_BUFFERFLAG_CODECCONFIG) | 855 | if (timestampDevTest && (flags != OMX_BUFFERFLAG_CODECCONFIG)) |
792 | timestampUslist.push_back(timestamp); | 856 | timestampUslist.push_back(timestamp); |
793 | if (maxBytesCount < bytesCount) maxBytesCount = bytesCount; | 857 | if (maxBytesCount < bytesCount) maxBytesCount = bytesCount; |
794 | } | 858 | } |
@@ -813,58 +877,59 @@ TEST_F(VideoDecHidlTest, DecodeTest) { | |||
813 | 877 | ||
814 | // set Port Params | 878 | // set Port Params |
815 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | 879 | uint32_t nFrameWidth, nFrameHeight, xFramerate; |
816 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar; | ||
817 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, | 880 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, |
818 | &xFramerate); | 881 | &xFramerate); |
882 | // get default color format | ||
883 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; | ||
884 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | ||
885 | &eColorFormat); | ||
886 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | ||
887 | status = | ||
888 | setVideoPortFormat(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
889 | eColorFormat, xFramerate); | ||
890 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
819 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | 891 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, |
820 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); | 892 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); |
821 | 893 | ||
822 | // disabling adaptive playback. | ||
823 | omxNode->prepareForAdaptivePlayback(kPortIndexOutput, false, 1920, 1080); | ||
824 | |||
825 | android::Vector<BufferInfo> iBuffer, oBuffer; | 894 | android::Vector<BufferInfo> iBuffer, oBuffer; |
826 | 895 | ||
827 | // set state to idle | 896 | // set state to idle |
828 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 897 | ASSERT_NO_FATAL_FAILURE(changeStateLoadedtoIdle( |
829 | kPortIndexInput, kPortIndexOutput, portMode); | 898 | omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, |
899 | kPortIndexOutput, portMode, true)); | ||
830 | // set state to executing | 900 | // set state to executing |
831 | changeStateIdletoExecute(omxNode, observer); | 901 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
832 | |||
833 | if (portMode[1] != PortMode::PRESET_BYTE_BUFFER) { | ||
834 | OMX_PARAM_PORTDEFINITIONTYPE portDef; | ||
835 | |||
836 | status = getPortParam(omxNode, OMX_IndexParamPortDefinition, | ||
837 | kPortIndexOutput, &portDef); | ||
838 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
839 | allocateGraphicBuffers( | ||
840 | omxNode, kPortIndexOutput, &oBuffer, | ||
841 | portDef.format.video.nFrameWidth, portDef.format.video.nFrameHeight, | ||
842 | &portDef.format.video.nStride, portDef.nBufferCountActual); | ||
843 | } | ||
844 | 902 | ||
845 | // Port Reconfiguration | 903 | // Port Reconfiguration |
846 | eleStream.open(mURL, std::ifstream::binary); | 904 | eleStream.open(mURL, std::ifstream::binary); |
847 | ASSERT_EQ(eleStream.is_open(), true); | 905 | ASSERT_EQ(eleStream.is_open(), true); |
848 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 906 | ASSERT_NO_FATAL_FAILURE(decodeNFrames( |
849 | kPortIndexOutput, eleStream, &Info, 0, (int)Info.size(), | 907 | omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, |
850 | portMode[1]); | 908 | kPortIndexOutput, eleStream, &Info, 0, (int)Info.size(), portMode[1])); |
851 | eleStream.close(); | 909 | eleStream.close(); |
852 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, | 910 | ASSERT_NO_FATAL_FAILURE( |
853 | kPortIndexInput, kPortIndexOutput, portMode[1]); | 911 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, |
854 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, portMode, | 912 | kPortIndexInput, kPortIndexOutput, portMode[1])); |
855 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr); | 913 | ASSERT_NO_FATAL_FAILURE(testEOS( |
856 | EXPECT_EQ(timestampUslist.empty(), true); | 914 | omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, portMode, |
915 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr)); | ||
916 | if (timestampDevTest) EXPECT_EQ(timestampUslist.empty(), true); | ||
857 | // set state to idle | 917 | // set state to idle |
858 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 918 | ASSERT_NO_FATAL_FAILURE( |
919 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
859 | // set state to executing | 920 | // set state to executing |
860 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 921 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
861 | kPortIndexInput, kPortIndexOutput); | 922 | &oBuffer, kPortIndexInput, |
923 | kPortIndexOutput)); | ||
862 | } | 924 | } |
863 | 925 | ||
864 | // end of sequence test | 926 | // Test for adaptive playback support |
865 | TEST_F(VideoDecHidlTest, EOSTest_M) { | 927 | TEST_F(VideoDecHidlTest, AdaptivePlaybackTest) { |
866 | description("Test End of stream monkeying"); | 928 | description("Tests for Adaptive Playback support"); |
867 | if (disableTest) return; | 929 | if (disableTest) return; |
930 | if (!(compName == avc || compName == hevc || compName == vp8 || | ||
931 | compName == vp9 || compName == mpeg2)) | ||
932 | return; | ||
868 | android::hardware::media::omx::V1_0::Status status; | 933 | android::hardware::media::omx::V1_0::Status status; |
869 | uint32_t kPortIndexInput = 0, kPortIndexOutput = 1; | 934 | uint32_t kPortIndexInput = 0, kPortIndexOutput = 1; |
870 | status = setRole(omxNode, gEnv->getRole().c_str()); | 935 | status = setRole(omxNode, gEnv->getRole().c_str()); |
@@ -877,44 +942,199 @@ TEST_F(VideoDecHidlTest, EOSTest_M) { | |||
877 | kPortIndexOutput = kPortIndexInput + 1; | 942 | kPortIndexOutput = kPortIndexInput + 1; |
878 | } | 943 | } |
879 | 944 | ||
945 | // set port mode | ||
946 | portMode[0] = PortMode::PRESET_BYTE_BUFFER; | ||
947 | portMode[1] = PortMode::DYNAMIC_ANW_BUFFER; | ||
948 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
949 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
950 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
951 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) { | ||
952 | portMode[1] = PortMode::PRESET_BYTE_BUFFER; | ||
953 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
954 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
955 | } | ||
956 | |||
957 | // prepare for adaptive playback | ||
958 | uint32_t adaptiveMaxWidth = 320; | ||
959 | uint32_t adaptiveMaxHeight = 240; | ||
960 | status = omxNode->prepareForAdaptivePlayback( | ||
961 | kPortIndexOutput, true, adaptiveMaxWidth, adaptiveMaxHeight); | ||
962 | if (strncmp(gEnv->getComponent().c_str(), "OMX.google.", 11) == 0) { | ||
963 | // SoftOMX Decoders donot support graphic buffer modes. So for them | ||
964 | // support for adaptive play back is mandatory in Byte Buffer mode | ||
965 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
966 | } else { | ||
967 | // for vendor codecs, support for adaptive play back is optional | ||
968 | // in byte buffer mode. | ||
969 | if (portMode[1] == PortMode::PRESET_BYTE_BUFFER) return; | ||
970 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) return; | ||
971 | } | ||
972 | |||
973 | // TODO: Handle this better !!! | ||
974 | // Without the knowledge of the maximum resolution of the frame to be | ||
975 | // decoded it is not possible to choose the size of the input buffer. | ||
976 | // The value below is based on the info. files of clips in res folder. | ||
977 | status = setPortBufferSize(omxNode, kPortIndexInput, 482304); | ||
978 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
979 | |||
880 | // set Port Params | 980 | // set Port Params |
881 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | 981 | uint32_t nFrameWidth, nFrameHeight, xFramerate; |
882 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar; | ||
883 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, | 982 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, |
884 | &xFramerate); | 983 | &xFramerate); |
984 | // get default color format | ||
985 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; | ||
986 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | ||
987 | &eColorFormat); | ||
988 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | ||
989 | status = | ||
990 | setVideoPortFormat(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
991 | eColorFormat, xFramerate); | ||
992 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
885 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | 993 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, |
886 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); | 994 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); |
887 | 995 | ||
996 | android::Vector<BufferInfo> iBuffer, oBuffer; | ||
997 | |||
998 | // set state to idle | ||
999 | ASSERT_NO_FATAL_FAILURE(changeStateLoadedtoIdle( | ||
1000 | omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1001 | kPortIndexOutput, portMode, true)); | ||
1002 | // set state to executing | ||
1003 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); | ||
1004 | |||
1005 | timestampDevTest = true; | ||
1006 | uint32_t timestampOffset = 0; | ||
1007 | for (uint32_t i = 0; i < STREAM_COUNT * 2; i++) { | ||
1008 | std::ifstream eleStream, eleInfo; | ||
1009 | char mURL[512], info[512]; | ||
1010 | android::Vector<FrameData> Info; | ||
1011 | strcpy(mURL, gEnv->getRes().c_str()); | ||
1012 | strcpy(info, gEnv->getRes().c_str()); | ||
1013 | GetURLForComponent(compName, mURL, info, i % STREAM_COUNT); | ||
1014 | eleInfo.open(info); | ||
1015 | ASSERT_EQ(eleInfo.is_open(), true); | ||
1016 | int bytesCount = 0; | ||
1017 | uint32_t flags = 0; | ||
1018 | uint32_t timestamp = 0; | ||
1019 | uint32_t timestampMax = 0; | ||
1020 | while (1) { | ||
1021 | if (!(eleInfo >> bytesCount)) break; | ||
1022 | eleInfo >> flags; | ||
1023 | eleInfo >> timestamp; | ||
1024 | timestamp += timestampOffset; | ||
1025 | Info.push_back({bytesCount, flags, timestamp}); | ||
1026 | if (timestampDevTest && (flags != OMX_BUFFERFLAG_CODECCONFIG)) | ||
1027 | timestampUslist.push_back(timestamp); | ||
1028 | if (timestampMax < timestamp) timestampMax = timestamp; | ||
1029 | } | ||
1030 | timestampOffset = timestampMax; | ||
1031 | eleInfo.close(); | ||
1032 | |||
1033 | // Port Reconfiguration | ||
1034 | eleStream.open(mURL, std::ifstream::binary); | ||
1035 | ASSERT_EQ(eleStream.is_open(), true); | ||
1036 | ASSERT_NO_FATAL_FAILURE( | ||
1037 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, | ||
1038 | kPortIndexInput, kPortIndexOutput, eleStream, &Info, | ||
1039 | 0, (int)Info.size(), portMode[1], false)); | ||
1040 | eleStream.close(); | ||
1041 | |||
1042 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, | ||
1043 | &nFrameHeight, &xFramerate); | ||
1044 | if ((nFrameWidth > adaptiveMaxWidth) || | ||
1045 | (nFrameHeight > adaptiveMaxHeight)) { | ||
1046 | if (nFrameWidth > adaptiveMaxWidth) adaptiveMaxWidth = nFrameWidth; | ||
1047 | if (nFrameHeight > adaptiveMaxHeight) | ||
1048 | adaptiveMaxHeight = nFrameHeight; | ||
1049 | EXPECT_TRUE(portSettingsChange); | ||
1050 | } else { | ||
1051 | // In DynamicANW Buffer mode, its ok to do a complete | ||
1052 | // reconfiguration even if a partial reconfiguration is sufficient. | ||
1053 | if (portMode[1] != PortMode::DYNAMIC_ANW_BUFFER) | ||
1054 | EXPECT_FALSE(portSettingsChange); | ||
1055 | } | ||
1056 | portSettingsChange = false; | ||
1057 | } | ||
1058 | ASSERT_NO_FATAL_FAILURE( | ||
1059 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, | ||
1060 | kPortIndexInput, kPortIndexOutput, portMode[1])); | ||
1061 | ASSERT_NO_FATAL_FAILURE(testEOS( | ||
1062 | omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode, | ||
1063 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr)); | ||
1064 | if (timestampDevTest) EXPECT_EQ(timestampUslist.empty(), true); | ||
1065 | // set state to idle | ||
1066 | ASSERT_NO_FATAL_FAILURE( | ||
1067 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
1068 | // set state to executing | ||
1069 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, | ||
1070 | &oBuffer, kPortIndexInput, | ||
1071 | kPortIndexOutput)); | ||
1072 | } | ||
1073 | |||
1074 | // end of sequence test | ||
1075 | TEST_F(VideoDecHidlTest, EOSTest_M) { | ||
1076 | description("Test End of stream monkeying"); | ||
1077 | if (disableTest) return; | ||
1078 | android::hardware::media::omx::V1_0::Status status; | ||
1079 | uint32_t kPortIndexInput = 0, kPortIndexOutput = 1; | ||
1080 | status = setRole(omxNode, gEnv->getRole().c_str()); | ||
1081 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1082 | OMX_PORT_PARAM_TYPE params; | ||
1083 | status = getParam(omxNode, OMX_IndexParamVideoInit, ¶ms); | ||
1084 | if (status == ::android::hardware::media::omx::V1_0::Status::OK) { | ||
1085 | ASSERT_EQ(params.nPorts, 2U); | ||
1086 | kPortIndexInput = params.nStartPortNumber; | ||
1087 | kPortIndexOutput = kPortIndexInput + 1; | ||
1088 | } | ||
1089 | |||
888 | // set port mode | 1090 | // set port mode |
889 | PortMode portMode[2]; | ||
890 | portMode[0] = portMode[1] = PortMode::PRESET_BYTE_BUFFER; | ||
891 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | 1091 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); |
892 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1092 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
893 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | 1093 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); |
894 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1094 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
895 | 1095 | ||
1096 | // set Port Params | ||
1097 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | ||
1098 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, | ||
1099 | &xFramerate); | ||
1100 | // get default color format | ||
1101 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; | ||
1102 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | ||
1103 | &eColorFormat); | ||
1104 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | ||
1105 | status = | ||
1106 | setVideoPortFormat(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
1107 | eColorFormat, xFramerate); | ||
1108 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1109 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
1110 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); | ||
1111 | |||
896 | android::Vector<BufferInfo> iBuffer, oBuffer; | 1112 | android::Vector<BufferInfo> iBuffer, oBuffer; |
897 | 1113 | ||
898 | // set state to idle | 1114 | // set state to idle |
899 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 1115 | ASSERT_NO_FATAL_FAILURE(changeStateLoadedtoIdle( |
900 | kPortIndexInput, kPortIndexOutput, portMode); | 1116 | omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, |
1117 | kPortIndexOutput, portMode, true)); | ||
901 | // set state to executing | 1118 | // set state to executing |
902 | changeStateIdletoExecute(omxNode, observer); | 1119 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
903 | 1120 | ||
904 | // request EOS at the start | 1121 | // request EOS at the start |
905 | testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode, | 1122 | ASSERT_NO_FATAL_FAILURE(testEOS( |
906 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr); | 1123 | omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode, |
907 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1124 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr)); |
908 | kPortIndexOutput); | 1125 | ASSERT_NO_FATAL_FAILURE(flushPorts(omxNode, observer, &iBuffer, &oBuffer, |
1126 | kPortIndexInput, kPortIndexOutput)); | ||
909 | EXPECT_GE(framesReceived, 0U); | 1127 | EXPECT_GE(framesReceived, 0U); |
910 | framesReceived = 0; | 1128 | framesReceived = 0; |
911 | timestampUs = 0; | 1129 | timestampUs = 0; |
912 | 1130 | ||
913 | // set state to idle | 1131 | // set state to idle |
914 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1132 | ASSERT_NO_FATAL_FAILURE( |
1133 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
915 | // set state to executing | 1134 | // set state to executing |
916 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1135 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
917 | kPortIndexInput, kPortIndexOutput); | 1136 | &oBuffer, kPortIndexInput, |
1137 | kPortIndexOutput)); | ||
918 | } | 1138 | } |
919 | 1139 | ||
920 | // end of sequence test | 1140 | // end of sequence test |
@@ -967,67 +1187,75 @@ TEST_F(VideoDecHidlTest, ThumbnailTest) { | |||
967 | 1187 | ||
968 | // set Port Params | 1188 | // set Port Params |
969 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | 1189 | uint32_t nFrameWidth, nFrameHeight, xFramerate; |
970 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar; | ||
971 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, | 1190 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, |
972 | &xFramerate); | 1191 | &xFramerate); |
1192 | // get default color format | ||
1193 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; | ||
1194 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | ||
1195 | &eColorFormat); | ||
1196 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | ||
1197 | status = | ||
1198 | setVideoPortFormat(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
1199 | eColorFormat, xFramerate); | ||
1200 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
973 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | 1201 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, |
974 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); | 1202 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); |
975 | 1203 | ||
976 | // set port mode | ||
977 | PortMode portMode[2]; | ||
978 | portMode[0] = portMode[1] = PortMode::PRESET_BYTE_BUFFER; | ||
979 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
980 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
981 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
982 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
983 | |||
984 | android::Vector<BufferInfo> iBuffer, oBuffer; | 1204 | android::Vector<BufferInfo> iBuffer, oBuffer; |
985 | 1205 | ||
986 | // set state to idle | 1206 | // set state to idle |
987 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 1207 | ASSERT_NO_FATAL_FAILURE(changeStateLoadedtoIdle( |
988 | kPortIndexInput, kPortIndexOutput, portMode); | 1208 | omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, |
1209 | kPortIndexOutput, portMode, true)); | ||
989 | // set state to executing | 1210 | // set state to executing |
990 | changeStateIdletoExecute(omxNode, observer); | 1211 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
991 | 1212 | ||
992 | // request EOS for thumbnail | 1213 | // request EOS for thumbnail |
993 | size_t i = 0; | 1214 | size_t i = 0; |
994 | while (!(Info[i].flags & OMX_BUFFERFLAG_SYNCFRAME)) i++; | 1215 | while (!(Info[i].flags & OMX_BUFFERFLAG_SYNCFRAME)) i++; |
995 | eleStream.open(mURL, std::ifstream::binary); | 1216 | eleStream.open(mURL, std::ifstream::binary); |
996 | ASSERT_EQ(eleStream.is_open(), true); | 1217 | ASSERT_EQ(eleStream.is_open(), true); |
997 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1218 | ASSERT_NO_FATAL_FAILURE(decodeNFrames( |
998 | kPortIndexOutput, eleStream, &Info, 0, i + 1, portMode[1]); | 1219 | omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, |
1220 | kPortIndexOutput, eleStream, &Info, 0, i + 1, portMode[1])); | ||
999 | eleStream.close(); | 1221 | eleStream.close(); |
1000 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, | 1222 | ASSERT_NO_FATAL_FAILURE( |
1001 | kPortIndexInput, kPortIndexOutput, portMode[1]); | 1223 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, |
1002 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, portMode, | 1224 | kPortIndexInput, kPortIndexOutput, portMode[1])); |
1003 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr); | 1225 | ASSERT_NO_FATAL_FAILURE(testEOS( |
1004 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1226 | omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, portMode, |
1005 | kPortIndexOutput); | 1227 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr)); |
1228 | ASSERT_NO_FATAL_FAILURE(flushPorts(omxNode, observer, &iBuffer, &oBuffer, | ||
1229 | kPortIndexInput, kPortIndexOutput)); | ||
1006 | EXPECT_GE(framesReceived, 1U); | 1230 | EXPECT_GE(framesReceived, 1U); |
1007 | framesReceived = 0; | 1231 | framesReceived = 0; |
1008 | timestampUs = 0; | 1232 | timestampUs = 0; |
1009 | 1233 | ||
1010 | eleStream.open(mURL, std::ifstream::binary); | 1234 | eleStream.open(mURL, std::ifstream::binary); |
1011 | ASSERT_EQ(eleStream.is_open(), true); | 1235 | ASSERT_EQ(eleStream.is_open(), true); |
1012 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1236 | ASSERT_NO_FATAL_FAILURE(decodeNFrames( |
1013 | kPortIndexOutput, eleStream, &Info, 0, i + 1, portMode[1], | 1237 | omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, |
1014 | false); | 1238 | kPortIndexOutput, eleStream, &Info, 0, i + 1, portMode[1], false)); |
1015 | eleStream.close(); | 1239 | eleStream.close(); |
1016 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, | 1240 | ASSERT_NO_FATAL_FAILURE( |
1017 | kPortIndexInput, kPortIndexOutput, portMode[1]); | 1241 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, |
1018 | testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode, | 1242 | kPortIndexInput, kPortIndexOutput, portMode[1])); |
1019 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr); | 1243 | ASSERT_NO_FATAL_FAILURE(testEOS( |
1020 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1244 | omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode, |
1021 | kPortIndexOutput); | 1245 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr)); |
1246 | ASSERT_NO_FATAL_FAILURE(flushPorts(omxNode, observer, &iBuffer, &oBuffer, | ||
1247 | kPortIndexInput, kPortIndexOutput)); | ||
1022 | EXPECT_GE(framesReceived, 1U); | 1248 | EXPECT_GE(framesReceived, 1U); |
1023 | framesReceived = 0; | 1249 | framesReceived = 0; |
1024 | timestampUs = 0; | 1250 | timestampUs = 0; |
1025 | 1251 | ||
1026 | // set state to idle | 1252 | // set state to idle |
1027 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1253 | ASSERT_NO_FATAL_FAILURE( |
1254 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
1028 | // set state to executing | 1255 | // set state to executing |
1029 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1256 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
1030 | kPortIndexInput, kPortIndexOutput); | 1257 | &oBuffer, kPortIndexInput, |
1258 | kPortIndexOutput)); | ||
1031 | } | 1259 | } |
1032 | 1260 | ||
1033 | // end of sequence test | 1261 | // end of sequence test |
@@ -1073,56 +1301,68 @@ TEST_F(VideoDecHidlTest, SimpleEOSTest) { | |||
1073 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1301 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1074 | 1302 | ||
1075 | // set port mode | 1303 | // set port mode |
1304 | portMode[0] = PortMode::PRESET_BYTE_BUFFER; | ||
1305 | portMode[1] = PortMode::PRESET_ANW_BUFFER; | ||
1076 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | 1306 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); |
1077 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1307 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1078 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | 1308 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); |
1079 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1309 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) { |
1310 | portMode[1] = PortMode::PRESET_BYTE_BUFFER; | ||
1311 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
1312 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1313 | } | ||
1080 | 1314 | ||
1081 | // set Port Params | 1315 | // set Port Params |
1082 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | 1316 | uint32_t nFrameWidth, nFrameHeight, xFramerate; |
1083 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar; | ||
1084 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, | 1317 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, |
1085 | &xFramerate); | 1318 | &xFramerate); |
1319 | // get default color format | ||
1320 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; | ||
1321 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | ||
1322 | &eColorFormat); | ||
1323 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | ||
1324 | status = | ||
1325 | setVideoPortFormat(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
1326 | eColorFormat, xFramerate); | ||
1327 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1086 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | 1328 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, |
1087 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); | 1329 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); |
1088 | 1330 | ||
1089 | // set port mode | ||
1090 | PortMode portMode[2]; | ||
1091 | portMode[0] = portMode[1] = PortMode::PRESET_BYTE_BUFFER; | ||
1092 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
1093 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1094 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
1095 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1096 | |||
1097 | android::Vector<BufferInfo> iBuffer, oBuffer; | 1331 | android::Vector<BufferInfo> iBuffer, oBuffer; |
1098 | 1332 | ||
1099 | // set state to idle | 1333 | // set state to idle |
1100 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 1334 | ASSERT_NO_FATAL_FAILURE(changeStateLoadedtoIdle( |
1101 | kPortIndexInput, kPortIndexOutput, portMode); | 1335 | omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, |
1336 | kPortIndexOutput, portMode, true)); | ||
1102 | // set state to executing | 1337 | // set state to executing |
1103 | changeStateIdletoExecute(omxNode, observer); | 1338 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
1104 | 1339 | ||
1105 | // request EOS at the end | 1340 | // request EOS at the end |
1106 | eleStream.open(mURL, std::ifstream::binary); | 1341 | eleStream.open(mURL, std::ifstream::binary); |
1107 | ASSERT_EQ(eleStream.is_open(), true); | 1342 | ASSERT_EQ(eleStream.is_open(), true); |
1108 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1343 | ASSERT_NO_FATAL_FAILURE(decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, |
1109 | kPortIndexOutput, eleStream, &Info, 0, (int)Info.size(), | 1344 | kPortIndexInput, kPortIndexOutput, |
1110 | portMode[1], false); | 1345 | eleStream, &Info, 0, (int)Info.size(), |
1346 | portMode[1], false)); | ||
1111 | eleStream.close(); | 1347 | eleStream.close(); |
1112 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, | 1348 | ASSERT_NO_FATAL_FAILURE( |
1113 | kPortIndexInput, kPortIndexOutput, portMode[1]); | 1349 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, |
1114 | testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode, | 1350 | kPortIndexInput, kPortIndexOutput, portMode[1])); |
1115 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr); | 1351 | ASSERT_NO_FATAL_FAILURE(testEOS( |
1116 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1352 | omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode, |
1117 | kPortIndexOutput); | 1353 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr)); |
1354 | ASSERT_NO_FATAL_FAILURE(flushPorts(omxNode, observer, &iBuffer, &oBuffer, | ||
1355 | kPortIndexInput, kPortIndexOutput)); | ||
1118 | framesReceived = 0; | 1356 | framesReceived = 0; |
1119 | timestampUs = 0; | 1357 | timestampUs = 0; |
1120 | 1358 | ||
1121 | // set state to idle | 1359 | // set state to idle |
1122 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1360 | ASSERT_NO_FATAL_FAILURE( |
1361 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
1123 | // set state to executing | 1362 | // set state to executing |
1124 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1363 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
1125 | kPortIndexInput, kPortIndexOutput); | 1364 | &oBuffer, kPortIndexInput, |
1365 | kPortIndexOutput)); | ||
1126 | } | 1366 | } |
1127 | 1367 | ||
1128 | // test input/output port flush | 1368 | // test input/output port flush |
@@ -1175,27 +1415,28 @@ TEST_F(VideoDecHidlTest, FlushTest) { | |||
1175 | 1415 | ||
1176 | // set Port Params | 1416 | // set Port Params |
1177 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | 1417 | uint32_t nFrameWidth, nFrameHeight, xFramerate; |
1178 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar; | ||
1179 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, | 1418 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, |
1180 | &xFramerate); | 1419 | &xFramerate); |
1420 | // get default color format | ||
1421 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; | ||
1422 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | ||
1423 | &eColorFormat); | ||
1424 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | ||
1425 | status = | ||
1426 | setVideoPortFormat(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
1427 | eColorFormat, xFramerate); | ||
1428 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1181 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | 1429 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, |
1182 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); | 1430 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); |
1183 | 1431 | ||
1184 | // set port mode | ||
1185 | PortMode portMode[2]; | ||
1186 | portMode[0] = portMode[1] = PortMode::PRESET_BYTE_BUFFER; | ||
1187 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
1188 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1189 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
1190 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1191 | |||
1192 | android::Vector<BufferInfo> iBuffer, oBuffer; | 1432 | android::Vector<BufferInfo> iBuffer, oBuffer; |
1193 | 1433 | ||
1194 | // set state to idle | 1434 | // set state to idle |
1195 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 1435 | ASSERT_NO_FATAL_FAILURE(changeStateLoadedtoIdle( |
1196 | kPortIndexInput, kPortIndexOutput, portMode); | 1436 | omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, |
1437 | kPortIndexOutput, portMode, true)); | ||
1197 | // set state to executing | 1438 | // set state to executing |
1198 | changeStateIdletoExecute(omxNode, observer); | 1439 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
1199 | 1440 | ||
1200 | // Decode 128 frames and flush. here 128 is chosen to ensure there is a key | 1441 | // Decode 128 frames and flush. here 128 is chosen to ensure there is a key |
1201 | // frame after this so that the below section can be convered for all | 1442 | // frame after this so that the below section can be convered for all |
@@ -1203,12 +1444,11 @@ TEST_F(VideoDecHidlTest, FlushTest) { | |||
1203 | int nFrames = 128; | 1444 | int nFrames = 128; |
1204 | eleStream.open(mURL, std::ifstream::binary); | 1445 | eleStream.open(mURL, std::ifstream::binary); |
1205 | ASSERT_EQ(eleStream.is_open(), true); | 1446 | ASSERT_EQ(eleStream.is_open(), true); |
1206 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1447 | ASSERT_NO_FATAL_FAILURE(decodeNFrames( |
1207 | kPortIndexOutput, eleStream, &Info, 0, nFrames, portMode[1], | 1448 | omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, |
1208 | false); | 1449 | kPortIndexOutput, eleStream, &Info, 0, nFrames, portMode[1], false)); |
1209 | // Note: Assumes 200 ms is enough to end any decode call that started | 1450 | ASSERT_NO_FATAL_FAILURE(flushPorts(omxNode, observer, &iBuffer, &oBuffer, |
1210 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1451 | kPortIndexInput, kPortIndexOutput)); |
1211 | kPortIndexOutput, 200000); | ||
1212 | framesReceived = 0; | 1452 | framesReceived = 0; |
1213 | 1453 | ||
1214 | // Seek to next key frame and start decoding till the end | 1454 | // Seek to next key frame and start decoding till the end |
@@ -1225,21 +1465,23 @@ TEST_F(VideoDecHidlTest, FlushTest) { | |||
1225 | index++; | 1465 | index++; |
1226 | } | 1466 | } |
1227 | if (keyFrame) { | 1467 | if (keyFrame) { |
1228 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1468 | ASSERT_NO_FATAL_FAILURE( |
1229 | kPortIndexOutput, eleStream, &Info, index, | 1469 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, |
1230 | Info.size() - index, portMode[1], false); | 1470 | kPortIndexInput, kPortIndexOutput, eleStream, &Info, |
1471 | index, Info.size() - index, portMode[1], false)); | ||
1231 | } | 1472 | } |
1232 | // Note: Assumes 200 ms is enough to end any decode call that started | ||
1233 | eleStream.close(); | 1473 | eleStream.close(); |
1234 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1474 | ASSERT_NO_FATAL_FAILURE(flushPorts(omxNode, observer, &iBuffer, &oBuffer, |
1235 | kPortIndexOutput, 200000); | 1475 | kPortIndexInput, kPortIndexOutput)); |
1236 | framesReceived = 0; | 1476 | framesReceived = 0; |
1237 | 1477 | ||
1238 | // set state to idle | 1478 | // set state to idle |
1239 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1479 | ASSERT_NO_FATAL_FAILURE( |
1480 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
1240 | // set state to executing | 1481 | // set state to executing |
1241 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1482 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
1242 | kPortIndexInput, kPortIndexOutput); | 1483 | &oBuffer, kPortIndexInput, |
1484 | kPortIndexOutput)); | ||
1243 | } | 1485 | } |
1244 | 1486 | ||
1245 | int main(int argc, char** argv) { | 1487 | int main(int argc, char** argv) { |
diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp index 7f9486d9..099658f8 100644 --- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp +++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp | |||
@@ -179,6 +179,7 @@ class VideoEncHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
179 | this->omxNode = _nl; | 179 | this->omxNode = _nl; |
180 | }) | 180 | }) |
181 | .isOk()); | 181 | .isOk()); |
182 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
182 | ASSERT_NE(omxNode, nullptr); | 183 | ASSERT_NE(omxNode, nullptr); |
183 | ASSERT_NE(gEnv->getRole().empty(), true) << "Invalid Component Role"; | 184 | ASSERT_NE(gEnv->getRole().empty(), true) << "Invalid Component Role"; |
184 | struct StringToName { | 185 | struct StringToName { |
@@ -237,11 +238,15 @@ class VideoEncHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
237 | ".secure"); | 238 | ".secure"); |
238 | } | 239 | } |
239 | if (isSecure) disableTest = true; | 240 | if (isSecure) disableTest = true; |
240 | if (disableTest) std::cerr << "[ ] Warning ! Test Disabled\n"; | 241 | if (disableTest) std::cout << "[ WARN ] Test Disabled \n"; |
241 | } | 242 | } |
242 | 243 | ||
243 | virtual void TearDown() override { | 244 | virtual void TearDown() override { |
244 | if (omxNode != nullptr) { | 245 | if (omxNode != nullptr) { |
246 | // If you have encountered a fatal failure, it is possible that | ||
247 | // freeNode() will not go through. Instead of hanging the app. | ||
248 | // let it pass through and report errors | ||
249 | if (::testing::Test::HasFatalFailure()) return; | ||
245 | EXPECT_TRUE((omxNode->freeNode()).isOk()); | 250 | EXPECT_TRUE((omxNode->freeNode()).isOk()); |
246 | omxNode = nullptr; | 251 | omxNode = nullptr; |
247 | } | 252 | } |
@@ -278,9 +283,8 @@ class VideoEncHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
278 | EXPECT_EQ(tsHit, true) | 283 | EXPECT_EQ(tsHit, true) |
279 | << "TimeStamp not recognized"; | 284 | << "TimeStamp not recognized"; |
280 | } else { | 285 | } else { |
281 | std::cerr | 286 | std::cout << "[ INFO ] Received non-zero " |
282 | << "[ ] Warning ! Received non-zero " | 287 | "output / TimeStamp not recognized \n"; |
283 | "output / TimeStamp not recognized \n"; | ||
284 | } | 288 | } |
285 | } | 289 | } |
286 | } | 290 | } |
@@ -442,7 +446,7 @@ void requestIDR(sp<IOmxNode> omxNode, OMX_U32 portIndex) { | |||
442 | status = setPortConfig(omxNode, OMX_IndexConfigVideoIntraVOPRefresh, | 446 | status = setPortConfig(omxNode, OMX_IndexConfigVideoIntraVOPRefresh, |
443 | portIndex, ¶m); | 447 | portIndex, ¶m); |
444 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) | 448 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) |
445 | std::cerr << "[ ] Warning ! unable to request IDR \n"; | 449 | std::cout << "[ INFO ] unable to request IDR \n"; |
446 | } | 450 | } |
447 | 451 | ||
448 | // modify bitrate | 452 | // modify bitrate |
@@ -453,7 +457,7 @@ void changeBitrate(sp<IOmxNode> omxNode, OMX_U32 portIndex, uint32_t nBitrate) { | |||
453 | status = | 457 | status = |
454 | setPortConfig(omxNode, OMX_IndexConfigVideoBitrate, portIndex, ¶m); | 458 | setPortConfig(omxNode, OMX_IndexConfigVideoBitrate, portIndex, ¶m); |
455 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) | 459 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) |
456 | std::cerr << "[ ] Warning ! unable to change Bitrate \n"; | 460 | std::cout << "[ INFO ] unable to change Bitrate \n"; |
457 | } | 461 | } |
458 | 462 | ||
459 | // modify framerate | 463 | // modify framerate |
@@ -465,7 +469,7 @@ Return<android::hardware::media::omx::V1_0::Status> changeFrameRate( | |||
465 | status = setPortConfig(omxNode, OMX_IndexConfigVideoFramerate, portIndex, | 469 | status = setPortConfig(omxNode, OMX_IndexConfigVideoFramerate, portIndex, |
466 | ¶m); | 470 | ¶m); |
467 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) | 471 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) |
468 | std::cerr << "[ ] Warning ! unable to change Framerate \n"; | 472 | std::cout << "[ INFO ] unable to change Framerate \n"; |
469 | return status; | 473 | return status; |
470 | } | 474 | } |
471 | 475 | ||
@@ -479,7 +483,7 @@ void changeRefreshPeriod(sp<IOmxNode> omxNode, OMX_U32 portIndex, | |||
479 | (OMX_INDEXTYPE)OMX_IndexConfigAndroidIntraRefresh, | 483 | (OMX_INDEXTYPE)OMX_IndexConfigAndroidIntraRefresh, |
480 | portIndex, ¶m); | 484 | portIndex, ¶m); |
481 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) | 485 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) |
482 | std::cerr << "[ ] Warning ! unable to change Refresh Period\n"; | 486 | std::cout << "[ INFO ] unable to change Refresh Period\n"; |
483 | } | 487 | } |
484 | 488 | ||
485 | // set intra refresh interval | 489 | // set intra refresh interval |
@@ -505,7 +509,7 @@ void setRefreshPeriod(sp<IOmxNode> omxNode, OMX_U32 portIndex, | |||
505 | status = setPortParam(omxNode, OMX_IndexParamVideoIntraRefresh, portIndex, | 509 | status = setPortParam(omxNode, OMX_IndexParamVideoIntraRefresh, portIndex, |
506 | ¶m); | 510 | ¶m); |
507 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) | 511 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) |
508 | std::cerr << "[ ] Warning ! unable to set Refresh Period \n"; | 512 | std::cout << "[ INFO ] unable to set Refresh Period \n"; |
509 | } | 513 | } |
510 | 514 | ||
511 | void setLatency(sp<IOmxNode> omxNode, OMX_U32 portIndex, uint32_t latency) { | 515 | void setLatency(sp<IOmxNode> omxNode, OMX_U32 portIndex, uint32_t latency) { |
@@ -515,7 +519,7 @@ void setLatency(sp<IOmxNode> omxNode, OMX_U32 portIndex, uint32_t latency) { | |||
515 | status = setPortConfig(omxNode, (OMX_INDEXTYPE)OMX_IndexConfigLatency, | 519 | status = setPortConfig(omxNode, (OMX_INDEXTYPE)OMX_IndexConfigLatency, |
516 | portIndex, ¶m); | 520 | portIndex, ¶m); |
517 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) | 521 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) |
518 | std::cerr << "[ ] Warning ! unable to set latency\n"; | 522 | std::cout << "[ INFO ] unable to set latency\n"; |
519 | } | 523 | } |
520 | 524 | ||
521 | void getLatency(sp<IOmxNode> omxNode, OMX_U32 portIndex, uint32_t* latency) { | 525 | void getLatency(sp<IOmxNode> omxNode, OMX_U32 portIndex, uint32_t* latency) { |
@@ -524,7 +528,7 @@ void getLatency(sp<IOmxNode> omxNode, OMX_U32 portIndex, uint32_t* latency) { | |||
524 | status = getPortConfig(omxNode, (OMX_INDEXTYPE)OMX_IndexConfigLatency, | 528 | status = getPortConfig(omxNode, (OMX_INDEXTYPE)OMX_IndexConfigLatency, |
525 | portIndex, ¶m); | 529 | portIndex, ¶m); |
526 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) | 530 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) |
527 | std::cerr << "[ ] Warning ! unable to get latency\n"; | 531 | std::cout << "[ INFO ] unable to get latency\n"; |
528 | else | 532 | else |
529 | *latency = param.nU32; | 533 | *latency = param.nU32; |
530 | } | 534 | } |
@@ -532,12 +536,15 @@ void getLatency(sp<IOmxNode> omxNode, OMX_U32 portIndex, uint32_t* latency) { | |||
532 | // Set Default port param. | 536 | // Set Default port param. |
533 | void setDefaultPortParam(sp<IOmxNode> omxNode, OMX_U32 portIndex, | 537 | void setDefaultPortParam(sp<IOmxNode> omxNode, OMX_U32 portIndex, |
534 | OMX_VIDEO_CODINGTYPE eCompressionFormat, | 538 | OMX_VIDEO_CODINGTYPE eCompressionFormat, |
539 | OMX_U32 nFrameWidth, OMX_U32 nFrameHeight, | ||
535 | OMX_U32 nBitrate, OMX_U32 xFramerate) { | 540 | OMX_U32 nBitrate, OMX_U32 xFramerate) { |
536 | android::hardware::media::omx::V1_0::Status status; | 541 | android::hardware::media::omx::V1_0::Status status; |
537 | OMX_PARAM_PORTDEFINITIONTYPE portDef; | 542 | OMX_PARAM_PORTDEFINITIONTYPE portDef; |
538 | status = getPortParam(omxNode, OMX_IndexParamPortDefinition, portIndex, | 543 | status = getPortParam(omxNode, OMX_IndexParamPortDefinition, portIndex, |
539 | &portDef); | 544 | &portDef); |
540 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 545 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
546 | portDef.format.video.nFrameWidth = nFrameWidth; | ||
547 | portDef.format.video.nFrameHeight = nFrameHeight; | ||
541 | portDef.format.video.nBitrate = nBitrate; | 548 | portDef.format.video.nBitrate = nBitrate; |
542 | portDef.format.video.xFramerate = xFramerate; | 549 | portDef.format.video.xFramerate = xFramerate; |
543 | portDef.format.video.bFlagErrorConcealment = OMX_TRUE; | 550 | portDef.format.video.bFlagErrorConcealment = OMX_TRUE; |
@@ -609,13 +616,13 @@ void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
609 | sp<CodecProducerListener> listener = nullptr) { | 616 | sp<CodecProducerListener> listener = nullptr) { |
610 | android::hardware::media::omx::V1_0::Status status; | 617 | android::hardware::media::omx::V1_0::Status status; |
611 | Message msg; | 618 | Message msg; |
612 | int timeOut = TIMEOUT_COUNTER; | 619 | int timeOut = TIMEOUT_COUNTER_Q; |
613 | 620 | ||
614 | while (timeOut--) { | 621 | while (timeOut--) { |
615 | size_t i = 0; | 622 | size_t i = 0; |
616 | status = | 623 | status = |
617 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); | 624 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); |
618 | EXPECT_EQ(status, | 625 | ASSERT_EQ(status, |
619 | android::hardware::media::omx::V1_0::Status::TIMED_OUT); | 626 | android::hardware::media::omx::V1_0::Status::TIMED_OUT); |
620 | // status == TIMED_OUT, it could be due to process time being large | 627 | // status == TIMED_OUT, it could be due to process time being large |
621 | // than DEFAULT_TIMEOUT or component needs output buffers to start | 628 | // than DEFAULT_TIMEOUT or component needs output buffers to start |
@@ -632,7 +639,9 @@ void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
632 | // Dispatch an output buffer assuming outQueue.empty() is true | 639 | // Dispatch an output buffer assuming outQueue.empty() is true |
633 | size_t index; | 640 | size_t index; |
634 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { | 641 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { |
635 | dispatchOutputBuffer(omxNode, oBuffer, index); | 642 | ASSERT_NO_FATAL_FAILURE( |
643 | dispatchOutputBuffer(omxNode, oBuffer, index)); | ||
644 | timeOut = TIMEOUT_COUNTER_Q; | ||
636 | } | 645 | } |
637 | } | 646 | } |
638 | } | 647 | } |
@@ -979,57 +988,25 @@ void encodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
979 | sp<CodecProducerListener> listener = nullptr) { | 988 | sp<CodecProducerListener> listener = nullptr) { |
980 | android::hardware::media::omx::V1_0::Status status; | 989 | android::hardware::media::omx::V1_0::Status status; |
981 | Message msg; | 990 | Message msg; |
982 | uint32_t ipCount = 0; | 991 | uint64_t timestamp = 0; |
992 | uint32_t flags = 0; | ||
993 | int timeOut = TIMEOUT_COUNTER_Q; | ||
994 | bool iQueued, oQueued; | ||
983 | 995 | ||
996 | uint32_t ipCount = 0; | ||
984 | if (ipCount == 0) { | 997 | if (ipCount == 0) { |
985 | status = changeFrameRate(omxNode, portIndexOutput, (24U << 16)); | 998 | status = changeFrameRate(omxNode, portIndexOutput, (24U << 16)); |
986 | if (status == ::android::hardware::media::omx::V1_0::Status::OK) | 999 | if (status == ::android::hardware::media::omx::V1_0::Status::OK) |
987 | xFramerate = (24U << 16); | 1000 | xFramerate = (24U << 16); |
988 | } | 1001 | } |
989 | |||
990 | // dispatch output buffers | ||
991 | for (size_t i = 0; i < oBuffer->size(); i++) { | ||
992 | dispatchOutputBuffer(omxNode, oBuffer, i); | ||
993 | } | ||
994 | // dispatch input buffers | ||
995 | int32_t timestampIncr = (int)((float)1000000 / (xFramerate >> 16)); | 1002 | int32_t timestampIncr = (int)((float)1000000 / (xFramerate >> 16)); |
996 | // timestamp scale = Nano sec | 1003 | if (inputDataIsMeta) timestampIncr *= 1000; // timestamp scale: Nano sec |
997 | if (inputDataIsMeta) timestampIncr *= 1000; | ||
998 | uint64_t timestamp = 0; | ||
999 | uint32_t flags = 0; | ||
1000 | for (size_t i = 0; i < iBuffer->size() && nFrames != 0; i++) { | ||
1001 | if (inputDataIsMeta) { | ||
1002 | if (listener->freeBuffers > listener->minUnDequeuedCount) { | ||
1003 | if (dispatchGraphicBuffer(omxNode, producer, listener, iBuffer, | ||
1004 | portIndexInput, eleStream, timestamp)) | ||
1005 | break; | ||
1006 | timestamp += timestampIncr; | ||
1007 | nFrames--; | ||
1008 | ipCount++; | ||
1009 | } | ||
1010 | } else { | ||
1011 | char* ipBuffer = static_cast<char*>( | ||
1012 | static_cast<void*>((*iBuffer)[i].mMemory->getPointer())); | ||
1013 | ASSERT_LE(bytesCount, | ||
1014 | static_cast<int>((*iBuffer)[i].mMemory->getSize())); | ||
1015 | if (fillByteBuffer(omxNode, ipBuffer, portIndexInput, eleStream)) | ||
1016 | break; | ||
1017 | if (signalEOS && (nFrames == 1)) flags = OMX_BUFFERFLAG_EOS; | ||
1018 | dispatchInputBuffer(omxNode, iBuffer, i, bytesCount, flags, | ||
1019 | timestamp); | ||
1020 | if (timestampUslist) timestampUslist->push_back(timestamp); | ||
1021 | timestamp += timestampIncr; | ||
1022 | nFrames--; | ||
1023 | ipCount++; | ||
1024 | } | ||
1025 | } | ||
1026 | 1004 | ||
1027 | int timeOut = TIMEOUT_COUNTER; | ||
1028 | bool stall = false; | ||
1029 | while (1) { | 1005 | while (1) { |
1006 | iQueued = oQueued = false; | ||
1030 | status = | 1007 | status = |
1031 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); | 1008 | observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); |
1032 | 1009 | // Port Reconfiguration | |
1033 | if (status == android::hardware::media::omx::V1_0::Status::OK) { | 1010 | if (status == android::hardware::media::omx::V1_0::Status::OK) { |
1034 | ASSERT_EQ(msg.type, Message::Type::EVENT); | 1011 | ASSERT_EQ(msg.type, Message::Type::EVENT); |
1035 | if (msg.data.eventData.event == OMX_EventPortSettingsChanged) { | 1012 | if (msg.data.eventData.event == OMX_EventPortSettingsChanged) { |
@@ -1037,8 +1014,10 @@ void encodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
1037 | ASSERT_EQ(msg.data.eventData.data2, | 1014 | ASSERT_EQ(msg.data.eventData.data2, |
1038 | OMX_IndexConfigAndroidIntraRefresh); | 1015 | OMX_IndexConfigAndroidIntraRefresh); |
1039 | } else if (msg.data.eventData.event == OMX_EventError) { | 1016 | } else if (msg.data.eventData.event == OMX_EventError) { |
1040 | EXPECT_TRUE(false) << "Received OMX_EventError, not sure why"; | 1017 | ASSERT_TRUE(false) << "Received OMX_EventError, not sure why"; |
1041 | break; | 1018 | } else if (msg.data.eventData.event == OMX_EventDataSpaceChanged) { |
1019 | // TODO: how am i supposed to respond now? | ||
1020 | std::cout << "[ INFO ] OMX_EventDataSpaceChanged \n"; | ||
1042 | } else { | 1021 | } else { |
1043 | ASSERT_TRUE(false); | 1022 | ASSERT_TRUE(false); |
1044 | } | 1023 | } |
@@ -1051,14 +1030,17 @@ void encodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
1051 | if (inputDataIsMeta) { | 1030 | if (inputDataIsMeta) { |
1052 | if (listener->freeBuffers > listener->minUnDequeuedCount) { | 1031 | if (listener->freeBuffers > listener->minUnDequeuedCount) { |
1053 | if (dispatchGraphicBuffer(omxNode, producer, listener, iBuffer, | 1032 | if (dispatchGraphicBuffer(omxNode, producer, listener, iBuffer, |
1054 | portIndexInput, eleStream, timestamp)) | 1033 | portIndexInput, eleStream, |
1055 | break; | 1034 | timestamp)) { |
1035 | if (::testing::Test::HasFailure()) | ||
1036 | ASSERT_TRUE(false); | ||
1037 | else | ||
1038 | break; | ||
1039 | } | ||
1056 | timestamp += timestampIncr; | 1040 | timestamp += timestampIncr; |
1057 | nFrames--; | 1041 | nFrames--; |
1058 | ipCount++; | 1042 | ipCount++; |
1059 | stall = false; | 1043 | iQueued = true; |
1060 | } else { | ||
1061 | stall = true; | ||
1062 | } | 1044 | } |
1063 | } else { | 1045 | } else { |
1064 | if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) { | 1046 | if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) { |
@@ -1070,31 +1052,32 @@ void encodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer, | |||
1070 | if (fillByteBuffer(omxNode, ipBuffer, portIndexInput, | 1052 | if (fillByteBuffer(omxNode, ipBuffer, portIndexInput, |
1071 | eleStream)) | 1053 | eleStream)) |
1072 | break; | 1054 | break; |
1073 | if (signalEOS && (nFrames == 1)) flags = OMX_BUFFERFLAG_EOS; | 1055 | flags = OMX_BUFFERFLAG_ENDOFFRAME; |
1074 | dispatchInputBuffer(omxNode, iBuffer, index, bytesCount, flags, | 1056 | if (signalEOS && (nFrames == 1)) flags |= OMX_BUFFERFLAG_EOS; |
1075 | timestamp); | 1057 | ASSERT_NO_FATAL_FAILURE(dispatchInputBuffer( |
1058 | omxNode, iBuffer, index, bytesCount, flags, timestamp)); | ||
1076 | if (timestampUslist) timestampUslist->push_back(timestamp); | 1059 | if (timestampUslist) timestampUslist->push_back(timestamp); |
1077 | timestamp += timestampIncr; | 1060 | timestamp += timestampIncr; |
1078 | nFrames--; | 1061 | nFrames--; |
1079 | ipCount++; | 1062 | ipCount++; |
1080 | stall = false; | 1063 | iQueued = true; |
1081 | } else { | ||
1082 | stall = true; | ||
1083 | } | 1064 | } |
1084 | } | 1065 | } |
1066 | // Dispatch output buffer | ||
1085 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { | 1067 | if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { |
1086 | dispatchOutputBuffer(omxNode, oBuffer, index); | 1068 | ASSERT_NO_FATAL_FAILURE( |
1087 | stall = false; | 1069 | dispatchOutputBuffer(omxNode, oBuffer, index)); |
1088 | } else | 1070 | oQueued = true; |
1089 | stall = true; | 1071 | } |
1090 | if (stall) | 1072 | // Reset Counters when either input or output buffer is dispatched |
1091 | timeOut--; | 1073 | if (iQueued || oQueued) |
1074 | timeOut = TIMEOUT_COUNTER_Q; | ||
1092 | else | 1075 | else |
1093 | timeOut = TIMEOUT_COUNTER; | 1076 | timeOut--; |
1094 | if (timeOut == 0) { | 1077 | if (timeOut == 0) { |
1095 | EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite"; | 1078 | ASSERT_TRUE(false) << "Wait on Input/Output is found indefinite"; |
1096 | break; | ||
1097 | } | 1079 | } |
1080 | // Runtime Param Configuration | ||
1098 | if (ipCount == 15) { | 1081 | if (ipCount == 15) { |
1099 | changeBitrate(omxNode, portIndexOutput, 768000); | 1082 | changeBitrate(omxNode, portIndexOutput, 768000); |
1100 | requestIDR(omxNode, portIndexOutput); | 1083 | requestIDR(omxNode, portIndexOutput); |
@@ -1164,7 +1147,7 @@ TEST_F(VideoEncHidlTest, BufferSourceCallBacks) { | |||
1164 | xFramerate, eColorFormat); | 1147 | xFramerate, eColorFormat); |
1165 | 1148 | ||
1166 | sp<DummyBufferSource> buffersource = new DummyBufferSource(omxNode); | 1149 | sp<DummyBufferSource> buffersource = new DummyBufferSource(omxNode); |
1167 | EXPECT_NE(buffersource, nullptr); | 1150 | ASSERT_NE(buffersource, nullptr); |
1168 | status = omxNode->setInputSurface(buffersource); | 1151 | status = omxNode->setInputSurface(buffersource); |
1169 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1152 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1170 | 1153 | ||
@@ -1178,20 +1161,20 @@ TEST_F(VideoEncHidlTest, BufferSourceCallBacks) { | |||
1178 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1161 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1179 | 1162 | ||
1180 | // set state to idle | 1163 | // set state to idle |
1181 | changeStateLoadedtoIdle(omxNode, observer, &buffersource->iBuffer, | 1164 | ASSERT_NO_FATAL_FAILURE(changeStateLoadedtoIdle( |
1182 | &buffersource->oBuffer, kPortIndexInput, | 1165 | omxNode, observer, &buffersource->iBuffer, &buffersource->oBuffer, |
1183 | kPortIndexOutput, portMode); | 1166 | kPortIndexInput, kPortIndexOutput, portMode)); |
1184 | // set state to executing | 1167 | // set state to executing |
1185 | changeStateIdletoExecute(omxNode, observer); | 1168 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
1186 | testEOS(omxNode, observer, &buffersource->iBuffer, &buffersource->oBuffer, | 1169 | ASSERT_NO_FATAL_FAILURE(testEOS(omxNode, observer, &buffersource->iBuffer, |
1187 | false, eosFlag); | 1170 | &buffersource->oBuffer, false, eosFlag)); |
1188 | // set state to idle | 1171 | // set state to idle |
1189 | changeStateExecutetoIdle(omxNode, observer, &buffersource->iBuffer, | 1172 | ASSERT_NO_FATAL_FAILURE(changeStateExecutetoIdle( |
1190 | &buffersource->oBuffer); | 1173 | omxNode, observer, &buffersource->iBuffer, &buffersource->oBuffer)); |
1191 | // set state to executing | 1174 | // set state to executing |
1192 | changeStateIdletoLoaded(omxNode, observer, &buffersource->iBuffer, | 1175 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded( |
1193 | &buffersource->oBuffer, kPortIndexInput, | 1176 | omxNode, observer, &buffersource->iBuffer, &buffersource->oBuffer, |
1194 | kPortIndexOutput); | 1177 | kPortIndexInput, kPortIndexOutput)); |
1195 | // test for callbacks | 1178 | // test for callbacks |
1196 | EXPECT_EQ(buffersource->callback, 31); | 1179 | EXPECT_EQ(buffersource->callback, 31); |
1197 | } | 1180 | } |
@@ -1245,8 +1228,9 @@ TEST_F(VideoEncHidlTest, EncodeTest) { | |||
1245 | 1228 | ||
1246 | // Configure output port | 1229 | // Configure output port |
1247 | uint32_t nBitRate = 512000; | 1230 | uint32_t nBitRate = 512000; |
1248 | setDefaultPortParam(omxNode, kPortIndexOutput, eCompressionFormat, nBitRate, | 1231 | ASSERT_NO_FATAL_FAILURE( |
1249 | xFramerate); | 1232 | setDefaultPortParam(omxNode, kPortIndexOutput, eCompressionFormat, |
1233 | nFrameWidth, nFrameHeight, nBitRate, xFramerate)); | ||
1250 | setRefreshPeriod(omxNode, kPortIndexOutput, 0); | 1234 | setRefreshPeriod(omxNode, kPortIndexOutput, 0); |
1251 | 1235 | ||
1252 | unsigned int index; | 1236 | unsigned int index; |
@@ -1263,8 +1247,7 @@ TEST_F(VideoEncHidlTest, EncodeTest) { | |||
1263 | status = setParam(omxNode, static_cast<OMX_INDEXTYPE>(index), ¶m); | 1247 | status = setParam(omxNode, static_cast<OMX_INDEXTYPE>(index), ¶m); |
1264 | } | 1248 | } |
1265 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) | 1249 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) |
1266 | std::cerr | 1250 | std::cout << "[ INFO ] unable to prependSPSPPSToIDRFrames\n"; |
1267 | << "[ ] Warning ! unable to prependSPSPPSToIDRFrames\n"; | ||
1268 | else | 1251 | else |
1269 | prependSPSPPS = true; | 1252 | prependSPSPPS = true; |
1270 | 1253 | ||
@@ -1283,27 +1266,32 @@ TEST_F(VideoEncHidlTest, EncodeTest) { | |||
1283 | android::Vector<BufferInfo> iBuffer, oBuffer; | 1266 | android::Vector<BufferInfo> iBuffer, oBuffer; |
1284 | 1267 | ||
1285 | // set state to idle | 1268 | // set state to idle |
1286 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 1269 | ASSERT_NO_FATAL_FAILURE( |
1287 | kPortIndexInput, kPortIndexOutput, portMode); | 1270 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, |
1271 | kPortIndexInput, kPortIndexOutput, portMode)); | ||
1288 | // set state to executing | 1272 | // set state to executing |
1289 | changeStateIdletoExecute(omxNode, observer); | 1273 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
1290 | 1274 | ||
1291 | eleStream.open(mURL, std::ifstream::binary); | 1275 | eleStream.open(mURL, std::ifstream::binary); |
1292 | ASSERT_EQ(eleStream.is_open(), true); | 1276 | ASSERT_EQ(eleStream.is_open(), true); |
1293 | encodeNFrames(omxNode, observer, kPortIndexInput, kPortIndexOutput, | 1277 | ASSERT_NO_FATAL_FAILURE(encodeNFrames( |
1294 | &iBuffer, &oBuffer, 32, xFramerate, | 1278 | omxNode, observer, kPortIndexInput, kPortIndexOutput, &iBuffer, |
1295 | (nFrameWidth * nFrameHeight * 3) >> 1, eleStream, | 1279 | &oBuffer, 32, xFramerate, (nFrameWidth * nFrameHeight * 3) >> 1, |
1296 | ×tampUslist); | 1280 | eleStream, ×tampUslist)); |
1297 | eleStream.close(); | 1281 | eleStream.close(); |
1298 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer); | 1282 | ASSERT_NO_FATAL_FAILURE( |
1299 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag); | 1283 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer)); |
1300 | EXPECT_EQ(timestampUslist.empty(), true); | 1284 | ASSERT_NO_FATAL_FAILURE( |
1285 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag)); | ||
1286 | if (timestampDevTest) EXPECT_EQ(timestampUslist.empty(), true); | ||
1301 | 1287 | ||
1302 | // set state to idle | 1288 | // set state to idle |
1303 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1289 | ASSERT_NO_FATAL_FAILURE( |
1290 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
1304 | // set state to executing | 1291 | // set state to executing |
1305 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1292 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
1306 | kPortIndexInput, kPortIndexOutput); | 1293 | &oBuffer, kPortIndexInput, |
1294 | kPortIndexOutput)); | ||
1307 | } | 1295 | } |
1308 | 1296 | ||
1309 | // test raw stream encode (input is ANW buffers) | 1297 | // test raw stream encode (input is ANW buffers) |
@@ -1330,6 +1318,11 @@ TEST_F(VideoEncHidlTest, EncodeTestBufferMetaModes) { | |||
1330 | setupRAWPort(omxNode, kPortIndexInput, nFrameWidth, nFrameHeight, 0, | 1318 | setupRAWPort(omxNode, kPortIndexInput, nFrameWidth, nFrameHeight, 0, |
1331 | xFramerate, eColorFormat); | 1319 | xFramerate, eColorFormat); |
1332 | 1320 | ||
1321 | // Configure output port | ||
1322 | uint32_t nBitRate = 512000; | ||
1323 | ASSERT_NO_FATAL_FAILURE( | ||
1324 | setDefaultPortParam(omxNode, kPortIndexOutput, eCompressionFormat, | ||
1325 | nFrameWidth, nFrameHeight, nBitRate, xFramerate)); | ||
1333 | // CreateInputSurface | 1326 | // CreateInputSurface |
1334 | EXPECT_TRUE(omx->createInputSurface( | 1327 | EXPECT_TRUE(omx->createInputSurface( |
1335 | [&](android::hardware::media::omx::V1_0::Status _s, | 1328 | [&](android::hardware::media::omx::V1_0::Status _s, |
@@ -1436,28 +1429,32 @@ TEST_F(VideoEncHidlTest, EncodeTestBufferMetaModes) { | |||
1436 | 1429 | ||
1437 | android::Vector<BufferInfo> iBuffer, oBuffer; | 1430 | android::Vector<BufferInfo> iBuffer, oBuffer; |
1438 | // set state to idle | 1431 | // set state to idle |
1439 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 1432 | ASSERT_NO_FATAL_FAILURE( |
1440 | kPortIndexInput, kPortIndexOutput, portMode); | 1433 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, |
1434 | kPortIndexInput, kPortIndexOutput, portMode)); | ||
1441 | // set state to executing | 1435 | // set state to executing |
1442 | changeStateIdletoExecute(omxNode, observer); | 1436 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
1443 | 1437 | ||
1444 | eleStream.open(mURL, std::ifstream::binary); | 1438 | eleStream.open(mURL, std::ifstream::binary); |
1445 | ASSERT_EQ(eleStream.is_open(), true); | 1439 | ASSERT_EQ(eleStream.is_open(), true); |
1446 | encodeNFrames(omxNode, observer, kPortIndexInput, kPortIndexOutput, | 1440 | ASSERT_NO_FATAL_FAILURE(encodeNFrames( |
1447 | &iBuffer, &oBuffer, 1024, xFramerate, | 1441 | omxNode, observer, kPortIndexInput, kPortIndexOutput, &iBuffer, |
1448 | (nFrameWidth * nFrameHeight * 3) >> 1, eleStream, nullptr, | 1442 | &oBuffer, 1024, xFramerate, (nFrameWidth * nFrameHeight * 3) >> 1, |
1449 | false, true, producer, listener); | 1443 | eleStream, nullptr, false, true, producer, listener)); |
1450 | eleStream.close(); | 1444 | eleStream.close(); |
1451 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, true, | 1445 | ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(omxNode, observer, &iBuffer, |
1452 | listener); | 1446 | &oBuffer, true, listener)); |
1453 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag); | 1447 | ASSERT_NO_FATAL_FAILURE( |
1448 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag)); | ||
1454 | 1449 | ||
1455 | // set state to idle | 1450 | // set state to idle |
1456 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1451 | ASSERT_NO_FATAL_FAILURE( |
1452 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
1457 | EXPECT_EQ(portDef.nBufferCountActual, listener->freeBuffers); | 1453 | EXPECT_EQ(portDef.nBufferCountActual, listener->freeBuffers); |
1458 | // set state to executing | 1454 | // set state to executing |
1459 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1455 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
1460 | kPortIndexInput, kPortIndexOutput); | 1456 | &oBuffer, kPortIndexInput, |
1457 | kPortIndexOutput)); | ||
1461 | 1458 | ||
1462 | returnval = producer->disconnect( | 1459 | returnval = producer->disconnect( |
1463 | NATIVE_WINDOW_API_CPU, IGraphicBufferProducer::DisconnectMode::API); | 1460 | NATIVE_WINDOW_API_CPU, IGraphicBufferProducer::DisconnectMode::API); |
@@ -1551,24 +1548,28 @@ TEST_F(VideoEncHidlTest, EncodeTestEOS) { | |||
1551 | 1548 | ||
1552 | android::Vector<BufferInfo> iBuffer, oBuffer; | 1549 | android::Vector<BufferInfo> iBuffer, oBuffer; |
1553 | // set state to idle | 1550 | // set state to idle |
1554 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 1551 | ASSERT_NO_FATAL_FAILURE( |
1555 | kPortIndexInput, kPortIndexOutput, portMode); | 1552 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, |
1553 | kPortIndexInput, kPortIndexOutput, portMode)); | ||
1556 | // set state to executing | 1554 | // set state to executing |
1557 | changeStateIdletoExecute(omxNode, observer); | 1555 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoExecute(omxNode, observer)); |
1558 | 1556 | ||
1559 | // send EOS | 1557 | // send EOS |
1560 | status = source->signalEndOfInputStream(); | 1558 | status = source->signalEndOfInputStream(); |
1561 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1559 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1562 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, true, | 1560 | ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(omxNode, observer, &iBuffer, |
1563 | listener); | 1561 | &oBuffer, true, listener)); |
1564 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag); | 1562 | ASSERT_NO_FATAL_FAILURE( |
1563 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag)); | ||
1565 | 1564 | ||
1566 | // set state to idle | 1565 | // set state to idle |
1567 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1566 | ASSERT_NO_FATAL_FAILURE( |
1567 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer)); | ||
1568 | EXPECT_EQ(portDef.nBufferCountActual, listener->freeBuffers); | 1568 | EXPECT_EQ(portDef.nBufferCountActual, listener->freeBuffers); |
1569 | // set state to executing | 1569 | // set state to executing |
1570 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1570 | ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, |
1571 | kPortIndexInput, kPortIndexOutput); | 1571 | &oBuffer, kPortIndexInput, |
1572 | kPortIndexOutput)); | ||
1572 | 1573 | ||
1573 | returnval = producer->disconnect( | 1574 | returnval = producer->disconnect( |
1574 | NATIVE_WINDOW_API_CPU, IGraphicBufferProducer::DisconnectMode::API); | 1575 | NATIVE_WINDOW_API_CPU, IGraphicBufferProducer::DisconnectMode::API); |
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 91aecf22..e1b6022f 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 | |||
@@ -15,7 +15,6 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #define LOG_TAG "media_omx_hidl_video_test_common" | 17 | #define LOG_TAG "media_omx_hidl_video_test_common" |
18 | |||
19 | #ifdef __LP64__ | 18 | #ifdef __LP64__ |
20 | #define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS | 19 | #define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS |
21 | #endif | 20 | #endif |
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 c1d7aeae..55de1258 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 | |||
@@ -18,14 +18,8 @@ | |||
18 | #define MEDIA_VIDEO_HIDL_TEST_COMMON_H | 18 | #define MEDIA_VIDEO_HIDL_TEST_COMMON_H |
19 | 19 | ||
20 | /* | 20 | /* |
21 | * Random Index used for monkey testing while get/set parameters | ||
22 | */ | ||
23 | #define RANDOM_INDEX 1729 | ||
24 | |||
25 | /* | ||
26 | * Common video utils | 21 | * Common video utils |
27 | */ | 22 | */ |
28 | |||
29 | void enumerateProfileAndLevel(sp<IOmxNode> omxNode, OMX_U32 portIndex, | 23 | void enumerateProfileAndLevel(sp<IOmxNode> omxNode, OMX_U32 portIndex, |
30 | std::vector<int32_t>* arrProfile, | 24 | std::vector<int32_t>* arrProfile, |
31 | std::vector<int32_t>* arrLevel); | 25 | std::vector<int32_t>* arrLevel); |