From 48c37d4f46240d8d70f3ee29fa5558a88a858a71 Mon Sep 17 00:00:00 2001 From: haorui wang <56127613+HR1025@users.noreply.github.com> Date: Thu, 8 Jan 2026 20:28:30 +0800 Subject: [PATCH] =?UTF-8?q?[what][bugfix][rtsp]=20=E4=BF=AE=E5=A4=8Dhandle?= =?UTF-8?q?ResPAUSE=20=E5=9B=9E=E8=B0=83=E6=9C=AA=E8=A2=AB=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E8=A7=A6=E5=8F=91=20(#4631)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [what][bugfix][rtsp][https://github.com/ZLMediaKit/ZLMediaKit/issues/4625] 修复handleResPAUSE 回调未被正常触发 --- src/Rtsp/RtspPlayer.cpp | 10 +++++++++- src/Rtsp/RtspPlayer.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index b55c7909..c1b668f7 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -446,7 +446,11 @@ void RtspPlayer::sendOptions() { } void RtspPlayer::sendKeepAlive() { - _on_response = [](const Parser &parser) {}; + if (_play_check_timer) + { + WarnL << "receive RTP packet before handleResPAUSE"; + } + _on_keepalive_reponse = [](const Parser &parser) {}; if (_supported_cmd.find("GET_PARAMETER") != _supported_cmd.end()) { // 支持GET_PARAMETER,用此命令保活 [AUTO-TRANSLATED:b45cd737] // Support GET_PARAMETER, use this command to keep alive @@ -532,6 +536,10 @@ void RtspPlayer::onWholeRtspPacket(Parser &parser) { try { decltype(_on_response) func; _on_response.swap(func); + if (!func) + { + _on_keepalive_reponse.swap(func); + } if (func) { func(parser); } diff --git a/src/Rtsp/RtspPlayer.h b/src/Rtsp/RtspPlayer.h index 909d39b4..9c98714e 100644 --- a/src/Rtsp/RtspPlayer.h +++ b/src/Rtsp/RtspPlayer.h @@ -162,6 +162,7 @@ private: float _speed = 0.0f; std::vector _sdp_track; std::function _on_response; + std::function _on_keepalive_reponse; protected: // RTP端口,trackid idx 为数组下标 [AUTO-TRANSLATED:77c186bb] // RTP port, trackid idx is the array subscript