From 5792af3dd57cb8e9d378916038b4a6f4d8eab8ea Mon Sep 17 00:00:00 2001 From: xiongguangjie Date: Sat, 25 Mar 2023 20:40:40 +0800 Subject: [PATCH] fix direct_proxy is 0 repush not success --- src/Common/MultiMediaSourceMuxer.cpp | 4 ++++ src/Common/MultiMediaSourceMuxer.h | 5 +++++ src/Rtsp/RtspSession.cpp | 20 +++++++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Common/MultiMediaSourceMuxer.cpp b/src/Common/MultiMediaSourceMuxer.cpp index 389da30f..08b75e1d 100644 --- a/src/Common/MultiMediaSourceMuxer.cpp +++ b/src/Common/MultiMediaSourceMuxer.cpp @@ -142,6 +142,10 @@ void MultiMediaSourceMuxer::setTrackListener(const std::weak_ptr &list _track_listener = listener; } +std::weak_ptr MultiMediaSourceMuxer::getTrackListener(){ + return _track_listener; +} + int MultiMediaSourceMuxer::totalReaderCount() const { auto hls = _hls; auto ret = (_rtsp ? _rtsp->readerCount() : 0) + diff --git a/src/Common/MultiMediaSourceMuxer.h b/src/Common/MultiMediaSourceMuxer.h index 7bedef98..9aef934c 100644 --- a/src/Common/MultiMediaSourceMuxer.h +++ b/src/Common/MultiMediaSourceMuxer.h @@ -51,6 +51,11 @@ public: */ void setTrackListener(const std::weak_ptr &listener); + /** + * 获取Track就绪事件监听器 + */ + std::weak_ptr getTrackListener(); + /** * 返回总的消费者个数 */ diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index b1e32305..70b76f12 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -301,8 +301,26 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) { }); return; } + }else{ + auto listener = rtsp_src->getListener(true); + //TraceL<(listener.lock()); + if(muxer){ + //TraceL; + rtsp_src_imp = dynamic_pointer_cast(muxer->getTrackListener().lock()); + if(rtsp_src_imp){ + //TraceL; + _push_src_ownership = rtsp_src_imp->getOwnership(); + if(_push_src_ownership){ + _push_src = std::move(rtsp_src_imp); + onResPushSrc(option); + return; + }else{ + WarnL<<"not reach this"; + } + } + } } - sendRtspResponse("406 Not Acceptable", { "Content-Type", "text/plain" }, "not reach this"); string err = StrPrinter << "ANNOUNCE: not reach this:" << _media_info.shortUrl() << endl; throw SockException(Err_shutdown, err);