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

sips/ice: use ScheduledExecutor

Change-Id: I1fc4a0a68446911aaee0102d7ddca4c0d5c6980e
parent 8038a295
......@@ -249,8 +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.");
Manager::instance().registerEventHandler((uintptr_t)this, [this]{ handleEvents(); });
}
SipsIceTransport::~SipsIceTransport()
......@@ -266,7 +264,6 @@ SipsIceTransport::~SipsIceTransport()
}
auto base = getTransportBase();
Manager::instance().unregisterEventHandler((uintptr_t)this);
// Stop low-level transport first
tls_.reset();
......@@ -394,6 +391,7 @@ SipsIceTransport::pushChangeStateEvent(ChangeStateEventData&& ev)
{
std::lock_guard<std::mutex> lk{stateChangeEventsMutex_};
stateChangeEvents_.emplace_back(std::move(ev));
scheduler_.run([this]{ handleEvents(); });
}
// - DO NOT BLOCK - (Called in TlsSession thread)
......@@ -412,6 +410,7 @@ SipsIceTransport::onRxData(std::vector<uint8_t>&& buf)
{
std::lock_guard<std::mutex> l(rxMtx_);
rxPending_.emplace_back(std::move(buf));
scheduler_.run([this]{ handleEvents(); });
}
/* Update local & remote certificates info. This function should be
......@@ -698,6 +697,7 @@ SipsIceTransport::send(pjsip_tx_data* tdata, const pj_sockaddr_t* rem_addr,
tdata->op_key.token = token;
tdata->op_key.callback = callback;
txQueue_.push_back(tdata);
scheduler_.run([this]{ handleEvents(); });
return PJ_EPENDING;
}
......
......@@ -24,6 +24,7 @@
#include "security/tls_session.h"
#include "ip_utils.h"
#include "noncopyable.h"
#include "scheduled_executor.h"
#include <pjsip.h>
#include <pj/pool.h>
......@@ -124,6 +125,8 @@ private:
std::mutex rxMtx_;
std::list<std::vector<uint8_t>> rxPending_;
ScheduledExecutor scheduler_;
pj_status_t send(pjsip_tx_data*, const pj_sockaddr_t*, int, void*, pjsip_transport_callback);
void handleEvents();
void pushChangeStateEvent(ChangeStateEventData&&);
......
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