From 69ce49813dc85d499b42c8dc890e7cac1fdb54fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Mon, 23 Mar 2015 17:13:49 -0400
Subject: [PATCH] sipcall: add onPeerRinging

Refs #69086

Change-Id: I5da61d5041cc2aeeb939f39356a835f5c2bb264f
---
 src/sip/sipcall.cpp     |  7 +++++++
 src/sip/sipcall.h       |  6 ++++++
 src/sip/sipvoiplink.cpp | 11 ++---------
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/sip/sipcall.cpp b/src/sip/sipcall.cpp
index dd42378293..ca6d8e0189 100644
--- a/src/sip/sipcall.cpp
+++ b/src/sip/sipcall.cpp
@@ -701,6 +701,13 @@ SIPCall::onAnswered()
     }
 }
 
+void
+SIPCall::onPeerRinging()
+{
+    setConnectionState(Call::RINGING);
+    Manager::instance().peerRingingCall(*this);
+}
+
 void
 SIPCall::setupLocalSDPFromIce()
 {
diff --git a/src/sip/sipcall.h b/src/sip/sipcall.h
index 36b76db139..9c1801f3f8 100644
--- a/src/sip/sipcall.h
+++ b/src/sip/sipcall.h
@@ -171,6 +171,12 @@ class SIPCall : public Call
 
         void updateSDPFromSTUN();
 
+        /**
+         * Tell the user that the call is ringing
+         * @param
+         */
+        void onPeerRinging();
+
         /**
          * Tell the user that the call was answered
          * @param
diff --git a/src/sip/sipvoiplink.cpp b/src/sip/sipvoiplink.cpp
index 7a3cd733cc..e607e43d93 100644
--- a/src/sip/sipvoiplink.cpp
+++ b/src/sip/sipvoiplink.cpp
@@ -784,13 +784,6 @@ SIPVoIPLink::requestKeyframe(const std::string &callID)
 // Private functions
 ///////////////////////////////////////////////////////////////////////////////
 
-static void
-makeCallRing(SIPCall &call)
-{
-    call.setConnectionState(Call::RINGING);
-    Manager::instance().peerRingingCall(call);
-}
-
 static void
 invite_session_state_changed_cb(pjsip_inv_session *inv, pjsip_event *ev)
 {
@@ -819,7 +812,7 @@ invite_session_state_changed_cb(pjsip_inv_session *inv, pjsip_event *ev)
 
     if (inv->state == PJSIP_INV_STATE_EARLY and ev and ev->body.tsx_state.tsx and
             ev->body.tsx_state.tsx->role == PJSIP_ROLE_UAC) {
-        makeCallRing(*call);
+        call->onPeerRinging();
     } else if (inv->state == PJSIP_INV_STATE_CONFIRMED and ev) {
         // After we sent or received a ACK - The connection is established
         call->onAnswered();
@@ -1121,7 +1114,7 @@ transaction_state_changed_cb(pjsip_inv_session * inv, pjsip_transaction *tsx,
                     return;
                 } else if (msg.find("Ringing") != std::string::npos and call) {
                     if (call)
-                        makeCallRing(*call);
+                        call->onPeerRinging();
                     else
                         RING_WARN("Ringing state on non existing call");
                     sendOK(inv->dlg, r_data, tsx);
-- 
GitLab