From c8fedccd786130c5ab40cbdf2e6b54b81b59ef89 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 26 Apr 2023 09:10:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=BF=E5=85=8D=E8=B7=B3=E8=BF=87=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=AD=A3=E5=B8=B8=E7=9A=84ts=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtp/TSDecoder.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Rtp/TSDecoder.cpp b/src/Rtp/TSDecoder.cpp index 4f00ada0..df1305ad 100644 --- a/src/Rtp/TSDecoder.cpp +++ b/src/Rtp/TSDecoder.cpp @@ -35,13 +35,15 @@ const char *TSSegment::onSearchPacketTail(const char *data, size_t len) { } return nullptr; } - //下一个包头 + //精确匹配下一个包头 if (((uint8_t *) data)[_size] == TS_SYNC_BYTE) { return data + _size; } - auto pos = memchr(data + _size, TS_SYNC_BYTE, len - _size); - if (pos) { - return (char *) pos; + //搜索下一个包头 + for (int i = 1; i < len - _size; ++i) { + if (((uint8_t *) data)[i] == TS_SYNC_BYTE && ((uint8_t *) data)[i + _size] == TS_SYNC_BYTE) { + return data + i; + } } if (remainDataSize() > 4 * _size) { //数据这么多都没ts包,全部清空