From cac91e03ef084c75be99e89556dc61ec217d1480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Tue, 6 Jan 2015 14:24:37 -0500 Subject: [PATCH] sipcall: stop rtp when call is closed Refs #63196 Change-Id: Id21496098bd2f446500efa3d7cb8bc3d72a10dcc --- daemon/src/sip/sipcall.cpp | 42 +++++++++++++++++++------------------- daemon/src/sip/sipcall.h | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/daemon/src/sip/sipcall.cpp b/daemon/src/sip/sipcall.cpp index 0f5f8eee6a..31f765ed0d 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 b8b8f72d22..fba24c03c3 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 -- GitLab