mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-23 03:10:04 +08:00
修复无人观看主动关闭webrtc推流线程安全的问题
This commit is contained in:
parent
3c4285a056
commit
704ea59502
@ -75,7 +75,6 @@ void WebRtcSession::onError(const SockException &err) {
|
|||||||
//在udp链接迁移时,新的WebRtcSession对象将接管WebRtcTransport对象的生命周期
|
//在udp链接迁移时,新的WebRtcSession对象将接管WebRtcTransport对象的生命周期
|
||||||
//本WebRtcSession对象将在超时后自动销毁
|
//本WebRtcSession对象将在超时后自动销毁
|
||||||
WarnP(this) << err.what();
|
WarnP(this) << err.what();
|
||||||
_transport = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRtcSession::onManager() {
|
void WebRtcSession::onManager() {
|
||||||
|
@ -489,7 +489,7 @@ void WebRtcTransportImp::onStartWebRTC() {
|
|||||||
if (!strongSelf) {
|
if (!strongSelf) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
strongSelf->onShutdown(SockException(Err_eof, "rtsp ring buffer detached"));
|
strongSelf->onShutdown(SockException(Err_shutdown, "rtsp ring buffer detached"));
|
||||||
});
|
});
|
||||||
|
|
||||||
RtcSession rtsp_send_sdp;
|
RtcSession rtsp_send_sdp;
|
||||||
@ -956,6 +956,8 @@ void WebRtcTransportImp::onBeforeEncryptRtp(const char *buf, int &len, void *ctx
|
|||||||
void WebRtcTransportImp::onShutdown(const SockException &ex){
|
void WebRtcTransportImp::onShutdown(const SockException &ex){
|
||||||
WarnL << ex.what();
|
WarnL << ex.what();
|
||||||
unrefSelf();
|
unrefSelf();
|
||||||
|
//触发发送dtls close通知
|
||||||
|
WebRtcTransport::onDestory();
|
||||||
auto session = _session.lock();
|
auto session = _session.lock();
|
||||||
if (session) {
|
if (session) {
|
||||||
session->shutdown(ex);
|
session->shutdown(ex);
|
||||||
@ -970,7 +972,13 @@ bool WebRtcTransportImp::close(MediaSource &sender, bool force) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
string err = StrPrinter << "close media:" << sender.getSchema() << "/" << sender.getVhost() << "/" << sender.getApp() << "/" << sender.getId() << " " << force;
|
string err = StrPrinter << "close media:" << sender.getSchema() << "/" << sender.getVhost() << "/" << sender.getApp() << "/" << sender.getId() << " " << force;
|
||||||
onShutdown(SockException(Err_shutdown,err));
|
weak_ptr<WebRtcTransportImp> weak_self = static_pointer_cast<WebRtcTransportImp>(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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user