mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
rtp包最大大小可配置
This commit is contained in:
parent
9e5d325e43
commit
7ed7e5386c
@ -201,6 +201,8 @@ sslport=19350
|
|||||||
audioMtuSize=600
|
audioMtuSize=600
|
||||||
#视频mtu大小,该参数限制rtp最大字节数,推荐不要超过1400
|
#视频mtu大小,该参数限制rtp最大字节数,推荐不要超过1400
|
||||||
videoMtuSize=1400
|
videoMtuSize=1400
|
||||||
|
#rtp包最大长度限制,可以降低内存分配,单位k
|
||||||
|
rtpMaxSize=10
|
||||||
|
|
||||||
[rtp_proxy]
|
[rtp_proxy]
|
||||||
#导出调试数据(包括rtp/ps/h264)至该目录,置空则关闭数据导出
|
#导出调试数据(包括rtp/ps/h264)至该目录,置空则关闭数据导出
|
||||||
|
@ -192,10 +192,13 @@ namespace Rtp {
|
|||||||
//RTP打包最大MTU,公网情况下更小
|
//RTP打包最大MTU,公网情况下更小
|
||||||
const string kVideoMtuSize = RTP_FIELD"videoMtuSize";
|
const string kVideoMtuSize = RTP_FIELD"videoMtuSize";
|
||||||
const string kAudioMtuSize = RTP_FIELD"audioMtuSize";
|
const string kAudioMtuSize = RTP_FIELD"audioMtuSize";
|
||||||
|
//rtp包最大长度限制,单位是k
|
||||||
|
const string kRtpMaxSize = RTP_FIELD"rtpMaxSize";
|
||||||
|
|
||||||
onceToken token([](){
|
onceToken token([](){
|
||||||
mINI::Instance()[kVideoMtuSize] = 1400;
|
mINI::Instance()[kVideoMtuSize] = 1400;
|
||||||
mINI::Instance()[kAudioMtuSize] = 600;
|
mINI::Instance()[kAudioMtuSize] = 600;
|
||||||
|
mINI::Instance()[kRtpMaxSize] = 10;
|
||||||
},nullptr);
|
},nullptr);
|
||||||
} //namespace Rtsp
|
} //namespace Rtsp
|
||||||
|
|
||||||
|
@ -228,6 +228,8 @@ namespace Rtp {
|
|||||||
extern const string kVideoMtuSize;
|
extern const string kVideoMtuSize;
|
||||||
//RTP打包最大MTU,公网情况下更小
|
//RTP打包最大MTU,公网情况下更小
|
||||||
extern const string kAudioMtuSize;
|
extern const string kAudioMtuSize;
|
||||||
|
//rtp包最大长度限制, 单位k
|
||||||
|
extern const string kRtpMaxSize;
|
||||||
} //namespace Rtsp
|
} //namespace Rtsp
|
||||||
|
|
||||||
////////////组播配置///////////
|
////////////组播配置///////////
|
||||||
|
@ -83,7 +83,8 @@ void RtpSession::onRtpPacket(const char *data, size_t len) {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (len > 1024 * 10) {
|
GET_CONFIG(uint32_t, rtpMaxSize, Rtp::kRtpMaxSize);
|
||||||
|
if (len > 1024 * rtpMaxSize) {
|
||||||
_search_rtp = true;
|
_search_rtp = true;
|
||||||
WarnL << "rtp包长度异常(" << len << "),发送端可能缓存溢出并覆盖,开始搜索ssrc以便恢复上下文";
|
WarnL << "rtp包长度异常(" << len << "),发送端可能缓存溢出并覆盖,开始搜索ssrc以便恢复上下文";
|
||||||
return;
|
return;
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
#include "Common/config.h"
|
#include "Common/config.h"
|
||||||
#include "RtpReceiver.h"
|
#include "RtpReceiver.h"
|
||||||
|
|
||||||
#define RTP_MAX_SIZE (10 * 1024)
|
|
||||||
|
|
||||||
namespace mediakit {
|
namespace mediakit {
|
||||||
|
|
||||||
RtpTrack::RtpTrack() {
|
RtpTrack::RtpTrack() {
|
||||||
@ -36,8 +34,9 @@ RtpPacket::Ptr RtpTrack::inputRtp(TrackType type, int sample_rate, uint8_t *ptr,
|
|||||||
WarnL << "rtp包太小:" << len;
|
WarnL << "rtp包太小:" << len;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (len > RTP_MAX_SIZE) {
|
GET_CONFIG(uint32_t, rtpMaxSize, Rtp::kRtpMaxSize);
|
||||||
WarnL << "超大的rtp包:" << len << " > " << RTP_MAX_SIZE;
|
if (len > 1024 * rtpMaxSize) {
|
||||||
|
WarnL << "超大的rtp包:" << len << " > " << 1024 * rtpMaxSize;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (!sample_rate) {
|
if (!sample_rate) {
|
||||||
|
@ -36,7 +36,7 @@ static bool loadFile(const char *path){
|
|||||||
|
|
||||||
uint32_t timeStamp_last = 0;
|
uint32_t timeStamp_last = 0;
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
char rtp[2 * 1024];
|
char rtp[50 * 1024];
|
||||||
struct sockaddr addr = {0};
|
struct sockaddr addr = {0};
|
||||||
auto sock = Socket::createSocket();
|
auto sock = Socket::createSocket();
|
||||||
size_t total_size = 0;
|
size_t total_size = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user