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

Commit 669ad13d authored by Andreas Huber's avatar Andreas Huber
Browse files

Allow optional specification of a PTS timestamp when signalling a discontinuity.

If present, rendering will be suppressed until reaching the timestamp.

Change-Id: Ic64bdf4225063c5a4d042ea9809960b843a46d19
related-to-bug: 3489454
parent ded35fcf
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -45,6 +45,12 @@ struct IStreamListener : public IInterface {

    virtual void queueBuffer(size_t index, size_t size) = 0;

    // When signalling a discontinuity you can optionally
    // specify an int64_t PTS timestamp in "msg".
    // If present, rendering of data following the discontinuity
    // will be suppressed until media time reaches this timestamp.
    static const char *const kKeyResumeAtPTS;

    virtual void issueCommand(
            Command cmd, bool synchronous, const sp<AMessage> &msg = NULL) = 0;
};
+3 −0
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@

namespace android {

// static
const char *const IStreamListener::kKeyResumeAtPTS = "resume-at-PTS";

enum {
    // IStreamSource
    SET_LISTENER = IBinder::FIRST_CALL_TRANSACTION,
+3 −1
Original line number Diff line number Diff line
@@ -96,10 +96,12 @@ bool NuPlayer::HTTPLiveSource::feedMoreTSData() {
        } else {
            if (buffer[0] == 0x00) {
                // XXX legacy
                sp<AMessage> extra;
                mTSParser->signalDiscontinuity(
                        buffer[1] == 0x00
                            ? ATSParser::DISCONTINUITY_SEEK
                            : ATSParser::DISCONTINUITY_FORMATCHANGE);
                            : ATSParser::DISCONTINUITY_FORMATCHANGE,
                        extra);
            } else {
                mTSParser->feedTSPacket(buffer, sizeof(buffer));
            }
+48 −0
Original line number Diff line number Diff line
@@ -191,6 +191,8 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {

            mAudioEOS = false;
            mVideoEOS = false;
            mSkipRenderingAudioUntilMediaTimeUs = -1;
            mSkipRenderingVideoUntilMediaTimeUs = -1;

            mSource->start();

@@ -592,6 +594,31 @@ status_t NuPlayer::feedDecoderInputData(bool audio, const sp<AMessage> &msg) {
            LOGV("%s discontinuity (formatChange=%d)",
                 audio ? "audio" : "video", formatChange);

            if (audio) {
                mSkipRenderingAudioUntilMediaTimeUs = -1;
            } else {
                mSkipRenderingVideoUntilMediaTimeUs = -1;
            }

            sp<AMessage> extra;
            if (accessUnit->meta()->findMessage("extra", &extra)
                    && extra != NULL) {
                int64_t resumeAtMediaTimeUs;
                if (extra->findInt64(
                            "resume-at-mediatimeUs", &resumeAtMediaTimeUs)) {
                    LOGI("suppressing rendering of %s until %lld us",
                            audio ? "audio" : "video", resumeAtMediaTimeUs);

                    if (audio) {
                        mSkipRenderingAudioUntilMediaTimeUs =
                            resumeAtMediaTimeUs;
                    } else {
                        mSkipRenderingVideoUntilMediaTimeUs =
                            resumeAtMediaTimeUs;
                    }
                }
            }

            flushDecoder(audio, formatChange);
        }

@@ -627,6 +654,27 @@ void NuPlayer::renderBuffer(bool audio, const sp<AMessage> &msg) {

    sp<ABuffer> buffer = static_cast<ABuffer *>(obj.get());

    int64_t &skipUntilMediaTimeUs =
        audio
            ? mSkipRenderingAudioUntilMediaTimeUs
            : mSkipRenderingVideoUntilMediaTimeUs;

    if (skipUntilMediaTimeUs >= 0) {
        int64_t mediaTimeUs;
        CHECK(buffer->meta()->findInt64("timeUs", &mediaTimeUs));

        if (mediaTimeUs < skipUntilMediaTimeUs) {
            LOGV("dropping %s buffer at time %lld as requested.",
                 audio ? "audio" : "video",
                 mediaTimeUs);

            reply->post();
            return;
        }

        skipUntilMediaTimeUs = -1;
    }

    mRenderer->queueBuffer(audio, buffer, reply);
}

+3 −0
Original line number Diff line number Diff line
@@ -112,6 +112,9 @@ private:
    bool mResetInProgress;
    bool mResetPostponed;

    int64_t mSkipRenderingAudioUntilMediaTimeUs;
    int64_t mSkipRenderingVideoUntilMediaTimeUs;

    status_t instantiateDecoder(bool audio, sp<Decoder> *decoder);

    status_t feedDecoderInputData(bool audio, const sp<AMessage> &msg);
Loading