diff --git a/src/Common/config.cpp b/src/Common/config.cpp index d13ed6b907..422605f598 100644 --- a/src/Common/config.cpp +++ b/src/Common/config.cpp @@ -242,6 +242,7 @@ const string kKeepAliveSecond = RTSP_FIELD "keepAliveSecond"; const string kDirectProxy = RTSP_FIELD "directProxy"; const string kLowLatency = RTSP_FIELD"lowLatency"; const string kRtpTransportType = RTSP_FIELD"rtpTransportType"; +const string kRingSize = RTSP_FIELD "ringSize"; static onceToken token([]() { // 默认Md5方式认证 [AUTO-TRANSLATED:6155d989] @@ -252,6 +253,7 @@ static onceToken token([]() { mINI::Instance()[kDirectProxy] = 1; mINI::Instance()[kLowLatency] = 0; mINI::Instance()[kRtpTransportType] = -1; + mINI::Instance()[kRingSize] = 2048; }); } // namespace Rtsp @@ -263,12 +265,13 @@ const string kHandshakeSecond = RTMP_FIELD "handshakeSecond"; const string kKeepAliveSecond = RTMP_FIELD "keepAliveSecond"; const string kDirectProxy = RTMP_FIELD "directProxy"; const string kEnhanced = RTMP_FIELD "enhanced"; - +const string kRingSize = RTMP_FIELD "ringSize"; static onceToken token([]() { mINI::Instance()[kHandshakeSecond] = 15; mINI::Instance()[kKeepAliveSecond] = 15; mINI::Instance()[kDirectProxy] = 1; mINI::Instance()[kEnhanced] = 0; + mINI::Instance()[kRingSize] = 1024; }); } // namespace Rtmp @@ -285,6 +288,7 @@ const string kAudioMtuSize = RTP_FIELD "audioMtuSize"; const string kRtpMaxSize = RTP_FIELD "rtpMaxSize"; const string kLowLatency = RTP_FIELD "lowLatency"; const string kH264StapA = RTP_FIELD "h264_stap_a"; +const string kRingSize = RTP_FIELD "ringSize"; static onceToken token([]() { mINI::Instance()[kVideoMtuSize] = 1400; @@ -292,6 +296,7 @@ static onceToken token([]() { mINI::Instance()[kRtpMaxSize] = 10; mINI::Instance()[kLowLatency] = 0; mINI::Instance()[kH264StapA] = 1; + mINI::Instance()[kRingSize] = 2048; }); } // namespace Rtp diff --git a/src/Common/config.h b/src/Common/config.h index a7d3a436f6..2f4205fd96 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -427,6 +427,7 @@ extern const std::string kLowLatency; // 迫使客户端重新SETUP并切换到对应协议。目前支持FFMPEG和VLC [AUTO-TRANSLATED:45f9cddb] // Force the client to re-SETUP and switch to the corresponding protocol. Currently supports FFMPEG and VLC extern const std::string kRtpTransportType; +extern const std::string kRingSize; } // namespace Rtsp // //////////RTMP服务器配置/////////// [AUTO-TRANSLATED:8de6f41f] @@ -444,6 +445,7 @@ extern const std::string kDirectProxy; // h265-rtmp是否采用增强型(或者国内扩展) [AUTO-TRANSLATED:4a52d042] // Whether h265-rtmp uses enhanced (or domestic extension) extern const std::string kEnhanced; +extern const std::string kRingSize; } // namespace Rtmp // //////////RTP配置/////////// [AUTO-TRANSLATED:23cbcb86] @@ -464,6 +466,7 @@ extern const std::string kLowLatency; // H264 rtp打包模式是否采用stap-a模式(为了在老版本浏览器上兼容webrtc)还是采用Single NAL unit packet per H.264 模式 [AUTO-TRANSLATED:30632378] // Whether H264 RTP packaging mode uses stap-a mode (for compatibility with webrtc on older browsers) or Single NAL unit packet per H.264 mode extern const std::string kH264StapA; +extern const std::string kRingSize; } // namespace Rtp // //////////组播配置/////////// [AUTO-TRANSLATED:dc39b9d6] diff --git a/src/Rtmp/RtmpMuxer.cpp b/src/Rtmp/RtmpMuxer.cpp index 6ea1c57577..0b711ede5f 100644 --- a/src/Rtmp/RtmpMuxer.cpp +++ b/src/Rtmp/RtmpMuxer.cpp @@ -10,6 +10,7 @@ #include "RtmpMuxer.h" #include "Extension/Factory.h" +#include "Common/config.h" namespace mediakit { @@ -19,7 +20,8 @@ RtmpMuxer::RtmpMuxer(const TitleMeta::Ptr &title) { } else { _metadata = title->getMetadata(); } - _rtmp_ring = std::make_shared(); + GET_CONFIG(int, ringSize, Rtmp::kRingSize); + _rtmp_ring = std::make_shared(ringSize); } bool RtmpMuxer::addTrack(const Track::Ptr &track) { diff --git a/src/Rtp/PSEncoder.cpp b/src/Rtp/PSEncoder.cpp index 24cb8ced6d..34a1d8955a 100644 --- a/src/Rtp/PSEncoder.cpp +++ b/src/Rtp/PSEncoder.cpp @@ -32,7 +32,8 @@ PSEncoderImp::PSEncoderImp(uint32_t ssrc, uint8_t payload_type, bool ps_or_ts) : } } _rtp_encoder->setRtpInfo(ssrc, video_mtu, 90000, payload_type); - auto ring = std::make_shared(); + GET_CONFIG(int, ringSize, Rtp::kRingSize); + auto ring = std::make_shared(ringSize); ring->setDelegate(std::make_shared([this](RtpPacket::Ptr rtp, bool is_key) { onRTP(std::move(rtp), is_key); })); _rtp_encoder->setRtpRing(std::move(ring)); InfoL << this << " " << ssrc; diff --git a/src/Rtp/RawEncoder.cpp b/src/Rtp/RawEncoder.cpp index c14254bd1f..b74c5b3f1a 100644 --- a/src/Rtp/RawEncoder.cpp +++ b/src/Rtp/RawEncoder.cpp @@ -29,9 +29,10 @@ RawEncoderImp::~RawEncoderImp() { } bool RawEncoderImp::addTrack(const Track::Ptr &track) { + GET_CONFIG(int, ringSize, Rtp::kRingSize); if (_send_audio && track->getTrackType() == TrackType::TrackAudio && !_rtp_encoder) { // audio _rtp_encoder = createRtpEncoder(track); - auto ring = std::make_shared(); + auto ring = std::make_shared(ringSize); ring->setDelegate(std::make_shared([this](RtpPacket::Ptr rtp, bool is_key) { onRTP(std::move(rtp), true); })); _rtp_encoder->setRtpRing(std::move(ring)); if (track->getCodecId() == CodecG711A || track->getCodecId() == CodecG711U) { @@ -45,7 +46,7 @@ bool RawEncoderImp::addTrack(const Track::Ptr &track) { if (!_send_audio && track->getTrackType() == TrackType::TrackVideo && !_rtp_encoder) { _rtp_encoder = createRtpEncoder(track); - auto ring = std::make_shared(); + auto ring = std::make_shared(ringSize); ring->setDelegate(std::make_shared([this](RtpPacket::Ptr rtp, bool is_key) { onRTP(std::move(rtp), is_key); })); _rtp_encoder->setRtpRing(std::move(ring)); return true; diff --git a/src/Rtsp/RtspMuxer.cpp b/src/Rtsp/RtspMuxer.cpp index f37ded12c2..65ae4b4101 100644 --- a/src/Rtsp/RtspMuxer.cpp +++ b/src/Rtsp/RtspMuxer.cpp @@ -50,7 +50,8 @@ RtspMuxer::RtspMuxer(const TitleSdp::Ptr &title) { _live = title->getDuration() == 0; _sdp = title->getSdp(); } - _rtpRing = std::make_shared(); + GET_CONFIG(int, ringSize, Rtsp::kRingSize); + _rtpRing = std::make_shared(ringSize); _rtpInterceptor = std::make_shared(); _rtpInterceptor->setDelegate(std::make_shared([this](RtpPacket::Ptr in, bool is_key) { onRtp(std::move(in), is_key); diff --git a/www/webassist/index.html b/www/webassist/index.html index 02ce630ef8..254925ce22 100644 --- a/www/webassist/index.html +++ b/www/webassist/index.html @@ -2002,6 +2002,15 @@ v-model="serverConfig.rtmp.keepAliveSecond"> +
+
+ Gop缓冲大小 +
+
+ +
+
@@ -2058,6 +2067,16 @@ v-model="serverConfig.rtsp.handshakeSecond"> +
+
+ + Gop缓冲大小 +
+
+ +
+
直接代理模式 @@ -2126,6 +2145,15 @@
+
+
+ Gop缓冲大小 +
+
+ +
+