diff --git a/src/Rtp/RtpProcess.cpp b/src/Rtp/RtpProcess.cpp index e4ca2dac..b9aa5f1b 100644 --- a/src/Rtp/RtpProcess.cpp +++ b/src/Rtp/RtpProcess.cpp @@ -49,10 +49,13 @@ RtpProcess::RtpProcess(const string &stream_id) { } } -RtpProcess::~RtpProcess() { +void RtpProcess::flush() { if (_process) { _process->flush(); } +} + +RtpProcess::~RtpProcess() { uint64_t duration = (_last_frame_time.createdTime() - _last_frame_time.elapsedTime()) / 1000; WarnP(this) << "RTP推流器(" << _media_info.shortUrl() diff --git a/src/Rtp/RtpProcess.h b/src/Rtp/RtpProcess.h index 3c3244a2..8b951216 100644 --- a/src/Rtp/RtpProcess.h +++ b/src/Rtp/RtpProcess.h @@ -18,7 +18,7 @@ namespace mediakit { -class RtpProcess : public RtcpContextForRecv, public toolkit::SockInfo, public MediaSinkInterface, public MediaSourceEventInterceptor, public std::enable_shared_from_this{ +class RtpProcess final : public RtcpContextForRecv, public toolkit::SockInfo, public MediaSinkInterface, public MediaSourceEventInterceptor, public std::enable_shared_from_this{ public: typedef std::shared_ptr Ptr; friend class RtpProcessHelper; @@ -57,6 +57,11 @@ public: */ void setStopCheckRtp(bool is_check=false); + /** + * flush输出缓存 + */ + void flush() override; + /// SockInfo override std::string get_local_ip() override; uint16_t get_local_port() override; diff --git a/src/Rtp/RtpSelector.cpp b/src/Rtp/RtpSelector.cpp index 66d44828..8ac620ac 100644 --- a/src/Rtp/RtpSelector.cpp +++ b/src/Rtp/RtpSelector.cpp @@ -112,6 +112,13 @@ RtpProcessHelper::RtpProcessHelper(const string &stream_id, const weak_ptrgetOwnerPoller(MediaSource::NullMediaSource())->async([process]() { process->flush(); }); + } catch (...) { + // 忽略getOwnerPoller可能抛出的异常 + } } void RtpProcessHelper::attachEvent() {