Merge "Add TimeFilter test in Tuner VTS" into rvc-dev am: aaff02f469
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/11799182 Change-Id: If01b4fd0136230cf95a54e0885e52f0a9d93d183
This commit is contained in:
commit
e9c1bf3383
9 changed files with 131 additions and 6 deletions
|
@ -93,9 +93,9 @@ Return<void> Demux::openFilter(const DemuxFilterType& type, uint32_t bufferSize,
|
|||
Return<void> Demux::openTimeFilter(openTimeFilter_cb _hidl_cb) {
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
|
||||
sp<TimeFilter> timeFilter = new TimeFilter(this);
|
||||
mTimeFilter = new TimeFilter(this);
|
||||
|
||||
_hidl_cb(Result::SUCCESS, timeFilter);
|
||||
_hidl_cb(Result::SUCCESS, mTimeFilter);
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
|
|
@ -152,6 +152,11 @@ class Demux : public IDemux {
|
|||
*/
|
||||
std::map<uint32_t, sp<Filter>> mFilters;
|
||||
|
||||
/**
|
||||
* Local reference to the opened Timer Filter instance.
|
||||
*/
|
||||
sp<TimeFilter> mTimeFilter;
|
||||
|
||||
/**
|
||||
* Local reference to the opened DVR object.
|
||||
*/
|
||||
|
|
|
@ -34,24 +34,32 @@ TimeFilter::TimeFilter(sp<Demux> demux) {
|
|||
|
||||
TimeFilter::~TimeFilter() {}
|
||||
|
||||
Return<Result> TimeFilter::setTimeStamp(uint64_t /* timeStamp */) {
|
||||
Return<Result> TimeFilter::setTimeStamp(uint64_t timeStamp) {
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
if (timeStamp == INVALID_TIME_STAMP) {
|
||||
return Result::INVALID_ARGUMENT;
|
||||
}
|
||||
mTimeStamp = timeStamp;
|
||||
mBeginTime = time(NULL);
|
||||
|
||||
return Result::SUCCESS;
|
||||
}
|
||||
|
||||
Return<Result> TimeFilter::clearTimeStamp() {
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
mTimeStamp = INVALID_TIME_STAMP;
|
||||
|
||||
return Result::SUCCESS;
|
||||
}
|
||||
|
||||
Return<void> TimeFilter::getTimeStamp(getTimeStamp_cb _hidl_cb) {
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
if (mTimeStamp == INVALID_TIME_STAMP) {
|
||||
_hidl_cb(Result::INVALID_STATE, mTimeStamp);
|
||||
}
|
||||
|
||||
uint64_t timeStamp = 0;
|
||||
|
||||
_hidl_cb(Result::SUCCESS, timeStamp);
|
||||
uint64_t currentTimeStamp = mTimeStamp + difftime(time(NULL), mBeginTime) * 900000;
|
||||
_hidl_cb(Result::SUCCESS, currentTimeStamp);
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
@ -66,6 +74,7 @@ Return<void> TimeFilter::getSourceTime(getSourceTime_cb _hidl_cb) {
|
|||
|
||||
Return<Result> TimeFilter::close() {
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
mTimeStamp = INVALID_TIME_STAMP;
|
||||
|
||||
return Result::SUCCESS;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <android/hardware/tv/tuner/1.0/ITimeFilter.h>
|
||||
#include "Demux.h"
|
||||
#include "time.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -35,6 +36,8 @@ using ::android::hardware::tv::tuner::V1_0::Result;
|
|||
|
||||
using FilterMQ = MessageQueue<uint8_t, kSynchronizedReadWrite>;
|
||||
|
||||
#define INVALID_TIME_STAMP -1
|
||||
|
||||
class Demux;
|
||||
|
||||
class TimeFilter : public ITimeFilter {
|
||||
|
@ -57,6 +60,8 @@ class TimeFilter : public ITimeFilter {
|
|||
|
||||
private:
|
||||
sp<Demux> mDemux;
|
||||
uint64_t mTimeStamp = INVALID_TIME_STAMP;
|
||||
time_t mBeginTime;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
|
|
|
@ -149,6 +149,44 @@ AssertionResult FilterTests::openFilterInDemux(DemuxFilterType type, uint32_t bu
|
|||
return AssertionResult(status == Result::SUCCESS);
|
||||
}
|
||||
|
||||
AssertionResult FilterTests::openTimeFilterInDemux() {
|
||||
if (!mDemux) {
|
||||
ALOGW("[vts] Test with openDemux first.");
|
||||
return failure();
|
||||
}
|
||||
|
||||
// Add time filter to the local demux
|
||||
Result status;
|
||||
mDemux->openTimeFilter([&](Result result, const sp<ITimeFilter>& filter) {
|
||||
mTimeFilter = filter;
|
||||
status = result;
|
||||
});
|
||||
|
||||
return AssertionResult(status == Result::SUCCESS);
|
||||
}
|
||||
|
||||
AssertionResult FilterTests::setTimeStamp(uint64_t timeStamp) {
|
||||
if (!mTimeFilter) {
|
||||
ALOGW("[vts] Test with openTimeFilterInDemux first.");
|
||||
return failure();
|
||||
}
|
||||
|
||||
mBeginTimeStamp = timeStamp;
|
||||
return AssertionResult(mTimeFilter->setTimeStamp(timeStamp) == Result::SUCCESS);
|
||||
}
|
||||
|
||||
AssertionResult FilterTests::getTimeStamp() {
|
||||
if (!mTimeFilter) {
|
||||
ALOGW("[vts] Test with openTimeFilterInDemux first.");
|
||||
return failure();
|
||||
}
|
||||
|
||||
Result status;
|
||||
mTimeFilter->getTimeStamp([&](Result result, uint64_t /*timeStamp*/) { status = result; });
|
||||
|
||||
return AssertionResult(status == Result::SUCCESS);
|
||||
}
|
||||
|
||||
AssertionResult FilterTests::getNewlyOpenedFilterId(uint32_t& filterId) {
|
||||
Result status;
|
||||
EXPECT_TRUE(mDemux) << "Test with openDemux first.";
|
||||
|
@ -229,6 +267,15 @@ AssertionResult FilterTests::stopFilter(uint32_t filterId) {
|
|||
return AssertionResult(status == Result::SUCCESS);
|
||||
}
|
||||
|
||||
AssertionResult FilterTests::clearTimeStamp() {
|
||||
if (!mTimeFilter) {
|
||||
ALOGW("[vts] Test with openTimeFilterInDemux first.");
|
||||
return failure();
|
||||
}
|
||||
|
||||
return AssertionResult(mTimeFilter->clearTimeStamp() == Result::SUCCESS);
|
||||
}
|
||||
|
||||
AssertionResult FilterTests::closeFilter(uint32_t filterId) {
|
||||
EXPECT_TRUE(mFilters[filterId]) << "Test with getNewlyOpenedFilterId first.";
|
||||
Result status = mFilters[filterId]->close();
|
||||
|
@ -244,3 +291,12 @@ AssertionResult FilterTests::closeFilter(uint32_t filterId) {
|
|||
}
|
||||
return AssertionResult(status == Result::SUCCESS);
|
||||
}
|
||||
|
||||
AssertionResult FilterTests::closeTimeFilter() {
|
||||
if (!mTimeFilter) {
|
||||
ALOGW("[vts] Test with openTimeFilterInDemux first.");
|
||||
return failure();
|
||||
}
|
||||
|
||||
return AssertionResult(mTimeFilter->close() == Result::SUCCESS);
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ using android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
|
|||
using android::hardware::tv::tuner::V1_0::IDemux;
|
||||
using android::hardware::tv::tuner::V1_0::IFilter;
|
||||
using android::hardware::tv::tuner::V1_0::IFilterCallback;
|
||||
using android::hardware::tv::tuner::V1_0::ITimeFilter;
|
||||
using android::hardware::tv::tuner::V1_0::ITuner;
|
||||
using android::hardware::tv::tuner::V1_0::Result;
|
||||
|
||||
|
@ -151,14 +152,19 @@ class FilterTests {
|
|||
std::map<uint32_t, sp<FilterCallback>> getFilterCallbacks() { return mFilterCallbacks; }
|
||||
|
||||
AssertionResult openFilterInDemux(DemuxFilterType type, uint32_t bufferSize);
|
||||
AssertionResult openTimeFilterInDemux();
|
||||
AssertionResult setTimeStamp(uint64_t timeStamp);
|
||||
AssertionResult getTimeStamp();
|
||||
AssertionResult getNewlyOpenedFilterId(uint32_t& filterId);
|
||||
AssertionResult configFilter(DemuxFilterSettings setting, uint32_t filterId);
|
||||
AssertionResult getFilterMQDescriptor(uint32_t filterId);
|
||||
AssertionResult setFilterDataSource(uint32_t sourceFilterId, uint32_t sinkFilterId);
|
||||
AssertionResult setFilterDataSourceToDemux(uint32_t filterId);
|
||||
AssertionResult startFilter(uint32_t filterId);
|
||||
AssertionResult clearTimeStamp();
|
||||
AssertionResult stopFilter(uint32_t filterId);
|
||||
AssertionResult closeFilter(uint32_t filterId);
|
||||
AssertionResult closeTimeFilter();
|
||||
|
||||
FilterEventType getFilterEventType(DemuxFilterType type) {
|
||||
FilterEventType eventType = FilterEventType::UNDEFINED;
|
||||
|
@ -214,6 +220,7 @@ class FilterTests {
|
|||
|
||||
sp<ITuner> mService;
|
||||
sp<IFilter> mFilter;
|
||||
sp<ITimeFilter> mTimeFilter;
|
||||
sp<IDemux> mDemux;
|
||||
std::map<uint32_t, sp<IFilter>> mFilters;
|
||||
std::map<uint32_t, sp<FilterCallback>> mFilterCallbacks;
|
||||
|
@ -223,4 +230,5 @@ class FilterTests {
|
|||
vector<uint32_t> mUsedFilterIds;
|
||||
|
||||
uint32_t mFilterId = -1;
|
||||
uint64_t mBeginTimeStamp;
|
||||
};
|
||||
|
|
|
@ -56,6 +56,23 @@ void TunerFilterHidlTest::configSingleFilterInDemuxTest(FilterConfig filterConf,
|
|||
ASSERT_TRUE(mFrontendTests.closeFrontend());
|
||||
}
|
||||
|
||||
void TunerFilterHidlTest::testTimeFilter(TimeFilterConfig filterConf) {
|
||||
if (!filterConf.supportTimeFilter) {
|
||||
return;
|
||||
}
|
||||
uint32_t demuxId;
|
||||
sp<IDemux> demux;
|
||||
|
||||
ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
|
||||
mFilterTests.setDemux(demux);
|
||||
ASSERT_TRUE(mFilterTests.openTimeFilterInDemux());
|
||||
ASSERT_TRUE(mFilterTests.setTimeStamp(filterConf.timeStamp));
|
||||
ASSERT_TRUE(mFilterTests.getTimeStamp());
|
||||
ASSERT_TRUE(mFilterTests.clearTimeStamp());
|
||||
ASSERT_TRUE(mFilterTests.closeTimeFilter());
|
||||
ASSERT_TRUE(mDemuxTests.closeDemux());
|
||||
}
|
||||
|
||||
void TunerBroadcastHidlTest::broadcastSingleFilterTest(FilterConfig filterConf,
|
||||
FrontendConfig frontendConf) {
|
||||
uint32_t feId;
|
||||
|
@ -435,6 +452,12 @@ TEST_P(TunerFilterHidlTest, SetFilterLinkage) {
|
|||
ASSERT_TRUE(mDemuxTests.closeDemux());
|
||||
}
|
||||
|
||||
TEST_P(TunerFilterHidlTest, testTimeFilter) {
|
||||
description("Open a timer filter in Demux and set time stamp.");
|
||||
// TODO use paramterized tests
|
||||
testTimeFilter(timeFilterArray[TIMER0]);
|
||||
}
|
||||
|
||||
TEST_P(TunerBroadcastHidlTest, BroadcastDataFlowVideoFilterTest) {
|
||||
description("Test Video Filter functionality in Broadcast use case.");
|
||||
broadcastSingleFilterTest(filterArray[TS_VIDEO1], frontendArray[DVBT]);
|
||||
|
|
|
@ -34,6 +34,7 @@ void initConfiguration() {
|
|||
initFrontendScanConfig();
|
||||
initLnbConfig();
|
||||
initFilterConfig();
|
||||
initTimeFilterConfig();
|
||||
initDvrConfig();
|
||||
initDescramblerConfig();
|
||||
}
|
||||
|
@ -127,6 +128,7 @@ class TunerFilterHidlTest : public testing::TestWithParam<std::string> {
|
|||
}
|
||||
|
||||
void configSingleFilterInDemuxTest(FilterConfig filterConf, FrontendConfig frontendConf);
|
||||
void testTimeFilter(TimeFilterConfig filterConf);
|
||||
|
||||
sp<ITuner> mService;
|
||||
FrontendTests mFrontendTests;
|
||||
|
|
|
@ -85,6 +85,11 @@ typedef enum {
|
|||
FILTER_MAX,
|
||||
} Filter;
|
||||
|
||||
typedef enum {
|
||||
TIMER0,
|
||||
TIMER_MAX,
|
||||
} TimeFilter;
|
||||
|
||||
typedef enum {
|
||||
SOURCE,
|
||||
SINK,
|
||||
|
@ -132,6 +137,11 @@ struct FilterConfig {
|
|||
bool operator<(const FilterConfig& /*c*/) const { return false; }
|
||||
};
|
||||
|
||||
struct TimeFilterConfig {
|
||||
bool supportTimeFilter;
|
||||
uint64_t timeStamp;
|
||||
};
|
||||
|
||||
struct FrontendConfig {
|
||||
FrontendType type;
|
||||
FrontendSettings settings;
|
||||
|
@ -174,6 +184,7 @@ static LnbConfig lnbArray[LNB_MAX];
|
|||
static vector<uint8_t> diseqcMsgArray[DISEQC_MAX];
|
||||
static ChannelConfig channelArray[FRONTEND_MAX];
|
||||
static FilterConfig filterArray[FILTER_MAX];
|
||||
static TimeFilterConfig timeFilterArray[TIMER_MAX];
|
||||
static DemuxFilterType filterLinkageTypes[LINKAGE_DIR][FILTER_MAIN_TYPE_BIT_COUNT];
|
||||
static DvrConfig dvrArray[DVR_MAX];
|
||||
static DescramblerConfig descramblerArray[DESC_MAX];
|
||||
|
@ -318,6 +329,12 @@ inline void initFilterConfig() {
|
|||
filterLinkageTypes[SINK][4] = filterLinkageTypes[SOURCE][4];
|
||||
};
|
||||
|
||||
/** Configuration array for the timer filter test */
|
||||
inline void initTimeFilterConfig() {
|
||||
timeFilterArray[TIMER0].supportTimeFilter = true;
|
||||
timeFilterArray[TIMER0].timeStamp = 1;
|
||||
}
|
||||
|
||||
/** Configuration array for the dvr test */
|
||||
inline void initDvrConfig() {
|
||||
RecordSettings recordSettings{
|
||||
|
|
Loading…
Reference in a new issue