diff --git a/src/Rtmp/RtmpSession.cpp b/src/Rtmp/RtmpSession.cpp index 81a71c11..88333fd8 100644 --- a/src/Rtmp/RtmpSession.cpp +++ b/src/Rtmp/RtmpSession.cpp @@ -50,7 +50,7 @@ void RtmpSession::onError(const SockException& err) { _push_src_ownership = nullptr; //延时10秒注销流 auto push_src = std::move(_push_src); - getPoller()->doDelayTask(_continue_push_ms, [push_src]() { return 0; }); + _delay_unregister_task = getPoller()->doDelayTask(_continue_push_ms, [push_src]() { return 0; }); } } @@ -223,6 +223,10 @@ void RtmpSession::onCmd_deleteStream(AMFDecoder &dec) { "code", "NetStream.Unpublish.Success", "description", "Stop publishing." }); //_push_src = nullptr; + //TraceL<<" delete stream"; + if(_delay_unregister_task){ + _delay_unregister_task->cancel(); + } throw std::runtime_error(StrPrinter << "Stop publishing" << endl); } diff --git a/src/Rtmp/RtmpSession.h b/src/Rtmp/RtmpSession.h index c6367d35..5289a43f 100644 --- a/src/Rtmp/RtmpSession.h +++ b/src/Rtmp/RtmpSession.h @@ -103,6 +103,8 @@ 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; };