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(); + } + } /** * 获取媒体源的环形缓冲