[svn-commits] kmoore: branch 11 r430415 - in /branches/11: ./ configs/ include/asterisk/ res/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jan 9 08:40:21 CST 2015


Author: kmoore
Date: Fri Jan  9 08:40:11 2015
New Revision: 430415

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=430415
Log:
res_fax: Add T.38 negotiation timeout option

This change makes the T.38 negotiation timeout configurable via
't38timeout' in res_fax.conf or FAXOPT(t38timeout). It was previously
hard coded to be 5000 milliseconds.

This change also handles T.38 switch failures by aborting the fax since
in the case where this can happen, both sides have agreed to switch to
T.38 and Asterisk is unable to do so.

Review: https://reviewboard.asterisk.org/r/4320/

Modified:
    branches/11/CHANGES
    branches/11/configs/res_fax.conf.sample
    branches/11/include/asterisk/res_fax.h
    branches/11/res/res_fax.c

Modified: branches/11/CHANGES
URL: http://svnview.digium.com/svn/asterisk/branches/11/CHANGES?view=diff&rev=430415&r1=430414&r2=430415
==============================================================================
--- branches/11/CHANGES (original)
+++ branches/11/CHANGES Fri Jan  9 08:40:11 2015
@@ -7,6 +7,17 @@
 === and the other UPGRADE files for older releases.
 ===
 ==============================================================================
+
+------------------------------------------------------------------------------
+--- Functionality changes since Asterisk 11.15 --------------------------------
+------------------------------------------------------------------------------
+
+res_fax
+-----------
+ * The T.38 negotiation timeout was previously hard coded at 5000 milliseconds
+   and is now configurable via the 't38timeout' configuration option in
+   res_fax.conf and via the fax options dialplan function 'FAXOPT(t38timeout)'.
+   The default remains at 5000 milliseconds.
 
 ------------------------------------------------------------------------------
 --- Functionality changes since Asterisk 11.8 --------------------------------

Modified: branches/11/configs/res_fax.conf.sample
URL: http://svnview.digium.com/svn/asterisk/branches/11/configs/res_fax.conf.sample?view=diff&rev=430415&r1=430414&r2=430415
==============================================================================
--- branches/11/configs/res_fax.conf.sample (original)
+++ branches/11/configs/res_fax.conf.sample Fri Jan  9 08:40:11 2015
@@ -26,3 +26,7 @@
 ; Enable/disable T.30 ECM (error correction mode) by default.
 ; Default: Enabled
 ;ecm=yes
+
+; T.38 Negotiation Timeout in milliseconds
+; Default: 5000
+t38timeout=5000

Modified: branches/11/include/asterisk/res_fax.h
URL: http://svnview.digium.com/svn/asterisk/branches/11/include/asterisk/res_fax.h?view=diff&rev=430415&r1=430414&r2=430415
==============================================================================
--- branches/11/include/asterisk/res_fax.h (original)
+++ branches/11/include/asterisk/res_fax.h Fri Jan  9 08:40:11 2015
@@ -174,6 +174,8 @@
 	struct ast_fax_t38_parameters our_t38_parameters;
 	/*! the other endpoint's T.38 session parameters, if any */
 	struct ast_fax_t38_parameters their_t38_parameters;
+	/*! T.38 negotiation in ms */
+	unsigned int t38timeout;
 	/*! the id of the t.38 gateway framehook for this channel */
 	int gateway_id;
 	/*! the timeout for this gateway in seconds */

Modified: branches/11/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/res/res_fax.c?view=diff&rev=430415&r1=430414&r2=430415
==============================================================================
--- branches/11/res/res_fax.c (original)
+++ branches/11/res/res_fax.c Fri Jan  9 08:40:11 2015
@@ -213,6 +213,9 @@
 					<enum name="statusstr">
 						<para>R/O Verbose Result Status of the FAX transmission.</para>
 					</enum>
+					<enum name="t38timeout">
+						<para>R/W The timeout used for T.38 negotiation.</para>
+					</enum>
 				</enumlist>
 			</parameter>
 		</syntax>
@@ -327,6 +330,7 @@
 #define RES_FAX_MAXRATE 14400
 #define RES_FAX_STATUSEVENTS 0
 #define RES_FAX_MODEM (AST_FAX_MODEM_V17 | AST_FAX_MODEM_V27 | AST_FAX_MODEM_V29)
+#define RES_FAX_T38TIMEOUT 5000
 
 struct fax_options {
 	enum ast_fax_modems modems;
@@ -334,6 +338,7 @@
 	uint32_t ecm:1;
 	unsigned int minrate;
 	unsigned int maxrate;
+	unsigned int t38timeout;
 };
 
 static struct fax_options general_options;
@@ -344,6 +349,7 @@
 	.statusevents = RES_FAX_STATUSEVENTS,
 	.modems = RES_FAX_MODEM,
 	.ecm = AST_FAX_OPTFLAG_TRUE,
+	.t38timeout = RES_FAX_T38TIMEOUT,
 };
 
 AST_RWLOCK_DEFINE_STATIC(options_lock);
@@ -489,6 +495,7 @@
 	d->modems = options.modems;
 	d->minrate = options.minrate;
 	d->maxrate = options.maxrate;
+	d->t38timeout = options.t38timeout;
 	d->gateway_id = -1;
 	d->faxdetect_id = -1;
 	d->gateway_timeout = 0;
@@ -1469,7 +1476,10 @@
 					break;
 				}
 				if (t38negotiated && !was_t38) {
-					fax->tech->switch_to_t38(fax);
+					if (fax->tech->switch_to_t38(fax)) {
+						GENERIC_FAX_EXEC_ERROR(fax, chan, "UNKNOWN", "T.38 switch failed");
+						break;
+					}
 					details->caps &= ~AST_FAX_TECH_AUDIO;
 					expected_frametype = AST_FRAME_MODEM;
 					expected_framesubclass.integer = AST_MODEM_T38;
@@ -1655,8 +1665,8 @@
 	/* request T.38 */
 	ast_debug(1, "Negotiating T.38 for receive on %s\n", ast_channel_name(chan));
 
-	/* wait up to five seconds for negotiation to complete */
-	timeout_ms = 5000;
+	/* wait for negotiation to complete */
+	timeout_ms = details->t38timeout;
 
 	/* set parameters based on the session's parameters */
 	t38_parameters_fax_to_ast(&t38_parameters, &details->our_t38_parameters);
@@ -3631,6 +3641,7 @@
 	ast_cli(a->fd, "\tMaximum Bit Rate: %u\n", options.maxrate);
 	ast_fax_modem_to_str(options.modems, modems, sizeof(modems));
 	ast_cli(a->fd, "\tModem Modulations Allowed: %s\n", modems);
+	ast_cli(a->fd, "\tT.38 Negotiation Timeout: %u\n", options.t38timeout);
 	ast_cli(a->fd, "\n\nFAX Technology Modules:\n\n");
 	AST_RWLIST_RDLOCK(&faxmodules);
 	AST_RWLIST_TRAVERSE(&faxmodules, fax, list) {
@@ -3808,6 +3819,23 @@
 	ast_rwlock_rdlock(&options_lock);
 	*options = general_options;
 	ast_rwlock_unlock(&options_lock);
+}
+
+static int set_t38timeout(const char *value, unsigned int *t38timeout)
+{
+	unsigned int timeout;
+
+	if (sscanf(value, "%u", &timeout) != 1) {
+		ast_log(LOG_ERROR, "Unable to get timeout from '%s'\n", value);
+		return -1;
+	} else if (timeout) {
+		*t38timeout = timeout;
+	} else {
+		ast_log(LOG_ERROR, "T.38 negotiation timeout must be non-zero\n");
+		return -1;
+	}
+
+	return 0;
 }
 
 /*! \brief configure res_fax */
@@ -3879,6 +3907,11 @@
 		} else if ((!strcasecmp(v->name, "modem")) || (!strcasecmp(v->name, "modems"))) {
 			options.modems = 0;
 			update_modem_bits(&options.modems, v->value);
+		} else if (!strcasecmp(v->name, "t38timeout")) {
+			if (set_t38timeout(v->value, &options.t38timeout)) {
+				res = -1;
+				goto end;
+			}
 		}
 	}
 
@@ -3978,6 +4011,8 @@
 		ast_copy_string(buf, details->resultstr, len);
 	} else if ((!strcasecmp(data, "modem")) || (!strcasecmp(data, "modems"))) {
 		ast_fax_modem_to_str(details->modems, buf, len);
+	} else if (!strcasecmp(data, "t38timeout")) {
+		snprintf(buf, len, "%u", details->t38timeout);
 	} else {
 		ast_log(LOG_WARNING, "channel '%s' can't read FAXOPT(%s) because it is unhandled!\n", ast_channel_name(chan), data);
 		res = -1;
@@ -4104,6 +4139,10 @@
 		if (!details->minrate) {
 			details->minrate = ast_fax_minrate();
 		}
+	} else if (!strcasecmp(data, "t38timeout")) {
+		if (set_t38timeout(value, &details->t38timeout)) {
+			res = -1;
+		}
 	} else if ((!strcasecmp(data, "modem")) || (!strcasecmp(data, "modems"))) {
 		update_modem_bits(&details->modems, value);
 	} else {




More information about the svn-commits mailing list