From 704ea59502dc64c744b2a58cabf6e025f3d801c2 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Wed, 15 Sep 2021 14:56:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E4=BA=BA=E8=A7=82?= =?UTF-8?q?=E7=9C=8B=E4=B8=BB=E5=8A=A8=E5=85=B3=E9=97=ADwebrtc=E6=8E=A8?= =?UTF-8?q?=E6=B5=81=E7=BA=BF=E7=A8=8B=E5=AE=89=E5=85=A8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/WebRtcSession.cpp | 1 - webrtc/WebRtcTransport.cpp | 12 ++++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/webrtc/WebRtcSession.cpp b/webrtc/WebRtcSession.cpp index 4756dc8f..76aecd26 100644 --- a/webrtc/WebRtcSession.cpp +++ b/webrtc/WebRtcSession.cpp @@ -75,7 +75,6 @@ void WebRtcSession::onError(const SockException &err) { //在udp链接迁移时,新的WebRtcSession对象将接管WebRtcTransport对象的生命周期 //本WebRtcSession对象将在超时后自动销毁 WarnP(this) << err.what(); - _transport = nullptr; } void WebRtcSession::onManager() { diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index 8b92d617..01213f4f 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -489,7 +489,7 @@ void WebRtcTransportImp::onStartWebRTC() { if (!strongSelf) { return; } - strongSelf->onShutdown(SockException(Err_eof, "rtsp ring buffer detached")); + strongSelf->onShutdown(SockException(Err_shutdown, "rtsp ring buffer detached")); }); RtcSession rtsp_send_sdp; @@ -956,6 +956,8 @@ void WebRtcTransportImp::onBeforeEncryptRtp(const char *buf, int &len, void *ctx void WebRtcTransportImp::onShutdown(const SockException &ex){ WarnL << ex.what(); unrefSelf(); + //触发发送dtls close通知 + WebRtcTransport::onDestory(); auto session = _session.lock(); if (session) { session->shutdown(ex); @@ -970,7 +972,13 @@ bool WebRtcTransportImp::close(MediaSource &sender, bool force) { return false; } string err = StrPrinter << "close media:" << sender.getSchema() << "/" << sender.getVhost() << "/" << sender.getApp() << "/" << sender.getId() << " " << force; - onShutdown(SockException(Err_shutdown,err)); + weak_ptr weak_self = static_pointer_cast(shared_from_this()); + getPoller()->async([weak_self, err]() { + auto strong_self = weak_self.lock(); + if (strong_self) { + strong_self->onShutdown(SockException(Err_shutdown, err)); + } + }); return true; }