Move testing ts on Cuttlefish under /data/ directory
/data directory is a proper place for test pusher to adb push the ts
during run time. It saves image size comparing to bundle the ts during
compiling.
Files under the /data directory could only be passed around by fd
instead of directly opening. This CL also changes the way the DVR VTS
reads the ts.
Also for virtual frontend, to read the shell data file, we need the
DVR playback to input the data when testing frontend.
This CL also changes the way default implementation reads the data -
from the dvr playback fmq.
Test: atest VtsHalTvTunerV1_0TargetTest
Bug: 153366959
Change-Id: I72a98e4c4c0328206da106fb1c3459745c1644b7
diff --git a/tv/tuner/1.0/default/Dvr.cpp b/tv/tuner/1.0/default/Dvr.cpp
index adb2635..68e175c 100644
--- a/tv/tuner/1.0/default/Dvr.cpp
+++ b/tv/tuner/1.0/default/Dvr.cpp
@@ -70,8 +70,7 @@
return status;
}
- // check if the attached filter is a record filter
- mFilters[filterId] = filter;
+ // TODO check if the attached filter is a record filter
if (!mDemux->attachRecordFilter(filterId)) {
return Result::INVALID_ARGUMENT;
}
@@ -94,19 +93,8 @@
return status;
}
- std::map<uint32_t, sp<IFilter>>::iterator it;
-
- it = mFilters.find(filterId);
- if (it != mFilters.end()) {
- mFilters.erase(filterId);
- if (!mDemux->detachRecordFilter(filterId)) {
- return Result::INVALID_ARGUMENT;
- }
- }
-
- // If all the filters are detached, record can't be started
- if (mFilters.empty()) {
- mIsRecordFilterAttached = false;
+ if (!mDemux->detachRecordFilter(filterId)) {
+ return Result::INVALID_ARGUMENT;
}
return Result::SUCCESS;
@@ -183,6 +171,10 @@
return true;
}
+EventFlag* Dvr::getDvrEventFlag() {
+ return mDvrEventFlag;
+}
+
void* Dvr::__threadLoopPlayback(void* user) {
Dvr* const self = static_cast<Dvr*>(user);
self->playbackThreadLoop();
@@ -205,8 +197,9 @@
}
// Our current implementation filter the data and write it into the filter FMQ immediately
// after the DATA_READY from the VTS/framework
- if (!readPlaybackFMQ() || !startFilterDispatcher()) {
- ALOGD("[Dvr] playback data failed to be filtered. Ending thread");
+ if (!readPlaybackFMQ(false /*isVirtualFrontend*/, false /*isRecording*/) ||
+ !startFilterDispatcher(false /*isVirtualFrontend*/, false /*isRecording*/)) {
+ ALOGE("[Dvr] playback data failed to be filtered. Ending thread");
break;
}
@@ -245,7 +238,7 @@
return mPlaybackStatus;
}
-bool Dvr::readPlaybackFMQ() {
+bool Dvr::readPlaybackFMQ(bool isVirtualFrontend, bool isRecording) {
// Read playback data from the input FMQ
int size = mDvrMQ->availableToRead();
int playbackPacketSize = mDvrSettings.playback().packetSize;
@@ -256,7 +249,15 @@
if (!mDvrMQ->read(dataOutputBuffer.data(), playbackPacketSize)) {
return false;
}
- startTpidFilter(dataOutputBuffer);
+ if (isVirtualFrontend) {
+ if (isRecording) {
+ mDemux->sendFrontendInputToRecord(dataOutputBuffer);
+ } else {
+ mDemux->startBroadcastTsFilter(dataOutputBuffer);
+ }
+ } else {
+ startTpidFilter(dataOutputBuffer);
+ }
}
return true;
@@ -275,7 +276,15 @@
}
}
-bool Dvr::startFilterDispatcher() {
+bool Dvr::startFilterDispatcher(bool isVirtualFrontend, bool isRecording) {
+ if (isVirtualFrontend) {
+ if (isRecording) {
+ return mDemux->startRecordFilterDispatcher();
+ } else {
+ return mDemux->startBroadcastFilterDispatcher();
+ }
+ }
+
std::map<uint32_t, sp<IFilter>>::iterator it;
// Handle the output data per filter type
for (it = mFilters.begin(); it != mFilters.end(); it++) {
@@ -329,27 +338,15 @@
return mRecordStatus;
}
-bool Dvr::addPlaybackFilter(sp<IFilter> filter) {
- uint32_t filterId;
- Result status;
-
- filter->getId([&](Result result, uint32_t id) {
- filterId = id;
- status = result;
- });
-
- if (status != Result::SUCCESS) {
- return false;
- }
-
+bool Dvr::addPlaybackFilter(uint32_t filterId, sp<IFilter> filter) {
mFilters[filterId] = filter;
return true;
}
-DvrType Dvr::getType() {
- return mType;
+bool Dvr::removePlaybackFilter(uint32_t filterId) {
+ mFilters.erase(filterId);
+ return true;
}
-
} // namespace implementation
} // namespace V1_0
} // namespace tuner