From b4fecdc9299337a4b7f559c0a10d66a4b1be92fc Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Fri, 5 Jul 2024 21:05:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=AF=B9=E8=B1=A1=E6=9E=90?= =?UTF-8?q?=E6=9E=84=E6=97=B6=E6=8A=9B=E5=BC=82=E5=B8=B8=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/FMP4/FMP4MediaSource.h | 8 +++++++- src/FMP4/FMP4MediaSourceMuxer.h | 8 +++++++- src/Record/HlsRecorder.h | 16 ++++++++++++++-- src/Rtmp/RtmpMediaSource.h | 8 +++++++- src/Rtsp/RtspMediaSource.h | 8 +++++++- src/Rtsp/RtspMediaSourceMuxer.h | 8 +++++++- src/TS/TSMediaSource.h | 8 +++++++- 7 files changed, 56 insertions(+), 8 deletions(-) diff --git a/src/FMP4/FMP4MediaSource.h b/src/FMP4/FMP4MediaSource.h index 55ab1a7086..5353f1a494 100644 --- a/src/FMP4/FMP4MediaSource.h +++ b/src/FMP4/FMP4MediaSource.h @@ -41,7 +41,13 @@ class FMP4MediaSource final : public MediaSource, public toolkit::RingDelegate(tuple); } - ~FMP4MediaSourceMuxer() override { MP4MuxerMemory::flush(); }; + ~FMP4MediaSourceMuxer() override { + try { + MP4MuxerMemory::flush(); + } catch (std::exception &ex) { + WarnL << ex.what(); + } + } void setListener(const std::weak_ptr &listener){ setDelegate(listener); diff --git a/src/Record/HlsRecorder.h b/src/Record/HlsRecorder.h index 26894ccfe9..bbd869b1e2 100644 --- a/src/Record/HlsRecorder.h +++ b/src/Record/HlsRecorder.h @@ -84,7 +84,13 @@ class HlsRecorder final : public HlsRecorderBase { using Ptr = std::shared_ptr; template HlsRecorder(ARGS && ...args) : HlsRecorderBase(false, std::forward(args)...) {} - ~HlsRecorder() override { this->flush(); } + ~HlsRecorder() override { + try { + this->flush(); + } catch (std::exception &ex) { + WarnL << ex.what(); + } + } private: void onWrite(std::shared_ptr buffer, uint64_t timestamp, bool key_pos) override { @@ -102,7 +108,13 @@ class HlsFMP4Recorder final : public HlsRecorderBase { using Ptr = std::shared_ptr; template HlsFMP4Recorder(ARGS && ...args) : HlsRecorderBase(true, std::forward(args)...) {} - ~HlsFMP4Recorder() override { this->flush(); } + ~HlsFMP4Recorder() override { + try { + this->flush(); + } catch (std::exception &ex) { + WarnL << ex.what(); + } + } void addTrackCompleted() override { HlsRecorderBase::addTrackCompleted(); diff --git a/src/Rtmp/RtmpMediaSource.h b/src/Rtmp/RtmpMediaSource.h index eb1e3ded72..55a7afd61f 100644 --- a/src/Rtmp/RtmpMediaSource.h +++ b/src/Rtmp/RtmpMediaSource.h @@ -48,7 +48,13 @@ class RtmpMediaSource : public MediaSource, public toolkit::RingDelegatesetDelegate(_media_src); } - ~RtspMediaSourceMuxer() override { RtspMuxer::flush(); } + ~RtspMediaSourceMuxer() override { + try { + RtspMuxer::flush(); + } catch (std::exception &ex) { + WarnL << ex.what(); + } + } void setListener(const std::weak_ptr &listener){ setDelegate(listener); diff --git a/src/TS/TSMediaSource.h b/src/TS/TSMediaSource.h index 5900ec569c..7915f701ed 100644 --- a/src/TS/TSMediaSource.h +++ b/src/TS/TSMediaSource.h @@ -40,7 +40,13 @@ class TSMediaSource final : public MediaSource, public toolkit::RingDelegate