diff --git a/daemon/src/sip/sipcall.cpp b/daemon/src/sip/sipcall.cpp index 0f5f8eee6a8939b2f51bea2a725b694e5146add3..31f765ed0d29edc8139a363272ac2d2fb69ae5c0 100644 --- a/daemon/src/sip/sipcall.cpp +++ b/daemon/src/sip/sipcall.cpp @@ -148,21 +148,6 @@ SIPCall::~SIPCall() } } -void -SIPCall::stopRtpIfCurrent() -{ - if (Manager::instance().isCurrentCall(*this)) { -#if USE_CCRTP - audiortp_.stop(); -#else - avformatrtp_->stop(); -#endif -#ifdef RING_VIDEO - videortp_.stop(); -#endif - } -} - SIPAccountBase& SIPCall::getSIPAccount() const { @@ -337,6 +322,9 @@ void SIPCall::answer() void SIPCall::hangup(int reason) { + // Stop all RTP streams + stopAllMedias(); + if (not inv or not inv->dlg) throw VoipLinkException("No invite session for this call"); @@ -372,6 +360,7 @@ SIPCall::hangup(int reason) sip_utils::addContactHeader(&contactStr, tdata); if (pjsip_inv_send_msg(inv.get(), tdata) != PJ_SUCCESS) { + RING_ERR("Error sending hangup message"); inv.reset(); return; } @@ -379,9 +368,6 @@ SIPCall::hangup(int reason) // Make sure user data is NULL in callbacks inv->mod_data[getSIPVoIPLink()->getModId()] = NULL; - // Stop all RTP streams - stopRtpIfCurrent(); - removeCall(); } @@ -706,6 +692,9 @@ SIPCall::internalOffHold(const std::function<void()> &SDPUpdateFunc) void SIPCall::peerHungup() { + // Stop all RTP streams + stopAllMedias(); + if (not inv) throw VoipLinkException("No invite session for this call"); @@ -722,9 +711,6 @@ SIPCall::peerHungup() inv.reset(); sip_utils::sip_strerror(ret); } - - // Stop all RTP streams - stopRtpIfCurrent(); } void @@ -967,3 +953,17 @@ SIPCall::startAllMedia() RING_ERR("%s", rtpException.what()); } } + +void +SIPCall::stopAllMedias() +{ + RING_DBG("SIPCall %s: stopping all medias", getCallId().c_str()); +#if USE_CCRTP + audiortp_.stop(); +#else + avformatrtp_->stop(); +#endif +#ifdef RING_VIDEO + videortp_.stop(); +#endif +} diff --git a/daemon/src/sip/sipcall.h b/daemon/src/sip/sipcall.h index b8b8f72d229aa63961a191ee162d5bbaf162c788..fba24c03c33f7e18db58d426e89fc073f2a79c9a 100644 --- a/daemon/src/sip/sipcall.h +++ b/daemon/src/sip/sipcall.h @@ -198,7 +198,7 @@ class SIPCall : public Call std::map<std::string, std::string> createHistoryEntry() const; - void stopRtpIfCurrent(); + void stopAllMedias(); /** * Transfer method used for both type of transfer