mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-03 17:27:33 +08:00
rtp使用ntp时间戳作为时间戳,用于实现rtsp音视频同步
This commit is contained in:
@@ -22,7 +22,7 @@ RtcpContext::RtcpContext(bool is_receiver) {
|
||||
_is_receiver = is_receiver;
|
||||
}
|
||||
|
||||
void RtcpContext::onRtp(uint16_t seq, uint32_t stamp, uint32_t sample_rate, size_t bytes) {
|
||||
void RtcpContext::onRtp(uint16_t seq, uint32_t stamp, uint64_t ntp_stamp_ms, uint32_t sample_rate, size_t bytes) {
|
||||
if (_is_receiver) {
|
||||
//接收者才做复杂的统计运算
|
||||
auto sys_stamp = getCurrentMillisecond();
|
||||
@@ -65,6 +65,7 @@ void RtcpContext::onRtp(uint16_t seq, uint32_t stamp, uint32_t sample_rate, size
|
||||
++_packets;
|
||||
_bytes += bytes;
|
||||
_last_rtp_stamp = stamp;
|
||||
_last_ntp_stamp_ms = ntp_stamp_ms;
|
||||
}
|
||||
|
||||
void RtcpContext::onRtcp(RtcpHeader *rtcp) {
|
||||
@@ -154,7 +155,7 @@ Buffer::Ptr RtcpContext::createRtcpSR(uint32_t rtcp_ssrc) {
|
||||
throw std::runtime_error("rtp接收者尝试发送sr包");
|
||||
}
|
||||
auto rtcp = RtcpSR::create(0);
|
||||
rtcp->setNtpStamp(getCurrentMillisecond(true));
|
||||
rtcp->setNtpStamp(_last_ntp_stamp_ms);
|
||||
rtcp->rtpts = htonl(_last_rtp_stamp);
|
||||
rtcp->ssrc = htonl(rtcp_ssrc);
|
||||
rtcp->packet_count = htonl((uint32_t) _packets);
|
||||
|
||||
Reference in New Issue
Block a user