Commit 9142eb77 authored by Adrien Béraud's avatar Adrien Béraud Committed by Gerrit Code Review

sip: end call on transport failure

Refs #68135

Change-Id: Ic05d6dd781680f3261c40afb4625876d776208fe
parent c6b7ecf2
......@@ -131,6 +131,7 @@ SIPCall::SIPCall(SIPAccountBase& account, const std::string& id, Call::CallType
SIPCall::~SIPCall()
{
setTransport({});
inv.reset(); // prevents callback usage
}
......@@ -183,6 +184,35 @@ void SIPCall::setContactHeader(pj_str_t *contact)
pj_strcpy(&contactHeader_, contact);
}
void
SIPCall::setTransport(const std::shared_ptr<SipTransport>& t)
{
const auto list_id = reinterpret_cast<uintptr_t>(this);
if (transport_)
transport_->removeStateListener(list_id);
transport_ = t;
if (transport_) {
std::weak_ptr<SIPCall> wthis_ = std::static_pointer_cast<SIPCall>(shared_from_this());
// listen for transport destruction
transport_->addStateListener(list_id,
[wthis_, t, list_id] (pjsip_transport_state state,
const pjsip_transport_state_info*)
{
if (auto this_ = wthis_.lock()) {
// end the call if the SIP transport is shut down
if (not SipTransport::isAlive(t, state)) {
RING_WARN("Ending call because underlying SIP transport was closed");
Manager::instance().callFailure(*this_);
this_->removeCall();
}
} else // should not happen
t->removeStateListener(list_id);
});
}
}
/**
* Send a reINVITE inside an active dialog to modify its state
* Local SDP session should be modified before calling this method
......
......@@ -134,9 +134,7 @@ class SIPCall : public Call
void setContactHeader(pj_str_t *contact);
void setTransport(const std::shared_ptr<SipTransport>& t) {
transport_ = t;
}
void setTransport(const std::shared_ptr<SipTransport>& t);
inline const std::shared_ptr<SipTransport>& getTransport() {
return transport_;
......
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