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);