Skip to content
Snippets Groups Projects
Commit cf72929a authored by Adrien Béraud's avatar Adrien Béraud
Browse files

sips/ice: use ScheduledExecutor

Change-Id: I1fc4a0a68446911aaee0102d7ddca4c0d5c6980e
parent 8038a295
No related branches found
No related tags found
No related merge requests found
...@@ -249,8 +249,6 @@ SipsIceTransport::SipsIceTransport(pjsip_endpoint* endpt, ...@@ -249,8 +249,6 @@ SipsIceTransport::SipsIceTransport(pjsip_endpoint* endpt,
if (pjsip_transport_register(base.tpmgr, &base) != PJ_SUCCESS) if (pjsip_transport_register(base.tpmgr, &base) != PJ_SUCCESS)
throw std::runtime_error("Can't register PJSIP transport."); throw std::runtime_error("Can't register PJSIP transport.");
Manager::instance().registerEventHandler((uintptr_t)this, [this]{ handleEvents(); });
} }
SipsIceTransport::~SipsIceTransport() SipsIceTransport::~SipsIceTransport()
...@@ -266,7 +264,6 @@ SipsIceTransport::~SipsIceTransport() ...@@ -266,7 +264,6 @@ SipsIceTransport::~SipsIceTransport()
} }
auto base = getTransportBase(); auto base = getTransportBase();
Manager::instance().unregisterEventHandler((uintptr_t)this);
// Stop low-level transport first // Stop low-level transport first
tls_.reset(); tls_.reset();
...@@ -394,6 +391,7 @@ SipsIceTransport::pushChangeStateEvent(ChangeStateEventData&& ev) ...@@ -394,6 +391,7 @@ SipsIceTransport::pushChangeStateEvent(ChangeStateEventData&& ev)
{ {
std::lock_guard<std::mutex> lk{stateChangeEventsMutex_}; std::lock_guard<std::mutex> lk{stateChangeEventsMutex_};
stateChangeEvents_.emplace_back(std::move(ev)); stateChangeEvents_.emplace_back(std::move(ev));
scheduler_.run([this]{ handleEvents(); });
} }
// - DO NOT BLOCK - (Called in TlsSession thread) // - DO NOT BLOCK - (Called in TlsSession thread)
...@@ -412,6 +410,7 @@ SipsIceTransport::onRxData(std::vector<uint8_t>&& buf) ...@@ -412,6 +410,7 @@ SipsIceTransport::onRxData(std::vector<uint8_t>&& buf)
{ {
std::lock_guard<std::mutex> l(rxMtx_); std::lock_guard<std::mutex> l(rxMtx_);
rxPending_.emplace_back(std::move(buf)); rxPending_.emplace_back(std::move(buf));
scheduler_.run([this]{ handleEvents(); });
} }
/* Update local & remote certificates info. This function should be /* 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, ...@@ -698,6 +697,7 @@ SipsIceTransport::send(pjsip_tx_data* tdata, const pj_sockaddr_t* rem_addr,
tdata->op_key.token = token; tdata->op_key.token = token;
tdata->op_key.callback = callback; tdata->op_key.callback = callback;
txQueue_.push_back(tdata); txQueue_.push_back(tdata);
scheduler_.run([this]{ handleEvents(); });
return PJ_EPENDING; return PJ_EPENDING;
} }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "security/tls_session.h" #include "security/tls_session.h"
#include "ip_utils.h" #include "ip_utils.h"
#include "noncopyable.h" #include "noncopyable.h"
#include "scheduled_executor.h"
#include <pjsip.h> #include <pjsip.h>
#include <pj/pool.h> #include <pj/pool.h>
...@@ -124,6 +125,8 @@ private: ...@@ -124,6 +125,8 @@ private:
std::mutex rxMtx_; std::mutex rxMtx_;
std::list<std::vector<uint8_t>> rxPending_; 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); pj_status_t send(pjsip_tx_data*, const pj_sockaddr_t*, int, void*, pjsip_transport_callback);
void handleEvents(); void handleEvents();
void pushChangeStateEvent(ChangeStateEventData&&); void pushChangeStateEvent(ChangeStateEventData&&);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment