Commit 704ea595 by ziyue

修复无人观看主动关闭webrtc推流线程安全的问题

parent 3c4285a0
...@@ -75,7 +75,6 @@ void WebRtcSession::onError(const SockException &err) { ...@@ -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() { ...@@ -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 ...@@ -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) { ...@@ -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;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论