Commit de87ae90 authored by Adrien Béraud's avatar Adrien Béraud

sips_transport_ice: start thread when connected

Change-Id: I5d6c119143c6eec64724226b3a2d5ebe279e0406
parent 58b78449
......@@ -249,16 +249,6 @@ SipsIceTransport::SipsIceTransport(pjsip_endpoint* endpt,
if (pjsip_transport_register(base.tpmgr, &base) != PJ_SUCCESS)
throw std::runtime_error("Can't register PJSIP transport.");
if (PJSIP_TRANSPORT_IS_RELIABLE(&trData_.base)) {
eventLoop_ = std::thread([this] {
try {
eventLoop();
} catch (const std::exception& e) {
JAMI_ERR() << "SipIceTransport: eventLoop() failure: " << e.what();
}
});
}
}
SipsIceTransport::~SipsIceTransport()
......@@ -312,12 +302,24 @@ SipsIceTransport::handleEvents()
for (auto& evdata : eventDataQueue) {
evdata.tls_info.ssl_sock_info = &evdata.ssl_info;
evdata.state_info.ext_info = &evdata.tls_info;
if (evdata.state == PJSIP_TP_STATE_CONNECTED) {
if (PJSIP_TRANSPORT_IS_RELIABLE(&trData_.base)) {
eventLoop_ = std::thread([this] {
try {
eventLoop();
} catch (const std::exception& e) {
JAMI_ERR() << "SipIceTransport: eventLoop() failure: " << e.what();
}
});
}
}
if (evdata.state != PJSIP_TP_STATE_DISCONNECTED) {
(*state_cb)(&trData_.base, evdata.state, &evdata.state_info);
} else {
JAMI_WARN("[SIPS] got disconnected event!");
disconnectedEvent = std::move(evdata);
disconnected = true;
stopLoop_ = true;
break;
}
}
......@@ -410,7 +412,7 @@ SipsIceTransport::pushChangeStateEvent(ChangeStateEventData&& ev)
// - DO NOT BLOCK - (Called in TlsSession thread)
void
SipsIceTransport::onTlsStateChange(UNUSED TlsSessionState state)
SipsIceTransport::onTlsStateChange(TlsSessionState state)
{
if (state == TlsSessionState::ESTABLISHED)
updateTransportState(PJSIP_TP_STATE_CONNECTED);
......
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