diff --git a/src/Common/MediaSource.cpp b/src/Common/MediaSource.cpp index f2861153..6f3a62e4 100644 --- a/src/Common/MediaSource.cpp +++ b/src/Common/MediaSource.cpp @@ -124,7 +124,11 @@ MediaSource::MediaSource(const string &schema, const MediaTuple& tuple): _tuple( } MediaSource::~MediaSource() { - unregist(); + try { + unregist(); + } catch (std::exception &ex) { + WarnL << "Exception occurred: " << ex.what(); + } } const string& MediaSource::getSchema() const { diff --git a/src/Player/PlayerProxy.cpp b/src/Player/PlayerProxy.cpp index 36b4d850..2a319ff8 100644 --- a/src/Player/PlayerProxy.cpp +++ b/src/Player/PlayerProxy.cpp @@ -202,7 +202,11 @@ PlayerProxy::~PlayerProxy() { _timer.reset(); // 避免析构时, 忘记回调api请求 if (_on_play) { - _on_play(SockException(Err_shutdown, "player proxy close")); + try { + _on_play(SockException(Err_shutdown, "player proxy close")); + } catch (std::exception &ex) { + WarnL << "Exception occurred: " << ex.what(); + } _on_play = nullptr; } } diff --git a/src/Pusher/MediaPusher.cpp b/src/Pusher/MediaPusher.cpp index 865b4d2a..f0ea401b 100644 --- a/src/Pusher/MediaPusher.cpp +++ b/src/Pusher/MediaPusher.cpp @@ -31,8 +31,7 @@ MediaPusher::MediaPusher(const string &schema, MediaPusher(MediaSource::find(schema, vhost, app, stream), poller){ } -MediaPusher::~MediaPusher() { -} +MediaPusher::~MediaPusher() = default; static void setOnCreateSocket_l(const std::shared_ptr &delegate, const Socket::onCreateSocket &cb){ auto helper = dynamic_pointer_cast(delegate); diff --git a/src/Record/HlsMaker.cpp b/src/Record/HlsMaker.cpp index df4cb8de..bc6cf53d 100644 --- a/src/Record/HlsMaker.cpp +++ b/src/Record/HlsMaker.cpp @@ -22,9 +22,7 @@ HlsMaker::HlsMaker(float seg_duration, uint32_t seg_number, bool seg_keep) { _seg_keep = seg_keep; } -HlsMaker::~HlsMaker() { -} - +HlsMaker::~HlsMaker() = default; void HlsMaker::makeIndexFile(bool eof) { char file_content[1024]; diff --git a/src/Record/HlsMediaSource.cpp b/src/Record/HlsMediaSource.cpp index d6d4f4b4..f3fe516b 100644 --- a/src/Record/HlsMediaSource.cpp +++ b/src/Record/HlsMediaSource.cpp @@ -46,7 +46,11 @@ HlsCookieData::~HlsCookieData() { GET_CONFIG(uint32_t, iFlowThreshold, General::kFlowThreshold); uint64_t bytes = _bytes.load(); if (bytes >= iFlowThreshold * 1024) { - NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _info, bytes, duration, true, static_cast(*_sock_info)); + try { + NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _info, bytes, duration, true, static_cast(*_sock_info)); + } catch (std::exception &ex) { + WarnL << "Exception occurred: " << ex.what(); + } } } } diff --git a/src/Record/MP4Demuxer.cpp b/src/Record/MP4Demuxer.cpp index a1c657fd..a1bbd34c 100644 --- a/src/Record/MP4Demuxer.cpp +++ b/src/Record/MP4Demuxer.cpp @@ -21,7 +21,7 @@ using namespace std; namespace mediakit { -MP4Demuxer::MP4Demuxer() {} +MP4Demuxer::MP4Demuxer() = default; MP4Demuxer::~MP4Demuxer() { closeMP4(); diff --git a/src/Rtp/RtpProcess.cpp b/src/Rtp/RtpProcess.cpp index 9700e09c..741cc4b1 100644 --- a/src/Rtp/RtpProcess.cpp +++ b/src/Rtp/RtpProcess.cpp @@ -66,7 +66,11 @@ RtpProcess::~RtpProcess() { //流量统计事件广播 GET_CONFIG(uint32_t, iFlowThreshold, General::kFlowThreshold); if (_total_bytes >= iFlowThreshold * 1024) { - NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _media_info, _total_bytes, duration, false, static_cast(*this)); + try { + NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _media_info, _total_bytes, duration, false, static_cast(*this)); + } catch (std::exception &ex) { + WarnL << "Exception occurred: " << ex.what(); + } } } diff --git a/src/Rtp/RtpSender.cpp b/src/Rtp/RtpSender.cpp index a15884f0..a102d5e2 100644 --- a/src/Rtp/RtpSender.cpp +++ b/src/Rtp/RtpSender.cpp @@ -28,7 +28,11 @@ RtpSender::RtpSender(EventPoller::Ptr poller) { } RtpSender::~RtpSender() { - flush(); + try { + flush(); + } catch (std::exception &ex) { + WarnL << "Exception occurred: " << ex.what(); + } } void RtpSender::startSend(const MediaSourceEvent::SendRtpArgs &args, const function &cb){ diff --git a/srt/SrtTransportImp.cpp b/srt/SrtTransportImp.cpp index 91ae7488..c3c18c5d 100644 --- a/srt/SrtTransportImp.cpp +++ b/srt/SrtTransportImp.cpp @@ -16,9 +16,11 @@ SrtTransportImp::~SrtTransportImp() { // 流量统计事件广播 GET_CONFIG(uint32_t, iFlowThreshold, General::kFlowThreshold); if (_total_bytes >= iFlowThreshold * 1024) { - NoticeCenter::Instance().emitEvent( - Broadcast::kBroadcastFlowReport, _media_info, _total_bytes, duration, !_is_pusher, - static_cast(*this)); + try { + NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _media_info, _total_bytes, duration, !_is_pusher, static_cast(*this)); + } catch (std::exception &ex) { + WarnL << "Exception occurred: " << ex.what(); + } } }