Commit 9d62becc authored by Guillaume Roguez's avatar Guillaume Roguez
Browse files

sip: move SipIceTransport events handling

This fix "single role" class design rule.

Refs #64903

Change-Id: Idc8a82d04d13380bddad75c766fc7b3175a54ef1
parent c488ccf0
......@@ -31,6 +31,7 @@
#include "sip_transport_ice.h"
#include "ice_transport.h"
#include "manager.h"
#include "logger.h"
#include <pjsip/sip_transport.h>
......@@ -158,10 +159,14 @@ SipIceTransport::SipIceTransport(pjsip_endpoint* endpt, pj_pool_t& /* pool */,
if (pjsip_transport_register(base.tpmgr, &base) != PJ_SUCCESS)
throw std::runtime_error("Can't register PJSIP transport.");
is_registered_ = true;
Manager::instance().registerEventHandler((uintptr_t)this,
[this]{ loop(); });
}
SipIceTransport::~SipIceTransport()
{
Manager::instance().unregisterEventHandler((uintptr_t)this);
pj_lock_destroy(base.lock);
pj_atomic_destroy(base.ref_cnt);
}
......
......@@ -36,7 +36,6 @@
#include "ringdht/sip_transport_ice.h"
#include "manager.h"
#include "client/configurationmanager.h"
#include "array_size.h"
#include "intrin.h"
......@@ -161,14 +160,11 @@ cp_(cp), pool_(pool), endpt_(endpt)
#if HAVE_DHT
pjsip_transport_register_type(PJSIP_TRANSPORT_DATAGRAM, "ICE", pjsip_transport_get_default_port_for_type(PJSIP_TRANSPORT_UDP), &ice_pj_transport_type_);
#endif
Manager::instance().registerEventHandler((uintptr_t)this, [this]{ handleEvents(); });
}
SipTransportBroker::~SipTransportBroker()
{
RING_DBG("Destroying SipTransportBroker");
Manager::instance().unregisterEventHandler((uintptr_t)this);
{
std::lock_guard<std::mutex> lock(transportMapMutex_);
......@@ -242,14 +238,6 @@ SipTransportBroker::transportStateChanged(pjsip_transport* tp, pjsip_transport_s
}
}
void
SipTransportBroker::handleEvents()
{
std::unique_lock<std::mutex> lock(iceMutex_);
for (auto& t : iceTransports_)
t.loop();
}
std::shared_ptr<SipTransport>
SipTransportBroker::findTransport(pjsip_transport* t)
{
......
......@@ -183,8 +183,6 @@ private:
void transportStateChanged(pjsip_transport*, pjsip_transport_state, const pjsip_transport_state_info*);
void handleEvents();
/**
* List of transports so we can bubble the events up.
*/
......
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