Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 13d62973 authored by Zhuoyao Zhang's avatar Zhuoyao Zhang Committed by Android (Google) Code Review
Browse files

Merge "Basic audio/video encoder/decoder test." into oc-dev

parents 238d6b95 f9c4003f
Loading
Loading
Loading
Loading

media/Android.bp

100755 → 100644
+1 −0
Original line number Original line Diff line number Diff line
@@ -5,4 +5,5 @@ subdirs = [
    "omx/1.0/vts/functional/audio",
    "omx/1.0/vts/functional/audio",
    "omx/1.0/vts/functional/component",
    "omx/1.0/vts/functional/component",
    "omx/1.0/vts/functional/master",
    "omx/1.0/vts/functional/master",
    "omx/1.0/vts/functional/video",
]
]
+49 −0
Original line number Original line Diff line number Diff line
## Codec OMX Tests
---

The current directory contains the following folders: audio, common, component, master
and video.

Besides common, all other folders contain basic OMX unit tests for testing audio and video decoder-encoder
components. common constitutes files that are used across test applications.

## master
Enumerates all the omx components (and their roles) available in android media framework.

Usage:

VtsHalMediaOmxV1\_0TargetMasterTest -I default

## component
This folder includes test fixtures that tests aspects common to all OMX compatible components. For instance, port enabling/disabling, enumerating port formats, state transitions, flush etc. stay common to all components irrespective of the service they offer. In a way this tests the OMX Core. Every standard OMX compatible component is expected to pass these tests.


Usage:

VtsHalMediaOmxV1\_0TargetComponentTest -I default -C <component name> -R <component role>

## audio
This folder includes test fixtures associated with audio encoder/decoder components such as encoding/decoding, EOS test, timestamp test etc. These tests are aimed towards testing the component specific aspects.

Usage:

VtsHalMediaOmxV1\_0TargetAudioDecTest -I default -C <component name> -R audio_decoder.<class>

VtsHalMediaOmxV1\_0TargetAudioEncTest -I default -C <component name> -R audio_encoder.<class>

## video
This folder includes test fixtures associated with video encoder/decoder components like encoding/decoding, EOS test, timestamp test etc. These tests are aimed towards testing the component specific aspects.

Usage:

VtsHalMediaOmxV1\_0TargetVideoDecTest -I default -C <component name> -R video_decoder.<class>

VtsHalMediaOmxV1\_0TargetVideoEncTest -I default -C <component name> -R video_encoder.<class>

## notes
Every component shall be tested by two applications,

* ComponentTest.

* AudioDecTest/AudioEncTest/VideoDecTest/VideoEncTest depending on the component class.
+142 −218
Original line number Original line Diff line number Diff line
@@ -155,7 +155,7 @@ class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase {
        const StringToName kStringToName[] = {
        const StringToName kStringToName[] = {
            {"mp3", mp3}, {"amrnb", amrnb},   {"amrwb", amrwb},
            {"mp3", mp3}, {"amrnb", amrnb},   {"amrwb", amrwb},
            {"aac", aac}, {"vorbis", vorbis}, {"opus", opus},
            {"aac", aac}, {"vorbis", vorbis}, {"opus", opus},
            {"pcm", pcm}, {"flac", flac},
            {"pcm", pcm},
        };
        };
        const size_t kNumStringToName =
        const size_t kNumStringToName =
            sizeof(kStringToName) / sizeof(kStringToName[0]);
            sizeof(kStringToName) / sizeof(kStringToName[0]);
@@ -184,7 +184,6 @@ class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase {
            {vorbis, OMX_AUDIO_CodingVORBIS},
            {vorbis, OMX_AUDIO_CodingVORBIS},
            {pcm, OMX_AUDIO_CodingPCM},
            {pcm, OMX_AUDIO_CodingPCM},
            {opus, (OMX_AUDIO_CODINGTYPE)OMX_AUDIO_CodingAndroidOPUS},
            {opus, (OMX_AUDIO_CODINGTYPE)OMX_AUDIO_CodingAndroidOPUS},
            {flac, OMX_AUDIO_CodingFLAC},
        };
        };
        static const size_t kNumCompToCoding =
        static const size_t kNumCompToCoding =
            sizeof(kCompToCoding) / sizeof(kCompToCoding[0]);
            sizeof(kCompToCoding) / sizeof(kCompToCoding[0]);
@@ -213,7 +212,6 @@ class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase {
        vorbis,
        vorbis,
        opus,
        opus,
        pcm,
        pcm,
        flac,
        unknown_comp,
        unknown_comp,
    };
    };


@@ -222,14 +220,21 @@ class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase {
    sp<IOmxNode> omxNode;
    sp<IOmxNode> omxNode;
    standardComp compName;
    standardComp compName;
    OMX_AUDIO_CODINGTYPE eEncoding;
    OMX_AUDIO_CODINGTYPE eEncoding;

   protected:
    static void description(const std::string& description) {
        RecordProperty("description", description);
    }
};
};


// Set Default port param.
void setDefaultPortParam(
void setDefaultPortParam(
    sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding,
    sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding,
    int32_t nChannels = 2, int32_t nSampleRate = 44100,
    int32_t nChannels = 2, int32_t nSampleRate = 44100,
    OMX_NUMERICALDATATYPE eNumData = OMX_NumericalDataSigned,
    OMX_NUMERICALDATATYPE eNumData = OMX_NumericalDataSigned,
    int32_t nBitPerSample = 16) {
    int32_t nBitPerSample = 16) {
    android::hardware::media::omx::V1_0::Status status;
    android::hardware::media::omx::V1_0::Status status;

    OMX_PARAM_PORTDEFINITIONTYPE portDef;
    OMX_PARAM_PORTDEFINITIONTYPE portDef;
    status = getPortParam(omxNode, OMX_IndexParamPortDefinition, portIndex,
    status = getPortParam(omxNode, OMX_IndexParamPortDefinition, portIndex,
                          &portDef);
                          &portDef);
@@ -246,18 +251,25 @@ void setDefaultPortParam(
            setupPCMPort(omxNode, portIndex, nChannels, eNumData, nBitPerSample,
            setupPCMPort(omxNode, portIndex, nChannels, eNumData, nBitPerSample,
                         nSampleRate);
                         nSampleRate);
            break;
            break;
        case OMX_AUDIO_CodingAAC:
            setupAACPort(omxNode, portIndex, OMX_AUDIO_AACObjectNull,
                         OMX_AUDIO_AACStreamFormatMP4ADTS, nChannels, 0,
                         nSampleRate);
        default:
        default:
            ASSERT_TRUE(false);
            break;
            break;
    }
    }
}
}


// In decoder components, often the input port parameters get updated upon
// parsing the header of elementary stream. Client needs to collect this
// information to reconfigure other ports that share data with this input
// port.
void getInputChannelInfo(sp<IOmxNode> omxNode, OMX_U32 kPortIndexInput,
void getInputChannelInfo(sp<IOmxNode> omxNode, OMX_U32 kPortIndexInput,
                         OMX_AUDIO_CODINGTYPE eEncoding, int32_t* nChannels,
                         OMX_AUDIO_CODINGTYPE eEncoding, int32_t* nChannels,
                         int32_t* nSampleRate) {
                         int32_t* nSampleRate) {
    android::hardware::media::omx::V1_0::Status status;
    *nChannels = 0;
    *nChannels = 0;
    *nSampleRate = 0;
    *nSampleRate = 0;
    android::hardware::media::omx::V1_0::Status status;


    switch ((int)eEncoding) {
    switch ((int)eEncoding) {
        case OMX_AUDIO_CodingPCM: {
        case OMX_AUDIO_CodingPCM: {
@@ -280,16 +292,6 @@ void getInputChannelInfo(sp<IOmxNode> omxNode, OMX_U32 kPortIndexInput,
            *nSampleRate = param.nSampleRate;
            *nSampleRate = param.nSampleRate;
            break;
            break;
        }
        }
        case OMX_AUDIO_CodingFLAC: {
            OMX_AUDIO_PARAM_FLACTYPE param;
            status = getPortParam(omxNode, OMX_IndexParamAudioFlac,
                                  kPortIndexInput, &param);
            ASSERT_EQ(status,
                      ::android::hardware::media::omx::V1_0::Status::OK);
            *nChannels = param.nChannels;
            *nSampleRate = param.nSampleRate;
            break;
        }
        case OMX_AUDIO_CodingAndroidOPUS: {
        case OMX_AUDIO_CodingAndroidOPUS: {
            OMX_AUDIO_PARAM_ANDROID_OPUSTYPE param;
            OMX_AUDIO_PARAM_ANDROID_OPUSTYPE param;
            status = getPortParam(omxNode,
            status = getPortParam(omxNode,
@@ -337,6 +339,7 @@ void getInputChannelInfo(sp<IOmxNode> omxNode, OMX_U32 kPortIndexInput,
    }
    }
}
}


// LookUpTable of clips and metadata for component testing
void GetURLForComponent(AudioDecHidlTest::standardComp comp, const char** mURL,
void GetURLForComponent(AudioDecHidlTest::standardComp comp, const char** mURL,
                        const char** info) {
                        const char** info) {
    struct CompToURL {
    struct CompToURL {
@@ -346,20 +349,26 @@ void GetURLForComponent(AudioDecHidlTest::standardComp comp, const char** mURL,
    };
    };
    static const CompToURL kCompToURL[] = {
    static const CompToURL kCompToURL[] = {
        {AudioDecHidlTest::standardComp::mp3,
        {AudioDecHidlTest::standardComp::mp3,
         "/sdcard/raw/MP3_48KHz_128kbps_s_1_17_CBR.audio.mp3",
         "/sdcard/media/bbb_mp3_stereo_192kbps_48000hz.mp3",
         "/sdcard/raw/MP3_48KHz_128kbps_s_1_17_CBR.audio.info"},
         "/sdcard/media/bbb_mp3_stereo_192kbps_48000hz.info"},
        {AudioDecHidlTest::standardComp::aac,
        {AudioDecHidlTest::standardComp::aac,
         "/sdcard/raw/H264_500_AAC_128.audio.aac",
         "/sdcard/media/bbb_aac_stereo_128kbps_48000hz.aac",
         "/sdcard/raw/H264_500_AAC_128.audio.info"},
         "/sdcard/media/bbb_aac_stereo_128kbps_48000hz.info"},
        {AudioDecHidlTest::standardComp::amrnb,
        {AudioDecHidlTest::standardComp::amrnb,
         "/sdcard/raw/H264_320_AMRNB_6.audio.amr",
         "/sdcard/media/sine_amrnb_1ch_12kbps_8000hz.amrnb",
         "/sdcard/raw/H264_320_AMRNB_6.audio.info"},
         "/sdcard/media/sine_amrnb_1ch_12kbps_8000hz.info"},
        {AudioDecHidlTest::standardComp::amrwb, "", ""},
        {AudioDecHidlTest::standardComp::amrwb,
        {AudioDecHidlTest::standardComp::vorbis, "", ""},
         "/sdcard/media/sine_amrwb_1ch_24kbps_16000hz.amrwb",
        {AudioDecHidlTest::standardComp::opus, "", ""},
         "/sdcard/media/sine_amrwb_1ch_24kbps_16000hz.info"},
        {AudioDecHidlTest::standardComp::flac, "", ""},
        {AudioDecHidlTest::standardComp::vorbis,
         "/sdcard/media/bbb_vorbis_stereo_128kbps_48000hz.vorbis",
         "/sdcard/media/bbb_vorbis_stereo_128kbps_48000hz.info"},
        {AudioDecHidlTest::standardComp::opus,
         "/sdcard/media/bbb_opus_stereo_128kbps_48000hz.opus",
         "/sdcard/media/bbb_opus_stereo_128kbps_48000hz.info"},
    };
    };


    *mURL = *info = nullptr;
    for (size_t i = 0; i < sizeof(kCompToURL) / sizeof(kCompToURL[0]); ++i) {
    for (size_t i = 0; i < sizeof(kCompToURL) / sizeof(kCompToURL[0]); ++i) {
        if (kCompToURL[i].comp == comp) {
        if (kCompToURL[i].comp == comp) {
            *mURL = kCompToURL[i].mURL;
            *mURL = kCompToURL[i].mURL;
@@ -369,42 +378,7 @@ void GetURLForComponent(AudioDecHidlTest::standardComp comp, const char** mURL,
    }
    }
}
}


void flushAllPorts(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
// Decode N Frames
                   android::Vector<BufferInfo>* iBuffer,
                   android::Vector<BufferInfo>* oBuffer,
                   OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput) {
    android::hardware::media::omx::V1_0::Status status;
    Message msg;
    // Flush
    status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush),
                                  kPortIndexInput);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
    status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
    ASSERT_EQ(msg.type, Message::Type::EVENT);
    ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
    ASSERT_EQ(msg.data.eventData.data1, OMX_CommandFlush);
    ASSERT_EQ(msg.data.eventData.data2, kPortIndexInput);
    // test if client got all its buffers back
    for (size_t i = 0; i < iBuffer->size(); ++i) {
        EXPECT_EQ((*iBuffer)[i].owner, client);
    }

    status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush),
                                  kPortIndexOutput);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
    status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
    ASSERT_EQ(msg.type, Message::Type::EVENT);
    ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
    ASSERT_EQ(msg.data.eventData.data1, OMX_CommandFlush);
    ASSERT_EQ(msg.data.eventData.data2, kPortIndexOutput);
    // test if client got all its buffers back
    for (size_t i = 0; i < oBuffer->size(); ++i) {
        EXPECT_EQ((*oBuffer)[i].owner, client);
    }
}

void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
                   android::Vector<BufferInfo>* iBuffer,
                   android::Vector<BufferInfo>* iBuffer,
                   android::Vector<BufferInfo>* oBuffer,
                   android::Vector<BufferInfo>* oBuffer,
@@ -420,38 +394,49 @@ void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
    }
    }
    // dispatch input buffers
    // dispatch input buffers
    int bytesCount = 0;
    int bytesCount = 0;
    for (size_t i = 0; i < iBuffer->size(); i++) {
    uint32_t flags = 0;
    uint64_t timestamp = 0;
    for (size_t i = 0; i < iBuffer->size() && nFrames != 0; i++) {
        char* ipBuffer = static_cast<char*>(
        char* ipBuffer = static_cast<char*>(
            static_cast<void*>((*iBuffer)[i].mMemory->getPointer()));
            static_cast<void*>((*iBuffer)[i].mMemory->getPointer()));
        if (!(eleInfo >> bytesCount)) break;
        if (!(eleInfo >> bytesCount)) break;
        ASSERT_LE(bytesCount,
                  static_cast<int>((*iBuffer)[i].mMemory->getSize()));
        eleStream.read(ipBuffer, bytesCount);
        eleStream.read(ipBuffer, bytesCount);
        ASSERT_EQ(eleStream.gcount(), bytesCount);
        ASSERT_EQ(eleStream.gcount(), bytesCount);
        dispatchInputBuffer(omxNode, iBuffer, i, bytesCount, 0, 0);
        eleInfo >> flags;
        eleInfo >> timestamp;
        dispatchInputBuffer(omxNode, iBuffer, i, bytesCount, 0, timestamp);
        nFrames--;
    }
    }


    while (nFrames != 0) {
    while (1) {
        status =
        status =
            observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
            observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);

        // Port Reconfiguration
        if (status == android::hardware::media::omx::V1_0::Status::OK &&
        if (status == android::hardware::media::omx::V1_0::Status::OK &&
            msg.type == Message::Type::EVENT &&
            msg.type == Message::Type::EVENT) {
            msg.data.eventData.event == OMX_EventPortSettingsChanged) {
            if (msg.data.eventData.event == OMX_EventPortSettingsChanged) {
                ASSERT_EQ(msg.data.eventData.data1, kPortIndexOutput);
                ASSERT_EQ(msg.data.eventData.data1, kPortIndexOutput);


                status = omxNode->sendCommand(
                status = omxNode->sendCommand(
                    toRawCommandType(OMX_CommandPortDisable), kPortIndexOutput);
                    toRawCommandType(OMX_CommandPortDisable), kPortIndexOutput);
            ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
                ASSERT_EQ(status,
                          android::hardware::media::omx::V1_0::Status::OK);


            status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer,
                status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT,
                                              oBuffer);
                                                  iBuffer, oBuffer);
                if (status ==
                if (status ==
                    android::hardware::media::omx::V1_0::Status::TIMED_OUT) {
                    android::hardware::media::omx::V1_0::Status::TIMED_OUT) {
                    for (size_t i = 0; i < oBuffer->size(); ++i) {
                    for (size_t i = 0; i < oBuffer->size(); ++i) {
                        // test if client got all its buffers back
                        // test if client got all its buffers back
                        EXPECT_EQ((*oBuffer)[i].owner, client);
                        EXPECT_EQ((*oBuffer)[i].owner, client);
                        // free the buffers
                        // free the buffers
                    status =
                        status = omxNode->freeBuffer(kPortIndexOutput,
                        omxNode->freeBuffer(kPortIndexOutput, (*oBuffer)[i].id);
                                                     (*oBuffer)[i].id);
                    ASSERT_EQ(status,
                        ASSERT_EQ(
                            status,
                            android::hardware::media::omx::V1_0::Status::OK);
                            android::hardware::media::omx::V1_0::Status::OK);
                    }
                    }
                    status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT,
                    status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT,
@@ -463,7 +448,7 @@ void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
                    ASSERT_EQ(msg.data.eventData.data1, OMX_CommandPortDisable);
                    ASSERT_EQ(msg.data.eventData.data1, OMX_CommandPortDisable);
                    ASSERT_EQ(msg.data.eventData.data2, kPortIndexOutput);
                    ASSERT_EQ(msg.data.eventData.data2, kPortIndexOutput);


                // Port Reconfigurations
                    // set Port Params
                    int32_t nChannels;
                    int32_t nChannels;
                    int32_t nSampleRate;
                    int32_t nSampleRate;
                    getInputChannelInfo(omxNode, kPortIndexInput, eEncoding,
                    getInputChannelInfo(omxNode, kPortIndexInput, eEncoding,
@@ -472,10 +457,12 @@ void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
                                        OMX_AUDIO_CodingPCM, nChannels,
                                        OMX_AUDIO_CodingPCM, nChannels,
                                        nSampleRate);
                                        nSampleRate);


                // If you can disable a port, then you should be able to enable
                    // If you can disable a port, then you should be able to
                    // enable
                    // it as well
                    // it as well
                    status = omxNode->sendCommand(
                    status = omxNode->sendCommand(
                    toRawCommandType(OMX_CommandPortEnable), kPortIndexOutput);
                        toRawCommandType(OMX_CommandPortEnable),
                        kPortIndexOutput);
                    ASSERT_EQ(status,
                    ASSERT_EQ(status,
                              android::hardware::media::omx::V1_0::Status::OK);
                              android::hardware::media::omx::V1_0::Status::OK);


@@ -502,33 +489,45 @@ void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
                } else {
                } else {
                    ASSERT_TRUE(false);
                    ASSERT_TRUE(false);
                }
                }
            continue;
            } else {
                EXPECT_TRUE(false);
                return;
            }
        }
        }

        if (nFrames == 0) break;

        // Dispatch input buffer
        size_t index = 0;
        size_t index = 0;
        if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) {
        if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) {
            char* ipBuffer = static_cast<char*>(
            char* ipBuffer = static_cast<char*>(
                static_cast<void*>((*iBuffer)[index].mMemory->getPointer()));
                static_cast<void*>((*iBuffer)[index].mMemory->getPointer()));
            if (!(eleInfo >> bytesCount)) break;
            if (!(eleInfo >> bytesCount)) break;
            ASSERT_LE(bytesCount,
                      static_cast<int>((*iBuffer)[index].mMemory->getSize()));
            eleStream.read(ipBuffer, bytesCount);
            eleStream.read(ipBuffer, bytesCount);
            ASSERT_EQ(eleStream.gcount(), bytesCount);
            ASSERT_EQ(eleStream.gcount(), bytesCount);
            dispatchInputBuffer(omxNode, iBuffer, index, bytesCount, 0, 0);
            eleInfo >> flags;
            eleInfo >> timestamp;
            dispatchInputBuffer(omxNode, iBuffer, index, bytesCount, 0,
                                timestamp);
            nFrames--;
        }
        }
        if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) {
        if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) {
            dispatchOutputBuffer(omxNode, oBuffer, index);
            dispatchOutputBuffer(omxNode, oBuffer, index);
        }
        }
        nFrames--;
    }
    }
}
}


// Set Component Role
TEST_F(AudioDecHidlTest, SetRole) {
TEST_F(AudioDecHidlTest, SetRole) {
    description("Test Set Component Role");
    android::hardware::media::omx::V1_0::Status status;
    android::hardware::media::omx::V1_0::Status status;
    status = setRole(omxNode, gEnv->getRole().c_str());
    status = setRole(omxNode, gEnv->getRole().c_str());
    ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
    ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
}
}


// Enumerate Port Format
TEST_F(AudioDecHidlTest, EnumeratePortFormat) {
TEST_F(AudioDecHidlTest, EnumeratePortFormat) {
    description("Test Component on Mandatory Port Parameters (Port Format)");
    android::hardware::media::omx::V1_0::Status status;
    android::hardware::media::omx::V1_0::Status status;
    uint32_t kPortIndexInput = 0, kPortIndexOutput = 1;
    uint32_t kPortIndexInput = 0, kPortIndexOutput = 1;
    status = setRole(omxNode, gEnv->getRole().c_str());
    status = setRole(omxNode, gEnv->getRole().c_str());
@@ -546,8 +545,8 @@ TEST_F(AudioDecHidlTest, EnumeratePortFormat) {
    EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
    EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
}
}


// Decode Test
TEST_F(AudioDecHidlTest, DecodeTest) {
TEST_F(AudioDecHidlTest, DecodeTest) {
    description("Tests Port Reconfiguration and Decode");
    android::hardware::media::omx::V1_0::Status status;
    android::hardware::media::omx::V1_0::Status status;
    uint32_t kPortIndexInput = 0, kPortIndexOutput = 1;
    uint32_t kPortIndexInput = 0, kPortIndexOutput = 1;
    status = setRole(omxNode, gEnv->getRole().c_str());
    status = setRole(omxNode, gEnv->getRole().c_str());
@@ -570,105 +569,30 @@ TEST_F(AudioDecHidlTest, DecodeTest) {
    eleInfo.open(info);
    eleInfo.open(info);
    ASSERT_EQ(eleInfo.is_open(), true);
    ASSERT_EQ(eleInfo.is_open(), true);


    if (eEncoding == OMX_AUDIO_CodingPCM)
    int32_t nChannels, nSampleRate;
    // Configure input port
    setDefaultPortParam(omxNode, kPortIndexInput, eEncoding);
    setDefaultPortParam(omxNode, kPortIndexInput, eEncoding);
    int32_t nChannels;
    int32_t nSampleRate;
    getInputChannelInfo(omxNode, kPortIndexInput, eEncoding, &nChannels,
    getInputChannelInfo(omxNode, kPortIndexInput, eEncoding, &nChannels,
                        &nSampleRate);
                        &nSampleRate);
    // Configure output port
    setDefaultPortParam(omxNode, kPortIndexOutput, OMX_AUDIO_CodingPCM,
    setDefaultPortParam(omxNode, kPortIndexOutput, OMX_AUDIO_CodingPCM,
                        nChannels, nSampleRate);
                        nChannels, nSampleRate);


    Message msg;
    android::Vector<BufferInfo> iBuffer, oBuffer;
    android::Vector<BufferInfo> iBuffer, oBuffer;


    status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
    // set state to idle
                                  OMX_StateIdle);
    changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer,
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
                            kPortIndexInput, kPortIndexOutput);

    // set state to executing
    status =
    changeStateIdletoExecute(omxNode, observer);
        observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, &iBuffer, &oBuffer);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);

    allocatePortBuffers(omxNode, &iBuffer, kPortIndexInput);
    status =
        observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, &iBuffer, &oBuffer);

    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
    allocatePortBuffers(omxNode, &oBuffer, kPortIndexOutput);

    status =
        observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, &iBuffer, &oBuffer);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
    ASSERT_EQ(msg.type, Message::Type::EVENT);
    ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
    ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
    ASSERT_EQ(msg.data.eventData.data2, OMX_StateIdle);

    status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
                                  OMX_StateExecuting);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
    status =
        observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, &iBuffer, &oBuffer);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
    ASSERT_EQ(msg.type, Message::Type::EVENT);
    ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
    ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
    ASSERT_EQ(msg.data.eventData.data2, OMX_StateExecuting);

    // Port Reconfiguration
    // Port Reconfiguration
    decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, eEncoding,
    decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, eEncoding,
                  kPortIndexInput, kPortIndexOutput, (1 << 12), eleStream,
                  kPortIndexInput, kPortIndexOutput, 1024, eleStream, eleInfo);
                  eleInfo);
    // set state to idle

    changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer);
    // flush
    // set state to executing
    flushAllPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
    changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
                  kPortIndexOutput);
                            kPortIndexInput, kPortIndexOutput);

    // set state to Idle
    status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
                                  OMX_StateIdle);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
    status =
        observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, &iBuffer, &oBuffer);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
    ASSERT_EQ(msg.type, Message::Type::EVENT);
    ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
    ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
    ASSERT_EQ(msg.data.eventData.data2, OMX_StateIdle);

    // set state to Loaded
    status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
                                  OMX_StateLoaded);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);

    // dont change state until all buffers are freed
    status =
        observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, &iBuffer, &oBuffer);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);

    for (size_t i = 0; i < iBuffer.size(); ++i) {
        status = omxNode->freeBuffer(kPortIndexInput, iBuffer[i].id);
        ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
    }

    // dont change state until all buffers are freed
    status =
        observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, &iBuffer, &oBuffer);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);

    for (size_t i = 0; i < oBuffer.size(); ++i) {
        status = omxNode->freeBuffer(kPortIndexOutput, oBuffer[i].id);
        ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
    }

    status =
        observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, &iBuffer, &oBuffer);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
    ASSERT_EQ(msg.type, Message::Type::EVENT);
    ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
    ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
    ASSERT_EQ(msg.data.eventData.data2, OMX_StateLoaded);


    eleInfo.close();
    eleInfo.close();
    eleStream.close();
    eleStream.close();
+212 −13

File changed.

Preview size limit exceeded, changes collapsed.

+221 −26

File changed.

Preview size limit exceeded, changes collapsed.

Loading