From 18dbbc8d19e325704d846598955d433f99c91550 Mon Sep 17 00:00:00 2001 From: dengjfzh <76604422+dengjfzh@users.noreply.github.com> Date: Sat, 27 May 2023 22:27:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=8D=E4=BD=8ETCP=20RTP=202=E5=AD=97?= =?UTF-8?q?=E8=8A=82=E5=A4=B4=E8=A2=AB=E8=AF=AF=E5=88=A4=E4=B8=BAEHOME?= =?UTF-8?q?=E5=A4=B4=E7=9A=84=E9=A3=8E=E9=99=A9=20(#2502)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当TCP RTP包大小为256字节时,可能触发RtpSplitter::onSearchPacketTail误判为EHOME格式。 这个修改一旦检测到数据不是EHOME格式,则后续不再进行尝试,以减小误判的风险。 --- src/Rtp/RtpSplitter.cpp | 23 +++++++++++++---------- src/Rtp/RtpSplitter.h | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Rtp/RtpSplitter.cpp b/src/Rtp/RtpSplitter.cpp index 78c5223c..0f4b6dc4 100644 --- a/src/Rtp/RtpSplitter.cpp +++ b/src/Rtp/RtpSplitter.cpp @@ -46,17 +46,20 @@ const char *RtpSplitter::onSearchPacketTail(const char *data, size_t len) { return nullptr; } - if (isEhome(data, len)) { - //是ehome协议 - if (len < kEHOME_OFFSET + 4) { - //数据不够 - return nullptr; + if ( _is_ehome ) { + if (isEhome(data, len)) { + //是ehome协议 + if (len < kEHOME_OFFSET + 4) { + //数据不够 + return nullptr; + } + //忽略ehome私有头后是rtsp样式的rtp,多4个字节, + _offset = kEHOME_OFFSET + 4; + _is_ehome = true; + //忽略ehome私有头 + return onSearchPacketTail_l(data + kEHOME_OFFSET + 2, len - kEHOME_OFFSET - 2); } - //忽略ehome私有头后是rtsp样式的rtp,多4个字节, - _offset = kEHOME_OFFSET + 4; - _is_ehome = true; - //忽略ehome私有头 - return onSearchPacketTail_l(data + kEHOME_OFFSET + 2, len - kEHOME_OFFSET - 2); + _is_ehome = false; } if ( _is_rtsp_interleaved ) { diff --git a/src/Rtp/RtpSplitter.h b/src/Rtp/RtpSplitter.h index 50e3af43..a2990a7f 100644 --- a/src/Rtp/RtpSplitter.h +++ b/src/Rtp/RtpSplitter.h @@ -35,7 +35,7 @@ protected: const char *onSearchPacketTail_l(const char *data, size_t len); private: - bool _is_ehome = false; + bool _is_ehome = true; bool _is_rtsp_interleaved = true; size_t _offset = 0; };