]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7406 #resolve #comment Added DTMF-Source header to DTMF event.
authorChris Rienzo <chris.rienzo@grasshopper.com>
Wed, 1 Apr 2015 15:00:43 +0000 (11:00 -0400)
committerChris Rienzo <chris.rienzo@grasshopper.com>
Wed, 1 Apr 2015 15:00:43 +0000 (11:00 -0400)
DTMF-Source may have the following values:
   APP : injected by application (send_dtmf, etc)
   ENDPOINT : detected by endpoint signaling (like SIP INFO)
   INBAND_AUDIO : detected by start_dtmf, spandsp_start_dtmf, etc
   RTP : detected as 2833/4733 telephone event
   UNKNOWN : unknown source

One possible use of this header is to determine telephone events
are being received, and if so, disable inband detection.

src/switch_channel.c
src/switch_ivr_async.c

index 64d42fb8d23db3a464fa8d2236750e1803b241ea..e15aa4cd0087eeb5fdb46f608b9aafeb914115fd 100644 (file)
@@ -631,9 +631,29 @@ SWITCH_DECLARE(switch_status_t) switch_channel_dequeue_dtmf(switch_channel_t *ch
        switch_mutex_unlock(channel->dtmf_mutex);
 
        if (!sensitive && status == SWITCH_STATUS_SUCCESS && switch_event_create(&event, SWITCH_EVENT_DTMF) == SWITCH_STATUS_SUCCESS) {
+               const char *dtmf_source_str = NULL;
                switch_channel_event_set_data(channel, event);
                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "DTMF-Digit", "%c", dtmf->digit);
                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "DTMF-Duration", "%u", dtmf->duration);
+               switch(dtmf->source) {
+                       case SWITCH_DTMF_INBAND_AUDIO:  /* From audio */
+                               dtmf_source_str = "INBAND_AUDIO";
+                               break;
+                       case SWITCH_DTMF_RTP:                   /* From RTP as a telephone event */
+                               dtmf_source_str = "RTP";
+                               break;
+                       case SWITCH_DTMF_ENDPOINT:              /* From endpoint signaling */
+                               dtmf_source_str = "ENDPOINT";
+                               break;
+                       case SWITCH_DTMF_APP:                   /* Injected by application */
+                               dtmf_source_str = "APP";
+                               break;
+                       case SWITCH_DTMF_UNKNOWN:               /* Unknown source */
+                       default:
+                               dtmf_source_str = "UNKNOWN";
+                               break;
+               }
+               switch_event_add_header(event, SWITCH_STACK_BOTTOM, "DTMF-Source", "%s", dtmf_source_str);
                if (switch_channel_test_flag(channel, CF_DIVERT_EVENTS)) {
                        switch_core_session_queue_event(channel->session, &event);
                } else {
index e7f05ac9ff5b3d3e2cc73cc1b8acb06bc3fc4f71..dec8b4cb350bc25c30189ed49f8e475a55d60359 100644 (file)
@@ -2988,6 +2988,7 @@ static switch_status_t generate_on_dtmf(switch_core_session_t *session, const sw
                                                switch_channel_event_set_data(channel, event);
                                                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "DTMF-Digit", "%c", dtmf->digit);
                                                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "DTMF-Duration", "%u", dtmf->duration);
+                                               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "DTMF-Source", "APP");
                                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "DTMF-Conversion", "native:inband");
                                                if (switch_channel_test_flag(channel, CF_DIVERT_EVENTS)) {
                                                        switch_core_session_queue_event(session, &event);