From 0eb38635cef766b845e63f98a87ba4b8a2a30782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=BC=A0=E5=B3=B0?= <59160162+zhang-chuanfeng@users.noreply.github.com> Date: Sun, 14 Jul 2024 09:27:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BD=E6=A0=87=E6=8E=A8=E6=B5=81=E4=B8=80?= =?UTF-8?q?=E7=9B=B4=E6=89=93=E5=8D=B0=20'Already=20existed=20a=20same=20t?= =?UTF-8?q?rack'=20(#3713)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/ZLMediaKit/ZLMediaKit/pull/3689 https://github.com/ZLMediaKit/ZLMediaKit/issues/3702#issuecomment-2222326053 --- src/Rtp/Decoder.cpp | 4 ++++ src/Rtp/Decoder.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/Rtp/Decoder.cpp b/src/Rtp/Decoder.cpp index 778541a9..5274c11d 100644 --- a/src/Rtp/Decoder.cpp +++ b/src/Rtp/Decoder.cpp @@ -85,6 +85,9 @@ DecoderImp::DecoderImp(const Decoder::Ptr &decoder, MediaSinkInterface *sink){ #if defined(ENABLE_RTPPROXY) || defined(ENABLE_HLS) void DecoderImp::onStream(int stream, int codecid, const void *extra, size_t bytes, int finish) { + if (_finished) { + return; + } // G711传统只支持 8000/1/16的规格,FFmpeg貌似做了扩展,但是这里不管它了 auto track = Factory::getTrackByCodecId(getCodecByMpegId(codecid), 8000, 1, 16); if (track) { @@ -92,6 +95,7 @@ void DecoderImp::onStream(int stream, int codecid, const void *extra, size_t byt } // 防止未获取视频track提前complete导致忽略后续视频的问题,用于兼容一些不太规范的ps流 if (finish && _have_video) { + _finished = true; _sink->addTrackCompleted(); InfoL << "Add track finished"; } diff --git a/src/Rtp/Decoder.h b/src/Rtp/Decoder.h index 9da460c4..4902157c 100644 --- a/src/Rtp/Decoder.h +++ b/src/Rtp/Decoder.h @@ -57,6 +57,7 @@ private: void onStream(int stream, int codecid, const void *extra, size_t bytes, int finish); private: + bool _finished = false; bool _have_video = false; Decoder::Ptr _decoder; MediaSinkInterface *_sink;