]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add last_dtmf_duration variable
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 11 Sep 2008 17:29:08 +0000 (17:29 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 11 Sep 2008 17:29:08 +0000 (17:29 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9526 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_core_io.c

index 69528341109e495cf28ea0c6a92d6e64951d9ce9..9111ec1667528f3671b5b41c2629b739bfa6be95 100644 (file)
@@ -1028,6 +1028,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core
        char *string;
        int i, argc;
        char *argv[256];
+       int dur_total = 0;
 
        switch_assert(session != NULL);
 
@@ -1078,10 +1079,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s send dtmf\ndigit=%c ms=%u samples=%u\n",
                                                                          switch_channel_get_name(session->channel), dtmf.digit, dur, dtmf.duration);
                                        sent++;
+                                       dur_total += dtmf.duration + 2000; /* account for 250ms pause */
                                }
                        }
                }
 
+               if (dur_total) {
+                       char tmp[32] = "";
+                       switch_snprintf(tmp, sizeof(tmp), "%d", dur_total / 8);
+                       switch_channel_set_variable(session->channel, "last_dtmf_duration", tmp);
+               }
+
        }
        return sent ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
 }