diff --git a/src/Rtsp/Rtsp.cpp b/src/Rtsp/Rtsp.cpp index b63985a0..9ea1d93d 100644 --- a/src/Rtsp/Rtsp.cpp +++ b/src/Rtsp/Rtsp.cpp @@ -538,8 +538,8 @@ uint32_t RtpPacket::getStamp() const { return ntohl(getHeader()->stamp); } -uint32_t RtpPacket::getStampMS() const { - return ntp_stamp & 0xFFFFFFFF; +uint32_t RtpPacket::getStampMS(bool ntp) const { + return ntp ? ntp_stamp & 0xFFFFFFFF : getStamp() * uint64_t(1000) / sample_rate; } uint32_t RtpPacket::getSSRC() const { diff --git a/src/Rtsp/Rtsp.h b/src/Rtsp/Rtsp.h index 84db8e84..ca9c00be 100644 --- a/src/Rtsp/Rtsp.h +++ b/src/Rtsp/Rtsp.h @@ -159,7 +159,7 @@ public: uint16_t getSeq() const; uint32_t getStamp() const; //主机字节序的时间戳,已经转换为毫秒 - uint32_t getStampMS() const; + uint32_t getStampMS(bool ntp = true) const; //主机字节序的ssrc uint32_t getSSRC() const; //有效负载,跳过csrc、ext diff --git a/webrtc/Nack.cpp b/webrtc/Nack.cpp index 6628e507..60d314b3 100644 --- a/webrtc/Nack.cpp +++ b/webrtc/Nack.cpp @@ -60,8 +60,8 @@ uint32_t NackList::get_cache_ms() { if (_nack_cache_seq.size() < 2) { return 0; } - uint32_t back = _nack_cache_pkt[_nack_cache_seq.back()]->getStampMS(); - uint32_t front = _nack_cache_pkt[_nack_cache_seq.front()]->getStampMS(); + uint32_t back = _nack_cache_pkt[_nack_cache_seq.back()]->getStampMS(false); + uint32_t front = _nack_cache_pkt[_nack_cache_seq.front()]->getStampMS(false); if (back >= front) { return back - front; }