[svn-commits] oej: branch 1.4 r65041 - /branches/1.4/channels/chan_sip.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Fri May 18 05:58:40 MST 2007


Author: oej
Date: Fri May 18 07:58:39 2007
New Revision: 65041

URL: http://svn.digium.com/view/asterisk?view=rev&rev=65041
Log:
- Adding support for putting calls OFF hold with a re-invite with blank SDP. This was a bug found while doing tests at SIPit in Antwerp.
- In order to not duplicate code, I restructured some of the code for putting calls on/off hold.

Thanks DEA for reminding me. This fix has been asleep in the videocaps branch until now.

Modified:
    branches/1.4/channels/chan_sip.c

Modified: branches/1.4/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_sip.c?view=diff&rev=65041&r1=65040&r2=65041
==============================================================================
--- branches/1.4/channels/chan_sip.c (original)
+++ branches/1.4/channels/chan_sip.c Fri May 18 07:58:39 2007
@@ -4737,6 +4737,33 @@
 	return 0;
 }
 
+/*! \brief Change hold state for a call */
+static void change_hold_state(struct sip_pvt *dialog, struct sip_request *req, int holdstate, int sendonly)
+{
+	if (global_notifyhold)
+		sip_peer_hold(dialog, holdstate);
+	if (global_callevents)
+		manager_event(EVENT_FLAG_CALL, holdstate ? "Hold" : "Unhold",
+			      "Channel: %s\r\n"
+			      "Uniqueid: %s\r\n",
+			      dialog->owner->name, 
+			      dialog->owner->uniqueid);
+	append_history(dialog, holdstate ? "Hold" : "Unhold", "%s", req->data);
+	if (!holdstate) { 	/* Put off remote hold */
+		ast_clear_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD);	/* Clear both flags */
+		return;
+	}
+	/* No address for RTP, we're on hold */
+
+	if (sendonly == 1)	/* One directional hold (sendonly/recvonly) */
+		ast_set_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD_ONEDIR);
+	else if (sendonly == 2)	/* Inactive stream */
+		ast_set_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD_INACTIVE);
+	else
+		ast_set_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD_ACTIVE);
+	return;
+}
+
 /*! \brief Process SIP SDP offer, select formats and activate RTP channels
 	If offer is rejected, we will not change any properties of the call
  	Return 0 on success, a negative value on errors.
@@ -5285,38 +5312,10 @@
 	}
 
 	/* Manager Hold and Unhold events must be generated, if necessary */
-	if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD) && sin.sin_addr.s_addr && (!sendonly || sendonly == -1)) {
-		append_history(p, "Unhold", "%s", req->data);
-		if (global_callevents)
-			manager_event(EVENT_FLAG_CALL, "Unhold",
-				      "Channel: %s\r\n"
-				      "Uniqueid: %s\r\n",
-				      p->owner->name, 
-				      p->owner->uniqueid);
-		if (global_notifyhold)
-			sip_peer_hold(p, 0);
-		ast_clear_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD);	/* Clear both flags */
-	} else if (!sin.sin_addr.s_addr || (sendonly && sendonly != -1)) {
-		/* No address for RTP, we're on hold */
-		append_history(p, "Hold", "%s", req->data);
-
-		if (global_callevents && !ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD)) {
-			manager_event(EVENT_FLAG_CALL, "Hold",
-				"Channel: %s\r\n"
-				"Uniqueid: %s\r\n",
-				p->owner->name, 
-				p->owner->uniqueid);
-		}
-		if (sendonly == 1)	/* One directional hold (sendonly/recvonly) */
-			ast_set_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD_ONEDIR);
-		else if (sendonly == 2)	/* Inactive stream */
-			ast_set_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD_INACTIVE);
-		else
-			ast_set_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD_ACTIVE);
-		if (global_notifyhold)
-			sip_peer_hold(p, 1);
-	}
-	
+	if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD) && sin.sin_addr.s_addr && (!sendonly || sendonly == -1))
+		change_hold_state(p, req, FALSE, sendonly);
+	else if (!sin.sin_addr.s_addr || (sendonly && sendonly != -1))
+		change_hold_state(p, req, TRUE, sendonly);
 	return 0;
 }
 
@@ -13405,8 +13404,13 @@
 				}
 			} else {
 				p->jointcapability = p->capability;
-				if (option_debug)
+				if (option_debug > 2)
 					ast_log(LOG_DEBUG, "Hm....  No sdp for the moment\n");
+				/* Some devices signal they want to be put off hold by sending a re-invite
+				   *without* an SDP, which is supposed to mean "Go back to your state"
+				   and since they put os on remote hold, we go back to off hold */
+				if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD))
+					change_hold_state(p, req, FALSE, 0);
 			}
 			if (!ast_test_flag(&p->flags[0], SIP_NO_HISTORY)) /* This is a response, note what it was for */
 				append_history(p, "ReInv", "Re-invite received");



More information about the svn-commits mailing list