From 9dd602c2427f84e4455dc91905e24c02a9c34f47 Mon Sep 17 00:00:00 2001 From: wxf Date: Sun, 18 Jul 2021 15:04:56 +0800 Subject: [PATCH] =?UTF-8?q?GB28181Process:=20=E4=B8=8D=E5=86=8D=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E7=BC=93=E5=AD=98=E6=9C=AA=E5=A4=84=E7=90=86=E5=AE=8C?= =?UTF-8?q?=E7=9A=84=20PS/TS=20=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * PS 帧已由 PSDecoder 缓存; * TS 帧在 TSDecoder 中有判断是否为 TS, 即使出错缓存也无意义; --- src/Rtp/GB28181Process.cpp | 23 +---------------------- src/Rtp/GB28181Process.h | 4 +--- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/Rtp/GB28181Process.cpp b/src/Rtp/GB28181Process.cpp index 42f004d2..c3fb9942 100644 --- a/src/Rtp/GB28181Process.cpp +++ b/src/Rtp/GB28181Process.cpp @@ -150,27 +150,6 @@ bool GB28181Process::inputRtp(bool, const char *data, size_t data_len) { return ref->inputRtp(TrackVideo, (unsigned char *) data, data_len); } -const char *GB28181Process::onSearchPacketTail(const char *packet,size_t bytes){ - try { - auto ret = _decoder->input((uint8_t *) packet, bytes); - if (ret >= 0) { - //解析成功全部或部分 - return packet + ret; - } - //解析失败,丢弃所有数据 - return packet + bytes; - } catch (std::exception &ex) { - InfoL << "解析ps或ts异常: bytes=" << bytes - << " ,exception=" << ex.what() - << " ,hex=" << hexdump((uint8_t *) packet, MIN(bytes,32)); - if (remainDataSize() > 256 * 1024) { - //缓存太多数据无法处理则上抛异常 - throw; - } - return nullptr; - } -} - void GB28181Process::onRtpDecode(const Frame::Ptr &frame) { if (frame->getCodecId() != CodecInvalid) { //这里不是ps或ts @@ -197,7 +176,7 @@ void GB28181Process::onRtpDecode(const Frame::Ptr &frame) { } if (_decoder) { - HttpRequestSplitter::input(frame->data(), frame->size()); + _decoder->input(reinterpret_cast(frame->data()), frame->size()); } } diff --git a/src/Rtp/GB28181Process.h b/src/Rtp/GB28181Process.h index 4d5d06d4..e1a60d5c 100644 --- a/src/Rtp/GB28181Process.h +++ b/src/Rtp/GB28181Process.h @@ -22,7 +22,7 @@ namespace mediakit{ class RtpReceiverImp; -class GB28181Process : public HttpRequestSplitter, public ProcessInterface{ +class GB28181Process : public ProcessInterface { public: typedef std::shared_ptr Ptr; GB28181Process(const MediaInfo &media_info, MediaSinkInterface *interface); @@ -38,8 +38,6 @@ public: protected: void onRtpSorted(RtpPacket::Ptr rtp); - const char *onSearchPacketTail(const char *data,size_t len) override; - ssize_t onRecvHeader(const char *data,size_t len) override { return 0; }; private: void onRtpDecode(const Frame::Ptr &frame);