Author: kmoore Date: Fri Jan 9 08:53:09 2015 New Revision: 430417 URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=430417 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/ ........ Merged revisions 430415 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 430416 from http://svn.asterisk.org/svn/asterisk/branches/13 Modified: trunk/ (props changed) trunk/CHANGES trunk/configs/samples/res_fax.conf.sample trunk/include/asterisk/res_fax.h trunk/res/res_fax.c Propchange: trunk/ ------------------------------------------------------------------------------ Binary property 'branch-13-merged' - no diff available. Modified: trunk/CHANGES URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=430417&r1=430416&r2=430417 ============================================================================== --- trunk/CHANGES (original) +++ trunk/CHANGES Fri Jan 9 08:53:09 2015 @@ -117,6 +117,13 @@ scenarios like 'phone' or 'agent' or 'trunk'. Additional information can be found in the sample configuration file at config/samples/pjsip_wizard.conf.sample. + +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. ARI ------------------ Modified: trunk/configs/samples/res_fax.conf.sample URL: http://svnview.digium.com/svn/asterisk/trunk/configs/samples/res_fax.conf.sample?view=diff&rev=430417&r1=430416&r2=430417 ============================================================================== --- trunk/configs/samples/res_fax.conf.sample (original) +++ trunk/configs/samples/res_fax.conf.sample Fri Jan 9 08:53:09 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: trunk/include/asterisk/res_fax.h URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/res_fax.h?view=diff&rev=430417&r1=430416&r2=430417 ============================================================================== --- trunk/include/asterisk/res_fax.h (original) +++ trunk/include/asterisk/res_fax.h Fri Jan 9 08:53:09 2015 @@ -175,6 +175,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: trunk/res/res_fax.c URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_fax.c?view=diff&rev=430417&r1=430416&r2=430417 ============================================================================== --- trunk/res/res_fax.c (original) +++ trunk/res/res_fax.c Fri Jan 9 08:53:09 2015 @@ -224,6 +224,9 @@ </enum> <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> @@ -521,6 +524,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; @@ -528,6 +532,7 @@ uint32_t ecm:1; unsigned int minrate; unsigned int maxrate; + unsigned int t38timeout; }; static struct fax_options general_options; @@ -538,6 +543,7 @@ .statusevents = RES_FAX_STATUSEVENTS, .modems = RES_FAX_MODEM, .ecm = AST_FAX_OPTFLAG_TRUE, + .t38timeout = RES_FAX_T38TIMEOUT, }; AST_RWLOCK_DEFINE_STATIC(options_lock); @@ -713,6 +719,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; @@ -1716,7 +1723,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; @@ -1904,8 +1914,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); @@ -3923,6 +3933,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) { @@ -4232,6 +4243,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 */ @@ -4303,6 +4331,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; + } } } @@ -4395,6 +4428,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; @@ -4521,6 +4556,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 { -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- svn-commits mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/svn-commits
