From 3204769d5ec5729347900da9cfceb38b4fa0f685 Mon Sep 17 00:00:00 2001 From: xiongguangjie Date: Tue, 16 Apr 2024 17:37:46 +0800 Subject: [PATCH] rtp packet ring buffer set 4096 avoid overflow --- src/Rtp/PSEncoder.cpp | 2 +- src/Rtp/RawEncoder.cpp | 4 ++-- src/Rtsp/RtspMuxer.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Rtp/PSEncoder.cpp b/src/Rtp/PSEncoder.cpp index 9de7f43b..13c32936 100644 --- a/src/Rtp/PSEncoder.cpp +++ b/src/Rtp/PSEncoder.cpp @@ -31,7 +31,7 @@ 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(); + auto ring = std::make_shared(4096); 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 c14254bd..7a62e8a5 100644 --- a/src/Rtp/RawEncoder.cpp +++ b/src/Rtp/RawEncoder.cpp @@ -31,7 +31,7 @@ RawEncoderImp::~RawEncoderImp() { bool RawEncoderImp::addTrack(const Track::Ptr &track) { if (_send_audio && track->getTrackType() == TrackType::TrackAudio && !_rtp_encoder) { // audio _rtp_encoder = createRtpEncoder(track); - auto ring = std::make_shared(); + auto ring = std::make_shared(4096); 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 +45,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(4096); 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 dae5f111..354caa62 100644 --- a/src/Rtsp/RtspMuxer.cpp +++ b/src/Rtsp/RtspMuxer.cpp @@ -46,8 +46,8 @@ RtspMuxer::RtspMuxer(const TitleSdp::Ptr &title) { _live = title->getDuration() == 0; _sdp = title->getSdp(); } - _rtpRing = std::make_shared(); - _rtpInterceptor = std::make_shared(); + _rtpRing = std::make_shared(4096); + _rtpInterceptor = std::make_shared(4096); _rtpInterceptor->setDelegate(std::make_shared([this](RtpPacket::Ptr in, bool is_key) { onRtp(std::move(in), is_key); }));