mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
修复webrtc rtx包计入receiver report统计导致simulcast推流失效的问题
This commit is contained in:
parent
6bc39058ab
commit
6ddd420f1c
@ -36,7 +36,7 @@ public:
|
||||
~RtpReceiverImp() override = default;
|
||||
|
||||
bool inputRtp(TrackType type, uint8_t *ptr, size_t len){
|
||||
return RtpTrack::inputRtp(type, _sample_rate, ptr, len);
|
||||
return RtpTrack::inputRtp(type, _sample_rate, ptr, len).operator bool();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -31,18 +31,18 @@ void RtpTrack::clear() {
|
||||
PacketSortor<RtpPacket::Ptr>::clear();
|
||||
}
|
||||
|
||||
bool RtpTrack::inputRtp(TrackType type, int sample_rate, uint8_t *ptr, size_t len) {
|
||||
RtpPacket::Ptr RtpTrack::inputRtp(TrackType type, int sample_rate, uint8_t *ptr, size_t len) {
|
||||
if (len < RtpPacket::kRtpHeaderSize) {
|
||||
WarnL << "rtp包太小:" << len;
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
if (len > RTP_MAX_SIZE) {
|
||||
WarnL << "超大的rtp包:" << len << " > " << RTP_MAX_SIZE;
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
if (!sample_rate) {
|
||||
//无法把时间戳转换成毫秒
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
RtpHeader *header = (RtpHeader *) ptr;
|
||||
if (header->version != RtpPacket::kRtpVersion) {
|
||||
@ -50,7 +50,7 @@ bool RtpTrack::inputRtp(TrackType type, int sample_rate, uint8_t *ptr, size_t le
|
||||
}
|
||||
if (!header->getPayloadSize(len)) {
|
||||
//无有效负载的rtp包
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//比对缓存ssrc
|
||||
@ -68,7 +68,7 @@ bool RtpTrack::inputRtp(TrackType type, int sample_rate, uint8_t *ptr, size_t le
|
||||
if (_ssrc_alive.elapsedTime() < 3 * 1000) {
|
||||
//接受正确ssrc的rtp在10秒内,那么我们认为存在多路rtp,忽略掉ssrc不匹配的rtp
|
||||
WarnL << "ssrc不匹配,rtp已丢弃:" << ssrc << " != " << _ssrc;
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
InfoL << "rtp流ssrc切换:" << _ssrc << " -> " << ssrc;
|
||||
_ssrc = ssrc;
|
||||
@ -90,14 +90,11 @@ bool RtpTrack::inputRtp(TrackType type, int sample_rate, uint8_t *ptr, size_t le
|
||||
data[3] = len & 0xFF;
|
||||
//拷贝rtp
|
||||
memcpy(&data[4], ptr, len);
|
||||
|
||||
//设置ntp时间戳
|
||||
rtp->ntp_stamp = _ntp_stamp.getNtpStamp(ntohl(rtp->getHeader()->stamp), sample_rate);
|
||||
|
||||
onBeforeRtpSorted(rtp);
|
||||
auto seq = rtp->getSeq();
|
||||
sortPacket(seq, std::move(rtp));
|
||||
return true;
|
||||
sortPacket(rtp->getSeq(), rtp);
|
||||
return rtp;
|
||||
}
|
||||
|
||||
void RtpTrack::setNtpStamp(uint32_t rtp_stamp, uint32_t sample_rate, uint64_t ntp_stamp_ms){
|
||||
|
@ -175,7 +175,7 @@ public:
|
||||
|
||||
void clear();
|
||||
uint32_t getSSRC() const;
|
||||
bool inputRtp(TrackType type, int sample_rate, uint8_t *ptr, size_t len);
|
||||
RtpPacket::Ptr inputRtp(TrackType type, int sample_rate, uint8_t *ptr, size_t len);
|
||||
void setNtpStamp(uint32_t rtp_stamp, uint32_t sample_rate, uint64_t ntp_stamp_ms);
|
||||
|
||||
protected:
|
||||
@ -236,7 +236,7 @@ public:
|
||||
* @return 解析成功返回true
|
||||
*/
|
||||
bool handleOneRtp(int index, TrackType type, int sample_rate, uint8_t *ptr, size_t len){
|
||||
return _track[index].inputRtp(type, sample_rate, ptr, len);
|
||||
return _track[index].inputRtp(type, sample_rate, ptr, len).operator bool();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -594,14 +594,15 @@ public:
|
||||
|
||||
~RtpChannel() override = default;
|
||||
|
||||
bool inputRtp(TrackType type, int sample_rate, uint8_t *ptr, size_t len, bool is_rtx){
|
||||
if (!is_rtx) {
|
||||
RtpHeader *rtp = (RtpHeader *) ptr;
|
||||
auto seq = ntohs(rtp->seq);
|
||||
RtpPacket::Ptr inputRtp(TrackType type, int sample_rate, uint8_t *ptr, size_t len, bool is_rtx) {
|
||||
auto rtp = RtpTrack::inputRtp(type, sample_rate, ptr, len);
|
||||
if (!is_rtx && rtp) {
|
||||
//统计rtp接受情况,便于生成nack rtcp包
|
||||
auto seq = rtp->getSeq();
|
||||
_nack_ctx.received(seq);
|
||||
_rtcp_context.onRtp(seq, rtp->getStamp(), rtp->ntp_stamp, sample_rate, len);
|
||||
}
|
||||
return RtpTrack::inputRtp(type, sample_rate, ptr, len);
|
||||
return rtp;
|
||||
}
|
||||
|
||||
Buffer::Ptr createRtcpRR(RtcpHeader *sr, uint32_t ssrc) {
|
||||
@ -609,14 +610,6 @@ public:
|
||||
return _rtcp_context.createRtcpRR(ssrc, getSSRC());
|
||||
}
|
||||
|
||||
protected:
|
||||
void onBeforeRtpSorted(const RtpPacket::Ptr &rtp) override {
|
||||
//统计rtp收到的情况,好做rr汇报
|
||||
_rtcp_context.onRtp(rtp->getSeq(), rtp->getStamp(), rtp->ntp_stamp, rtp->sample_rate,
|
||||
rtp->size() - RtpPacket::kRtpTcpHeaderSize);
|
||||
RtpTrackImp::onBeforeRtpSorted(rtp);
|
||||
}
|
||||
|
||||
private:
|
||||
NackContext _nack_ctx;
|
||||
RtcpContext _rtcp_context{true};
|
||||
|
Loading…
Reference in New Issue
Block a user