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.
This commit is contained in:
Chris Rienzo 2015-04-01 11:00:43 -04:00
parent 7add4b25db
commit 3c2afc6a2c
2 changed files with 21 additions and 0 deletions

View 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 {

View 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);