From 7a24a226617753f2bc8b924d81f755b02b0979b0 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 2 Jul 2022 13:13:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=8E=A8=E6=B5=81=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtmp/RtmpSession.cpp | 10 +++------- src/Rtmp/RtmpSession.h | 2 -- src/Rtsp/RtspSession.cpp | 4 ++-- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/Rtmp/RtmpSession.cpp b/src/Rtmp/RtmpSession.cpp index 88333fd8..566fcad1 100644 --- a/src/Rtmp/RtmpSession.cpp +++ b/src/Rtmp/RtmpSession.cpp @@ -28,7 +28,7 @@ RtmpSession::~RtmpSession() { } void RtmpSession::onError(const SockException& err) { - bool is_player = !_push_src; + bool is_player = !_push_src_ownership; uint64_t duration = _ticker.createdTime() / 1000; WarnP(this) << (is_player ? "RTMP播放器(" : "RTMP推流器(") << _media_info._vhost << "/" @@ -50,7 +50,7 @@ void RtmpSession::onError(const SockException& err) { _push_src_ownership = nullptr; //延时10秒注销流 auto push_src = std::move(_push_src); - _delay_unregister_task = getPoller()->doDelayTask(_continue_push_ms, [push_src]() { return 0; }); + getPoller()->doDelayTask(_continue_push_ms, [push_src]() { return 0; }); } } @@ -222,11 +222,7 @@ void RtmpSession::onCmd_deleteStream(AMFDecoder &dec) { sendStatus({ "level", "status", "code", "NetStream.Unpublish.Success", "description", "Stop publishing." }); - //_push_src = nullptr; - //TraceL<<" delete stream"; - if(_delay_unregister_task){ - _delay_unregister_task->cancel(); - } + _push_src = nullptr; throw std::runtime_error(StrPrinter << "Stop publishing" << endl); } diff --git a/src/Rtmp/RtmpSession.h b/src/Rtmp/RtmpSession.h index 5289a43f..c6367d35 100644 --- a/src/Rtmp/RtmpSession.h +++ b/src/Rtmp/RtmpSession.h @@ -103,8 +103,6 @@ private: std::weak_ptr _play_src; AMFValue _push_metadata; RtmpMediaSourceImp::Ptr _push_src; - //延迟注销任务 - toolkit::EventPoller::DelayTask::Ptr _delay_unregister_task; std::shared_ptr _push_src_ownership; RtmpMediaSource::RingType::RingReader::Ptr _ring_reader; }; diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index ce66a3f2..f7093d63 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -60,7 +60,7 @@ RtspSession::~RtspSession() { } void RtspSession::onError(const SockException &err) { - bool is_player = !_push_src; + bool is_player = !_push_src_ownership; uint64_t duration = _alive_ticker.createdTime() / 1000; WarnP(this) << (is_player ? "RTSP播放器(" : "RTSP推流器(") << _media_info._vhost << "/" @@ -868,7 +868,7 @@ void RtspSession::handleReq_Pause(const Parser &parser) { void RtspSession::handleReq_Teardown(const Parser &parser) { sendRtspResponse("200 OK"); - //_push_src = nullptr; + _push_src = nullptr; throw SockException(Err_shutdown,"recv teardown request"); }