]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
spandsp: fixing t38 with configurable tone type.
authorJames Zhang <jzhang@sangoma.com>
Thu, 2 Feb 2012 16:38:12 +0000 (11:38 -0500)
committerJames Zhang <jzhang@sangoma.com>
Thu, 2 Feb 2012 16:38:12 +0000 (11:38 -0500)
         - tone_type value is taken from dialplan
           t38_gateway function's 2nd parameter
         - tone type could be one of
           cng|ced_preamble|ans|ans_pr|ansam|preamble
         - in dialplan, if enable t38 in ftdm-to-sip,
           tone type should be set to "t38_gateway peer cng"
         - if enable t38 in sip-to-ftdm,
           tone type should be set to "t38_gateway peer ced_preamble"

src/mod/applications/mod_spandsp/mod_spandsp.c

index 68ac50f1374b2e866e33ced92308721b18624dcb..2f9b47419d48f094dcc310020d4ae059894731e9 100644 (file)
@@ -125,12 +125,14 @@ static void event_handler(switch_event_t *event)
 SWITCH_STANDARD_APP(t38_gateway_function)
 {
     switch_channel_t *channel = switch_core_session_get_channel(session);
-    time_t timeout = switch_epoch_time_now(NULL) + 20;
+    time_t timeout = 20;
     const char *var;
     int argc = 0;
     char *argv[2] = { 0 };
     char *dupdata;
     const char *direction = NULL, *flags = NULL;
+
+       int tone_type = 0;
     
     if (!zstr(data) && (dupdata = switch_core_session_strdup(session, data))) {
         if ((argc = switch_split(dupdata, ' ', argv))) {
@@ -156,14 +158,35 @@ SWITCH_STANDARD_APP(t38_gateway_function)
         if ((var = switch_channel_get_variable(channel, "t38_gateway_detect_timeout"))) {
             long to = atol(var);
             if (to > -1) {
-                timeout = (time_t) (switch_epoch_time_now(NULL) + to);
+                timeout = to;
             } else {
                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s invalid timeout value.\n", switch_channel_get_name(channel));
             }
         }
 
+               if (!strcasecmp(flags, "cng")) {
+                       tone_type = MODEM_CONNECT_TONES_FAX_CNG;
+               } else if (!strcasecmp(flags, "ans")) {
+                       tone_type = MODEM_CONNECT_TONES_ANS;
+               } else if (!strcasecmp(flags, "ans_pr")) {
+                       tone_type = MODEM_CONNECT_TONES_ANS_PR;
+               } else if (!strcasecmp(flags, "ansam")) {
+                       tone_type = MODEM_CONNECT_TONES_ANSAM;
+               } else if (!strcasecmp(flags, "ansam_pr")) {
+                       tone_type = MODEM_CONNECT_TONES_ANSAM_PR;
+               } else if (!strcasecmp(flags, "preamble")) {
+                       tone_type = MODEM_CONNECT_TONES_FAX_PREAMBLE;
+               } else if (!strcasecmp(flags, "ced_preamble")) {
+                       tone_type = MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE;
+               } else {
+                       tone_type = MODEM_CONNECT_TONES_NONE;
+               }
+
+
+
         //switch_ivr_tone_detect_session(session, "t38", "1100.0", "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);
+               //spandsp_fax_detect_session(session, "rw", timeout, MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE, 1, direction, NULL, t38_gateway_start);
+               spandsp_fax_detect_session(session, "rw", timeout, tone_type, 1, direction, NULL, t38_gateway_start);
     }
 }