avoid loopback ffmpeg push stream exit receive deleteStream message after broken pipe

This commit is contained in:
xiongguangjie 2022-07-02 12:33:32 +08:00
parent f96da3d166
commit 87dd1c7f7f
2 changed files with 7 additions and 1 deletions

View File

@ -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);
}

View File

@ -103,6 +103,8 @@ private:
std::weak_ptr<RtmpMediaSource> _play_src;
AMFValue _push_metadata;
RtmpMediaSourceImp::Ptr _push_src;
//延迟注销任务
toolkit::EventPoller::DelayTask::Ptr _delay_unregister_task;
std::shared_ptr<void> _push_src_ownership;
RtmpMediaSource::RingType::RingReader::Ptr _ring_reader;
};