Commit 412cdcc4 authored by Éloi Bail's avatar Éloi Bail Committed by Guillaume Roguez

daemon: manage properly ice creation failure

Refs #68903

Change-Id: If4ea91d765d38e5476230a33b83683953b41c998
Signed-off-by: Guillaume Roguez's avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent 3b1729c4
......@@ -265,12 +265,13 @@ Call::getNullDetails()
};
}
void
bool
Call::initIceTransport(bool master, unsigned channel_num)
{
auto& iceTransportFactory = Manager::instance().getIceTransportFactory();
iceTransport_ = iceTransportFactory.createTransport(getCallId().c_str(), channel_num,
master, account_.getUPnPActive());
return static_cast<bool>(iceTransport_);
}
int
......
......@@ -303,7 +303,7 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
void removeCall();
void initIceTransport(bool master, unsigned channel_num=4);
bool initIceTransport(bool master, unsigned channel_num=4);
int waitForIceInitialization(unsigned timeout);
......
......@@ -835,9 +835,14 @@ IceTransportFactory::createTransport(const char* name,
IceTransportCompleteCb&& on_initdone_cb,
IceTransportCompleteCb&& on_negodone_cb)
{
return std::make_shared<IceTransport>(name, component_count, master, upnp_enabled,
std::forward<IceTransportCompleteCb>(on_initdone_cb),
std::forward<IceTransportCompleteCb>(on_negodone_cb));
try {
return std::make_shared<IceTransport>(name, component_count, master, upnp_enabled,
std::forward<IceTransportCompleteCb>(on_initdone_cb),
std::forward<IceTransportCompleteCb>(on_negodone_cb));
} catch(const std::exception& e) {
RING_ERR("%s",e.what());
return nullptr;
}
}
void
......
......@@ -330,7 +330,7 @@ SIPAccount::newOutgoingCall(const std::string& toUrl)
bool
SIPAccount::SIPStartCall(std::shared_ptr<SIPCall>& call)
{
// Add Ice headers to local SDP
// Add Ice headers to local SDP if ice transport exist
call->setupLocalSDPFromIce();
std::string toUri(call->getPeerNumber()); // expecting a fully well formed sip uri
......
......@@ -230,8 +230,9 @@ SIPCall::SIPSessionReinvite()
acc.getActiveAccountCodecInfoList(acc.isVideoEnabled() ? MEDIA_VIDEO : MEDIA_NONE),
acc.getSrtpKeyExchange(),
getState() == Call::HOLD);
initIceTransport(true);
setupLocalSDPFromIce();
if (initIceTransport(true))
setupLocalSDPFromIce();
pjmedia_sdp_session *local_sdp = sdp_->getLocalSdpSession();
pjsip_tx_data *tdata;
......@@ -701,6 +702,11 @@ SIPCall::onAnswered()
void
SIPCall::setupLocalSDPFromIce()
{
if (not iceTransport_) {
RING_WARN("null icetransport: no attributes added to SDP");
return;
}
if (waitForIceInitialization(DEFAULT_ICE_INIT_TIMEOUT) <= 0) {
RING_ERR("ICE init failed, ICE will not be used for medias");
return;
......@@ -879,8 +885,8 @@ SIPCall::onReceiveOffer(const pjmedia_sdp_session* offer)
);
auto ice_attrs = Sdp::getIceAttributes(offer);
if (not ice_attrs.ufrag.empty() and not ice_attrs.pwd.empty()) {
initIceTransport(false);
setupLocalSDPFromIce();
if (initIceTransport(false))
setupLocalSDPFromIce();
}
sdp_->startNegotiation();
pjsip_inv_set_sdp_answer(inv.get(), sdp_->getLocalSdpSession());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment