Merge changes from topic "frontend"

* changes:
  Playback VTS modulization
  Add DVBC/DVBS/ISDBT/ISDBS/ISDBS3/ATSC3 support default implementation
  Add DVBC/DVBS/ISDBT/ISDBS/ISDBS3/ATSC3 support
This commit is contained in:
Amy Zhang 2019-09-25 19:56:03 +00:00 committed by Gerrit Code Review
commit 6494b4c9a6
14 changed files with 1570 additions and 71 deletions

View file

@ -13,6 +13,7 @@ hidl_interface {
"IDescrambler.hal",
"IFrontend.hal",
"IFrontendCallback.hal",
"ILnb.hal",
"ITuner.hal",
],
interfaces: [

View file

@ -16,6 +16,7 @@
package android.hardware.tv.tuner@1.0;
import IFrontendCallback;
import ILnb;
/**
* A Tuner Frontend is used to tune to a frequency and lock signal. It provide
@ -79,4 +80,98 @@ interface IFrontend {
* UNKNOWN_ERROR if failed for other reasons.
*/
close() generates (Result result);
/**
* Scan the frontend to use the settings given.
*
* This uses the frontend to start a scan from signal delivery information.
* If previous scan isn't completed, this call MUST stop previous scan,
* and start a new scan.
* Scan is an async call, with FrontendScanMessage sent via callback.
*
* @param settings Signal delivery information which the frontend uses to
* scan the signal.
* @param type the type which the frontend uses to scan the signal.
*
* @return result Result status of the operation.
* SUCCESS if successful,
* INVALID_STATE if tuning can't be applied at current stage,
* UNKNOWN_ERROR if tuning failed for other reasons.
*/
scan(FrontendSettings settings, FrontendScanType type) generates (Result result);
/**
* Stops a previous scanning.
*
* If the method completes successfully, the frontend stop previous
* scanning.
*
* @return result Result status of the operation.
* SUCCESS if successfully stop tuning.
* UNKNOWN_ERROR if failed for other reasons.
*/
stopScan() generates (Result result);
/**
* Gets the statuses of the frontend.
*
* This retrieve the statuses of the frontend for given status types.
*
* @param statusTypes an array of status type which the caller request.
*
* @return result Result status of the operation.
* SUCCESS if successful,
* INVALID_STATE if tuning can't be applied at current stage,
* UNKNOWN_ERROR if tuning failed for other reasons.
* @return statuses an array of statuses which response the caller's
* request.
*/
getStatus(vec<FrontendStatusType> statusTypes) generates (Result result, vec<FrontendStatus> statuses);
/**
* Sets Low-Noise Block downconverter (LNB) for satellite frontend.
*
* This assigns a hardware LNB resource to the satellite frontend. It can be
* called multiple times to update LNB assignment. The LNB resource must be
* released when the frontend is closed.
*
* @param lnbId the Id of assigned LNB resource.
*
* @return result Result status of the operation.
* SUCCESS if successful,
* INVALID_STATE if the frontend can't be set with a LNB, such as
* cable frontend.
* UNKNOWN_ERROR if failed for other reasons.
*/
setLnb(ILnb lnb) generates (Result result);
/**
* Enble or Disable Low Noise Amplifier (LNA).
*
* @param bEnable true if activate LNA module; false if deactivate LNA
*
* @return result Result status of the operation.
* SUCCESS if successful,
* INVALID_STATE if the frontend doesn't support LNA.
* UNKNOWN_ERROR if failed for other reasons.
*/
setLna(bool bEnable) generates (Result result);
/**
* Sends DiSEqC (Digital Satellite Equipment Control) message.
*
* Client sends DiSeqc message to DiSEqc compatible device through the
* frontend. The response message from the device comes back to the client
* through frontend's callback onDiseqcMessage.
*
* @param diseqcMessage a byte array of data for DiSEqC message which is
* specified by EUTELSAT Bus Functional Specification Version 4.2.
*
* @return result Result status of the operation.
* SUCCESS if successful,
* INVALID_STATE if the frontend can't send DiSEqc Message, such as
* cable frontend.
* UNKNOWN_ERROR if failed for other reasons.
*/
sendDiseqcMessage(vec<uint8_t> diseqcMessage) generates (Result result);
};

View file

@ -33,5 +33,13 @@ interface IFrontendCallback {
* Specification Version 4.2.
*/
oneway onDiseqcMessage(vec<uint8_t> diseqcMessage);
};
/**
* The callback function that must be called by HAL implementation to notify
* the client of scan messages.
*
* @param type the type of scan message.
* @param message the scan message sent by HAL to the client.
*/
oneway onScanMessage(FrontendScanMessageType type, FrontendScanMessage message);
};

68
tv/tuner/1.0/ILnb.hal Normal file
View file

@ -0,0 +1,68 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.tv.tuner@1.0;
/**
* A Tuner LNB (low-noise block downconverter) is used by satellite frontend
* to receive the microwave signal from the satellite, amplify it, and
* downconvert the frequency to a lower frequency.
*/
interface ILnb {
/**
* Set the lnb's power voltage.
*
* @param voltage the power's voltage the Lnb to use.
* @return result Result status of the operation.
* SUCCESS if successful,
* INVALID_ARGUMENT if the selected voltage isn't allowed,
* UNKNOWN_ERROR if failed for other reasons.
*/
setVoltage(FrontendLnbVoltage voltage) generates (Result result);
/**
* Set the lnb's tone mode.
*
* @param tone the tone mode the Lnb to use.
* @return result Result status of the operation.
* SUCCESS if successful,
* INVALID_ARGUMENT if the selected tone mode isn't allowed,
* UNKNOWN_ERROR if failed for other reasons.
*/
setTone(FrontendLnbTone tone) generates (Result result);
/**
* Select the lnb's position.
*
* @param position the position the Lnb to use.
* @return result Result status of the operation.
* SUCCESS if successful,
* INVALID_ARGUMENT if the selected position isn't allowed,
* UNKNOWN_ERROR if failed for other reasons.
*/
setSatellitePosition(FrontendLnbPosition position) generates (Result result);
/**
* Releases the LNB instance
*
* Associated resources are released. close may be called more than once.
* Calls to any other method after this will return an error
*
* @return result Result status of the operation.
* SUCCESS if successful,
* UNKNOWN_ERROR if failed for other reasons.
*/
close() generates (Result result);
};

View file

@ -19,6 +19,7 @@ package android.hardware.tv.tuner@1.0;
import IDemux;
import IDescrambler;
import IFrontend;
import ILnb;
/**
* Top level interface to manage Frontend, Demux and Decrambler hardware
@ -45,6 +46,7 @@ interface ITuner {
* @param frontendId the id of the frontend to be opened.
* @return result Result status of the operation.
* SUCCESS if successful,
* UNAVAILABLE if no resource.
* UNKNOWN_ERROR if creation failed for other reasons.
* @return frontend the newly created frontend interface.
*/
@ -62,7 +64,7 @@ interface ITuner {
* @return demuxId newly created demux id.
* @return demux the newly created demux interface.
*/
openDemux()
openDemux()
generates (Result result, DemuxId demuxId, IDemux demux);
/**
@ -75,6 +77,48 @@ interface ITuner {
* UNKNOWN_ERROR if creation failed for other reasons.
* @return descrambler the newly created descrambler interface.
*/
openDescrambler()
openDescrambler()
generates (Result result, IDescrambler descrambler);
/**
* Create a new instance of Descrambler.
*
* It is used by the client to create a Descrambler instance.
*
* @return result Result status of the operation.
* SUCCESS if successful,
* UNKNOWN_ERROR if creation failed for other reasons.
* @return descrambler the newly created descrambler interface.
*/
getFrontendInfo(FrontendId frontendId)
generates (Result result, FrontendInfo info);
/**
* Get low-noise block downconverter (LNB) IDs.
*
* It is used by the client to get all available LNBs' IDs.
*
* @return result Result status of the operation.
* SUCCESS if successful,
* UNKNOWN_ERROR if tuning failed for other reasons.
* @return frontendIds an array of LnbId for the available LNBs.
*/
getLnbIds() generates (Result result, vec<LnbId> lnbIds);
/**
* Create a new instance of Lnb given a lnbId.
*
* It is used by the client to create a Lnb instance for satellite Frontend.
*
* @param lnbId the id of the LNB to be opened.
* @return result Result status of the operation.
* SUCCESS if successful,
* UNAVAILABLE if no resource.
* UNKNOWN_ERROR if creation failed for other reasons.
* @return lnb the newly created Lnb interface.
*/
openLnbById(LnbId lnbId)
generates (Result result, ILnb lnb);
};

View file

@ -8,6 +8,7 @@ cc_defaults {
"Descrambler.cpp",
"Demux.cpp",
"Tuner.cpp",
"Lnb.cpp",
"service.cpp",
],

View file

@ -77,6 +77,46 @@ Return<Result> Frontend::stopTune() {
return Result::SUCCESS;
}
Return<Result> Frontend::scan(const FrontendSettings& /* settings */, FrontendScanType /* type */) {
ALOGV("%s", __FUNCTION__);
return Result::SUCCESS;
}
Return<Result> Frontend::stopScan() {
ALOGV("%s", __FUNCTION__);
return Result::SUCCESS;
}
Return<void> Frontend::getStatus(const hidl_vec<FrontendStatusType>& /* statusTypes */,
getStatus_cb _hidl_cb) {
ALOGV("%s", __FUNCTION__);
vector<FrontendStatus> statuses;
_hidl_cb(Result::SUCCESS, statuses);
return Void();
}
Return<Result> Frontend::setLna(bool /* bEnable */) {
ALOGV("%s", __FUNCTION__);
return Result::SUCCESS;
}
Return<Result> Frontend::setLnb(const sp<ILnb>& /* lnb */) {
ALOGV("%s", __FUNCTION__);
return Result::SUCCESS;
}
Return<Result> Frontend::sendDiseqcMessage(const hidl_vec<uint8_t>& /* diseqcMessage */) {
ALOGV("%s", __FUNCTION__);
return Result::SUCCESS;
}
FrontendType Frontend::getFrontendType() {
return mType;
}

View file

@ -38,6 +38,7 @@ using ::android::hardware::tv::tuner::V1_0::Result;
class Frontend : public IFrontend {
public:
Frontend();
Frontend(FrontendType type, FrontendId id);
virtual Return<Result> close() override;
@ -48,6 +49,19 @@ class Frontend : public IFrontend {
virtual Return<Result> stopTune() override;
virtual Return<Result> scan(const FrontendSettings& settings, FrontendScanType type) override;
virtual Return<Result> stopScan() override;
virtual Return<void> getStatus(const hidl_vec<FrontendStatusType>& statusTypes,
getStatus_cb _hidl_cb) override;
virtual Return<Result> sendDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage) override;
virtual Return<Result> setLna(bool bEnable) override;
virtual Return<Result> setLnb(const sp<ILnb>& lnb) override;
FrontendType getFrontendType();
FrontendId getFrontendId();

View file

@ -0,0 +1,62 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "android.hardware.tv.tuner@1.0-Lnb"
#include "Lnb.h"
#include <utils/Log.h>
namespace android {
namespace hardware {
namespace tv {
namespace tuner {
namespace V1_0 {
namespace implementation {
Lnb::Lnb() {}
Lnb::~Lnb() {}
Return<Result> Lnb::setVoltage(FrontendLnbVoltage /* voltage */) {
ALOGV("%s", __FUNCTION__);
return Result::SUCCESS;
}
Return<Result> Lnb::setTone(FrontendLnbTone /* tone */) {
ALOGV("%s", __FUNCTION__);
return Result::SUCCESS;
}
Return<Result> Lnb::setSatellitePosition(FrontendLnbPosition /* position */) {
ALOGV("%s", __FUNCTION__);
return Result::SUCCESS;
}
Return<Result> Lnb::close() {
ALOGV("%s", __FUNCTION__);
return Result::SUCCESS;
}
} // namespace implementation
} // namespace V1_0
} // namespace tuner
} // namespace tv
} // namespace hardware
} // namespace android

View file

@ -0,0 +1,60 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_HARDWARE_TV_TUNER_V1_0_LNB_H_
#define ANDROID_HARDWARE_TV_TUNER_V1_0_LNB_H_
#include <android/hardware/tv/tuner/1.0/ILnb.h>
#include <android/hardware/tv/tuner/1.0/ITuner.h>
using namespace std;
namespace android {
namespace hardware {
namespace tv {
namespace tuner {
namespace V1_0 {
namespace implementation {
using ::android::hardware::tv::tuner::V1_0::FrontendLnbPosition;
using ::android::hardware::tv::tuner::V1_0::FrontendLnbTone;
using ::android::hardware::tv::tuner::V1_0::FrontendLnbVoltage;
using ::android::hardware::tv::tuner::V1_0::Result;
class Lnb : public ILnb {
public:
Lnb();
virtual Return<Result> setVoltage(FrontendLnbVoltage voltage);
virtual Return<Result> setTone(FrontendLnbTone tone) override;
virtual Return<Result> setSatellitePosition(FrontendLnbPosition position) override;
virtual Return<Result> close() override;
private:
virtual ~Lnb();
};
} // namespace implementation
} // namespace V1_0
} // namespace tuner
} // namespace tv
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_TV_TUNER_V1_0_LNB_H_

View file

@ -22,6 +22,7 @@
#include "Demux.h"
#include "Descrambler.h"
#include "Frontend.h"
#include "Lnb.h"
namespace android {
namespace hardware {
@ -95,6 +96,33 @@ Return<void> Tuner::openDescrambler(openDescrambler_cb _hidl_cb) {
return Void();
}
Return<void> Tuner::getFrontendInfo(FrontendId /* frontendId */, getFrontendInfo_cb _hidl_cb) {
ALOGV("%s", __FUNCTION__);
FrontendInfo info;
_hidl_cb(Result::SUCCESS, info);
return Void();
}
Return<void> Tuner::getLnbIds(getLnbIds_cb _hidl_cb) {
ALOGV("%s", __FUNCTION__);
vector<LnbId> lnbIds;
_hidl_cb(Result::SUCCESS, lnbIds);
return Void();
}
Return<void> Tuner::openLnbById(LnbId /* lnbId */, openLnbById_cb _hidl_cb) {
ALOGV("%s", __FUNCTION__);
sp<ILnb> lnb = new Lnb();
_hidl_cb(Result::SUCCESS, lnb);
return Void();
}
} // namespace implementation
} // namespace V1_0
} // namespace tuner

View file

@ -41,6 +41,13 @@ class Tuner : public ITuner {
virtual Return<void> openDescrambler(openDescrambler_cb _hidl_cb) override;
virtual Return<void> getFrontendInfo(FrontendId frontendId,
getFrontendInfo_cb _hidl_cb) override;
virtual Return<void> getLnbIds(getLnbIds_cb _hidl_cb) override;
virtual Return<void> openLnbById(LnbId lnbId, openLnbById_cb _hidl_cb) override;
private:
virtual ~Tuner();
// Static mFrontends array to maintain local frontends information

File diff suppressed because it is too large Load diff

View file

@ -36,6 +36,7 @@
#include <utils/Mutex.h>
#include <fstream>
#include <iostream>
#include <map>
#define WAIT_TIMEOUT 3000000000
@ -72,6 +73,8 @@ using android::hardware::tv::tuner::V1_0::FrontendDvbtSettings;
using android::hardware::tv::tuner::V1_0::FrontendEventType;
using android::hardware::tv::tuner::V1_0::FrontendId;
using android::hardware::tv::tuner::V1_0::FrontendInnerFec;
using android::hardware::tv::tuner::V1_0::FrontendScanMessage;
using android::hardware::tv::tuner::V1_0::FrontendScanMessageType;
using android::hardware::tv::tuner::V1_0::FrontendSettings;
using android::hardware::tv::tuner::V1_0::IDemux;
using android::hardware::tv::tuner::V1_0::IDemuxCallback;
@ -159,12 +162,21 @@ class FrontendCallback : public IFrontendCallback {
return Void();
}
virtual Return<void> onScanMessage(FrontendScanMessageType /* type */,
const FrontendScanMessage& /* message */) override {
android::Mutex::Autolock autoLock(mMsgLock);
mScanMessageReceived = true;
mMsgCondition.signal();
return Void();
};
void testOnEvent(sp<IFrontend>& frontend, FrontendSettings settings);
void testOnDiseqcMessage(sp<IFrontend>& frontend, FrontendSettings settings);
private:
bool mEventReceived = false;
bool mDiseqcMessageReceived = false;
bool mScanMessageReceived = false;
FrontendEventType mEventType;
hidl_vec<uint8_t> mEventMessage;
android::Mutex mMsgLock;
@ -205,8 +217,8 @@ class DemuxCallback : public IDemuxCallback {
ALOGW("[VTS] FILTER EVENT %d", filterEvent.filterId);
android::Mutex::Autolock autoLock(mMsgLock);
mFilterEventReceived = true;
// maybe assemble here??
mFilterEvent = filterEvent;
mFilterIdToEvent[filterEvent.filterId] = filterEvent;
startFilterEventThread(filterEvent);
mMsgCondition.signal();
return Void();
}
@ -236,11 +248,19 @@ class DemuxCallback : public IDemuxCallback {
void testOnFilterEvent(uint32_t filterId);
void testOnSectionFilterEvent(sp<IDemux>& demux, uint32_t filterId, MQDesc& filterMQDescriptor,
MQDesc& inputMQDescriptor);
void startPlaybackInputThread(InputConf inputConf, MQDesc& inputMQDescriptor);
bool readAndCompareSectionEventData();
void testFilterDataOutput();
// Legacy
bool readAndCompareSectionEventData(uint32_t filterId);
void startPlaybackInputThread(InputConf inputConf, MQDesc& inputMQDescriptor);
void startFilterEventThread(DemuxFilterEvent event);
static void* __threadLoopInput(void* threadArgs);
static void* __threadLoopFilter(void* threadArgs);
void inputThreadLoop(InputConf inputConf, bool* keepWritingInputFMQ, MQDesc& inputMQDescriptor);
void filterThreadLoop(DemuxFilterEvent& event);
void updateFilterMQ(uint32_t filterId, MQDesc& filterMQDescriptor);
void updateGoldenOutputMap(uint32_t filterId, string goldenOutputFile);
private:
struct InputThreadArgs {
@ -249,22 +269,34 @@ class DemuxCallback : public IDemuxCallback {
bool* keepWritingInputFMQ;
MQDesc& inputMQDesc;
};
bool mFilterEventReceived = false;
std::vector<uint8_t> mDataOutputBuffer;
std::unique_ptr<FilterMQ> mFilterMQ;
std::unique_ptr<FilterMQ> mInputMQ;
struct FilterThreadArgs {
DemuxCallback* user;
DemuxFilterEvent& event;
};
uint16_t mDataLength = 0;
DemuxFilterEvent mFilterEvent;
android::Mutex mMsgLock;
android::Mutex mReadLock;
android::Condition mMsgCondition;
EventFlag* mFilterMQEventFlag;
std::vector<uint8_t> mDataOutputBuffer;
bool mFilterEventReceived;
std::map<uint32_t, string> mFilterIdToGoldenOutput;
std::map<uint32_t, DemuxFilterEvent> mFilterIdToEvent;
std::map<uint32_t, std::unique_ptr<FilterMQ>> mFilterIdToMQ;
std::unique_ptr<FilterMQ> mInputMQ;
std::map<uint32_t, EventFlag*> mFilterIdToMQEventFlag;
EventFlag* mInputMQEventFlag;
android::Mutex mMsgLock;
android::Mutex mFilterOutputLock;
android::Condition mMsgCondition;
android::Condition mFilterOutputCondition;
bool mKeepWritingInputFMQ;
bool mInputThreadRunning;
pthread_t mInputThread;
pthread_t mFilterThread;
};
// Legacy
void DemuxCallback::testOnFilterEvent(uint32_t filterId) {
android::Mutex::Autolock autoLock(mMsgLock);
while (!mFilterEventReceived) {
@ -276,7 +308,7 @@ void DemuxCallback::testOnFilterEvent(uint32_t filterId) {
// Reset the filter event recieved flag
mFilterEventReceived = false;
// Check if filter id match
EXPECT_TRUE(filterId == mFilterEvent.filterId) << "filter id match";
EXPECT_TRUE(filterId == mFilterIdToEvent[filterId].filterId) << "filter id match";
}
void DemuxCallback::startPlaybackInputThread(InputConf inputConf, MQDesc& inputMQDescriptor) {
@ -291,28 +323,42 @@ void DemuxCallback::startPlaybackInputThread(InputConf inputConf, MQDesc& inputM
pthread_setname_np(mInputThread, "test_playback_input_loop");
}
/*void DemuxCallback::testPlaybackDataFlow(bool* keepWritingInputFMQ) {
// timeout logic here
void DemuxCallback::startFilterEventThread(DemuxFilterEvent event) {
struct FilterThreadArgs* threadArgs =
(struct FilterThreadArgs*)malloc(sizeof(struct FilterThreadArgs));
threadArgs->user = this;
threadArgs->event = event;
// assemble logic here
pthread_create(&mFilterThread, NULL, __threadLoopFilter, (void*)threadArgs);
pthread_setname_np(mFilterThread, "test_playback_input_loop");
}
void DemuxCallback::testFilterDataOutput() {
android::Mutex::Autolock autoLock(mFilterOutputLock);
while (!mFilterIdToMQ.empty()) {
if (-ETIMEDOUT == mFilterOutputCondition.waitRelative(mFilterOutputLock, WAIT_TIMEOUT)) {
EXPECT_TRUE(false) << "filter output does not match golden output within timeout";
return;
}
}
}
}*/
// Legacy
void DemuxCallback::testOnSectionFilterEvent(sp<IDemux>& demux, uint32_t filterId,
MQDesc& filterMQDescriptor,
MQDesc& inputMQDescriptor) {
Result status;
// Create MQ to read the output into the local buffer
mFilterMQ = std::make_unique<FilterMQ>(filterMQDescriptor, true /* resetPointers */);
EXPECT_TRUE(mFilterMQ);
mFilterIdToMQ[filterId] =
std::make_unique<FilterMQ>(filterMQDescriptor, true /* resetPointers */);
EXPECT_TRUE(mFilterIdToMQ[filterId]);
// Get the MQ to write the input to the HAL
mInputMQ = std::make_unique<FilterMQ>(inputMQDescriptor, true /* resetPointers */);
EXPECT_TRUE(mInputMQ);
// Create the EventFlag that is used to signal the HAL impl that data have been
// read the Filter FMQ
EXPECT_TRUE(EventFlag::createEventFlag(mFilterMQ->getEventFlagWord(), &mFilterMQEventFlag) ==
android::OK);
EXPECT_TRUE(EventFlag::createEventFlag(mFilterIdToMQ[filterId]->getEventFlagWord(),
&mFilterIdToMQEventFlag[filterId]) == android::OK);
// Create the EventFlag that is used to signal the HAL impl that data have been
// written into the Input FMQ
EXPECT_TRUE(EventFlag::createEventFlag(mInputMQ->getEventFlagWord(), &mInputMQEventFlag) ==
@ -329,21 +375,24 @@ void DemuxCallback::testOnSectionFilterEvent(sp<IDemux>& demux, uint32_t filterI
mInputMQEventFlag->wake(static_cast<uint32_t>(DemuxQueueNotifyBits::DATA_READY));
testOnFilterEvent(filterId);
// checksum of mDataOutputBuffer and Input golden input
if (readAndCompareSectionEventData() && i < SECTION_READ_COUNT - 1) {
mFilterMQEventFlag->wake(static_cast<uint32_t>(DemuxQueueNotifyBits::DATA_CONSUMED));
if (readAndCompareSectionEventData(filterId) && i < SECTION_READ_COUNT - 1) {
mFilterIdToMQEventFlag[filterId]->wake(
static_cast<uint32_t>(DemuxQueueNotifyBits::DATA_CONSUMED));
}
}
}
bool DemuxCallback::readAndCompareSectionEventData() {
// Legacy
bool DemuxCallback::readAndCompareSectionEventData(uint32_t filterId) {
bool result = false;
for (int i = 0; i < mFilterEvent.events.size(); i++) {
DemuxFilterSectionEvent event = mFilterEvent.events[i].section();
DemuxFilterEvent filterEvent = mFilterIdToEvent[filterId];
for (int i = 0; i < filterEvent.events.size(); i++) {
DemuxFilterSectionEvent event = filterEvent.events[i].section();
mDataLength = event.dataLength;
EXPECT_TRUE(mDataLength == goldenDataOutputBuffer.size()) << "buffer size does not match";
mDataOutputBuffer.resize(mDataLength);
result = mFilterMQ->read(mDataOutputBuffer.data(), mDataLength);
result = mFilterIdToMQ[filterId]->read(mDataOutputBuffer.data(), mDataLength);
EXPECT_TRUE(result) << "can't read from Filter MQ";
for (int i = 0; i < mDataLength; i++) {
@ -353,6 +402,18 @@ bool DemuxCallback::readAndCompareSectionEventData() {
return result;
}
void DemuxCallback::updateFilterMQ(uint32_t filterId, MQDesc& filterMQDescriptor) {
mFilterIdToMQ[filterId] =
std::make_unique<FilterMQ>(filterMQDescriptor, true /* resetPointers */);
EXPECT_TRUE(mFilterIdToMQ[filterId]);
EXPECT_TRUE(EventFlag::createEventFlag(mFilterIdToMQ[filterId]->getEventFlagWord(),
&mFilterIdToMQEventFlag[filterId]) == android::OK);
}
void DemuxCallback::updateGoldenOutputMap(uint32_t filterId, string goldenOutputFile) {
mFilterIdToGoldenOutput[filterId] = goldenOutputFile;
}
void* DemuxCallback::__threadLoopInput(void* threadArgs) {
DemuxCallback* const self =
static_cast<DemuxCallback*>(((struct InputThreadArgs*)threadArgs)->user);
@ -413,6 +474,26 @@ void DemuxCallback::inputThreadLoop(InputConf inputConf, bool* keepWritingInputF
inputData.close();
}
void* DemuxCallback::__threadLoopFilter(void* threadArgs) {
DemuxCallback* const self =
static_cast<DemuxCallback*>(((struct FilterThreadArgs*)threadArgs)->user);
self->filterThreadLoop(((struct FilterThreadArgs*)threadArgs)->event);
return 0;
}
void DemuxCallback::filterThreadLoop(DemuxFilterEvent& /*event*/) {
android::Mutex::Autolock autoLock(mFilterOutputLock);
// Read from MQ[event.filterId] per event and filter type
// Assemble to filterOutput[filterId]
// check if filterOutput[filterId] matches goldenOutput[filterId]
// If match, remove filterId entry from MQ map
// end thread
}
// Test environment for Tuner HIDL HAL.
class TunerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
public:
@ -462,16 +543,19 @@ class TunerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
::testing::AssertionResult createDemuxWithFrontend(int32_t frontendId);
::testing::AssertionResult getInputMQDescriptor();
::testing::AssertionResult addInputToDemux(DemuxInputSettings setting);
::testing::AssertionResult addSectionFilterToDemux();
::testing::AssertionResult addFilterToDemux(DemuxFilterType type, DemuxFilterSettings setting);
::testing::AssertionResult getFilterMQDescriptor(const uint32_t filterId);
::testing::AssertionResult closeDemux();
::testing::AssertionResult createDescrambler();
::testing::AssertionResult closeDescrambler();
::testing::AssertionResult readSectionFilterDataOutput();
::testing::AssertionResult playbackDataFlowTest(vector<FilterConf> filterConf,
InputConf inputConf, string goldenOutput);
InputConf inputConf,
vector<string> goldenOutputFiles);
// Legacy
::testing::AssertionResult addSectionFilterToDemux();
::testing::AssertionResult readSectionFilterDataOutput();
};
::testing::AssertionResult TunerHidlTest::createFrontend(int32_t frontendId) {
@ -507,8 +591,6 @@ class TunerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
FrontendDvbtSettings frontendDvbtSettings{
.frequency = 0,
.modulation = FrontendAtscModulation::UNDEFINED,
.fec = FrontendInnerFec::FEC_UNDEFINED,
};
frontendSettings.dvbt(frontendDvbtSettings);
mFrontendCallback->testOnEvent(mFrontend, frontendSettings);
@ -650,6 +732,7 @@ class TunerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
return ::testing::AssertionResult(status == Result::SUCCESS);
}
// Legacy
::testing::AssertionResult TunerHidlTest::addSectionFilterToDemux() {
Result status;
@ -717,6 +800,7 @@ class TunerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
return ::testing::AssertionResult(status == Result::SUCCESS);
}
// Legacy
::testing::AssertionResult TunerHidlTest::readSectionFilterDataOutput() {
// Filter Configuration Module
DemuxInputSettings setting{
@ -744,7 +828,7 @@ class TunerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
::testing::AssertionResult TunerHidlTest::playbackDataFlowTest(vector<FilterConf> filterConf,
InputConf inputConf,
string /*goldenOutput*/) {
vector<string> goldenOutputFiles) {
Result status;
// Filter Configuration Module
for (int i = 0; i < filterConf.size(); i++) {
@ -754,6 +838,12 @@ class TunerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
getFilterMQDescriptor(mFilterId) == ::testing::AssertionFailure()) {
return ::testing::AssertionFailure();
}
mDemuxCallback->updateFilterMQ(mFilterId, mFilterMQDescriptor);
mDemuxCallback->updateGoldenOutputMap(mFilterId, goldenOutputFiles[i]);
status = mDemux->startFilter(mFilterId);
if (status != Result::SUCCESS) {
return ::testing::AssertionFailure();
}
}
// Playback Input Module
@ -769,12 +859,9 @@ class TunerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
}
// Data Verify Module
// golden output, created FMQ to read and EventFlags to DATA_CONSUMED
// Maintain each filter's real output (and how to assemble?????)
// mDemuxCallback->testPlaybackDataFlow();
mDemuxCallback->testFilterDataOutput();
// Clean Up Module
// TODO what about remove input, remove filters
return closeDemux();
}