Skip to content
Snippets Groups Projects
Commit e4daf6cd authored by Stepan Salenikovich's avatar Stepan Salenikovich Committed by gerrit2
Browse files

ringaccount: perform ICE init after returning call

This way we don't have to wait for the ICE init before the manager
can get a callId to return to the client. The ICE init can take a long
time in certain cases (eg: bad TURN password, slow UPnP) which causes
the UI to freeze while waiting for the daemon to return outgoingCall()
with the callId.

Note this changes the behaviour of the daemon slightly. Before if the
ICE init failed then no callId would be returned. Now the callId is
always returned and the call will later emit a state change of Fail if
the ICE init fails.

Tuleap: #620
Change-Id: I712d1d52be9e9b809b794bb7694ad31bdd2e3bb1
parent 2f006c57
No related branches found
No related tags found
No related merge requests found
...@@ -182,29 +182,36 @@ RingAccount::newOutgoingCall(const std::string& toUrl) ...@@ -182,29 +182,36 @@ RingAccount::newOutgoingCall(const std::string& toUrl)
auto& manager = Manager::instance(); auto& manager = Manager::instance();
auto call = manager.callFactory.newCall<SIPCall, RingAccount>(*this, manager.getNewCallID(), auto call = manager.callFactory.newCall<SIPCall, RingAccount>(*this, manager.getNewCallID(),
Call::CallType::OUTGOING); Call::CallType::OUTGOING);
call->setIPToIP(true); call->setIPToIP(true);
call->setSecure(isTlsEnabled()); call->setSecure(isTlsEnabled());
// Create an ICE transport for SIP channel
auto ice = createIceTransport(("sip:" + call->getCallId()).c_str(),
ICE_COMPONENTS, true, getIceOptions());
if (not ice) {
call->removeCall();
return nullptr;
}
auto shared_this = std::static_pointer_cast<RingAccount>(shared_from_this());
auto iceInitTimeout = std::chrono::steady_clock::now() + std::chrono::seconds {ICE_INIT_TIMEOUT};
// TODO: for now, we automatically trust all explicitly called peers // TODO: for now, we automatically trust all explicitly called peers
setCertificateStatus(toUri, tls::TrustStore::PermissionStatus::ALLOWED); setCertificateStatus(toUri, tls::TrustStore::PermissionStatus::ALLOWED);
auto shared_this = std::static_pointer_cast<RingAccount>(shared_from_this());
std::weak_ptr<SIPCall> weak_call = call; std::weak_ptr<SIPCall> weak_call = call;
manager.addTask([shared_this, weak_call, ice, iceInitTimeout, toUri] { manager.addTask([shared_this, weak_call, toUri] {
auto call = weak_call.lock(); auto call = weak_call.lock();
if (not call) if (not call) {
call->onFailure();
return false; return false;
}
// Create an ICE transport for SIP channel
std::shared_ptr<IceTransport> ice {};
try {
ice = shared_this->createIceTransport(("sip:" + call->getCallId()).c_str(),
ICE_COMPONENTS, true, shared_this->getIceOptions());
} catch (std::runtime_error& e) {
RING_ERR("%s", e.what());
call->onFailure();
return false;
}
auto iceInitTimeout = std::chrono::steady_clock::now() + std::chrono::seconds {ICE_INIT_TIMEOUT};
/* First step: wait for an initialized ICE transport for SIP channel */ /* First step: wait for an initialized ICE transport for SIP channel */
if (ice->isFailed() or std::chrono::steady_clock::now() >= iceInitTimeout) { if (ice->isFailed() or std::chrono::steady_clock::now() >= iceInitTimeout) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment