[asterisk-commits] branch oej/test-this-branch r11845 - in /team/oej/test-this-branch: ./ channels/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Mar 5 03:19:17 MST 2006


Author: oej
Date: Sun Mar  5 04:19:14 2006
New Revision: 11845

URL: http://svn.digium.com/view/asterisk?rev=11845&view=rev
Log:
Issue #6576 - Support SIP_CODEC for early media too

Modified:
    team/oej/test-this-branch/README.test-this-branch
    team/oej/test-this-branch/channels/chan_sip.c

Modified: team/oej/test-this-branch/README.test-this-branch
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/README.test-this-branch?rev=11845&r1=11844&r2=11845&view=diff
==============================================================================
--- team/oej/test-this-branch/README.test-this-branch (original)
+++ team/oej/test-this-branch/README.test-this-branch Sun Mar  5 04:19:14 2006
@@ -34,6 +34,7 @@
 - Carrier ENUM support (otmar, #5526)
 - HDLC mode support for ZAP channels (crich, #6251)
 - Show manager CLI commands (junky, #5240)
+- Support SIP_CODEC for early media (oej, #6576)
 
 Coming here soon:
 - metermaids: Subscription support for parking lots (#5779)

Modified: team/oej/test-this-branch/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/channels/chan_sip.c?rev=11845&r1=11844&r2=11845&view=diff
==============================================================================
--- team/oej/test-this-branch/channels/chan_sip.c (original)
+++ team/oej/test-this-branch/channels/chan_sip.c Sun Mar  5 04:19:14 2006
@@ -2620,12 +2620,35 @@
 	return 0;
 }
 
+/*! \brief Try setting codec suggested by the SIP_CODEC channel variable */
+static void try_suggested_sip_codec(struct sip_pvt *p)
+{
+	int fmt;
+	const char *codec;
+
+	codec = pbx_builtin_getvar_helper(p->owner, "SIP_CODEC");
+	if (!codec)
+		return;
+
+	fmt = ast_getformatbyname(codec);
+	if (fmt) {
+		ast_log(LOG_NOTICE, "Changing codec to '%s' for this call because of ${SIP_CODEC) variable\n",codec);
+	if (p->jointcapability & fmt) {
+		p->jointcapability &= fmt;
+		p->capability &= fmt;
+	} else
+		ast_log(LOG_NOTICE, "Ignoring ${SIP_CODEC} variable because it is not shared by both ends.\n");
+	} else
+		ast_log(LOG_NOTICE, "Ignoring ${SIP_CODEC} variable because of unrecognized/not configured codec (check allow/disallow in sip.conf): %s\n",codec);
+	return;
+}
+
+
 /*! \brief  sip_answer: Answer SIP call , send 200 OK on Invite 
  * Part of PBX interface */
 static int sip_answer(struct ast_channel *ast)
 {
-	int res = 0,fmt;
-	const char *codec;
+	int res = 0;
 	struct sip_pvt *p = ast->tech_pvt;
 
 	ast_mutex_lock(&p->lock);
@@ -2633,19 +2656,7 @@
 #ifdef OSP_SUPPORT	
 		time(&p->ospstart);
 #endif
-	
-		codec=pbx_builtin_getvar_helper(p->owner,"SIP_CODEC");
-		if (codec) {
-			fmt=ast_getformatbyname(codec);
-			if (fmt) {
-				ast_log(LOG_NOTICE, "Changing codec to '%s' for this call because of ${SIP_CODEC) variable\n",codec);
-				if (p->jointcapability & fmt) {
-					p->jointcapability &= fmt;
-					p->capability &= fmt;
-				} else
-					ast_log(LOG_NOTICE, "Ignoring ${SIP_CODEC} variable because it is not shared by both ends.\n");
-			} else ast_log(LOG_NOTICE, "Ignoring ${SIP_CODEC} variable because of unrecognized/not configured codec (check allow/disallow in sip.conf): %s\n",codec);
-		}
+		try_suggested_sip_codec(p);	
 
 		ast_setstate(ast, AST_STATE_UP);
 		if (option_debug)
@@ -4731,6 +4742,7 @@
 	}
 	respprep(&resp, p, msg, req);
 	if (p->rtp) {
+		try_suggested_sip_codec(p);
 		add_sdp(&resp, p);
 	} else {
 		ast_log(LOG_ERROR, "Can't add SDP to response, since we have no RTP session allocated. Call-ID %s\n", p->callid);



More information about the asterisk-commits mailing list