From d879c5901d76f4ba1307ed5d2198388be0e63700 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 17 Jan 2021 10:28:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BB=B6=E8=BF=9F=E6=B8=85=E7=A9=BA=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtmp/RtmpPlayer.cpp | 2 +- src/Rtmp/RtmpPusher.cpp | 2 +- src/Rtsp/RtspPusher.cpp | 11 ++++++++--- src/Rtsp/RtspPusher.h | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Rtmp/RtmpPlayer.cpp b/src/Rtmp/RtmpPlayer.cpp index 247a6d19..e6483707 100644 --- a/src/Rtmp/RtmpPlayer.cpp +++ b/src/Rtmp/RtmpPlayer.cpp @@ -133,7 +133,7 @@ void RtmpPlayer::onPlayResult_l(const SockException &ex, bool handshake_done) { //创建rtmp数据接收超时检测定时器 _rtmp_recv_timer = std::make_shared(timeout_ms / 2000.0, lam, getPoller()); } else { - teardown(); + shutdown(SockException(Err_shutdown,"teardown")); } } diff --git a/src/Rtmp/RtmpPusher.cpp b/src/Rtmp/RtmpPusher.cpp index a7d08cf5..3043e7a0 100644 --- a/src/Rtmp/RtmpPusher.cpp +++ b/src/Rtmp/RtmpPusher.cpp @@ -65,7 +65,7 @@ void RtmpPusher::onPublishResult(const SockException &ex, bool handshake_done) { } if (ex) { - teardown(); + shutdown(SockException(Err_shutdown,"teardown")); } } diff --git a/src/Rtsp/RtspPusher.cpp b/src/Rtsp/RtspPusher.cpp index dd7ef315..5b330785 100644 --- a/src/Rtsp/RtspPusher.cpp +++ b/src/Rtsp/RtspPusher.cpp @@ -26,12 +26,17 @@ RtspPusher::~RtspPusher() { DebugL << endl; } -void RtspPusher::teardown() { +void RtspPusher::sendTeardown(){ if (alive()) { - sendRtspRequest("TEARDOWN", _content_base); + if (!_content_base.empty()) { + sendRtspRequest("TEARDOWN", _content_base); + } shutdown(SockException(Err_shutdown, "teardown")); } +} +void RtspPusher::teardown() { + sendTeardown(); reset(); CLEAR_ARR(_udp_socks); _nonce.clear(); @@ -107,7 +112,7 @@ void RtspPusher::onPublishResult(const SockException &ex, bool handshake_done) { } if (ex) { - teardown(); + sendTeardown(); } } diff --git a/src/Rtsp/RtspPusher.h b/src/Rtsp/RtspPusher.h index 5f521763..3d4225db 100644 --- a/src/Rtsp/RtspPusher.h +++ b/src/Rtsp/RtspPusher.h @@ -60,6 +60,7 @@ private: void sendSetup(unsigned int track_idx); void sendRecord(); void sendOptions(); + void sendTeardown(); void handleResAnnounce(const Parser &parser); void handleResSetup(const Parser &parser, unsigned int track_idx);