From c445ad2cdf37f28684bc29891b8b9ca854ac95f0 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 17 Jan 2021 10:25:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Drtsp=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E5=99=A8=E5=9C=A8=E5=A4=84=E7=90=86rtp=E5=8C=85=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=B8=85=E7=A9=BA=E7=8A=B6=E6=80=81=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtsp/RtpReceiver.h | 6 ++++-- src/Rtsp/RtspPlayer.cpp | 10 +++++++--- src/Rtsp/RtspPlayer.h | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Rtsp/RtpReceiver.h b/src/Rtsp/RtpReceiver.h index f9a972f0..9832f649 100644 --- a/src/Rtsp/RtpReceiver.h +++ b/src/Rtsp/RtpReceiver.h @@ -116,9 +116,11 @@ private: } void popIterator(typename map::iterator it) { - _cb(it->first, it->second); - _next_seq_out = it->first + 1; + auto seq = it->first; + auto data = std::move(it->second); _rtp_sort_cache_map.erase(it); + _next_seq_out = seq + 1; + _cb(seq, data); } void tryPopPacket() { diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index e7f8e601..4f1dc306 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -30,19 +30,23 @@ enum PlayType { }; RtspPlayer::RtspPlayer(const EventPoller::Ptr &poller) : TcpClient(poller){ - RtpReceiver::setPoolSize(64); } + RtspPlayer::~RtspPlayer(void) { DebugL << endl; } -void RtspPlayer::teardown(){ + +void RtspPlayer::sendTeardown(){ if (alive()) { if (!_content_base.empty()) { sendRtspRequest("TEARDOWN", _content_base); } shutdown(SockException(Err_shutdown, "teardown")); } +} +void RtspPlayer::teardown(){ + sendTeardown(); _md5_nonce.clear(); _realm.clear(); _sdp_track.clear(); @@ -792,7 +796,7 @@ void RtspPlayer::onPlayResult_l(const SockException &ex , bool handshake_done) { //创建rtp数据接收超时检测定时器 _rtp_check_timer = std::make_shared(timeoutMS / 2000.0, lam, getPoller()); } else { - teardown(); + sendTeardown(); } } diff --git a/src/Rtsp/RtspPlayer.h b/src/Rtsp/RtspPlayer.h index 14a58766..fa459aa3 100644 --- a/src/Rtsp/RtspPlayer.h +++ b/src/Rtsp/RtspPlayer.h @@ -102,6 +102,7 @@ private: void sendSetup(unsigned int track_idx); void sendPause(int type , uint32_t ms); void sendDescribe(); + void sendTeardown(); void sendKeepAlive(); void sendRtspRequest(const string &cmd, const string &url ,const StrCaseMap &header = StrCaseMap()); void sendRtspRequest(const string &cmd, const string &url ,const std::initializer_list &header);