Merge "Add SECTION/TS/AUDIO/VIDEO Tuner vts Broadcast tests" into rvc-dev am: 8bc18c0ed5

Change-Id: If37ca2bc2a79252987a87f2bf962ba915164cefa
This commit is contained in:
TreeHugger Robot 2020-04-09 03:41:28 +00:00 committed by Automerger Merge Worker
commit bf60e12c49
2 changed files with 152 additions and 89 deletions

View file

@ -889,6 +889,7 @@ class TunerHidlTest : public testing::TestWithParam<std::string> {
RecordSettings recordSetting,
vector<string> goldenOutputFiles);
AssertionResult broadcastDataFlowTest(vector<string> goldenOutputFiles);
void broadcastFilterTest(int selectedFilter, int feId);
FilterEventType getFilterEventType(DemuxFilterType type);
};
@ -1183,6 +1184,28 @@ AssertionResult TunerHidlTest::broadcastDataFlowTest(vector<string> /*goldenOutp
return success();
}
void TunerHidlTest::broadcastFilterTest(int selectedFilter, int feId) {
ASSERT_TRUE(openFrontend(feId));
ASSERT_TRUE(setFrontendCallback());
ASSERT_TRUE(openDemux());
ASSERT_TRUE(setDemuxFrontendDataSource(feId));
ASSERT_TRUE(openFilterInDemux(filterArray[selectedFilter].type));
uint32_t filterId;
ASSERT_TRUE(getNewlyOpenedFilterId(filterId));
ASSERT_TRUE(configFilter(filterArray[selectedFilter].setting, filterId));
ASSERT_TRUE(getFilterMQDescriptor(filterId));
ASSERT_TRUE(startFilter(filterId));
// tune test
ASSERT_TRUE(tuneFrontend(frontendArray[DVBT]));
// broadcast data flow test
ASSERT_TRUE(broadcastDataFlowTest(goldenOutputFiles));
ASSERT_TRUE(stopTuneFrontend());
ASSERT_TRUE(stopFilter(filterId));
ASSERT_TRUE(closeFilter(filterId));
ASSERT_TRUE(closeDemux());
ASSERT_TRUE(closeFrontend());
}
/*
* TODO: re-enable the tests after finalizing the test refactoring.
*/
@ -1401,16 +1424,14 @@ TEST_P(TunerHidlTest, TuneFrontend) {
description("Tune one Frontend with specific setting and check Lock event");
ASSERT_TRUE(getFrontendIds());
ASSERT_TRUE(mFeIds.size() > 0);
ALOGW("[vts] expected Frontend type is %d", frontendArray[0].type);
for (size_t i = 0; i < mFeIds.size(); i++) {
ASSERT_TRUE(getFrontendInfo(mFeIds[i]));
ALOGW("[vts] Frontend type is %d", mFrontendInfo.type);
if (mFrontendInfo.type != frontendArray[0].type) {
if (mFrontendInfo.type != frontendArray[DVBT].type) {
continue;
}
ASSERT_TRUE(openFrontend(mFeIds[i]));
ASSERT_TRUE(setFrontendCallback());
ASSERT_TRUE(tuneFrontend(frontendArray[0]));
ASSERT_TRUE(tuneFrontend(frontendArray[DVBT]));
ASSERT_TRUE(stopTuneFrontend());
ASSERT_TRUE(closeFrontend());
break;
@ -1424,12 +1445,12 @@ TEST_P(TunerHidlTest, AutoScanFrontend) {
for (size_t i = 0; i < mFeIds.size(); i++) {
ASSERT_TRUE(getFrontendInfo(mFeIds[i]));
if (mFrontendInfo.type != frontendArray[0].type) {
if (mFrontendInfo.type != frontendScanArray[SCAN_DVBT].type) {
continue;
}
ASSERT_TRUE(openFrontend(mFeIds[i]));
ASSERT_TRUE(setFrontendCallback());
ASSERT_TRUE(scanFrontend(frontendScanArray[0], FrontendScanType::SCAN_AUTO));
ASSERT_TRUE(scanFrontend(frontendScanArray[SCAN_DVBT], FrontendScanType::SCAN_AUTO));
ASSERT_TRUE(stopScanFrontend());
ASSERT_TRUE(closeFrontend());
break;
@ -1443,12 +1464,12 @@ TEST_P(TunerHidlTest, BlindScanFrontend) {
for (size_t i = 0; i < mFeIds.size(); i++) {
ASSERT_TRUE(getFrontendInfo(mFeIds[i]));
if (mFrontendInfo.type != frontendArray[0].type) {
if (mFrontendInfo.type != frontendScanArray[SCAN_DVBT].type) {
continue;
}
ASSERT_TRUE(openFrontend(mFeIds[i]));
ASSERT_TRUE(setFrontendCallback());
ASSERT_TRUE(scanFrontend(frontendScanArray[0], FrontendScanType::SCAN_BLIND));
ASSERT_TRUE(scanFrontend(frontendScanArray[SCAN_DVBT], FrontendScanType::SCAN_BLIND));
ASSERT_TRUE(stopScanFrontend());
ASSERT_TRUE(closeFrontend());
break;
@ -1464,7 +1485,7 @@ TEST_P(TunerHidlTest, OpenDemuxWithFrontendDataSource) {
for (size_t i = 0; i < mFeIds.size(); i++) {
ASSERT_TRUE(getFrontendInfo(mFeIds[i]));
if (mFrontendInfo.type != frontendArray[0].type) {
if (mFrontendInfo.type != frontendArray[DVBT].type) {
continue;
}
ASSERT_TRUE(openFrontend(mFeIds[i]));
@ -1484,14 +1505,14 @@ TEST_P(TunerHidlTest, OpenFilterInDemux) {
for (size_t i = 0; i < mFeIds.size(); i++) {
ASSERT_TRUE(getFrontendInfo(mFeIds[i]));
if (mFrontendInfo.type != frontendArray[0].type) {
if (mFrontendInfo.type != frontendArray[DVBT].type) {
continue;
}
ASSERT_TRUE(openFrontend(mFeIds[i]));
ASSERT_TRUE(setFrontendCallback());
ASSERT_TRUE(openDemux());
ASSERT_TRUE(setDemuxFrontendDataSource(mFeIds[i]));
ASSERT_TRUE(openFilterInDemux(filterArray[0].type));
ASSERT_TRUE(openFilterInDemux(filterArray[TS_VIDEO0].type));
uint32_t filterId;
ASSERT_TRUE(getNewlyOpenedFilterId(filterId));
ASSERT_TRUE(closeFilter(filterId));
@ -1508,17 +1529,17 @@ TEST_P(TunerHidlTest, StartFilterInDemux) {
for (size_t i = 0; i < mFeIds.size(); i++) {
ASSERT_TRUE(getFrontendInfo(mFeIds[i]));
if (mFrontendInfo.type != frontendArray[0].type) {
if (mFrontendInfo.type != frontendArray[DVBT].type) {
continue;
}
ASSERT_TRUE(openFrontend(mFeIds[i]));
ASSERT_TRUE(setFrontendCallback());
ASSERT_TRUE(openDemux());
ASSERT_TRUE(setDemuxFrontendDataSource(mFeIds[i]));
ASSERT_TRUE(openFilterInDemux(filterArray[0].type));
ASSERT_TRUE(openFilterInDemux(filterArray[TS_VIDEO0].type));
uint32_t filterId;
ASSERT_TRUE(getNewlyOpenedFilterId(filterId));
ASSERT_TRUE(configFilter(filterArray[0].setting, filterId));
ASSERT_TRUE(configFilter(filterArray[TS_VIDEO0].setting, filterId));
ASSERT_TRUE(getFilterMQDescriptor(filterId));
ASSERT_TRUE(startFilter(filterId));
ASSERT_TRUE(stopFilter(filterId));
@ -1546,35 +1567,62 @@ TEST_P(TunerHidlTest, CloseDescrambler) {
/*============================== End Descrambler Tests ==============================*/
/*============================== Start Data Flow Tests ==============================*/
TEST_P(TunerHidlTest, BroadcastDataFlowWithAudioFilterTest) {
description("Open Demux with a Frontend as its data source.");
TEST_P(TunerHidlTest, BroadcastDataFlowVideoFilterTest) {
description("Test Video Filter functionality in Broadcast use case.");
ASSERT_TRUE(getFrontendIds());
ASSERT_TRUE(mFeIds.size() > 0);
for (size_t i = 0; i < mFeIds.size(); i++) {
ASSERT_TRUE(getFrontendInfo(mFeIds[i]));
if (mFrontendInfo.type != frontendArray[0].type) {
if (mFrontendInfo.type != frontendArray[DVBT].type) {
continue;
}
ASSERT_TRUE(openFrontend(mFeIds[i]));
ASSERT_TRUE(setFrontendCallback());
ASSERT_TRUE(openDemux());
ASSERT_TRUE(setDemuxFrontendDataSource(mFeIds[i]));
ASSERT_TRUE(openFilterInDemux(filterArray[0].type));
uint32_t filterId;
ASSERT_TRUE(getNewlyOpenedFilterId(filterId));
ASSERT_TRUE(configFilter(filterArray[0].setting, filterId));
ASSERT_TRUE(getFilterMQDescriptor(filterId));
ASSERT_TRUE(startFilter(filterId));
// tune test
ASSERT_TRUE(tuneFrontend(frontendArray[0]));
// broadcast data flow test
ASSERT_TRUE(broadcastDataFlowTest(goldenOutputFiles));
ASSERT_TRUE(stopTuneFrontend());
ASSERT_TRUE(stopFilter(filterId));
ASSERT_TRUE(closeFilter(filterId));
ASSERT_TRUE(closeDemux());
ASSERT_TRUE(closeFrontend());
broadcastFilterTest(TS_VIDEO1, mFeIds[i]);
break;
}
}
TEST_P(TunerHidlTest, BroadcastDataFlowAudioFilterTest) {
description("Test Audio Filter functionality in Broadcast use case.");
ASSERT_TRUE(getFrontendIds());
ASSERT_TRUE(mFeIds.size() > 0);
for (size_t i = 0; i < mFeIds.size(); i++) {
ASSERT_TRUE(getFrontendInfo(mFeIds[i]));
if (mFrontendInfo.type != frontendArray[DVBT].type) {
continue;
}
broadcastFilterTest(TS_AUDIO0, mFeIds[i]);
break;
}
}
TEST_P(TunerHidlTest, BroadcastDataFlowTsFilterTest) {
description("Test TS Filter functionality in Broadcast use case.");
ASSERT_TRUE(getFrontendIds());
ASSERT_TRUE(mFeIds.size() > 0);
for (size_t i = 0; i < mFeIds.size(); i++) {
ASSERT_TRUE(getFrontendInfo(mFeIds[i]));
if (mFrontendInfo.type != frontendArray[DVBT].type) {
continue;
}
broadcastFilterTest(TS_TS0, mFeIds[i]);
break;
}
}
TEST_P(TunerHidlTest, BroadcastDataFlowSectionFilterTest) {
description("Test Section Filter functionality in Broadcast use case.");
ASSERT_TRUE(getFrontendIds());
ASSERT_TRUE(mFeIds.size() > 0);
for (size_t i = 0; i < mFeIds.size(); i++) {
ASSERT_TRUE(getFrontendInfo(mFeIds[i]));
if (mFrontendInfo.type != frontendArray[DVBT].type) {
continue;
}
broadcastFilterTest(TS_SECTION0, mFeIds[i]);
break;
}
}
@ -1671,20 +1719,20 @@ TEST_P(TunerHidlTest, AvBufferTest) {
for (size_t i = 0; i < mFeIds.size(); i++) {
ASSERT_TRUE(getFrontendInfo(mFeIds[i]));
if (mFrontendInfo.type != frontendArray[1].type) {
if (mFrontendInfo.type != frontendArray[DVBS].type) {
continue;
}
ASSERT_TRUE(openFrontend(mFeIds[i]));
ASSERT_TRUE(setFrontendCallback());
ASSERT_TRUE(openDemux());
ASSERT_TRUE(openFilterInDemux(filterArray[0].type));
ASSERT_TRUE(openFilterInDemux(filterArray[TS_VIDEO0].type));
uint32_t filterId;
ASSERT_TRUE(getNewlyOpenedFilterId(filterId));
ASSERT_TRUE(configFilter(filterArray[0].setting, filterId));
ASSERT_TRUE(configFilter(filterArray[TS_VIDEO0].setting, filterId));
ASSERT_TRUE(startFilter(filterId));
ASSERT_TRUE(setDemuxFrontendDataSource(mFeIds[i]));
// tune test
ASSERT_TRUE(tuneFrontend(frontendArray[1]));
ASSERT_TRUE(tuneFrontend(frontendArray[DVBS]));
// broadcast data flow test
ASSERT_TRUE(broadcastDataFlowTest(goldenOutputFiles));
ASSERT_TRUE(stopTuneFrontend());

View file

@ -14,42 +14,18 @@
* limitations under the License.
*/
#include <android-base/logging.h>
#include <android/hardware/tv/tuner/1.0/IDemux.h>
#include <android/hardware/tv/tuner/1.0/IDescrambler.h>
#include <android/hardware/tv/tuner/1.0/IDvr.h>
#include <android/hardware/tv/tuner/1.0/IDvrCallback.h>
#include <android/hardware/tv/tuner/1.0/IFilter.h>
#include <android/hardware/tv/tuner/1.0/IFilterCallback.h>
#include <android/hardware/tv/tuner/1.0/IFrontend.h>
#include <android/hardware/tv/tuner/1.0/IFrontendCallback.h>
#include <android/hardware/tv/tuner/1.0/ITuner.h>
#include <android/hardware/tv/tuner/1.0/types.h>
#include <binder/MemoryDealer.h>
#include <fmq/MessageQueue.h>
#include <hidl/HidlSupport.h>
#include <hidl/HidlTransportSupport.h>
#include <hidl/Status.h>
#include <hidlmemory/FrameworkUtils.h>
#include <utils/Condition.h>
#include <utils/Mutex.h>
#include <fstream>
#include <iostream>
#include <map>
using android::hardware::tv::tuner::V1_0::DemuxFilterEvent;
using android::hardware::tv::tuner::V1_0::DemuxFilterMainType;
using android::hardware::tv::tuner::V1_0::DemuxFilterPesDataSettings;
using android::hardware::tv::tuner::V1_0::DemuxFilterPesEvent;
using android::hardware::tv::tuner::V1_0::DemuxFilterRecordSettings;
using android::hardware::tv::tuner::V1_0::DemuxFilterSectionEvent;
using android::hardware::tv::tuner::V1_0::DemuxFilterSectionSettings;
using android::hardware::tv::tuner::V1_0::DemuxFilterSettings;
using android::hardware::tv::tuner::V1_0::DemuxFilterStatus;
using android::hardware::tv::tuner::V1_0::DemuxFilterType;
using android::hardware::tv::tuner::V1_0::DemuxQueueNotifyBits;
using android::hardware::tv::tuner::V1_0::DemuxTpid;
using android::hardware::tv::tuner::V1_0::DemuxTsFilterSettings;
using android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
using android::hardware::tv::tuner::V1_0::FrontendDvbtBandwidth;
using android::hardware::tv::tuner::V1_0::FrontendDvbtCoderate;
@ -62,12 +38,27 @@ using android::hardware::tv::tuner::V1_0::FrontendDvbtTransmissionMode;
using android::hardware::tv::tuner::V1_0::FrontendSettings;
using android::hardware::tv::tuner::V1_0::FrontendType;
namespace {
typedef enum {
TS_VIDEO0,
TS_VIDEO1,
TS_AUDIO0,
TS_PES0,
TS_PCR0,
TS_SECTION0,
TS_TS0,
FILTER_MAX,
} Filter;
#define frontend_transponders_count 2
#define channels_count 1
#define frontend_scan_count 1
#define filter_count 2
typedef enum {
DVBT,
DVBS,
FRONTEND_MAX,
} Frontend;
typedef enum {
SCAN_DVBT,
SCAN_MAX,
} FrontendScan;
struct FilterConfig {
DemuxFilterType type;
@ -87,10 +78,10 @@ struct ChannelConfig {
DemuxTpid audioPid;
};
static FrontendConfig frontendArray[frontend_transponders_count];
static FrontendConfig frontendScanArray[channels_count];
static ChannelConfig channelArray[frontend_scan_count];
static FilterConfig filterArray[filter_count];
static FrontendConfig frontendArray[FILTER_MAX];
static FrontendConfig frontendScanArray[SCAN_MAX];
static ChannelConfig channelArray[FRONTEND_MAX];
static FilterConfig filterArray[FILTER_MAX];
static vector<string> goldenOutputFiles;
/** Configuration array for the frontend tune test */
@ -107,14 +98,14 @@ inline void initFrontendConfig() {
.isHighPriority = true,
.standard = FrontendDvbtStandard::T,
};
frontendArray[0].type = FrontendType::DVBT, frontendArray[0].settings.dvbt(dvbtSettings);
frontendArray[1].type = FrontendType::DVBS;
frontendArray[DVBT].type = FrontendType::DVBT, frontendArray[DVBT].settings.dvbt(dvbtSettings);
frontendArray[DVBS].type = FrontendType::DVBS;
};
/** Configuration array for the frontend scan test */
inline void initFrontendScanConfig() {
frontendScanArray[0].type = FrontendType::DVBT;
frontendScanArray[0].settings.dvbt({
frontendScanArray[SCAN_DVBT].type = FrontendType::DVBT;
frontendScanArray[SCAN_DVBT].settings.dvbt({
.frequency = 578000,
.transmissionMode = FrontendDvbtTransmissionMode::MODE_8K,
.bandwidth = FrontendDvbtBandwidth::BANDWIDTH_8MHZ,
@ -130,19 +121,43 @@ inline void initFrontendScanConfig() {
/** Configuration array for the filter test */
inline void initFilterConfig() {
// TS Video filter setting
filterArray[0].type.mainType = DemuxFilterMainType::TS;
filterArray[0].type.subType.tsFilterType(DemuxTsFilterType::VIDEO);
filterArray[0].setting.ts().tpid = 119;
filterArray[0].setting.ts().filterSettings.av({.isPassthrough = false});
// TS VIDEO filter setting for default implementation testing
filterArray[TS_VIDEO0].type.mainType = DemuxFilterMainType::TS;
filterArray[TS_VIDEO0].type.subType.tsFilterType(DemuxTsFilterType::VIDEO);
filterArray[TS_VIDEO0].setting.ts().tpid = 119;
filterArray[TS_VIDEO0].setting.ts().filterSettings.av({.isPassthrough = false});
filterArray[TS_VIDEO1].type.mainType = DemuxFilterMainType::TS;
filterArray[TS_VIDEO1].type.subType.tsFilterType(DemuxTsFilterType::VIDEO);
filterArray[TS_VIDEO1].setting.ts().tpid = 81;
filterArray[TS_VIDEO1].setting.ts().filterSettings.av({.isPassthrough = false});
// TS AUDIO filter setting
filterArray[TS_AUDIO0].type.mainType = DemuxFilterMainType::TS;
filterArray[TS_AUDIO0].type.subType.tsFilterType(DemuxTsFilterType::AUDIO);
filterArray[TS_AUDIO0].setting.ts().tpid = 84;
filterArray[TS_AUDIO0].setting.ts().filterSettings.av({.isPassthrough = false});
// TS PES filter setting
filterArray[1].type.mainType = DemuxFilterMainType::TS;
filterArray[1].type.subType.tsFilterType(DemuxTsFilterType::PES);
filterArray[1].setting.ts().tpid = 256;
filterArray[1].setting.ts().filterSettings.pesData({
.isRaw = true,
filterArray[TS_PES0].type.mainType = DemuxFilterMainType::TS;
filterArray[TS_PES0].type.subType.tsFilterType(DemuxTsFilterType::PES);
filterArray[TS_PES0].setting.ts().tpid = 256;
filterArray[TS_PES0].setting.ts().filterSettings.pesData({
.isRaw = false,
.streamId = 0xbd,
});
// TS PCR filter setting
filterArray[TS_PCR0].type.mainType = DemuxFilterMainType::TS;
filterArray[TS_PCR0].type.subType.tsFilterType(DemuxTsFilterType::PCR);
filterArray[TS_PCR0].setting.ts().tpid = 81;
filterArray[TS_PCR0].setting.ts().filterSettings.noinit();
// TS filter setting
filterArray[TS_TS0].type.mainType = DemuxFilterMainType::TS;
filterArray[TS_TS0].type.subType.tsFilterType(DemuxTsFilterType::TS);
filterArray[TS_TS0].setting.ts().tpid = 48;
filterArray[TS_TS0].setting.ts().filterSettings.noinit();
// TS SECTION filter setting
filterArray[TS_SECTION0].type.mainType = DemuxFilterMainType::TS;
filterArray[TS_SECTION0].type.subType.tsFilterType(DemuxTsFilterType::SECTION);
filterArray[TS_SECTION0].setting.ts().tpid = 48;
filterArray[TS_SECTION0].setting.ts().filterSettings.section({
.isRaw = false,
});
};
} // namespace