diff --git a/src/sip/sipcall.cpp b/src/sip/sipcall.cpp index 53ab650af0b761f5f18c9a37bf96d9763ecfa136..df972e9730dc98846ac92e12fd734e1534b86af5 100644 --- a/src/sip/sipcall.cpp +++ b/src/sip/sipcall.cpp @@ -183,7 +183,7 @@ void SIPCall::setContactHeader(pj_str_t *contact) } void -SIPCall::setTransport(const std::shared_ptr<SipTransport>& t) +SIPCall::setTransport(std::shared_ptr<SipTransport> t) { const auto list_id = reinterpret_cast<uintptr_t>(this); if (transport_) @@ -195,18 +195,15 @@ SIPCall::setTransport(const std::shared_ptr<SipTransport>& t) // listen for transport destruction transport_->addStateListener(list_id, - [wthis_, t, list_id] (pjsip_transport_state state, - const pjsip_transport_state_info*) - { + [wthis_] (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) and this_->getConnectionState() != ConnectionState::DISCONNECTED) { + if (not SipTransport::isAlive(this_->transport_, state) and this_->getConnectionState() != ConnectionState::DISCONNECTED) { RING_WARN("[call:%s] Ending call because underlying SIP transport was closed", this_->getCallId().c_str()); this_->onFailure(ECONNRESET); } - } else // should not happen - t->removeStateListener(list_id); + } }); } } diff --git a/src/sip/sipcall.h b/src/sip/sipcall.h index 2d70dbfb4781bbbf2452953919ce042a4168039f..4c252066bb59aecdac7d368a3b6c18a5b50b9403 100644 --- a/src/sip/sipcall.h +++ b/src/sip/sipcall.h @@ -128,10 +128,10 @@ class SIPCall : public Call void setContactHeader(pj_str_t *contact); - void setTransport(const std::shared_ptr<SipTransport>& t); + void setTransport(std::shared_ptr<SipTransport> t); - inline const std::shared_ptr<SipTransport>& getTransport() { - return transport_; + inline SipTransport* getTransport() { + return transport_.get(); } void sendSIPInfo(const char *const body, const char *const subtype);