From 3028612a0e0e88a775291ec76f6e8f7cec467367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E8=A1=B2=E4=B8=8D=E5=87=BA=E5=AE=B6?= Date: Thu, 11 Sep 2025 16:52:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Drtsp=E7=82=B9=E6=92=AD?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98=20(#4445)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtsp/RtspPlayer.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index 60d4e78d..932cc853 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -411,12 +411,11 @@ void RtspPlayer::handleResSETUP(const Parser &parser, unsigned int track_idx) { // All SETUP commands have been sent // 发送play命令 [AUTO-TRANSLATED:47a826d1] // Send PLAY command - if (_speed==0.0f) { + if (_speed == 0.0f) { sendPause(type_play, 0); } else { sendPause(type_speed, 0); } - } void RtspPlayer::sendDescribe() { @@ -465,15 +464,11 @@ void RtspPlayer::sendPause(int type, uint32_t seekMS) { // Start or pause RTSP switch (type) { case type_pause: sendRtspRequest("PAUSE", _control_url, {}); break; - case type_play: - // sendRtspRequest("PLAY", _content_base); - // break; + case type_play: sendRtspRequest("PLAY", _content_base); break; case type_seek: sendRtspRequest("PLAY", _control_url, { "Range", StrPrinter << "npt=" << setiosflags(ios::fixed) << setprecision(2) << seekMS / 1000.0 << "-" }); break; - case type_speed: - speed(_speed); - break; + case type_speed: speed(_speed); break; default: WarnL << "unknown type : " << type; _on_response = nullptr; @@ -632,11 +627,6 @@ void RtspPlayer::sendRtspRequest(const string &cmd, const string &url, const std key = val; } } - if (cmd == "PLAY") { - for (auto &pr : _custom_header) { - header_map.emplace(pr.first, pr.second); - } - } sendRtspRequest(cmd, url, header_map); } @@ -698,6 +688,11 @@ void RtspPlayer::sendRtspRequest(const string &cmd, const string &url, const Str for (auto &pr : header) { printer << pr.first << ": " << pr.second << "\r\n"; } + if (cmd == "PLAY") { + for (auto &pr : _custom_header) { + printer << pr.first << ": " << pr.second << "\r\n"; + } + } printer << "\r\n"; SockSender::send(std::move(printer)); }