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

Commit 9f82b731 authored by Wei Jia's avatar Wei Jia Committed by android-build-merger
Browse files

Merge "RTSP: correctly discard stale access unit after seeking." into nyc-dev

am: 505abca7

* commit '505abca7':
  RTSP: correctly discard stale access unit after seeking.

Change-Id: Ic3fcf038963ed1511ecff9e7bca6ef2dfd3522d9
parents 1c81d9b5 505abca7
Loading
Loading
Loading
Loading
+23 −4
Original line number Diff line number Diff line
@@ -1048,16 +1048,29 @@ struct MyHandler : public AHandler {
                    break;
                }

                if (seqNum < track->mFirstSeqNumInSegment) {
                    ALOGV("dropping stale access-unit (%d < %d)",
                if (track->mNewSegment) {
                    // The sequence number from RTP packet has only 16 bits and is adjusted
                    // by the client. Only the low 16 bits of seq in RTP-Info of reply of
                    // RTSP "PLAY" command should be used to detect the first RTP patcket
                    // after seeking.
                    if ((((seqNum ^ track->mFirstSeqNumInSegment) & 0xffff) != 0)) {
                        // Not the first rtp packet of the stream after seeking, discarding.
                        ALOGV("discarding stale access unit (0x%x : 0x%x)",
                             seqNum, track->mFirstSeqNumInSegment);
                        break;
                    }

                if (track->mNewSegment) {
                    // Now found the first rtp packet of the stream after seeking.
                    track->mFirstSeqNumInSegment = seqNum;
                    track->mNewSegment = false;
                }

                if (seqNum < track->mFirstSeqNumInSegment) {
                    ALOGV("dropping stale access-unit (%d < %d)",
                         seqNum, track->mFirstSeqNumInSegment);
                    break;
                }

                onAccessUnitComplete(trackIndex, accessUnit);
                break;
            }
@@ -1336,6 +1349,12 @@ struct MyHandler : public AHandler {
                mPausing = false;
                mSeekPending = false;

                // Discard all stale access units.
                for (size_t i = 0; i < mTracks.size(); ++i) {
                    TrackInfo *track = &mTracks.editItemAt(i);
                    track->mPackets.clear();
                }

                sp<AMessage> msg = mNotify->dup();
                msg->setInt32("what", kWhatSeekDone);
                msg->post();