#define SWITCH_DTMF_LOG_LEN 1000
typedef uint8_t switch_byte_t;
+/*!
+ \enum switch_dtmf_source_t
+ \brief DTMF sources
+<pre>
+ SWITCH_DTMF_UNKNOWN - Unknown source
+ SWITCH_DTMF_INBAND_AUDIO - From audio
+ SWITCH_DTMF_RTP - From RTP as a telephone event
+ SWITCH_DTMF_ENDPOINT - From endpoint signaling
+ SWITCH_DTMF_APP - From application
+</pre>
+ */
+typedef enum {
+ SWITCH_DTMF_UNKNOWN,
+ SWITCH_DTMF_INBAND_AUDIO,
+ SWITCH_DTMF_RTP,
+ SWITCH_DTMF_ENDPOINT,
+ SWITCH_DTMF_APP
+} switch_dtmf_source_t;
+
typedef enum {
DTMF_FLAG_SKIP_PROCESS = (1 << 0)
} dtmf_flag_t;
char digit;
uint32_t duration;
int32_t flags;
+ switch_dtmf_source_t source;
} switch_dtmf_t;
typedef enum {
pvt->last_digit = digit;
dtmf.digit = digit;
dtmf.duration = switch_core_default_dtmf_duration(0);
+ dtmf.source = SWITCH_DTMF_INBAND_AUDIO;
switch_channel_queue_dtmf(switch_core_session_get_channel(pvt->session), &dtmf);
pvt->digit_begin = pvt->samples;
} else {
const char *signal_ptr;
const char *rec_header;
const char *clientcode_header;
- switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0) };
+ switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0), 0, SWITCH_DTMF_ENDPOINT };
switch_event_t *event;
private_object_t *tech_pvt = NULL;
SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf_string(switch_channel_t *channel, const char *dtmf_string)
{
char *p;
- switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0), 0};
+ switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0), 0, SWITCH_DTMF_APP };
int sent = 0, dur;
char *string;
int i, argc;
switch_dtmf_t dtmf;
dtmf.digit = *p;
dtmf.duration = switch_core_default_dtmf_duration(0);
+ dtmf.source = SWITCH_DTMF_INBAND_AUDIO;
switch_channel_queue_dtmf(channel, &dtmf);
p++;
}
if (!switch_buffer_inuse(pvt->audio_buffer)) {
if (switch_queue_trypop(pvt->digit_queue, &pop) == SWITCH_STATUS_SUCCESS) {
switch_dtmf_t *dtmf = (switch_dtmf_t *) pop;
- char buf[2] = "";
- int duration = dtmf->duration;
-
- buf[0] = dtmf->digit;
- if (duration > 8000) {
- duration = 4000;
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)),
+ if (dtmf->source != SWITCH_DTMF_INBAND_AUDIO) {
+ char buf[2] = "";
+ int duration = dtmf->duration;
+
+ buf[0] = dtmf->digit;
+ if (duration > 8000) {
+ duration = 4000;
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)),
SWITCH_LOG_WARNING, "%s Truncating ridiculous DTMF duration %d ms to 1/2 second.\n",
switch_channel_get_name(switch_core_session_get_channel(pvt->session)), dtmf->duration / 8);
+ }
+ pvt->ts.duration = duration;
+ teletone_run(&pvt->ts, buf);
}
- pvt->ts.duration = duration;
- teletone_run(&pvt->ts, buf);
free(pop);
}
}
switch_dtmf_t dtmf;
dtmf.digit = c;
dtmf.duration = switch_core_default_dtmf_duration(0);
+ dtmf.source = SWITCH_DTMF_INBAND_AUDIO;
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Queue speech detected dtmf %c\n", c);
switch_channel_queue_dtmf(channel, &dtmf);
}
if (!rtp_session->dtmf_data.in_digit_queued && (rtp_session->rtp_bugs & RTP_BUG_IGNORE_DTMF_DURATION) &&
rtp_session->dtmf_data.in_digit_ts) {
- switch_dtmf_t dtmf = { key, switch_core_min_dtmf_duration(0) };
+ switch_dtmf_t dtmf = { key, switch_core_min_dtmf_duration(0), 0, SWITCH_DTMF_RTP };
#ifdef DEBUG_2833
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Early Queuing digit %c:%d\n", dtmf.digit, dtmf.duration / 8);
#endif
rtp_session->dtmf_data.in_digit_sanity = 2000;
}
if (rtp_session->dtmf_data.in_digit_ts) {
- switch_dtmf_t dtmf = { key, duration };
+ switch_dtmf_t dtmf = { key, duration, 0, SWITCH_DTMF_RTP };
if (ts > rtp_session->dtmf_data.in_digit_ts) {
dtmf.duration += (ts - rtp_session->dtmf_data.in_digit_ts);