Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b563709 authored by Amy Zhang's avatar Amy Zhang Committed by Android (Google) Code Review
Browse files

Merge "Add Scrambling Status Monitor merchanism in Tuner 1.1"

parents 803f77cd b6d44ea4
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -81,4 +81,21 @@ interface IFilter extends @1.0::IFilter {
     *         UNKNOWN_ERROR if failed for other reasons.
     */
    configureAvStreamType(AvStreamType avStreamType) generates (Result result);

    /**
     * Configure the filter to monitor specific Scrambling Status.
     *
     * Scrambling Status should be sent through the filer callback at the following two scenarios:
     *   1. When this method is called, the first detected scrambling status should be sent.
     *   2. When the filter transits into the monitored statuses configured through this method,
     *      event should be sent.
     *
     * @param statuses Scrambling Statuses to monitor. Set corresponding bit to monitor. Reset to
     *        stop monitoring.
     * @return result Result status of the operation.
     *         SUCCESS if successful,
     *         INVALID_STATE if configure can't be applied,
     *         UNKNOWN_ERROR if failed for other reasons.
     */
    configureScramblingEvent(bitfield<ScramblingStatus> statuses) generates (Result result);
};
+22 −0
Original line number Diff line number Diff line
@@ -249,6 +249,28 @@ Return<Result> Filter::configureAvStreamType(const V1_1::AvStreamType& avStreamT
    return Result::SUCCESS;
}

Return<Result> Filter::configureScramblingEvent(uint32_t statuses) {
    ALOGV("%s", __FUNCTION__);

    mStatuses = statuses;
    if (mCallback_1_1 != nullptr) {
        // Assuming current status is always NOT_SCRAMBLED
        V1_1::DemuxFilterEventExt filterEventExt;
        V1_1::DemuxFilterEventExt::Event event;
        event.scramblingStatus(V1_1::ScramblingStatus::NOT_SCRAMBLED);
        int size = filterEventExt.events.size();
        filterEventExt.events.resize(size + 1);
        filterEventExt.events[size] = event;
        DemuxFilterEvent emptyFilterEvent;

        mCallback_1_1->onFilterEvent_1_1(emptyFilterEvent, filterEventExt);
        mFilterEventExt.events.resize(0);
    } else {
        return Result::INVALID_STATE;
    }
    return Result::SUCCESS;
}

bool Filter::createFilterMQ() {
    ALOGV("%s", __FUNCTION__);

+5 −0
Original line number Diff line number Diff line
@@ -84,6 +84,8 @@ class Filter : public V1_1::IFilter {

    virtual Return<Result> configureAvStreamType(const V1_1::AvStreamType& avStreamType) override;

    virtual Return<Result> configureScramblingEvent(uint32_t statuses) override;

    /**
     * To create a FilterMQ and its Event Flag.
     *
@@ -230,6 +232,9 @@ class Filter : public V1_1::IFilter {

    uint32_t mAudioStreamType;
    uint32_t mVideoStreamType;

    // Scrambling status to be monitored
    uint32_t mStatuses = 0;
};

}  // namespace implementation
+21 −0
Original line number Diff line number Diff line
@@ -125,6 +125,8 @@ struct DemuxFilterEventExt {
        DemuxFilterRecordEventExt tsRecord;

        DemuxFilterRecordEventExt mmtpRecord;

        ScramblingStatus scramblingStatus;
    };

    /**
@@ -133,6 +135,25 @@ struct DemuxFilterEventExt {
    vec<Event> events;
};

/**
 * Scrambling Status Type.
 */
@export
enum ScramblingStatus : uint32_t {
    /**
     * Content’s scrambling status is unknown
     */
    UNKNOWN = 1 << 0,
    /**
     * Content is not scrambled.
     */
    NOT_SCRAMBLED = 1 << 1,
    /**
     * Content is scrambled.
     */
    SCRAMBLED = 1 << 2,
};

typedef FrontendDvbcSpectralInversion FrontendSpectralInversion;

/**
+31 −0
Original line number Diff line number Diff line
@@ -28,6 +28,18 @@ void FilterCallback::testFilterDataOutput() {
    ALOGW("[vts] pass and stop");
}

void FilterCallback::testFilterScramblingEvent() {
    android::Mutex::Autolock autoLock(mMsgLock);
    while (mScramblingStatusEvent < 1) {
        if (-ETIMEDOUT == mMsgCondition.waitRelative(mMsgLock, WAIT_TIMEOUT)) {
            EXPECT_TRUE(false) << "scrambling event does not output within timeout";
            return;
        }
    }
    mScramblingStatusEvent = 0;
    ALOGW("[vts] pass and stop");
}

void FilterCallback::readFilterEventData() {
    ALOGW("[vts] reading filter event");
    // todo separate filter handlers
@@ -56,6 +68,9 @@ void FilterCallback::readFilterEventData() {
                      eventExt.mmtpRecord().pts, eventExt.mmtpRecord().firstMbInSlice,
                      eventExt.mmtpRecord().mpuSequenceNumber);
                break;
            case DemuxFilterEventExt::Event::hidl_discriminator::scramblingStatus:
                mScramblingStatusEvent++;
                break;
            default:
                break;
        }
@@ -240,3 +255,19 @@ AssertionResult FilterTests::closeFilter(uint64_t filterId) {
    }
    return AssertionResult(status == Result::SUCCESS);
}

AssertionResult FilterTests::configureScramblingEvent(uint64_t filterId, uint32_t statuses) {
    EXPECT_TRUE(mFilters[filterId]) << "Test with getNewlyOpenedFilterId first.";
    Result status;

    sp<android::hardware::tv::tuner::V1_1::IFilter> filter_v1_1 =
            android::hardware::tv::tuner::V1_1::IFilter::castFrom(mFilters[filterId]);
    if (filter_v1_1 != NULL) {
        status = filter_v1_1->configureScramblingEvent(statuses);
        mFilterCallbacks[filterId]->testFilterScramblingEvent();
    } else {
        ALOGW("[vts] Can't cast IFilter into v1_1.");
        return failure();
    }
    return AssertionResult(status == Result::SUCCESS);
}
Loading