sip: end call on transport failure

Refs #68135

Change-Id: Ic05d6dd781680f3261c40afb4625876d776208fe
This commit is contained in:
Adrien Béraud
2015-03-18 18:11:41 -04:00
committed by Gerrit Code Review
parent c6b7ecf2bd
commit 9142eb7790
2 changed files with 31 additions and 3 deletions

View File

@ -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

View File

@ -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_;