[asterisk-commits] kpfleming: branch kpfleming/udptl-updates r206278 - in /team/kpfleming/udptl-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 13 17:01:40 CDT 2009


Author: kpfleming
Date: Mon Jul 13 17:01:36 2009
New Revision: 206278

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=206278
Log:
remove remaining t.38 'capabilities' code from chan_sip, and implement storage and forwarding of ast_control_t38_parameters structures instead

in app_fax, always provide our preferred t.38 session parameters, and let channel driver implement rules to make our preferences compatible
with the other end's offer when necessary


Modified:
    team/kpfleming/udptl-updates/apps/app_fax.c
    team/kpfleming/udptl-updates/channels/chan_sip.c

Modified: team/kpfleming/udptl-updates/apps/app_fax.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/kpfleming/udptl-updates/apps/app_fax.c?view=diff&rev=206278&r1=206277&r2=206278
==============================================================================
--- team/kpfleming/udptl-updates/apps/app_fax.c (original)
+++ team/kpfleming/udptl-updates/apps/app_fax.c Mon Jul 13 17:01:36 2009
@@ -514,10 +514,10 @@
 										     .version = 0,
 										     .max_ifp = 800,
 										     .rate = AST_T38_RATE_9600,
-										     .rate_management = parameters->rate_management,
-										     .fill_bit_removal = parameters->fill_bit_removal,
-										     .transcoding_mmr = parameters->transcoding_mmr,
-										     .transcoding_jbig = parameters->transcoding_jbig,
+										     .rate_management = AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF,
+										     .fill_bit_removal = 1,
+										     .transcoding_mmr = 1,
+										     .transcoding_jbig = 1,
 				};
 				ast_debug(1, "T38 request received, accepting\n");
 				/* Complete T38 switchover */

Modified: team/kpfleming/udptl-updates/channels/chan_sip.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/kpfleming/udptl-updates/channels/chan_sip.c?view=diff&rev=206278&r1=206277&r2=206278
==============================================================================
--- team/kpfleming/udptl-updates/channels/chan_sip.c (original)
+++ team/kpfleming/udptl-updates/channels/chan_sip.c Mon Jul 13 17:01:36 2009
@@ -1537,34 +1537,6 @@
 
 /*@}*/ 
 
-/*! \name SIPflagsT38
-	T.38 set of flags */
-
-/*@{*/ 
-#define T38FAX_FILL_BIT_REMOVAL			(1 << 0)	/*!< Default: 0 (unset)*/
-#define T38FAX_TRANSCODING_MMR			(1 << 1)	/*!< Default: 0 (unset)*/
-#define T38FAX_TRANSCODING_JBIG			(1 << 2)	/*!< Default: 0 (unset)*/
-/* Rate management */
-#define T38FAX_RATE_MANAGEMENT_TRANSFERRED_TCF	(0 << 3)
-#define T38FAX_RATE_MANAGEMENT_LOCAL_TCF	(1 << 3)	/*!< Unset for transferredTCF (UDPTL), set for localTCF (TPKT) */
-/* UDP Error correction */
-#define T38FAX_UDP_EC_NONE			(0 << 4)	/*!< two bits, if unset NO t38UDPEC field in T38 SDP*/
-#define T38FAX_UDP_EC_FEC			(1 << 4)	/*!< Set for t38UDPFEC */
-#define T38FAX_UDP_EC_REDUNDANCY		(2 << 4)	/*!< Set for t38UDPRedundancy */
-/* T38 Spec version */
-#define T38FAX_VERSION				(3 << 6)	/*!< two bits, 2 values so far, up to 4 values max */
-#define T38FAX_VERSION_0			(0 << 6)	/*!< Version 0 */
-#define T38FAX_VERSION_1			(1 << 6)	/*!< Version 1 */
-/* Maximum Fax Rate */
-#define T38FAX_RATE_2400			(1 << 8)	/*!< 2400 bps t38FaxRate */
-#define T38FAX_RATE_4800			(1 << 9)	/*!< 4800 bps t38FaxRate */
-#define T38FAX_RATE_7200			(1 << 10)	/*!< 7200 bps t38FaxRate */
-#define T38FAX_RATE_9600			(1 << 11)	/*!< 9600 bps t38FaxRate */
-#define T38FAX_RATE_12000			(1 << 12)	/*!< 12000 bps t38FaxRate */
-#define T38FAX_RATE_14400			(1 << 13)	/*!< 14400 bps t38FaxRate */
-
-/*@}*/ 
-
 /*! \brief debugging state
  * We store separately the debugging requests from the config file
  * and requests from the CLI. Debugging is enabled if either is set
@@ -4904,7 +4876,7 @@
 {
 	int old = p->t38.state;
 	struct ast_channel *chan = p->owner;
-	struct ast_control_t38_parameters parameters = { 0, };
+	struct ast_control_t38_parameters parameters = { .request_response = 0 };
 
 	/* Don't bother changing if we are already in the state wanted */
 	if (old == state)
@@ -4919,10 +4891,12 @@
 
 	/* Given the state requested and old state determine what control frame we want to queue up */
 	if (state == T38_PEER_REINVITE) {
+		parameters = p->t38.their_parms;
+		parameters.max_ifp = ast_udptl_get_far_max_ifp(p->udptl);
 		parameters.request_response = AST_T38_REQUEST_NEGOTIATE;
-		/* KPF: store their parameters */
 	} else if (state == T38_ENABLED) {
 		parameters = p->t38.their_parms;
+		parameters.max_ifp = ast_udptl_get_far_max_ifp(p->udptl);
 		parameters.request_response = AST_T38_NEGOTIATED;
 	} else if (state == T38_DISABLED && old == T38_ENABLED)
 		parameters.request_response = AST_T38_TERMINATED;
@@ -4957,7 +4931,6 @@
 }
 
 /*! \brief Set the global T38 capabilities on a SIP dialog structure */
-/* KPF: override EC mode based on what remote end answers with or asks for */
 static void set_t38_capabilities(struct sip_pvt *p)
 {
 	if (p->udptl) {
@@ -6242,15 +6215,10 @@
 				we simply forget the frames if we get modem frames before the bridge is up.
 				Fax will re-transmit.
 			*/
-			if (ast->_state == AST_STATE_UP) {
-				if (ast_test_flag(&p->flags[1], SIP_PAGE2_T38SUPPORT) && p->t38.state == T38_DISABLED) {
-					if (!p->pendinginvite) {
-						change_t38_state(p, T38_LOCAL_REINVITE);
-						transmit_reinvite_with_sdp(p, TRUE, FALSE);
-					}
-				} else if (p->udptl && p->t38.state == T38_ENABLED) {
-					res = ast_udptl_write(p->udptl, frame);
-				}
+			if ((ast->_state == AST_STATE_UP) &&
+			    p->udptl &&
+			    (p->t38.state == T38_ENABLED)) {
+				res = ast_udptl_write(p->udptl, frame);
 			}
 			sip_pvt_unlock(p);
 		}
@@ -6387,9 +6355,27 @@
 	case AST_T38_REQUEST_NEGOTIATE:         /* Request T38 */
 		if (p->t38.state == T38_PEER_REINVITE) {
 			AST_SCHED_DEL_UNREF(sched, p->t38id, dialog_unref(p, "when you delete the t38id sched, you should dec the refcount for the stored dialog ptr"));
+			p->t38.our_parms = *parameters;
+			/* modify our parameters to conform to the peer's parameters,
+			 * based on the rules in the ITU T.38 recommendation
+			 */
+			if (!p->t38.their_parms.fill_bit_removal) {
+				p->t38.our_parms.fill_bit_removal = FALSE;
+			}
+			if (!p->t38.their_parms.transcoding_mmr) {
+				p->t38.our_parms.transcoding_mmr = FALSE;
+			}
+			if (!p->t38.their_parms.transcoding_jbig) {
+				p->t38.our_parms.transcoding_jbig = FALSE;
+			}
+			p->t38.our_parms.version = MIN(p->t38.our_parms.version, p->t38.their_parms.version);
+			p->t38.our_parms.rate_management = p->t38.their_parms.rate_management;
+			ast_udptl_set_local_max_ifp(p->udptl, p->t38.our_parms.max_ifp);
 			change_t38_state(p, T38_ENABLED);
 			transmit_response_with_t38_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL);
 		} else if (ast_test_flag(&p->flags[1], SIP_PAGE2_T38SUPPORT) && p->t38.state != T38_ENABLED) {
+			p->t38.our_parms = *parameters;
+			ast_udptl_set_local_max_ifp(p->udptl, p->t38.our_parms.max_ifp);
 			change_t38_state(p, T38_LOCAL_REINVITE);
 			if (!p->pendinginvite) {
 				transmit_reinvite_with_sdp(p, TRUE, FALSE);
@@ -6499,7 +6485,7 @@
 		break;
 	case AST_CONTROL_T38_PARAMETERS:
 		if (datalen != sizeof(struct ast_control_t38_parameters)) {
-			ast_log(LOG_ERROR, "Invalid datalen for AST_CONTROL_T38_PARAMETERS. Expected %d, got %d\n", (int)sizeof(struct ast_control_t38_parameters), (int)datalen);
+			ast_log(LOG_ERROR, "Invalid datalen for AST_CONTROL_T38_PARAMETERS. Expected %d, got %d\n", (int) sizeof(struct ast_control_t38_parameters), (int) datalen);
 		} else {
 			const struct ast_control_t38_parameters *parameters = data;
 			interpret_t38_parameters(p, parameters);
@@ -7900,7 +7886,6 @@
 	int vportno = -1;		/*!< RTP Video port number */
 	int tportno = -1;		/*!< RTP Text port number */
 	int udptlportno = -1;
-	int peert38capability = 0;
 	char s[256];
 	int old = 0;
 
@@ -8428,6 +8413,7 @@
 		int found = 0, x;
 		
 		old = 0;
+		memset(&p->t38.their_parms, 0, sizeof(p->t38.their_parms));
 		
 		/* Scan trough the a= lines for T38 attributes and set apropriate fileds */
 		iterator = req->sdp_start;
@@ -8440,99 +8426,92 @@
 				ast_debug(3, "T38MaxBitRate: %d\n", x);
 				switch (x) {
 				case 14400:
-					peert38capability |= T38FAX_RATE_14400 | T38FAX_RATE_12000 | T38FAX_RATE_9600 | T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400;
+					p->t38.their_parms.rate = AST_T38_RATE_14400;
 					break;
 				case 12000:
-					peert38capability |= T38FAX_RATE_12000 | T38FAX_RATE_9600 | T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400;
+					p->t38.their_parms.rate = AST_T38_RATE_12000;
 					break;
 				case 9600:
-					peert38capability |= T38FAX_RATE_9600 | T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400;
+					p->t38.their_parms.rate = AST_T38_RATE_9600;
 					break;
 				case 7200:
-					peert38capability |= T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400;
+					p->t38.their_parms.rate = AST_T38_RATE_7200;
 					break;
 				case 4800:
-					peert38capability |= T38FAX_RATE_4800 | T38FAX_RATE_2400;
+					p->t38.their_parms.rate = AST_T38_RATE_4800;
 					break;
 				case 2400:
-					peert38capability |= T38FAX_RATE_2400;
+					p->t38.their_parms.rate = AST_T38_RATE_2400;
 					break;
 				}
 			} else if ((sscanf(a, "T38FaxVersion:%d", &x) == 1)) {
 				found = 1;
 				ast_debug(3, "FaxVersion: %d\n", x);
-				if (x == 0)
-					peert38capability |= T38FAX_VERSION_0;
-				else if (x == 1)
-					peert38capability |= T38FAX_VERSION_1;
+				p->t38.their_parms.version = x;
 			} else if ((sscanf(a, "T38FaxMaxDatagram:%d", &x) == 1) || (sscanf(a, "T38MaxDatagram:%d", &x) == 1)) {
 				found = 1;
 				ast_debug(3, "FaxMaxDatagram: %d\n", x);
 				ast_udptl_set_far_max_datagram(p->udptl, x);
 			} else if ((strncmp(a, "T38FaxFillBitRemoval", 20) == 0)) {
 				found = 1;
-				if(sscanf(a, "T38FaxFillBitRemoval:%d", &x) == 1) {
-				    ast_debug(3, "FillBitRemoval: %d\n", x);
-				    if(x == 1)
-					peert38capability |= T38FAX_FILL_BIT_REMOVAL;
+				if (sscanf(a, "T38FaxFillBitRemoval:%d", &x) == 1) {
+					ast_debug(3, "FillBitRemoval: %d\n", x);
+					if (x == 1) {
+						p->t38.their_parms.fill_bit_removal = TRUE;
+					}
 				} else {
-				    ast_debug(3, "FillBitRemoval\n");
-				    peert38capability |= T38FAX_FILL_BIT_REMOVAL;
+					ast_debug(3, "FillBitRemoval\n");
+					p->t38.their_parms.fill_bit_removal = TRUE;
 				}
 			} else if ((strncmp(a, "T38FaxTranscodingMMR", 20) == 0)) {
 				found = 1;
-				if(sscanf(a, "T38FaxTranscodingMMR:%d", &x) == 1) {
-				    ast_debug(3, "Transcoding MMR: %d\n", x);
-				    if(x == 1)
-					peert38capability |= T38FAX_TRANSCODING_MMR;
+				if (sscanf(a, "T38FaxTranscodingMMR:%d", &x) == 1) {
+					ast_debug(3, "Transcoding MMR: %d\n", x);
+					if (x == 1) {
+						p->t38.their_parms.transcoding_mmr = TRUE;
+					}
 				} else {
-				    ast_debug(3, "Transcoding MMR\n");
-				    peert38capability |= T38FAX_TRANSCODING_MMR;
+					ast_debug(3, "Transcoding MMR\n");
+					p->t38.their_parms.transcoding_mmr = TRUE;
 				}
 			} else if ((strncmp(a, "T38FaxTranscodingJBIG", 21) == 0)) {
 				found = 1;
-				if(sscanf(a, "T38FaxTranscodingJBIG:%d", &x) == 1) {
-				    ast_debug(3, "Transcoding JBIG: %d\n", x);
-				    if(x == 1)
-					peert38capability |= T38FAX_TRANSCODING_JBIG;
+				if (sscanf(a, "T38FaxTranscodingJBIG:%d", &x) == 1) {
+					ast_debug(3, "Transcoding JBIG: %d\n", x);
+					if (x == 1) {
+						p->t38.their_parms.transcoding_jbig = TRUE;
+					}
 				} else {
-				    ast_debug(3, "Transcoding JBIG\n");
-				    peert38capability |= T38FAX_TRANSCODING_JBIG;
+					ast_debug(3, "Transcoding JBIG\n");
+					p->t38.their_parms.transcoding_jbig = TRUE;
 				}
 			} else if ((sscanf(a, "T38FaxRateManagement:%255s", s) == 1)) {
 				found = 1;
 				ast_debug(3, "RateManagement: %s\n", s);
 				if (!strcasecmp(s, "localTCF"))
-					peert38capability |= T38FAX_RATE_MANAGEMENT_LOCAL_TCF;
+					p->t38.their_parms.rate_management = AST_T38_RATE_MANAGEMENT_LOCAL_TCF;
 				else if (!strcasecmp(s, "transferredTCF"))
-					peert38capability |= T38FAX_RATE_MANAGEMENT_TRANSFERRED_TCF;
+					p->t38.their_parms.rate_management = AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF;
 			} else if ((sscanf(a, "T38FaxUdpEC:%255s", s) == 1)) {
 				found = 1;
 				ast_debug(3, "UDP EC: %s\n", s);
 				if (!strcasecmp(s, "t38UDPRedundancy")) {
-					peert38capability |= T38FAX_UDP_EC_REDUNDANCY;
 					ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_REDUNDANCY);
 				} else if (!strcasecmp(s, "t38UDPFEC")) {
-					peert38capability |= T38FAX_UDP_EC_FEC;
 					ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_FEC);
 				} else {
-					peert38capability |= T38FAX_UDP_EC_NONE;
 					ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_NONE);
 				}
 			}
 		}
-		if (found) { /* Some cisco equipment returns nothing beside c= and m= lines in 200 OK T38 SDP */
-			/* KPF: fill in default parameters */
-		}
 
 		/* Remote party offers T38, we need to update state */
-		if (t38action == SDP_T38_ACCEPT) {
-			if (p->t38.state == T38_LOCAL_REINVITE)
-				change_t38_state(p, T38_ENABLED);
-		} else if (t38action == SDP_T38_INITIATE) {
-			if (p->owner && p->lastinvite) {
-				change_t38_state(p, T38_PEER_REINVITE); /* T38 Offered in re-invite from remote party */
-			}
+		if ((t38action == SDP_T38_ACCEPT) &&
+		    (p->t38.state == T38_LOCAL_REINVITE)) {
+			change_t38_state(p, T38_ENABLED);
+		} else if ((t38action == SDP_T38_INITIATE) &&
+			   p->owner && p->lastinvite) {
+			change_t38_state(p, T38_PEER_REINVITE); /* T38 Offered in re-invite from remote party */
 		}
 	} else {
 		change_t38_state(p, T38_DISABLED);




More information about the asterisk-commits mailing list