mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Merge "res_fax: Fix FAXOPT(faxdetect) timeout option."
This commit is contained in:
@@ -179,11 +179,11 @@ struct ast_fax_session_details {
|
|||||||
unsigned int t38timeout;
|
unsigned int t38timeout;
|
||||||
/*! the id of the t.38 gateway framehook for this channel */
|
/*! the id of the t.38 gateway framehook for this channel */
|
||||||
int gateway_id;
|
int gateway_id;
|
||||||
/*! the timeout for this gateway in seconds */
|
/*! The timeout for this gateway in ms */
|
||||||
int gateway_timeout;
|
int gateway_timeout;
|
||||||
/*! the id of the faxdetect framehook for this channel */
|
/*! the id of the faxdetect framehook for this channel */
|
||||||
int faxdetect_id;
|
int faxdetect_id;
|
||||||
/*! The timeout for this fax detect in seconds */
|
/*! The timeout for this fax detect in ms */
|
||||||
int faxdetect_timeout;
|
int faxdetect_timeout;
|
||||||
/*! flags used for fax detection */
|
/*! flags used for fax detection */
|
||||||
int faxdetect_flags;
|
int faxdetect_flags;
|
||||||
|
@@ -468,8 +468,6 @@ struct fax_gateway {
|
|||||||
struct fax_detect {
|
struct fax_detect {
|
||||||
/*! \brief the start of our timeout counter */
|
/*! \brief the start of our timeout counter */
|
||||||
struct timeval timeout_start;
|
struct timeval timeout_start;
|
||||||
/*! \brief faxdetect timeout */
|
|
||||||
int timeout;
|
|
||||||
/*! \brief DSP Processor */
|
/*! \brief DSP Processor */
|
||||||
struct ast_dsp *dsp;
|
struct ast_dsp *dsp;
|
||||||
/*! \brief original audio formats */
|
/*! \brief original audio formats */
|
||||||
@@ -3539,13 +3537,13 @@ static void destroy_faxdetect(void *data)
|
|||||||
ast_dsp_free(faxdetect->dsp);
|
ast_dsp_free(faxdetect->dsp);
|
||||||
faxdetect->dsp = NULL;
|
faxdetect->dsp = NULL;
|
||||||
}
|
}
|
||||||
ao2_ref(faxdetect->details, -1);
|
ao2_cleanup(faxdetect->details);
|
||||||
ao2_cleanup(faxdetect->orig_format);
|
ao2_cleanup(faxdetect->orig_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Create a new fax detect object.
|
/*! \brief Create a new fax detect object.
|
||||||
* \param chan the channel attaching to
|
* \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
|
* \param flags required options
|
||||||
* \return NULL or a fax gateway object
|
* \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;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!ast_tvzero(faxdetect->timeout_start) &&
|
if (!ast_tvzero(faxdetect->timeout_start)
|
||||||
(ast_tvdiff_ms(ast_tvnow(), faxdetect->timeout_start) > faxdetect->timeout))) {
|
&& 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);
|
ast_framehook_detach(chan, details->faxdetect_id);
|
||||||
details->faxdetect_id = -1;
|
details->faxdetect_id = -1;
|
||||||
return f;
|
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.
|
/*! \brief Attach a faxdetect framehook object to a channel.
|
||||||
* \param chan the channel to attach to
|
* \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
|
* \return the faxdetect structure or NULL on error
|
||||||
* \param flags required options
|
* \param flags required options
|
||||||
* \retval -1 error
|
* \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;
|
details->gateway_timeout = 0;
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
unsigned int gwtimeout;
|
unsigned int gwtimeout;
|
||||||
if (sscanf(timeout, "%u", &gwtimeout) == 1) {
|
|
||||||
|
if (sscanf(timeout, "%30u", &gwtimeout) == 1) {
|
||||||
|
if (gwtimeout >= 0) {
|
||||||
details->gateway_timeout = gwtimeout * 1000;
|
details->gateway_timeout = gwtimeout * 1000;
|
||||||
|
} else {
|
||||||
|
ast_log(LOG_WARNING, "%s(%s) timeout cannot be negative. Ignoring timeout\n",
|
||||||
|
cmd, data);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING, "Unsupported timeout '%s' passed to FAXOPT(%s).\n", timeout, data);
|
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 (ast_true(val) || !strcasecmp(val, "t38") || !strcasecmp(val, "cng")) {
|
||||||
if (details->faxdetect_id < 0) {
|
if (details->faxdetect_id < 0) {
|
||||||
if (timeout && (sscanf(timeout, "%u", &fdtimeout) == 1)) {
|
if (timeout) {
|
||||||
if (fdtimeout > 0) {
|
if (sscanf(timeout, "%30u", &fdtimeout) == 1) {
|
||||||
fdtimeout = fdtimeout * 1000;
|
if (fdtimeout >= 0) {
|
||||||
|
fdtimeout *= 1000;
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING, "Timeout cannot be negative ignoring timeout\n");
|
ast_log(LOG_WARNING, "%s(%s) timeout cannot be negative. Ignoring timeout\n",
|
||||||
|
cmd, data);
|
||||||
|
fdtimeout = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ast_log(LOG_WARNING, "Unsupported timeout '%s' passed to FAXOPT(%s).\n",
|
||||||
|
timeout, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user