From 3c2afc6a2c952303bc0d72a00558c04a8fa144a3 Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Wed, 1 Apr 2015 11:00:43 -0400 Subject: [PATCH] FS-7406 #resolve #comment Added DTMF-Source header to DTMF event. 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 | 20 ++++++++++++++++++++ src/switch_ivr_async.c | 1 + 2 files changed, 21 insertions(+) diff --git a/src/switch_channel.c b/src/switch_channel.c index 64d42fb8d2..e15aa4cd00 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -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 { diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index e7f05ac9ff..dec8b4cb35 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -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);