添加RTP异常包处理逻辑

This commit is contained in:
xiongziliang 2019-04-24 11:40:54 +08:00
parent 9ce5c146a9
commit c0d3185a38
4 changed files with 11 additions and 2 deletions

View File

@ -98,7 +98,14 @@ bool RtpReceiver::handleOneRtp(int iTrackidx,SdpTrack::Ptr &track, unsigned char
ext = (AV_RB16(pucData + rtppt.offset - 2) + 1) << 2;
rtppt.offset += ext;
}
if(rtppt.length - rtppt.offset <= 0){
WarnL << "无有效负载的rtp包:" << rtppt.length << "<=" << (int)rtppt.offset;
return false;
}
if(uiLen > sizeof(rtppt.payload) - 4){
WarnL << "超长的rtp包:" << uiLen << ">" << sizeof(rtppt.payload) - 4;
return false;
}
memcpy(rtppt.payload + 4, pucData, uiLen);

View File

@ -447,6 +447,7 @@ void RtspPlayer::onWholeRtspPacket(Parser &parser) {
void RtspPlayer::onRtpPacket(const char *data, uint64_t len) {
if(len > 1600){
//没有大于MTU的包
WarnL << "大于MTU的RTP包:" << len << ",来自:" << get_peer_ip();
return;
}
int trackIdx = -1;

View File

@ -1,4 +1,4 @@
/*
/*
* MIT License
*
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
@ -188,6 +188,7 @@ void RtspSession::onRtpPacket(const char *data, uint64_t len) {
}
if(len > 1600){
//没有大于MTU的包
WarnL << "大于MTU的RTP包:" << len << ",来自:" << get_peer_ip();
return;
}
int trackIdx = -1;

View File

@ -46,7 +46,7 @@ public:
uint32_t timeStamp;
uint16_t sequence;
uint32_t ssrc;
uint8_t payload[1560];
uint8_t payload[1600];
uint8_t offset;
TrackType type;
};