startSendRtp、startRecord接口支持缓存多个gop (#4180)
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
Linux / build (push) Has been cancelled
macOS / build (push) Has been cancelled
Windows / build (push) Has been cancelled

This commit is contained in:
xia-chu 2025-03-07 23:26:48 +08:00
parent 479a3fb9bb
commit 11d1b849ec
4 changed files with 11 additions and 11 deletions

View File

@ -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-2016c.2.4规定)

View File

@ -400,7 +400,7 @@ bool MultiMediaSourceMuxer::isRecording(MediaSource &sender, Recorder::type type
void MultiMediaSourceMuxer::startSendRtp(MediaSource &sender, const MediaSourceEvent::SendRtpArgs &args, const std::function<void(uint16_t, const toolkit::SockException &)> 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() {

View File

@ -231,7 +231,7 @@ protected:
bool onTrackFrame_l(const Frame::Ptr &frame);
private:
void createGopCacheIfNeed();
void createGopCacheIfNeed(size_t gop_count);
std::shared_ptr<MediaSinkInterface> makeRecorder(MediaSource &sender, Recorder::type type);
private:

View File

@ -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-2016c.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),