From d6d187486cabf5933acd380d7f153ae79ec6a420 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 24 Oct 2011 09:48:08 -0500 Subject: [PATCH] FS-3624 --resolve --- .../applications/mod_spandsp/mod_spandsp.c | 28 +++++++++++++------ .../applications/mod_spandsp/mod_spandsp.h | 2 +- .../mod_spandsp/mod_spandsp_fax.c | 6 ++-- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.c b/src/mod/applications/mod_spandsp/mod_spandsp.c index 644f17f1ac..358b055a7c 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp.c @@ -74,25 +74,35 @@ SWITCH_STANDARD_APP(stop_dtmf_session_function) SWITCH_STANDARD_APP(spandsp_fax_detect_session_function) { int argc = 0; - char *argv[3] = { 0 }; + char *argv[4] = { 0 }; char *dupdata; const char *app = NULL, *arg = NULL; int timeout = 0; + int tone_type = MODEM_CONNECT_TONES_FAX_CNG; if (!zstr(data) && (dupdata = switch_core_session_strdup(session, data))) { - if ((argc = switch_split(dupdata, ' ', argv)) == 3) { + if ((argc = switch_split(dupdata, ' ', argv)) >= 2) { app = argv[0]; arg = argv[1]; - timeout = atoi(argv[2]); - if (timeout < 0) { - timeout = 0; - } + if (argc > 2) { + timeout = atoi(argv[2]); + if (timeout < 0) { + timeout = 0; + } + } + if (argc > 3) { + if (!strcmp(argv[3], "ced")) { + tone_type = MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE; + } else { + tone_type = MODEM_CONNECT_TONES_FAX_CNG; + } + } } } if (app) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Enabling fax detection '%s' '%s'\n", argv[0], argv[1]); - spandsp_fax_detect_session(session, "rw", timeout, 1, app, arg, NULL); + spandsp_fax_detect_session(session, "rw", timeout, tone_type, 1, app, arg, NULL); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot Enable fax detection '%s' '%s'\n", argv[0], argv[1]); } @@ -151,7 +161,7 @@ SWITCH_STANDARD_APP(t38_gateway_function) } //switch_ivr_tone_detect_session(session, "t38", "1100.0", "rw", timeout, 1, direction, NULL, t38_gateway_start); - spandsp_fax_detect_session(session, "rw", timeout, 1, direction, NULL, t38_gateway_start); + spandsp_fax_detect_session(session, "rw", timeout, MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE, 1, direction, NULL, t38_gateway_start); } } @@ -270,7 +280,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init) SWITCH_ADD_APP(app_interface, "spandsp_start_dtmf", "Detect dtmf", "Detect inband dtmf on the session", dtmf_session_function, "", SAF_MEDIA_TAP); SWITCH_ADD_APP(app_interface, "spandsp_start_fax_detect", "start fax detect", "start fax detect", spandsp_fax_detect_session_function, - "[ ][ ]", SAF_NONE); + "[ ][ ][ ]", SAF_NONE); SWITCH_ADD_APP(app_interface, "spandsp_stop_fax_detect", "stop fax detect", "stop fax detect", spandsp_stop_fax_detect_session_function, "", SAF_NONE); diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.h b/src/mod/applications/mod_spandsp/mod_spandsp.h index 220ce7b037..9127b39791 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.h +++ b/src/mod/applications/mod_spandsp/mod_spandsp.h @@ -70,7 +70,7 @@ switch_status_t callprogress_detector_start(switch_core_session_t *session, cons switch_status_t callprogress_detector_stop(switch_core_session_t *session); switch_status_t spandsp_fax_detect_session(switch_core_session_t *session, - const char *flags, int timeout, + const char *flags, int timeout, int tone_type, int hits, const char *app, const char *data, switch_tone_detect_callback_t callback); switch_status_t spandsp_fax_stop_detect_session(switch_core_session_t *session); diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index 499b16e0d3..db2134a725 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -1861,6 +1861,7 @@ typedef struct { char *data; char *key; int up; + int tone_type; int total_hits; int hits; int sleep; @@ -1910,7 +1911,7 @@ static switch_bool_t tone_detect_callback(switch_media_bug_t *bug, void *user_da case SWITCH_ABC_TYPE_INIT: if (cont) { cont->bug_running = 1; - modem_connect_tones_rx_init(&cont->rx_tones, MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE, NULL, NULL); + modem_connect_tones_rx_init(&cont->rx_tones, cont->tone_type, NULL, NULL); } break; case SWITCH_ABC_TYPE_CLOSE: @@ -2018,7 +2019,7 @@ switch_status_t spandsp_fax_stop_detect_session(switch_core_session_t *session) } switch_status_t spandsp_fax_detect_session(switch_core_session_t *session, - const char *flags, int timeout, + const char *flags, int timeout, int tone_type, int hits, const char *app, const char *data, switch_tone_detect_callback_t callback) { switch_channel_t *channel = switch_core_session_get_channel(session); @@ -2051,6 +2052,7 @@ switch_status_t spandsp_fax_detect_session(switch_core_session_t *session, cont->data = switch_core_session_strdup(session, data); } + cont->tone_type = tone_type; cont->callback = callback; cont->up = 1; cont->session = session;