rtp包最大大小可配置

This commit is contained in:
monktan
2021-08-11 15:48:15 +08:00
parent 9e5d325e43
commit 7ed7e5386c
6 changed files with 13 additions and 6 deletions

View File

@@ -192,10 +192,13 @@ namespace Rtp {
//RTP打包最大MTU,公网情况下更小
const string kVideoMtuSize = RTP_FIELD"videoMtuSize";
const string kAudioMtuSize = RTP_FIELD"audioMtuSize";
//rtp包最大长度限制单位是k
const string kRtpMaxSize = RTP_FIELD"rtpMaxSize";
onceToken token([](){
mINI::Instance()[kVideoMtuSize] = 1400;
mINI::Instance()[kAudioMtuSize] = 600;
mINI::Instance()[kRtpMaxSize] = 10;
},nullptr);
} //namespace Rtsp

View File

@@ -228,6 +228,8 @@ namespace Rtp {
extern const string kVideoMtuSize;
//RTP打包最大MTU,公网情况下更小
extern const string kAudioMtuSize;
//rtp包最大长度限制, 单位k
extern const string kRtpMaxSize;
} //namespace Rtsp
////////////组播配置///////////

View File

@@ -83,7 +83,8 @@ void RtpSession::onRtpPacket(const char *data, size_t len) {
}
return;
}
if (len > 1024 * 10) {
GET_CONFIG(uint32_t, rtpMaxSize, Rtp::kRtpMaxSize);
if (len > 1024 * rtpMaxSize) {
_search_rtp = true;
WarnL << "rtp包长度异常(" << len << ")发送端可能缓存溢出并覆盖开始搜索ssrc以便恢复上下文";
return;

View File

@@ -11,8 +11,6 @@
#include "Common/config.h"
#include "RtpReceiver.h"
#define RTP_MAX_SIZE (10 * 1024)
namespace mediakit {
RtpTrack::RtpTrack() {
@@ -36,8 +34,9 @@ RtpPacket::Ptr RtpTrack::inputRtp(TrackType type, int sample_rate, uint8_t *ptr,
WarnL << "rtp包太小:" << len;
return nullptr;
}
if (len > RTP_MAX_SIZE) {
WarnL << "超大的rtp包:" << len << " > " << RTP_MAX_SIZE;
GET_CONFIG(uint32_t, rtpMaxSize, Rtp::kRtpMaxSize);
if (len > 1024 * rtpMaxSize) {
WarnL << "超大的rtp包:" << len << " > " << 1024 * rtpMaxSize;
return nullptr;
}
if (!sample_rate) {