From a0df228d1221067ecb6d65b59aba6b3a9db99895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Thu, 4 Jun 2020 12:31:28 -0400 Subject: [PATCH] media: improve media switching speed Destroying an ice session take quite some time and must be done in the io pool Change-Id: I159d249927a3aecbff640143902c8a6d33a52282 --- src/sip/sipcall.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sip/sipcall.cpp b/src/sip/sipcall.cpp index 71b9cc6b04..3fa2829385 100644 --- a/src/sip/sipcall.cpp +++ b/src/sip/sipcall.cpp @@ -1251,8 +1251,12 @@ SIPCall::waitForIceAndStartMedia() // Nego succeed: move to the new media transport call->stopAllMedia(); - if (call->tmpMediaTransport_) + if (call->tmpMediaTransport_) { + // Destroy the ICE media transport on another thread. This can take quite some time. + if (call->mediaTransport_) + dht::ThreadPool::io().run([ice=std::make_shared<decltype(call->mediaTransport_)>(std::move(call->mediaTransport_))] { }); call->mediaTransport_ = std::move(call->tmpMediaTransport_); + } call->startAllMedia(); return false; } -- GitLab