解决GB28181推流无ntp时间戳导致的问题

This commit is contained in:
xiongziliang
2021-08-21 18:52:52 +08:00
parent ce41fa268e
commit 41c09757a7
3 changed files with 15 additions and 4 deletions

View File

@@ -89,14 +89,20 @@ RtpPacket::Ptr RtpTrack::inputRtp(TrackType type, int sample_rate, uint8_t *ptr,
data[3] = len & 0xFF;
//拷贝rtp
memcpy(&data[4], ptr, len);
//设置ntp时间戳
rtp->ntp_stamp = _ntp_stamp.getNtpStamp(ntohl(rtp->getHeader()->stamp), sample_rate);
if (_disable_ntp) {
//不支持ntp时间戳例如国标推流那么直接使用rtp时间戳
rtp->ntp_stamp = rtp->getStamp() * uint64_t(1000) / sample_rate;
} else {
//设置ntp时间戳
rtp->ntp_stamp = _ntp_stamp.getNtpStamp(ntohl(rtp->getHeader()->stamp), sample_rate);
}
onBeforeRtpSorted(rtp);
sortPacket(rtp->getSeq(), rtp);
return rtp;
}
void RtpTrack::setNtpStamp(uint32_t rtp_stamp, uint32_t sample_rate, uint64_t ntp_stamp_ms){
void RtpTrack::setNtpStamp(uint32_t rtp_stamp, uint32_t sample_rate, uint64_t ntp_stamp_ms) {
_disable_ntp = rtp_stamp == 0 && sample_rate == 0 && ntp_stamp_ms == 0;
_ntp_stamp.setNtpStamp(rtp_stamp, sample_rate, ntp_stamp_ms);
}