]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-3624 --resolve
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 24 Oct 2011 14:48:08 +0000 (09:48 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 24 Oct 2011 14:48:08 +0000 (09:48 -0500)
src/mod/applications/mod_spandsp/mod_spandsp.c
src/mod/applications/mod_spandsp/mod_spandsp.h
src/mod/applications/mod_spandsp/mod_spandsp_fax.c

index 644f17f1ac11622829fd1fd8f1068530c6c4648b..358b055a7c5fc44b2fb8f308c5eed6c7147f67de 100644 (file)
@@ -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, 
-                   "<app>[ <arg>][ <timeout>]", SAF_NONE);
+                                  "<app>[ <arg>][ <timeout>][ <tone_type>]", 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);
                    
index 220ce7b037e808c549c1004aa3e0a42abb0c2207..9127b3979105f5864dfb9a79c130bdfe68541c25 100644 (file)
@@ -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);
index 499b16e0d3ce2877322b1cad35186293e2548276..db2134a725e3e526381954c588fae5c64b22c29a 100644 (file)
@@ -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;