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 55ab1a70..5353f1a4 100644 --- a/src/FMP4/FMP4MediaSource.h +++ b/src/FMP4/FMP4MediaSource.h @@ -41,7 +41,13 @@ public: FMP4MediaSource(const MediaTuple& tuple, int ring_size = FMP4_GOP_SIZE) : MediaSource(FMP4_SCHEMA, tuple), _ring_size(ring_size) {} - ~FMP4MediaSource() override { flush(); } + ~FMP4MediaSource() override { + try { + flush(); + } catch (std::exception &ex) { + WarnL << ex.what(); + } + } /** * 获取媒体源的环形缓冲 diff --git a/src/FMP4/FMP4MediaSourceMuxer.h b/src/FMP4/FMP4MediaSourceMuxer.h index 2725531e..300533b9 100644 --- a/src/FMP4/FMP4MediaSourceMuxer.h +++ b/src/FMP4/FMP4MediaSourceMuxer.h @@ -26,7 +26,13 @@ public: _media_src = std::make_shared(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 26894ccf..bbd869b1 100644 --- a/src/Record/HlsRecorder.h +++ b/src/Record/HlsRecorder.h @@ -84,7 +84,13 @@ public: 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 @@ public: 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 eb1e3ded..55a7afd6 100644 --- a/src/Rtmp/RtmpMediaSource.h +++ b/src/Rtmp/RtmpMediaSource.h @@ -48,7 +48,13 @@ public: */ RtmpMediaSource(const MediaTuple& tuple, int ring_size = RTMP_GOP_SIZE): MediaSource(RTMP_SCHEMA, tuple), _ring_size(ring_size) {} - ~RtmpMediaSource() override { flush(); } + ~RtmpMediaSource() override { + try { + flush(); + } catch (std::exception &ex) { + WarnL << ex.what(); + } + } /** * 获取媒体源的环形缓冲 diff --git a/src/Rtsp/RtspMediaSource.h b/src/Rtsp/RtspMediaSource.h index 11253817..b0b2a11f 100644 --- a/src/Rtsp/RtspMediaSource.h +++ b/src/Rtsp/RtspMediaSource.h @@ -44,7 +44,13 @@ public: */ RtspMediaSource(const MediaTuple& tuple, int ring_size = RTP_GOP_SIZE): MediaSource(RTSP_SCHEMA, tuple), _ring_size(ring_size) {} - ~RtspMediaSource() override { flush(); } + ~RtspMediaSource() override { + try { + flush(); + } catch (std::exception &ex) { + WarnL << ex.what(); + } + } /** * 获取媒体源的环形缓冲 diff --git a/src/Rtsp/RtspMediaSourceMuxer.h b/src/Rtsp/RtspMediaSourceMuxer.h index 1954344f..a8d33545 100644 --- a/src/Rtsp/RtspMediaSourceMuxer.h +++ b/src/Rtsp/RtspMediaSourceMuxer.h @@ -29,7 +29,13 @@ public: getRtpRing()->setDelegate(_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 5900ec56..7915f701 100644 --- a/src/TS/TSMediaSource.h +++ b/src/TS/TSMediaSource.h @@ -40,7 +40,13 @@ public: TSMediaSource(const MediaTuple& tuple, int ring_size = TS_GOP_SIZE): MediaSource(TS_SCHEMA, tuple), _ring_size(ring_size) {} - ~TSMediaSource() override { flush(); } + ~TSMediaSource() override { + try { + flush(); + } catch (std::exception &ex) { + WarnL << ex.what(); + } + } /** * 获取媒体源的环形缓冲