diff options
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | channels/chan_dahdi.c | 15 | ||||
-rw-r--r-- | channels/chan_dahdi.h | 5 | ||||
-rw-r--r-- | configs/samples/chan_dahdi.conf.sample | 9 | ||||
-rw-r--r-- | include/asterisk/res_fax.h | 4 | ||||
-rw-r--r-- | res/res_fax.c | 38 |
6 files changed, 61 insertions, 16 deletions
@@ -12,6 +12,12 @@ --- Functionality changes from Asterisk 13.10.0 to Asterisk 13.11.0 ---------- ------------------------------------------------------------------------------ +chan_dahdi +------------------ + * Added "faxdetect_timeout" option. + The option determines how many seconds into a call before faxdetect + is disabled for the call. Setting the value to zero disables the timeout. + res_pjsip ------------------ * Added "fax_detect_timeout" to endpoint. diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index e9d0b5bd3..ae6a8a44c 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -2348,7 +2348,6 @@ static void my_pri_ss7_open_media(void *p) if (pvt->dsp_features && pvt->dsp) { ast_dsp_set_features(pvt->dsp, pvt->dsp_features); - pvt->dsp_features = 0; } } #endif /* defined(HAVE_PRI) || defined(HAVE_SS7) */ @@ -8643,6 +8642,15 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast) /* Perform busy detection etc on the dahdi line */ int mute; + if ((p->dsp_features & DSP_FEATURE_FAX_DETECT) + && p->faxdetect_timeout + && p->faxdetect_timeout <= ast_channel_get_up_time(ast)) { + p->dsp_features &= ~DSP_FEATURE_FAX_DETECT; + ast_dsp_set_features(p->dsp, p->dsp_features); + ast_debug(1, "Channel driver fax CNG detection timeout on %s\n", + ast_channel_name(ast)); + } + f = ast_dsp_process(ast, p->dsp, &p->subs[idx].f); /* Check if DSP code thinks we should be muting this frame and mute the conference if so */ @@ -12542,6 +12550,7 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf, tmp->callprogress = conf->chan.callprogress; tmp->waitfordialtone = conf->chan.waitfordialtone; tmp->dialtone_detect = conf->chan.dialtone_detect; + tmp->faxdetect_timeout = conf->chan.faxdetect_timeout; tmp->cancallforward = conf->chan.cancallforward; tmp->dtmfrelax = conf->chan.dtmfrelax; tmp->callwaiting = tmp->permcallwaiting; @@ -17793,6 +17802,10 @@ static int process_dahdi(struct dahdi_chan_conf *confp, const char *cat, struct confp->chan.callprogress |= CALLPROGRESS_FAX_OUTGOING; } else if (!strcasecmp(v->value, "both") || ast_true(v->value)) confp->chan.callprogress |= CALLPROGRESS_FAX_INCOMING | CALLPROGRESS_FAX_OUTGOING; + } else if (!strcasecmp(v->name, "faxdetect_timeout")) { + if (sscanf(v->value, "%30u", &confp->chan.faxdetect_timeout) != 1) { + confp->chan.faxdetect_timeout = 0; + } } else if (!strcasecmp(v->name, "echocancel")) { process_echocancel(confp, v->value, v->lineno); } else if (!strcasecmp(v->name, "echotraining")) { diff --git a/channels/chan_dahdi.h b/channels/chan_dahdi.h index 4bb5d19a2..ab5c1eba9 100644 --- a/channels/chan_dahdi.h +++ b/channels/chan_dahdi.h @@ -612,6 +612,11 @@ struct dahdi_pvt { */ int dialtone_detect; int dialtone_scanning_time_elapsed; /*!< Amount of audio scanned for dialtone, in frames */ + /*! + * \brief The number of seconds into call to disable fax detection. (0 = disabled) + * \note Set from the "faxdetect_timeout" value read in from chan_dahdi.conf + */ + unsigned int faxdetect_timeout; struct timeval waitingfordt; /*!< Time we started waiting for dialtone */ struct timeval flashtime; /*!< Last flash-hook time */ /*! \brief Opaque DSP configuration structure. */ diff --git a/configs/samples/chan_dahdi.conf.sample b/configs/samples/chan_dahdi.conf.sample index a5daede30..6dd365f47 100644 --- a/configs/samples/chan_dahdi.conf.sample +++ b/configs/samples/chan_dahdi.conf.sample @@ -1119,6 +1119,15 @@ pickupgroup=1 ;faxdetect=outgoing ;faxdetect=no ; +; When 'faxdetect' is enabled, one could use 'faxdetect_timeout' to disable fax +; detection after the specified number of seconds into a call. Be aware that +; outgoing analog channels may consider the channel is answered immediately +; when dialing completes. Analog does not have a reliable method of detecting +; when the far end answers. Zero disables the timeout. +; Default is 0 to disable the timeout. +; +;faxdetect_timeout=30 +; ; When 'faxdetect' is used, one could use 'faxbuffers' to configure the DAHDI ; transmit buffer policy. The default is *OFF*. When this configuration ; option is used, the faxbuffer policy will be used for the life of the call diff --git a/include/asterisk/res_fax.h b/include/asterisk/res_fax.h index 2304da734..5119bfa6c 100644 --- a/include/asterisk/res_fax.h +++ b/include/asterisk/res_fax.h @@ -179,11 +179,11 @@ struct ast_fax_session_details { unsigned int t38timeout; /*! the id of the t.38 gateway framehook for this channel */ int gateway_id; - /*! the timeout for this gateway in seconds */ + /*! The timeout for this gateway in ms */ int gateway_timeout; /*! the id of the faxdetect framehook for this channel */ int faxdetect_id; - /*! The timeout for this fax detect in seconds */ + /*! The timeout for this fax detect in ms */ int faxdetect_timeout; /*! flags used for fax detection */ int faxdetect_flags; diff --git a/res/res_fax.c b/res/res_fax.c index ad6e2386c..9aec7f550 100644 --- a/res/res_fax.c +++ b/res/res_fax.c @@ -468,8 +468,6 @@ struct fax_gateway { struct fax_detect { /*! \brief the start of our timeout counter */ struct timeval timeout_start; - /*! \brief faxdetect timeout */ - int timeout; /*! \brief DSP Processor */ struct ast_dsp *dsp; /*! \brief original audio formats */ @@ -3539,13 +3537,13 @@ static void destroy_faxdetect(void *data) ast_dsp_free(faxdetect->dsp); faxdetect->dsp = NULL; } - ao2_ref(faxdetect->details, -1); + ao2_cleanup(faxdetect->details); ao2_cleanup(faxdetect->orig_format); } /*! \brief Create a new fax detect object. * \param chan the channel attaching to - * \param timeout remove framehook in this time if set + * \param timeout in ms to remove framehook in this time if not zero * \param flags required options * \return NULL or a fax gateway object */ @@ -3652,8 +3650,9 @@ static struct ast_frame *fax_detect_framehook(struct ast_channel *chan, struct a return f; } - if ((!ast_tvzero(faxdetect->timeout_start) && - (ast_tvdiff_ms(ast_tvnow(), faxdetect->timeout_start) > faxdetect->timeout))) { + if (!ast_tvzero(faxdetect->timeout_start) + && ast_tvdiff_ms(ast_tvnow(), faxdetect->timeout_start) > details->faxdetect_timeout) { + ast_debug(1, "FAXOPT(faxdetect) timeout on %s\n", ast_channel_name(chan)); ast_framehook_detach(chan, details->faxdetect_id); details->faxdetect_id = -1; return f; @@ -3732,7 +3731,7 @@ static struct ast_frame *fax_detect_framehook(struct ast_channel *chan, struct a /*! \brief Attach a faxdetect framehook object to a channel. * \param chan the channel to attach to - * \param timeout remove framehook in this time if set + * \param timeout in ms to remove framehook in this time if not zero * \return the faxdetect structure or NULL on error * \param flags required options * \retval -1 error @@ -4480,8 +4479,14 @@ static int acf_faxopt_write(struct ast_channel *chan, const char *cmd, char *dat details->gateway_timeout = 0; if (timeout) { unsigned int gwtimeout; - if (sscanf(timeout, "%u", &gwtimeout) == 1) { - details->gateway_timeout = gwtimeout * 1000; + + if (sscanf(timeout, "%30u", &gwtimeout) == 1) { + if (gwtimeout >= 0) { + details->gateway_timeout = gwtimeout * 1000; + } else { + ast_log(LOG_WARNING, "%s(%s) timeout cannot be negative. Ignoring timeout\n", + cmd, data); + } } else { ast_log(LOG_WARNING, "Unsupported timeout '%s' passed to FAXOPT(%s).\n", timeout, data); } @@ -4516,11 +4521,18 @@ static int acf_faxopt_write(struct ast_channel *chan, const char *cmd, char *dat if (ast_true(val) || !strcasecmp(val, "t38") || !strcasecmp(val, "cng")) { if (details->faxdetect_id < 0) { - if (timeout && (sscanf(timeout, "%u", &fdtimeout) == 1)) { - if (fdtimeout > 0) { - fdtimeout = fdtimeout * 1000; + if (timeout) { + if (sscanf(timeout, "%30u", &fdtimeout) == 1) { + if (fdtimeout >= 0) { + fdtimeout *= 1000; + } else { + ast_log(LOG_WARNING, "%s(%s) timeout cannot be negative. Ignoring timeout\n", + cmd, data); + fdtimeout = 0; + } } else { - ast_log(LOG_WARNING, "Timeout cannot be negative ignoring timeout\n"); + ast_log(LOG_WARNING, "Unsupported timeout '%s' passed to FAXOPT(%s).\n", + timeout, data); } } |