新增rtp ssrc异常处理逻辑

This commit is contained in:
xia-chu 2021-04-11 20:35:00 +08:00
parent 65f072a82b
commit 8a51bd2d9e
2 changed files with 15 additions and 4 deletions

View File

@ -53,12 +53,22 @@ bool RtpReceiver::handleOneRtp(int index, TrackType type, int sample_rate, uint8
auto ssrc = ntohl(header->ssrc);
if (!_ssrc[index]) {
//保存SSRC至track对象
//记录并锁定ssrc
_ssrc[index] = ssrc;
} else if (_ssrc[index] != ssrc) {
_ssrc_alive[index].resetTime();
} else if (_ssrc[index] == ssrc) {
//ssrc匹配正确,刷新计时器
_ssrc_alive[index].resetTime();
} else {
//ssrc错误
WarnL << "ssrc错误:" << ssrc << " != " << _ssrc[index];
return false;
if (_ssrc_alive[index].elapsedTime() < 10 * 1000) {
//接受正确ssrc的rtp在10秒内那么我们认为存在多路rtp,忽略掉ssrc不匹配的rtp
WarnL << "ssrc比匹配,rtp已丢弃:" << ssrc << " != " << _ssrc[index];
return false;
}
InfoL << "rtp流ssrc切换:" << _ssrc[index] << " -> " << ssrc;
_ssrc[index] = ssrc;
_ssrc_alive[index].resetTime();
}
auto rtp = RtpPacket::create();

View File

@ -198,6 +198,7 @@ protected:
private:
uint32_t _ssrc[2] = {0, 0};
Ticker _ssrc_alive[2];
//rtp排序缓存根据seq排序
PacketSortor<RtpPacket::Ptr> _rtp_sortor[2];
};