[prev in list] [next in list] [prev in thread] [next in thread] 

List:       semsdev
Subject:    [Semsdev] git:1.4: b/f: stopping failed outbound calls
From:       Stefan Sayer <stefan.sayer () googlemail ! com>
Date:       2012-04-30 16:36:13
Message-ID: 20120430163613.B2755EF8078 () rimmer ! ryngle ! com
[Download RAW message or body]

Module: sems
Branch: 1.4
Commit: 26fdaa8eaf35e058c735af9ebb8ada38e4267d3c
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=26fdaa8eaf35e058c735af9ebb8ada38e4267d3c


Author: Stefan Sayer <stefan.sayer@googlemail.com>
Committer: Stefan Sayer <stefan.sayer@googlemail.com>
Date:   Mon Apr 30 18:26:30 2012 +0200

b/f: stopping failed outbound calls

applications which are doing outbound calls should implement
onFailedOutboundCall if the behavior should be different than
setting stopped.

Reported by Andrei Samusenko

---

 apps/conference/Conference.cpp             |   40 +++++++++++----------------
 apps/conference/Conference.h               |    1 +
 apps/dsm/DSMCall.cpp                       |   20 +++++++-------
 apps/dsm/DSMCall.h                         |    1 +
 apps/webconference/WebConferenceDialog.cpp |    6 ----
 core/AmB2BSession.cpp                      |    4 +++
 core/AmB2BSession.h                        |    1 +
 core/AmSession.cpp                         |   21 +++++++++++---
 core/AmSession.h                           |    3 ++
 9 files changed, 52 insertions(+), 45 deletions(-)

diff --git a/apps/conference/Conference.cpp b/apps/conference/Conference.cpp
index d4899a8..f42ab35 100644
--- a/apps/conference/Conference.cpp
+++ b/apps/conference/Conference.cpp
@@ -968,34 +968,26 @@ void ConferenceDialog::onSipReply(const AmSipReply& reply, int \
old_dlg_status, c  }
       break;
 
-    case AmSipDialog::Disconnected:
-
-      if(!transfer_req.get()){
-
-	disconnectDialout();
-	//switch(reply.code){
-	//default:
-	    
-	AmSessionContainer::instance()
-	  ->postEvent(dialout_channel->getConfID(),
-		      new DialoutConfEvent(DoConfError,
-					   dialout_channel->getConfID()));
-	//}
-      }
-      else {
-		
-	dlg.reply(*(transfer_req.get()),reply.code,reply.reason);
-	transfer_req.reset(0);
-	setStopped();
-      }
-      break;
-
-	    
-
     default: break;
     }
 
+  }
+}
+
+void ConferenceDialog::onOutboundCallFailed(const AmSipReply& reply) {
+  DBG("Outbound call failed with reply %d %s.\n", 
+      reply.code, reply.reason.c_str());
 
+  if(!transfer_req.get()){
+    disconnectDialout();
+    AmSessionContainer::instance()
+      ->postEvent(dialout_channel->getConfID(),
+		  new DialoutConfEvent(DoConfError,
+				       dialout_channel->getConfID()));
+  } else {
+    dlg.reply(*(transfer_req.get()),reply.code,reply.reason);
+    transfer_req.reset(0);
+    setStopped();
   }
 }
 
diff --git a/apps/conference/Conference.h b/apps/conference/Conference.h
index a04ce94..801d87a 100644
--- a/apps/conference/Conference.h
+++ b/apps/conference/Conference.h
@@ -154,6 +154,7 @@ public:
   void onSessionStart(const AmSipRequest& req);
   void onBye(const AmSipRequest& req);
 
+  void onOutboundCallFailed(const AmSipReply& reply);
   void onSipRequest(const AmSipRequest& req);
   void onSipReply(const AmSipReply& reply, int old_dlg_status,
 		  const string& trans_method);
diff --git a/apps/dsm/DSMCall.cpp b/apps/dsm/DSMCall.cpp
index 11f095e..d48f2fc 100644
--- a/apps/dsm/DSMCall.cpp
+++ b/apps/dsm/DSMCall.cpp
@@ -320,16 +320,16 @@ void DSMCall::onSipReply(const AmSipReply& reply, int \
old_dlg_status, const stri  
   AmB2BCallerSession::onSipReply(reply,old_dlg_status,trans_method);
 
-  if ((old_dlg_status < AmSipDialog::Connected) && 
-      (dlg.getStatus() == AmSipDialog::Disconnected)) {
-    DBG("Outbound call failed with reply %d %s.\n", 
-	reply.code, reply.reason.c_str());
-    map<string, string> params;
-    params["code"] = int2str(reply.code);
-    params["reason"] = reply.reason;
-    engine.runEvent(this, this, DSMCondition::FailedCall, &params);
-    setStopped();
-  }
+}
+
+void DSMCall::onOutboundCallFailed(const AmSipReply& reply) {
+  DBG("Outbound call failed with reply %d %s.\n",
+      reply.code, reply.reason.c_str());
+  map<string, string> params;
+  params["code"] = int2str(reply.code);
+  params["reason"] = reply.reason;
+  engine.runEvent(this, this, DSMCondition::FailedCall, &params);
+  setStopped();
 }
 
 void DSMCall::onSystemEvent(AmSystemEvent* ev) {
diff --git a/apps/dsm/DSMCall.h b/apps/dsm/DSMCall.h
index 2dffdeb..7e7405a 100644
--- a/apps/dsm/DSMCall.h
+++ b/apps/dsm/DSMCall.h
@@ -80,6 +80,7 @@ public:
   void startSession();
   void onCancel();
   void onBye(const AmSipRequest& req);
+  void onOutboundCallFailed(const AmSipReply& reply);
   void onDtmf(int event, int duration_msec);
   void onBeforeDestroy();
 
diff --git a/apps/webconference/WebConferenceDialog.cpp \
b/apps/webconference/WebConferenceDialog.cpp index 7e73bb3..1eac3ef 100644
--- a/apps/webconference/WebConferenceDialog.cpp
+++ b/apps/webconference/WebConferenceDialog.cpp
@@ -206,12 +206,6 @@ void WebConferenceDialog::onSipReply(const AmSipReply& reply, \
int old_dlg_status  AmSipDialog::status2str[old_dlg_status],
       AmSipDialog::status2str[dlg.getStatus()]);
 
-  if ((old_dlg_status < AmSipDialog::Connected) && 
-      (dlg.getStatus() == AmSipDialog::Disconnected)) {
-    DBG("Call failed.\n");
-    setStopped();
-  }
-
   // update status to map
   if (is_dialout) {
     // map AmSipDialog state to WebConferenceState
diff --git a/core/AmB2BSession.cpp b/core/AmB2BSession.cpp
index 9017271..c080232 100644
--- a/core/AmB2BSession.cpp
+++ b/core/AmB2BSession.cpp
@@ -464,6 +464,10 @@ void AmB2BSession::onInvite2xx(const AmSipReply& reply)
   }
 }
 
+void AmB2BSession::onOutboundCallFailed(const AmSipReply& reply) {
+  // in B2B session failed B leg is handled in A leg - ignore here
+}
+
 int AmB2BSession::relayEvent(AmEvent* ev)
 {
   DBG("AmB2BSession::relayEvent: to other_id='%s'\n",
diff --git a/core/AmB2BSession.h b/core/AmB2BSession.h
index 00265fa..4c8853d 100644
--- a/core/AmB2BSession.h
+++ b/core/AmB2BSession.h
@@ -185,6 +185,7 @@ class AmB2BSession: public AmSession
 		  int old_dlg_status, const string& trans_method);
   void onInvite2xx(const AmSipReply& reply);
 
+  void onOutboundCallFailed(const AmSipReply& reply);
   void onSessionTimeout();
   void onNoAck(unsigned int cseq);
 
diff --git a/core/AmSession.cpp b/core/AmSession.cpp
index 5f45a57..3806199 100644
--- a/core/AmSession.cpp
+++ b/core/AmSession.cpp
@@ -906,14 +906,14 @@ void AmSession::onSipReply(const AmSipReply& reply,
 	AmSipDialog::status2str[old_dlg_status], 
 	sess_stopped.get() ? "true" : "false");
 
-
+  DBG("negotiate_onreply = %s\n", negotiate_onreply?"true":"false");
   if (negotiate_onreply) {    
     if(old_dlg_status < AmSipDialog::Connected){
-      
+      DBG("old is < conn\n");
       switch(dlg.getStatus()){
 	
       case AmSipDialog::Connected:
-	
+	      DBG("case conn\n");
 	try {
 	  RTPStream()->setMonitorRTPTimeout(true);
 
@@ -942,7 +942,7 @@ void AmSession::onSipReply(const AmSipReply& reply,
 	break;
 	
       case AmSipDialog::Pending:
-
+	DBG("case pending\n");
 	switch(reply.code){
 	  // todo: 180 with body (remote rbt)
 	case 180: { 
@@ -979,7 +979,13 @@ void AmSession::onSipReply(const AmSipReply& reply,
 	  }
 	} break;
 	default:  break;// continue waiting.
-	}
+	} break;
+
+      case AmSipDialog::Disconnected: {
+	// status change: <Connected -> Disconnected => outbound call failed
+	onOutboundCallFailed(reply);
+      }; break;
+
       } // switch dlg status
     } // status < Connected
   } //if negotiate_onreply
@@ -1039,6 +1045,11 @@ void AmSession::onBye(const AmSipRequest& req)
   setStopped();
 }
 
+void AmSession::onOutboundCallFailed(const AmSipReply& reply) {
+  DBG("Outbound call failed. Stopping session.\n");
+  setStopped();
+}
+
 int AmSession::acceptAudio(const string& body,
 			   const string& hdrs,
 			   string*       sdp_reply)
diff --git a/core/AmSession.h b/core/AmSession.h
index 218259b..f4fbf17 100644
--- a/core/AmSession.h
+++ b/core/AmSession.h
@@ -562,6 +562,9 @@ public:
    */
   virtual void onBye(const AmSipRequest& req);
 
+  /** onOutboundCallFailed is called when an outbound call fails */
+  virtual void onOutboundCallFailed(const AmSipReply& reply);
+
   /** Entry point for SIP Requests   */
   virtual void onSipRequest(const AmSipRequest& req);
 

_______________________________________________
Semsdev mailing list
Semsdev@lists.iptel.org
http://lists.iptel.org/mailman/listinfo/semsdev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic