From 50c6c2513d36648a890bd8c88a7e3dfdba698b05 Mon Sep 17 00:00:00 2001 From: xiongguangjie Date: Tue, 14 Dec 2021 17:17:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Drtsp=20tcp=20=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E5=88=B0=20rtsp-simple-server=20=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=20(#1274)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * for push rtsp to rtsp-simple-server remeber annoce response sessionid and setup tcp add mode=record * fix push rtsp to rtsp-simple-server over udp error add mode=record * 优化代码 Co-authored-by: 夏楚 <771730766@qq.com> --- src/Rtsp/RtspPusher.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Rtsp/RtspPusher.cpp b/src/Rtsp/RtspPusher.cpp index f754466a..8b7226bd 100644 --- a/src/Rtsp/RtspPusher.cpp +++ b/src/Rtsp/RtspPusher.cpp @@ -45,7 +45,6 @@ void RtspPusher::teardown() { _track_vec.clear(); _session_id.clear(); _content_base.clear(); - _session_id.clear(); _cseq = 1; _publish_timer.reset(); _beat_timer.reset(); @@ -207,6 +206,8 @@ void RtspPusher::handleResAnnounce(const Parser &parser) { if (_content_base.back() == '/') { _content_base.pop_back(); } + + _session_id = parser["Session"]; sendSetup(0); } @@ -263,14 +264,14 @@ void RtspPusher::sendSetup(unsigned int track_idx) { case Rtsp::RTP_TCP: { sendRtspRequest("SETUP", control_url, {"Transport", StrPrinter << "RTP/AVP/TCP;unicast;interleaved=" << track->_type * 2 - << "-" << track->_type * 2 + 1}); + << "-" << track->_type * 2 + 1 << ";mode=record"}); } break; case Rtsp::RTP_UDP: { createUdpSockIfNecessary(track_idx); int port = _rtp_sock[track_idx]->get_local_port(); sendRtspRequest("SETUP", control_url, - {"Transport", StrPrinter << "RTP/AVP;unicast;client_port=" << port << "-" << port + 1}); + {"Transport", StrPrinter << "RTP/AVP;unicast;client_port=" << port << "-" << port + 1 << ";mode=record"}); } break; default: @@ -566,4 +567,4 @@ void RtspPusher::sendRtspRequest(const string &cmd, const string &url,const StrC } -} /* namespace mediakit */ \ No newline at end of file +} /* namespace mediakit */