TT#136954 add explicit flag to en/disable DTMF detection

Change-Id: I0da522ec5b195d580b44e6c5d0cfc42b73a8ac4b
pull/1430/head
Richard Fuchs 4 years ago
parent 975cd33a9c
commit e7edfc03b4

@ -107,6 +107,7 @@ static void cli_incoming_call_tag(str *instr, struct cli_writer *cw);
static void cli_incoming_tag_info(str *instr, struct cli_writer *cw); static void cli_incoming_tag_info(str *instr, struct cli_writer *cw);
#ifdef WITH_TRANSCODING #ifdef WITH_TRANSCODING
static void cli_incoming_tag_delay(str *instr, struct cli_writer *cw); static void cli_incoming_tag_delay(str *instr, struct cli_writer *cw);
static void cli_incoming_tag_detdtmf(str *instr, struct cli_writer *cw);
#endif #endif
static const cli_handler_t cli_top_handlers[] = { static const cli_handler_t cli_top_handlers[] = {
@ -181,6 +182,7 @@ static const cli_handler_t cli_tag_handlers[] = {
{ "info", cli_incoming_tag_info }, { "info", cli_incoming_tag_info },
#ifdef WITH_TRANSCODING #ifdef WITH_TRANSCODING
{ "delay", cli_incoming_tag_delay }, { "delay", cli_incoming_tag_delay },
{ "detect-dtmf", cli_incoming_tag_detdtmf },
#endif #endif
{ NULL, }, { NULL, },
}; };
@ -1547,6 +1549,23 @@ static void cli_incoming_tag_delay(str *instr, struct cli_writer *cw) {
} }
codec_update_all_handlers(cw->ml); codec_update_all_handlers(cw->ml);
} }
static void cli_incoming_tag_detdtmf(str *instr, struct cli_writer *cw) {
if (str_shift(instr, 1)) {
cw->cw_printf(cw, "More parameters required.\n");
return;
}
int onoff = str_to_i(instr, 1);
if (onoff != 0 && onoff != 1) {
cw->cw_printf(cw, "Invalid setting %i\n", onoff);
return;
}
cw->cw_printf(cw, "%s audio DTMF detection\n", onoff ? "Enabling" : "Disabling");
cw->ml->detect_dtmf = onoff ? 1 : 0;
codec_update_all_handlers(cw->ml);
}
#endif #endif

@ -1094,13 +1094,23 @@ void codec_handlers_update(struct call_media *receiver, struct call_media *sink,
&& sink_dtmf_pt->for_transcoding) && sink_dtmf_pt->for_transcoding)
pcm_dtmf_detect = true; pcm_dtmf_detect = true;
if (pcm_dtmf_detect) if (receiver->monologue->detect_dtmf)
pcm_dtmf_detect = true;
if (pcm_dtmf_detect) {
if (sink_dtmf_pt)
ilogs(codec, LOG_DEBUG, "Enabling PCM DTMF detection from " STR_FORMAT ilogs(codec, LOG_DEBUG, "Enabling PCM DTMF detection from " STR_FORMAT
" to " STR_FORMAT " to " STR_FORMAT
"/" STR_FORMAT, "/" STR_FORMAT,
STR_FMT(&pt->encoding_with_params), STR_FMT(&pt->encoding_with_params),
STR_FMT(&sink_pt->encoding_with_params), STR_FMT(&sink_pt->encoding_with_params),
STR_FMT(&sink_dtmf_pt->encoding_with_params)); STR_FMT(&sink_dtmf_pt->encoding_with_params));
else
ilogs(codec, LOG_DEBUG, "Enabling PCM DTMF detection from " STR_FORMAT
" to " STR_FORMAT,
STR_FMT(&pt->encoding_with_params),
STR_FMT(&sink_pt->encoding_with_params));
}
// we can now decide whether we can do passthrough, or transcode // we can now decide whether we can do passthrough, or transcode
@ -3102,7 +3112,7 @@ static int packet_encoded_rtp(encoder_t *enc, void *u1, void *u2) {
static void __dtmf_detect(struct codec_ssrc_handler *ch, AVFrame *frame) { static void __dtmf_detect(struct codec_ssrc_handler *ch, AVFrame *frame) {
if (!ch->dtmf_dsp) if (!ch->dtmf_dsp)
return; return;
if (ch->handler->dtmf_payload_type == -1 || !ch->handler->pcm_dtmf_detect) { if (!ch->handler->pcm_dtmf_detect) {
ch->dtmf_event.code = 0; ch->dtmf_event.code = 0;
return; return;
} }

@ -449,6 +449,7 @@ struct call_monologue {
unsigned int silence_media:1; unsigned int silence_media:1;
unsigned int rec_forwarding:1; unsigned int rec_forwarding:1;
unsigned int inject_dtmf:1; unsigned int inject_dtmf:1;
unsigned int detect_dtmf:1;
}; };
struct call_iterator_list { struct call_iterator_list {

Loading…
Cancel
Save