Commit 16dc05e6 authored by Adrien Béraud's avatar Adrien Béraud Committed by Guillaume Roguez

siptransport: move inline methods from .h to .cpp

Refs #63196

Change-Id: I76f22d7de82c380c5f7d984205627763e118b8e1
parent a251e834
......@@ -111,6 +111,39 @@ SipTransport::stateToStr(pjsip_transport_state state)
return TRANSPORT_STATE_STR[std::min<size_t>(state, TRANSPORT_STATE_SZ-1)];
}
void
SipTransport::stateCallback(pjsip_transport_state state, const pjsip_transport_state_info *info)
{
std::vector<SipTransportStateCallback> cbs {};
{
std::lock_guard<std::mutex> lock(stateListenersMutex_);
cbs.reserve(stateListeners.size());
for (auto& l : stateListeners)
cbs.push_back(l.second);
}
for (auto& cb : cbs)
cb(state, info);
}
void
SipTransport::addStateListener(uintptr_t lid, SipTransportStateCallback cb)
{
std::lock_guard<std::mutex> lock(stateListenersMutex_);
stateListeners[lid] = cb;
}
bool
SipTransport::removeStateListener(uintptr_t lid)
{
std::lock_guard<std::mutex> lock(stateListenersMutex_);
auto it = stateListeners.find(lid);
if (it != stateListeners.end()) {
stateListeners.erase(it);
return true;
}
return false;
}
SipTransportBroker::SipTransportBroker(pjsip_endpoint *endpt, pj_caching_pool& cp, pj_pool_t& pool) :
#if HAVE_DHT
iceTransports_(),
......
......@@ -115,36 +115,14 @@ struct SipTransport
static const char* stateToStr(pjsip_transport_state state);
void stateCallback(pjsip_transport_state state, const pjsip_transport_state_info *info) {
std::vector<SipTransportStateCallback> cbs {};
{
std::lock_guard<std::mutex> lock(stateListenersMutex_);
cbs.reserve(stateListeners.size());
for (auto& l : stateListeners)
cbs.push_back(l.second);
}
for (auto& cb : cbs)
cb(state, info);
}
void stateCallback(pjsip_transport_state state, const pjsip_transport_state_info *info);
pjsip_transport* get() {
return transport;
}
void addStateListener(uintptr_t lid, SipTransportStateCallback cb) {
std::lock_guard<std::mutex> lock(stateListenersMutex_);
stateListeners[lid] = cb;
}
bool removeStateListener(uintptr_t lid) {
std::lock_guard<std::mutex> lock(stateListenersMutex_);
auto it = stateListeners.find(lid);
if (it != stateListeners.end()) {
stateListeners.erase(it);
return true;
}
return false;
}
void addStateListener(uintptr_t lid, SipTransportStateCallback cb);
bool removeStateListener(uintptr_t lid);
static bool isAlive(const std::shared_ptr<SipTransport>&, pjsip_transport_state state);
......@@ -239,6 +217,8 @@ private:
* List of transports so we can bubble the events up.
*/
std::map<pjsip_transport*, std::weak_ptr<SipTransport>> transports_ {};
std::mutex transportMapMutex_ {};
std::condition_variable transportDestroyedCv_ {};
/**
* Transports are stored in this map in order to retreive them in case
......@@ -256,9 +236,6 @@ private:
std::mutex iceMutex_ {};
#endif
std::mutex transportMapMutex_ {};
std::condition_variable transportDestroyedCv_ {};
pj_caching_pool& cp_;
pj_pool_t& pool_;
pjsip_endpoint *endpt_;
......
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