[asterisk-commits] file: branch file/t38improvements r200944 - in /team/file/t38improvements: ch...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 16 10:59:13 CDT 2009


Author: file
Date: Tue Jun 16 10:59:09 2009
New Revision: 200944

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=200944
Log:
Add progress thus far. This introduces a new control frame type (AST_CONTROL_T38_PARAMETERS) which has a T38 parameters structure as the data. This structure contains error cancellation and maximum rate (for now). This is the basis of allowing the channel or application on the other side to have a say in what is negotiated and know what is negotiated.

Modified:
    team/file/t38improvements/channels/chan_sip.c
    team/file/t38improvements/include/asterisk/frame.h
    team/file/t38improvements/main/channel.c
    team/file/t38improvements/main/frame.c
    team/file/t38improvements/main/rtp_engine.c

Modified: team/file/t38improvements/channels/chan_sip.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/file/t38improvements/channels/chan_sip.c?view=diff&rev=200944&r1=200943&r2=200944
==============================================================================
--- team/file/t38improvements/channels/chan_sip.c (original)
+++ team/file/t38improvements/channels/chan_sip.c Tue Jun 16 10:59:09 2009
@@ -4812,12 +4812,39 @@
 	}
 }
 
+/*! \brief Helper function which interprets T.38 capabilities and fills a parameters structure in */
+static void fill_t38_parameters(int capabilities, struct ast_control_t38_parameters *parameters)
+{
+	if (capabilities & T38FAX_RATE_14400) {
+		parameters->rate = AST_T38_RATE_14400;
+	} else if (capabilities & T38FAX_RATE_12000) {
+		parameters->rate = AST_T38_RATE_12000;
+	} else if (capabilities & T38FAX_RATE_9600) {
+		parameters->rate = AST_T38_RATE_9600;
+	} else if (capabilities & T38FAX_RATE_7200) {
+		parameters->rate = AST_T38_RATE_7200;
+	} else if (capabilities & T38FAX_RATE_4800) {
+		parameters->rate = AST_T38_RATE_4800;
+	} else if (capabilities & T38FAX_RATE_2400) {
+		parameters->rate = AST_T38_RATE_2400;
+	}
+
+	if (capabilities & T38FAX_UDP_EC_REDUNDANCY) {
+		parameters->ec = AST_T38_EC_REDUNDANCY;
+	} else if (capabilities & T38FAX_UDP_EC_FEC) {
+		parameters->ec = AST_T38_EC_FEC;
+	} else if (capabilities & T38FAX_UDP_EC_NONE) {
+		parameters->ec = AST_T38_EC_NONE;
+	}
+}
+
 /*! \brief Change the T38 state on a SIP dialog */
 static void change_t38_state(struct sip_pvt *p, int state)
 {
 	int old = p->t38.state;
 	struct ast_channel *chan = p->owner;
 	enum ast_control_t38 message = 0;
+	struct ast_control_t38_parameters parameters = { 0, };
 
 	/* Don't bother changing if we are already in the state wanted */
 	if (old == state)
@@ -4835,18 +4862,22 @@
 		return;
 
 	/* Given the state requested and old state determine what control frame we want to queue up */
-	if (state == T38_PEER_REINVITE)
-		message = AST_T38_REQUEST_NEGOTIATE;
-	else if (state == T38_ENABLED)
-		message = AST_T38_NEGOTIATED;
-	else if (state == T38_DISABLED && old == T38_ENABLED)
-		message = AST_T38_TERMINATED;
+	if (state == T38_PEER_REINVITE) {
+		message = parameters.request_response = AST_T38_REQUEST_NEGOTIATE;
+		fill_t38_parameters(p->t38.peercapability, &parameters);
+	} else if (state == T38_ENABLED) {
+		message = parameters.request_response = AST_T38_NEGOTIATED;
+		fill_t38_parameters(p->t38.jointcapability, &parameters);
+	} else if (state == T38_DISABLED && old == T38_ENABLED)
+		message = parameters.request_response = AST_T38_TERMINATED;
 	else if (state == T38_DISABLED && old == T38_LOCAL_REINVITE)
-		message = AST_T38_REFUSED;
+		message = parameters.request_response = AST_T38_REFUSED;
 
 	/* Woot we got a message, create a control frame and send it on! */
 	if (message)
 		ast_queue_control_data(chan, AST_CONTROL_T38, &message, sizeof(message));
+	if (parameters.request_response)
+		ast_queue_control_data(chan, AST_CONTROL_T38_PARAMETERS, &parameters, sizeof(parameters));
 
 	if (ast_test_flag(&p->flags[1], SIP_PAGE2_FAX_DETECT) && !p->outgoing_call) {
 		/* fax detection is enabled and this is an incoming call */

Modified: team/file/t38improvements/include/asterisk/frame.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/file/t38improvements/include/asterisk/frame.h?view=diff&rev=200944&r1=200943&r2=200944
==============================================================================
--- team/file/t38improvements/include/asterisk/frame.h (original)
+++ team/file/t38improvements/include/asterisk/frame.h Tue Jun 16 10:59:09 2009
@@ -323,7 +323,8 @@
 	AST_CONTROL_SRCUPDATE = 20,     /*!< Indicate source of media has changed */
 	AST_CONTROL_TRANSFER = 21,      /*!< Indicate status of a transfer request */
 	AST_CONTROL_CONNECTED_LINE = 22,/*!< Indicate connected line has changed */
-	AST_CONTROL_REDIRECTING = 23    /*!< Indicate redirecting id has changed */
+	AST_CONTROL_REDIRECTING = 23,    /*!< Indicate redirecting id has changed */
+	AST_CONTROL_T38_PARAMETERS = 24, /*! T38 state change request/notification with parameters */
 };
 
 enum ast_control_t38 {
@@ -332,6 +333,27 @@
 	AST_T38_NEGOTIATED,		/*!< T38 negotiated (fax mode) */
 	AST_T38_TERMINATED,		/*!< T38 terminated (back to voice) */
 	AST_T38_REFUSED			/*!< T38 refused for some reason (usually rejected by remote end) */
+};
+
+enum ast_control_t38_ec {
+	AST_T38_EC_NONE = 0,
+	AST_T38_EC_FEC,
+	AST_T38_EC_REDUNDANCY,
+};
+
+enum ast_control_t38_rate {
+	AST_T38_RATE_2400 = 0,
+	AST_T38_RATE_4800,
+	AST_T38_RATE_7200,
+	AST_T38_RATE_9600,
+	AST_T38_RATE_12000,
+	AST_T38_RATE_14400,
+};
+
+struct ast_control_t38_parameters {
+	enum ast_control_t38 request_response; /*!< Request or response of the T38 control frame */
+	enum ast_control_t38_ec ec;            /*!< Error correction parameter */
+	enum ast_control_t38_rate rate;        /*!< Maximum fax rate supported */
 };
 
 enum ast_control_transfer {

Modified: team/file/t38improvements/main/channel.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/file/t38improvements/main/channel.c?view=diff&rev=200944&r1=200943&r2=200944
==============================================================================
--- team/file/t38improvements/main/channel.c (original)
+++ team/file/t38improvements/main/channel.c Tue Jun 16 10:59:09 2009
@@ -3334,6 +3334,7 @@
 	case AST_CONTROL_CONNECTED_LINE:
 	case AST_CONTROL_REDIRECTING:
 	case AST_CONTROL_TRANSFER:
+	case AST_CONTROL_T38_PARAMETERS:
 		break;
 
 	case AST_CONTROL_CONGESTION:
@@ -3464,6 +3465,7 @@
 	case AST_CONTROL_TRANSFER:
 	case AST_CONTROL_CONNECTED_LINE:
 	case AST_CONTROL_REDIRECTING:
+	case AST_CONTROL_T38_PARAMETERS:
 		/* Nothing left to do for these. */
 		res = 0;
 		break;

Modified: team/file/t38improvements/main/frame.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/file/t38improvements/main/frame.c?view=diff&rev=200944&r1=200943&r2=200944
==============================================================================
--- team/file/t38improvements/main/frame.c (original)
+++ team/file/t38improvements/main/frame.c Tue Jun 16 10:59:09 2009
@@ -840,6 +840,25 @@
 			}
 			snprintf(subclass, sizeof(subclass), "T38/%s", message);
 			break;
+		case AST_CONTROL_T38_PARAMETERS:
+			if (f->datalen != sizeof(struct ast_control_t38_parameters *)) {
+				message = "Invalid";
+			} else {
+				struct ast_control_t38_parameters *parameters = f->data.ptr;
+				enum ast_control_t38 state = parameters->request_response;
+				if (state == AST_T38_REQUEST_NEGOTIATE)
+					message = "Negotiation Requested";
+				else if (state == AST_T38_REQUEST_TERMINATE)
+					message = "Negotiation Request Terminated";
+				else if (state == AST_T38_NEGOTIATED)
+					message = "Negotiated";
+				else if (state == AST_T38_TERMINATED)
+					message = "Terminated";
+				else if (state == AST_T38_REFUSED)
+					message = "Refused";
+			}
+			snprintf(subclass, sizeof(subclass), "T38_Parameters/%s", message);
+			break;
 		case -1:
 			strcpy(subclass, "Stop generators");
 			break;

Modified: team/file/t38improvements/main/rtp_engine.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/file/t38improvements/main/rtp_engine.c?view=diff&rev=200944&r1=200943&r2=200944
==============================================================================
--- team/file/t38improvements/main/rtp_engine.c (original)
+++ team/file/t38improvements/main/rtp_engine.c Tue Jun 16 10:59:09 2009
@@ -837,7 +837,8 @@
 			    (fr->subclass == AST_CONTROL_UNHOLD) ||
 			    (fr->subclass == AST_CONTROL_VIDUPDATE) ||
 			    (fr->subclass == AST_CONTROL_T38) ||
-			    (fr->subclass == AST_CONTROL_SRCUPDATE)) {
+			    (fr->subclass == AST_CONTROL_SRCUPDATE) ||
+			    (fr->subclass == AST_CONTROL_T38_PARAMETERS)) {
 				/* If we are going on hold, then break callback mode and P2P bridging */
 				if (fr->subclass == AST_CONTROL_HOLD) {
 					if (instance0->engine->local_bridge) {
@@ -1056,7 +1057,8 @@
 			    (fr->subclass == AST_CONTROL_UNHOLD) ||
 			    (fr->subclass == AST_CONTROL_VIDUPDATE) ||
 			    (fr->subclass == AST_CONTROL_T38) ||
-			    (fr->subclass == AST_CONTROL_SRCUPDATE)) {
+			    (fr->subclass == AST_CONTROL_SRCUPDATE) ||
+			    (fr->subclass == AST_CONTROL_T38_PARAMETERS)) {
 				if (fr->subclass == AST_CONTROL_HOLD) {
 					/* If we someone went on hold we want the other side to reinvite back to us */
 					if (who == c0) {




More information about the asterisk-commits mailing list