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

Commit 489aaa45 authored by Robert Shih's avatar Robert Shih Committed by Android Git Automerger
Browse files

am 9febc8a6: Merge "RTSP: clear data/eos status before returning from seek" into mnc-dev

* commit '9febc8a6':
  RTSP: clear data/eos status before returning from seek
parents 8a546413 9febc8a6
Loading
Loading
Loading
Loading
+51 −3
Original line number Diff line number Diff line
@@ -138,8 +138,10 @@ void NuPlayer::RTSPSource::pause() {
}

void NuPlayer::RTSPSource::resume() {
    if (mHandler != NULL) {
        mHandler->resume();
    }
}

status_t NuPlayer::RTSPSource::feedMoreTSData() {
    Mutex::Autolock _l(mBufferingLock);
@@ -295,13 +297,19 @@ status_t NuPlayer::RTSPSource::seekTo(int64_t seekTimeUs) {
    sp<AMessage> msg = new AMessage(kWhatPerformSeek, this);
    msg->setInt32("generation", ++mSeekGeneration);
    msg->setInt64("timeUs", seekTimeUs);
    msg->post(200000ll);

    return OK;
    sp<AMessage> response;
    status_t err = msg->postAndAwaitResponse(&response);
    if (err == OK && response != NULL) {
        CHECK(response->findInt32("err", &err));
    }

    return err;
}

void NuPlayer::RTSPSource::performSeek(int64_t seekTimeUs) {
    if (mState != CONNECTED) {
        finishSeek(INVALID_OPERATION);
        return;
    }

@@ -320,9 +328,11 @@ void NuPlayer::RTSPSource::onMessageReceived(const sp<AMessage> &msg) {
    } else if (msg->what() == kWhatPerformSeek) {
        int32_t generation;
        CHECK(msg->findInt32("generation", &generation));
        CHECK(msg->senderAwaitsResponse(&mSeekReplyID));

        if (generation != mSeekGeneration) {
            // obsolete.
            finishSeek(OK);
            return;
        }

@@ -368,6 +378,37 @@ void NuPlayer::RTSPSource::onMessageReceived(const sp<AMessage> &msg) {
        case MyHandler::kWhatSeekDone:
        {
            mState = CONNECTED;
            if (mSeekReplyID != NULL) {
                // Unblock seekTo here in case we attempted to seek in a live stream
                finishSeek(OK);
            }
            break;
        }

        case MyHandler::kWhatSeekPaused:
        {
            sp<AnotherPacketSource> source = getSource(true /* audio */);
            if (source != NULL) {
                source->queueDiscontinuity(ATSParser::DISCONTINUITY_NONE,
                        /* extra */ NULL,
                        /* discard */ true);
            }
            source = getSource(false /* video */);
            if (source != NULL) {
                source->queueDiscontinuity(ATSParser::DISCONTINUITY_NONE,
                        /* extra */ NULL,
                        /* discard */ true);
            };

            status_t err = OK;
            msg->findInt32("err", &err);
            finishSeek(err);

            if (err == OK) {
                int64_t timeUs;
                CHECK(msg->findInt64("time", &timeUs));
                mHandler->continueSeekAfterPause(timeUs);
            }
            break;
        }

@@ -700,5 +741,12 @@ bool NuPlayer::RTSPSource::stopBufferingIfNecessary() {
    return true;
}

void NuPlayer::RTSPSource::finishSeek(status_t err) {
    CHECK(mSeekReplyID != NULL);
    sp<AMessage> seekReply = new AMessage;
    seekReply->setInt32("err", err);
    seekReply->postReply(mSeekReplyID);
    mSeekReplyID = NULL;
}

}  // namespace android
+3 −0
Original line number Diff line number Diff line
@@ -116,6 +116,8 @@ private:
    int64_t mEOSTimeoutAudio;
    int64_t mEOSTimeoutVideo;

    sp<AReplyToken> mSeekReplyID;

    sp<AnotherPacketSource> getSource(bool audio);

    void onConnected();
@@ -131,6 +133,7 @@ private:
    void setError(status_t err);
    void startBufferingIfNecessary();
    bool stopBufferingIfNecessary();
    void finishSeek(status_t err);

    DISALLOW_EVIL_CONSTRUCTORS(RTSPSource);
};
+26 −2
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ struct MyHandler : public AHandler {
    enum {
        kWhatConnected                  = 'conn',
        kWhatDisconnected               = 'disc',
        kWhatSeekPaused                 = 'spau',
        kWhatSeekDone                   = 'sdon',

        kWhatAccessUnit                 = 'accU',
@@ -220,6 +221,12 @@ struct MyHandler : public AHandler {
        msg->post();
    }

    void continueSeekAfterPause(int64_t timeUs) {
        sp<AMessage> msg = new AMessage('see1', this);
        msg->setInt64("time", timeUs);
        msg->post();
    }

    bool isSeekable() const {
        return mSeekable;
    }
@@ -1180,7 +1187,7 @@ struct MyHandler : public AHandler {
                mCheckPending = true;
                ++mCheckGeneration;

                sp<AMessage> reply = new AMessage('see1', this);
                sp<AMessage> reply = new AMessage('see0', this);
                reply->setInt64("time", timeUs);

                if (mPausing) {
@@ -1203,9 +1210,26 @@ struct MyHandler : public AHandler {
                break;
            }

            case 'see1':
            case 'see0':
            {
                // Session is paused now.
                status_t err = OK;
                msg->findInt32("result", &err);

                int64_t timeUs;
                CHECK(msg->findInt64("time", &timeUs));

                sp<AMessage> notify = mNotify->dup();
                notify->setInt32("what", kWhatSeekPaused);
                notify->setInt32("err", err);
                notify->setInt64("time", timeUs);
                notify->post();
                break;

            }

            case 'see1':
            {
                for (size_t i = 0; i < mTracks.size(); ++i) {
                    TrackInfo *info = &mTracks.editItemAt(i);