[svn-commits] mjordan: branch mjordan/udptl r350360 - /team/mjordan/udptl/channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jan 11 09:14:58 CST 2012


Author: mjordan
Date: Wed Jan 11 09:14:52 2012
New Revision: 350360

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=350360
Log:
Moved T38 initialization to SDP parsing.  We'll see how that goes.

Modified:
    team/mjordan/udptl/channels/chan_sip.c

Modified: team/mjordan/udptl/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/udptl/channels/chan_sip.c?view=diff&rev=350360&r1=350359&r2=350360
==============================================================================
--- team/mjordan/udptl/channels/chan_sip.c (original)
+++ team/mjordan/udptl/channels/chan_sip.c Wed Jan 11 09:14:52 2012
@@ -8648,6 +8648,35 @@
 	return ast_sockaddr_isnull(addr) || ast_sockaddr_is_any(addr);
 }
 
+static int initialize_udptl(struct sip_pvt *p)
+{
+	if (!ast_test_flag(&p->flags[1], SIP_PAGE2_T38SUPPORT)) {
+		return 1;
+	}
+
+	/* If we've already initialized T38, don't take any further action */
+	if (p->udptl) {
+		return 0;
+	}
+
+	/* If T38 could be supported by this dialog, create it now */
+	if ((p->udptl = ast_udptl_new_with_bindaddr(sched, io, 0, &bindaddr))) {
+		ast_udptl_setqos(p->udptl, global_tos_audio, global_cos_audio);
+		/* Since the udptl session probably didn't exist when check_user_full was called,
+		 * apply the peer's T38 information here if one exists
+		 */
+		p->t38_maxdatagram = p->relatedpeer ? p->relatedpeer->t38_maxdatagram : global_t38_maxdatagram;
+		set_t38_capabilities(p);
+	} else {
+		/* udptl creation failed, T38 can not be supported on this dialog */
+		ast_log(AST_LOG_WARNING, "UDPTL creation failed - disabling T38 for this dialog\n");
+		ast_clear_flag(&p->flags[1], SIP_PAGE2_T38SUPPORT);
+		return 1;
+	}
+
+	return 0;
+}
+
 /*! \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.
@@ -8891,8 +8920,12 @@
 				ast_rtp_codecs_payloads_set_m_type(&newtextrtp, NULL, codec);
 			}
 		/* Search for image media definition */
-		} else if (p->udptl && ((sscanf(m, "image %30u udptl t38%n", &x, &len) == 1 && len > 0 && x) ||
+		} else if (((sscanf(m, "image %30u udptl t38%n", &x, &len) == 1 && len > 0 && x) ||
 					(sscanf(m, "image %30u UDPTL t38%n", &x, &len) == 1 && len > 0 && x) )) {
+			if (initialize_udptl(p)) {
+				continue;
+			}
+
 			if (p->offered_media[SDP_IMAGE].order_offered) {
 				ast_log(LOG_WARNING, "Multiple T.38 streams are not supported\n");
 				return -3;
@@ -9569,6 +9602,10 @@
 	int found = FALSE;
 	char s[256];
 	unsigned int x;
+
+	if (initialize_udptl(p)) {
+		return found;
+	}
 
 	if ((sscanf(a, "T38FaxMaxBuffer:%30u", &x) == 1)) {
 		ast_debug(3, "MaxBufferSize:%d\n", x);
@@ -22379,21 +22416,6 @@
 		}
 		if (authpeer) {
 			p->relatedpeer = ref_peer(authpeer, "setting dialog's relatedpeer pointer");
-		}
-		/* If T38 could be supported by this dialog, create it now */
-		if (ast_test_flag(&p->flags[1], SIP_PAGE2_T38SUPPORT) && !p->udptl) {
-			if ((p->udptl = ast_udptl_new_with_bindaddr(sched, io, 0, &bindaddr))) {
-				ast_udptl_setqos(p->udptl, global_tos_audio, global_cos_audio);
-				/* Since the udptl session probably didn't exist when check_user_full was called,
-				 * apply the peer's T38 information here if one exists
-				 */
-				p->t38_maxdatagram = authpeer ? authpeer->t38_maxdatagram : global_t38_maxdatagram;
-				set_t38_capabilities(p);
-			} else {
-				/* udptl creation failed, T38 can not be supported on this dialog */
-				ast_log(AST_LOG_WARNING, "UDPTL creation failed - disabling T38 for this dialog\n");
-				ast_clear_flag(&p->flags[1], SIP_PAGE2_T38SUPPORT);
-			}
 		}
 
 		req->authenticated = 1;




More information about the svn-commits mailing list