From e063cb3a003b898d3588f2164f9a32a13123226d Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Mon, 25 May 2020 21:54:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E4=B8=80=E4=BA=9B=E4=B8=8D?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E7=9A=84rtsp=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtsp/RtspSplitter.cpp | 19 +++++++++++++++++++ src/Rtsp/RtspSplitter.h | 1 + 2 files changed, 20 insertions(+) diff --git a/src/Rtsp/RtspSplitter.cpp b/src/Rtsp/RtspSplitter.cpp index caaf1054..1c97f369 100644 --- a/src/Rtsp/RtspSplitter.cpp +++ b/src/Rtsp/RtspSplitter.cpp @@ -10,10 +10,29 @@ #include #include "RtspSplitter.h" +#include "Util/logger.h" +#include "Util/util.h" namespace mediakit{ const char *RtspSplitter::onSearchPacketTail(const char *data, int len) { + auto ret = onSearchPacketTail_l(data, len); + if(ret){ + return ret; + } + + if (len > 256 * 1024) { + //rtp大于256KB + ret = (char *) memchr(data, '$', len); + if (!ret) { + WarnL << "rtp缓存溢出:" << hexdump(data, 1024); + reset(); + } + } + return ret; +} + +const char *RtspSplitter::onSearchPacketTail_l(const char *data, int len) { if(!_enableRecvRtp || data[0] != '$'){ //这是rtsp包 _isRtpPacket = false; diff --git a/src/Rtsp/RtspSplitter.h b/src/Rtsp/RtspSplitter.h index c319410c..3cd35821 100644 --- a/src/Rtsp/RtspSplitter.h +++ b/src/Rtsp/RtspSplitter.h @@ -48,6 +48,7 @@ protected: virtual int64_t getContentLength(Parser &parser); protected: const char *onSearchPacketTail(const char *data,int len) override ; + const char *onSearchPacketTail_l(const char *data,int len) ; int64_t onRecvHeader(const char *data,uint64_t len) override; void onRecvContent(const char *data,uint64_t len) override; private: