修复rtsp tcp 推送到 rtsp-simple-server 失败的问题, (#1274)

* 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>
This commit is contained in:
xiongguangjie 2021-12-14 17:17:05 +08:00 committed by GitHub
parent 7aaa10eb3c
commit 50c6c2513d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,7 +45,6 @@ void RtspPusher::teardown() {
_track_vec.clear(); _track_vec.clear();
_session_id.clear(); _session_id.clear();
_content_base.clear(); _content_base.clear();
_session_id.clear();
_cseq = 1; _cseq = 1;
_publish_timer.reset(); _publish_timer.reset();
_beat_timer.reset(); _beat_timer.reset();
@ -208,6 +207,8 @@ void RtspPusher::handleResAnnounce(const Parser &parser) {
_content_base.pop_back(); _content_base.pop_back();
} }
_session_id = parser["Session"];
sendSetup(0); sendSetup(0);
} }
@ -263,14 +264,14 @@ void RtspPusher::sendSetup(unsigned int track_idx) {
case Rtsp::RTP_TCP: { case Rtsp::RTP_TCP: {
sendRtspRequest("SETUP", control_url, {"Transport", sendRtspRequest("SETUP", control_url, {"Transport",
StrPrinter << "RTP/AVP/TCP;unicast;interleaved=" << track->_type * 2 StrPrinter << "RTP/AVP/TCP;unicast;interleaved=" << track->_type * 2
<< "-" << track->_type * 2 + 1}); << "-" << track->_type * 2 + 1 << ";mode=record"});
} }
break; break;
case Rtsp::RTP_UDP: { case Rtsp::RTP_UDP: {
createUdpSockIfNecessary(track_idx); createUdpSockIfNecessary(track_idx);
int port = _rtp_sock[track_idx]->get_local_port(); int port = _rtp_sock[track_idx]->get_local_port();
sendRtspRequest("SETUP", control_url, 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; break;
default: default: