diff --git a/conf/config.ini b/conf/config.ini index 894bef44..baff3108 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -332,8 +332,8 @@ h265_pt=99 ps_pt=96 #rtp opus 负载的pt opus_pt=100 -#RtpSender相关功能是否提前开启gop缓存优化级联秒开体验,默认开启 -#如果不调用startSendRtp相关接口,可以置0节省内存 +#startSendRtp、startRecord相关功能是否提前开启gop缓存优化级联秒开体验,默认开启, 并缓存1个GOP +#如果不调用startSendRtp、startRecord后相关接口,可以置0节省内存;如果缓存多个gop,可以加大该参数 gop_cache=1 #国标发送g711 rtp 打包时,每个包的语音时长是多少,默认是100 ms,范围为20~180ms (gb28181-2016,c.2.4规定), diff --git a/src/Common/MultiMediaSourceMuxer.cpp b/src/Common/MultiMediaSourceMuxer.cpp index ea2031d3..0dd76519 100644 --- a/src/Common/MultiMediaSourceMuxer.cpp +++ b/src/Common/MultiMediaSourceMuxer.cpp @@ -400,7 +400,7 @@ bool MultiMediaSourceMuxer::isRecording(MediaSource &sender, Recorder::type type void MultiMediaSourceMuxer::startSendRtp(MediaSource &sender, const MediaSourceEvent::SendRtpArgs &args, const std::function cb) { #if defined(ENABLE_RTPPROXY) - createGopCacheIfNeed(); + createGopCacheIfNeed(1); auto ring = _ring; auto ssrc = args.ssrc; @@ -576,9 +576,9 @@ void MultiMediaSourceMuxer::onAllTrackReady() { } #if defined(ENABLE_RTPPROXY) - GET_CONFIG(bool, gop_cache, RtpProxy::kGopCache); - if (gop_cache) { - createGopCacheIfNeed(); + GET_CONFIG(size_t, gop_cache, RtpProxy::kGopCache); + if (gop_cache > 0) { + createGopCacheIfNeed(gop_cache); } #endif @@ -593,7 +593,7 @@ void MultiMediaSourceMuxer::onAllTrackReady() { InfoL << "stream: " << shortUrl() << " , codec info: " << getTrackInfoStr(this); } -void MultiMediaSourceMuxer::createGopCacheIfNeed() { +void MultiMediaSourceMuxer::createGopCacheIfNeed(size_t gop_count) { if (_ring) { return; } @@ -607,7 +607,7 @@ void MultiMediaSourceMuxer::createGopCacheIfNeed() { strong_self->onReaderChanged(*src, strong_self->totalReaderCount()); }); } - }); + }, gop_count); } void MultiMediaSourceMuxer::resetTracks() { diff --git a/src/Common/MultiMediaSourceMuxer.h b/src/Common/MultiMediaSourceMuxer.h index cd5279d0..9e0721af 100644 --- a/src/Common/MultiMediaSourceMuxer.h +++ b/src/Common/MultiMediaSourceMuxer.h @@ -231,7 +231,7 @@ protected: bool onTrackFrame_l(const Frame::Ptr &frame); private: - void createGopCacheIfNeed(); + void createGopCacheIfNeed(size_t gop_count); std::shared_ptr makeRecorder(MediaSource &sender, Recorder::type type); private: diff --git a/src/Common/config.h b/src/Common/config.h index f9b19219..301592e4 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -553,8 +553,8 @@ extern const std::string kPSPT; // rtp server opus 的pt [AUTO-TRANSLATED:9f91f85a] // Rtp server opus pt extern const std::string kOpusPT; -// RtpSender相关功能是否提前开启gop缓存优化级联秒开体验,默认开启 [AUTO-TRANSLATED:40c37c77] -// Whether to enable gop cache optimization cascade second-open experience for RtpSender related functions, enabled by default +// startSendRtp、startRecord相关功能是否提前开启gop缓存优化级联秒开体验,默认开启, 并缓存1个GOP [AUTO-TRANSLATED:40c37c77] +// Whether to enable gop cache optimization cascade second-open experience for startSendRtp/startRecord related functions, enabled by default, and cached 1 GOP extern const std::string kGopCache; // 国标发送g711 rtp 打包时,每个包的语音时长是多少,默认是100 ms,范围为20~180ms (gb28181-2016,c.2.4规定), [AUTO-TRANSLATED:3b3916a3] // When sending g711 rtp packets in national standard, what is the duration of each packet, the default is 100 ms, the range is 20~180ms (gb28181-2016, c.2.4),