RTSPSource: relax error condition.
Allow stream to play when first RTP packet is missed and first arrived packet
is not far away from the expected first seq num.
Bug: 29747759
Bug: 29625129
Change-Id: I0acb839eb4a4d4d24fff4852186f7c8ccd35ac1b
diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h
index abe2582..42a1182 100644
--- a/media/libstagefright/rtsp/MyHandler.h
+++ b/media/libstagefright/rtsp/MyHandler.h
@@ -1843,13 +1843,19 @@
// RTSP "PLAY" command should be used to detect the first RTP packet
// after seeking.
if (track->mAllowedStaleAccessUnits > 0) {
- if ((((seqNum ^ track->mFirstSeqNumInSegment) & 0xffff) != 0)) {
+ uint32_t seqNum16 = seqNum & 0xffff;
+ uint32_t firstSeqNumInSegment16 = track->mFirstSeqNumInSegment & 0xffff;
+ if (seqNum16 > firstSeqNumInSegment16 + kMaxAllowedStaleAccessUnits
+ || seqNum16 < firstSeqNumInSegment16) {
// Not the first rtp packet of the stream after seeking, discarding.
track->mAllowedStaleAccessUnits--;
ALOGV("discarding stale access unit (0x%x : 0x%x)",
seqNum, track->mFirstSeqNumInSegment);
continue;
}
+ ALOGW_IF(seqNum16 != firstSeqNumInSegment16,
+ "Missing the first packet(%u), now take packet(%u) as first one",
+ track->mFirstSeqNumInSegment, seqNum);
} else { // track->mAllowedStaleAccessUnits <= 0
mNumAccessUnitsReceived = 0;
ALOGW_IF(track->mAllowedStaleAccessUnits == 0,