Loading media/libstagefright/rtsp/MyHandler.h +24 −7 Original line number Diff line number Diff line Loading @@ -64,6 +64,10 @@ static int64_t kDefaultKeepAliveTimeoutUs = 60000000ll; static int64_t kPauseDelayUs = 3000000ll; // The allowed maximum number of stale access units at the beginning of // a new sequence. static int32_t kMaxAllowedStaleAccessUnits = 20; namespace android { static bool GetAttribute(const char *s, const char *key, AString *value) { Loading Loading @@ -1049,16 +1053,26 @@ struct MyHandler : public AHandler { } 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 // The sequence number from RTP packet has only 16 bits and is extended // by ARTPSource. Only the low 16 bits of seq in RTP-Info of reply of // RTSP "PLAY" command should be used to detect the first RTP packet // after seeking. if (track->mAllowedStaleAccessUnits > 0) { if ((((seqNum ^ track->mFirstSeqNumInSegment) & 0xffff) != 0)) { // 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); break; } } else { // track->mAllowedStaleAccessUnits <= 0 mNumAccessUnitsReceived = 0; ALOGW_IF(track->mAllowedStaleAccessUnits == 0, "Still no first rtp packet after %d stale ones", kMaxAllowedStaleAccessUnits); track->mAllowedStaleAccessUnits = -1; break; } // Now found the first rtp packet of the stream after seeking. track->mFirstSeqNumInSegment = seqNum; Loading Loading @@ -1516,6 +1530,7 @@ struct MyHandler : public AHandler { TrackInfo *info = &mTracks.editItemAt(trackIndex); info->mFirstSeqNumInSegment = seq; info->mNewSegment = true; info->mAllowedStaleAccessUnits = kMaxAllowedStaleAccessUnits; CHECK(GetAttribute((*it).c_str(), "rtptime", &val)); Loading Loading @@ -1559,6 +1574,7 @@ private: bool mUsingInterleavedTCP; uint32_t mFirstSeqNumInSegment; bool mNewSegment; int32_t mAllowedStaleAccessUnits; uint32_t mRTPAnchor; int64_t mNTPAnchorUs; Loading Loading @@ -1642,6 +1658,7 @@ private: info->mUsingInterleavedTCP = false; info->mFirstSeqNumInSegment = 0; info->mNewSegment = true; info->mAllowedStaleAccessUnits = kMaxAllowedStaleAccessUnits; info->mRTPSocket = -1; info->mRTCPSocket = -1; info->mRTPAnchor = 0; Loading Loading
media/libstagefright/rtsp/MyHandler.h +24 −7 Original line number Diff line number Diff line Loading @@ -64,6 +64,10 @@ static int64_t kDefaultKeepAliveTimeoutUs = 60000000ll; static int64_t kPauseDelayUs = 3000000ll; // The allowed maximum number of stale access units at the beginning of // a new sequence. static int32_t kMaxAllowedStaleAccessUnits = 20; namespace android { static bool GetAttribute(const char *s, const char *key, AString *value) { Loading Loading @@ -1049,16 +1053,26 @@ struct MyHandler : public AHandler { } 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 // The sequence number from RTP packet has only 16 bits and is extended // by ARTPSource. Only the low 16 bits of seq in RTP-Info of reply of // RTSP "PLAY" command should be used to detect the first RTP packet // after seeking. if (track->mAllowedStaleAccessUnits > 0) { if ((((seqNum ^ track->mFirstSeqNumInSegment) & 0xffff) != 0)) { // 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); break; } } else { // track->mAllowedStaleAccessUnits <= 0 mNumAccessUnitsReceived = 0; ALOGW_IF(track->mAllowedStaleAccessUnits == 0, "Still no first rtp packet after %d stale ones", kMaxAllowedStaleAccessUnits); track->mAllowedStaleAccessUnits = -1; break; } // Now found the first rtp packet of the stream after seeking. track->mFirstSeqNumInSegment = seqNum; Loading Loading @@ -1516,6 +1530,7 @@ struct MyHandler : public AHandler { TrackInfo *info = &mTracks.editItemAt(trackIndex); info->mFirstSeqNumInSegment = seq; info->mNewSegment = true; info->mAllowedStaleAccessUnits = kMaxAllowedStaleAccessUnits; CHECK(GetAttribute((*it).c_str(), "rtptime", &val)); Loading Loading @@ -1559,6 +1574,7 @@ private: bool mUsingInterleavedTCP; uint32_t mFirstSeqNumInSegment; bool mNewSegment; int32_t mAllowedStaleAccessUnits; uint32_t mRTPAnchor; int64_t mNTPAnchorUs; Loading Loading @@ -1642,6 +1658,7 @@ private: info->mUsingInterleavedTCP = false; info->mFirstSeqNumInSegment = 0; info->mNewSegment = true; info->mAllowedStaleAccessUnits = kMaxAllowedStaleAccessUnits; info->mRTPSocket = -1; info->mRTCPSocket = -1; info->mRTPAnchor = 0; Loading