Add the address of the first macroblock as an extended field in Tuner 1.1

Record event

Test: atest VtsHalTvTunerV1_1TargetTest
Bug: 158816517
Change-Id: I46b77210d5b97325f770bbb4095897f431aa0ee6
This commit is contained in:
Amy Zhang 2020-10-19 16:13:35 -07:00
parent 1ea0c17ea4
commit 4a6663fd32
6 changed files with 35 additions and 11 deletions

View file

@ -340,17 +340,17 @@ void Filter::filterThreadLoop() {
while (mFilterThreadRunning) {
std::lock_guard<std::mutex> lock(mFilterEventLock);
if (mFilterEvent.events.size() == 0) {
if (mFilterEvent.events.size() == 0 && mFilterEventExt.events.size() == 0) {
continue;
}
// After successfully write, send a callback and wait for the read to be done
if (mCallback != nullptr) {
mCallback->onFilterEvent(mFilterEvent);
mFilterEvent.events.resize(0);
} else if (mCallback_1_1 != nullptr) {
if (mCallback_1_1 != nullptr) {
mCallback_1_1->onFilterEvent_1_1(mFilterEvent, mFilterEventExt);
mFilterEventExt.events.resize(0);
} else if (mCallback != nullptr) {
mCallback->onFilterEvent(mFilterEvent);
}
mFilterEvent.events.resize(0);
break;
}
// We do not wait for the last read to be done
@ -659,6 +659,8 @@ Result Filter::startRecordFilterHandler() {
V1_1::DemuxFilterRecordEventExt recordEventExt;
recordEventExt = {
.pts = (mPts == 0) ? time(NULL) * 900000 : mPts,
.firstMbInSlice = 0, // random address
.mpuSequenceNumber = 1, // random sequence number
};
int size;

View file

@ -47,9 +47,13 @@ import android.hidl.safe_union@1.0::Monostate;
@export
enum Constant : @1.0::Constant {
/**
* An invalid mpuSequenceNumber in DemuxFilterMmtpRecordEvent.
* An invalid mpuSequenceNumber in DemuxFilterRecordEventExt.
*/
INVALID_MMTP_RECORD_EVENT_MPT_SEQUENCE_NUM = 0xFFFFFFFF,
/**
* An invalid first macroblock address in DemuxFilterRecordEventExt.
*/
INVALID_FIRST_MACROBLOCK_IN_SLICE = 0xFFFFFFFF,
/**
* An invalid frenquency that can be used as the default value of the frontend setting.
*/
@ -77,7 +81,7 @@ enum Constant64Bit : uint64_t {
*/
INVALID_AV_SYNC_ID_64BIT = 0xFFFFFFFFFFFFFFFF,
/**
* An invalid pts in the DemuxFilterTsRecordEvent or DemuxFilterMmtpRecordEvent.
* An invalid pts.
*/
INVALID_PRESENTATION_TIME_STAMP = 0xFFFFFFFFFFFFFFFF,
};
@ -96,6 +100,11 @@ struct DemuxFilterRecordEventExt {
* MPU sequence number of the filtered data. This is only used for MMTP.
*/
uint32_t mpuSequenceNumber;
/**
* Specifies the address of the first macroblock in the slice defined in ITU-T Rec. H.264.
*/
uint32_t firstMbInSlice;
};
/**

View file

@ -192,9 +192,10 @@ void DvrCallback::recordThreadLoop(RecordSettings* /*recordSettings*/, bool* kee
bool DvrCallback::readRecordFMQ() {
android::Mutex::Autolock autoLock(mMsgLock);
bool result = false;
int readSize = mRecordMQ->availableToRead();
mDataOutputBuffer.clear();
mDataOutputBuffer.resize(mRecordMQ->availableToRead());
result = mRecordMQ->read(mDataOutputBuffer.data(), mRecordMQ->availableToRead());
mDataOutputBuffer.resize(readSize);
result = mRecordMQ->read(mDataOutputBuffer.data(), readSize);
EXPECT_TRUE(result) << "can't read from Record MQ";
mMsgCondition.signal();
return result;

View file

@ -47,8 +47,14 @@ void FilterCallback::readFilterEventData() {
auto eventExt = mFilterEventExt.events[i];
switch (eventExt.getDiscriminator()) {
case DemuxFilterEventExt::Event::hidl_discriminator::tsRecord:
ALOGD("[vts] Extended TS record filter event, pts=%" PRIu64 ".",
eventExt.tsRecord().pts);
ALOGD("[vts] Extended TS record filter event, pts=%" PRIu64 ", firstMbInSlice=%d",
eventExt.tsRecord().pts, eventExt.tsRecord().firstMbInSlice);
break;
case DemuxFilterEventExt::Event::hidl_discriminator::mmtpRecord:
ALOGD("[vts] Extended MMTP record filter event, pts=%" PRIu64
", firstMbInSlice=%d, mpuSequenceNumber=%d",
eventExt.mmtpRecord().pts, eventExt.mmtpRecord().firstMbInSlice,
eventExt.mmtpRecord().mpuSequenceNumber);
break;
default:
break;

View file

@ -22,6 +22,10 @@ AssertionResult TunerBroadcastHidlTest::filterDataOutputTest() {
return filterDataOutputTestBase(mFilterTests);
}
AssertionResult TunerRecordHidlTest::filterDataOutputTest() {
return filterDataOutputTestBase(mFilterTests);
}
void TunerFilterHidlTest::configSingleFilterInDemuxTest(FilterConfig filterConf,
FrontendConfig frontendConf) {
uint32_t feId;
@ -115,6 +119,7 @@ void TunerRecordHidlTest::recordSingleFilterTest(FilterConfig filterConf,
ASSERT_TRUE(mFilterTests.startFilter(filterId));
ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
mDvrTests.testRecordOutput();
ASSERT_TRUE(filterDataOutputTest());
mDvrTests.stopRecordThread();
ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
ASSERT_TRUE(mFilterTests.stopFilter(filterId));

View file

@ -87,6 +87,7 @@ class TunerRecordHidlTest : public testing::TestWithParam<std::string> {
void recordSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf,
DvrConfig dvrConf);
AssertionResult filterDataOutputTest();
sp<ITuner> mService;
FrontendTests mFrontendTests;