MT#55283 Allow dtmf injection when also using a delay buffer

previously, dtmf_inject wouldn't add the events as the dtmf_payload_type
was set to -1 as part of the delay buffer handling. However, as we
know we want this DTMF, this change updates the function to check for
and use the real_dtmf_payload_type value

Then, in codec_add_dtmf_event, we can check the injected bool and
if set, use the real_dtmf_payload_type again to decide whether to
push the event onto the queue

closes #1722

Change-Id: I34e35f92e014f4aed9e045737df7400155b86602
pull/1729/head
Tom Briden 2 years ago committed by Richard Fuchs
parent 1ef2e94d4b
commit e40e6c5cd0

@ -2584,7 +2584,8 @@ void codec_add_dtmf_event(struct codec_ssrc_handler *ch, int code, int level, ui
// add to queue if we're doing PCM -> DTMF event conversion
// this does not capture events when doing DTMF delay (dtmf_payload_type == -1)
if (ch->handler->dtmf_payload_type != -1) {
// unless this is an injected event, in which case we check the real payload type
if (ch->handler->dtmf_payload_type != -1 || (injected && ch->handler->real_dtmf_payload_type != -1)) {
struct dtmf_event *ev = g_slice_alloc(sizeof(*ev));
*ev = new_ev;
g_queue_push_tail(&ch->dtmf_events, ev);

@ -594,6 +594,7 @@ const char *dtmf_inject(struct call_media *media, int code, int volume, int dura
struct codec_handler *ch = NULL;
struct codec_ssrc_handler *csh = NULL;
int pt = -1;
int ch_pt = -1;
for (int i = 0; i < ssrc_in->tracker.most_len; i++) {
pt = ssrc_in->tracker.most[i];
if (pt == 255)
@ -602,8 +603,11 @@ const char *dtmf_inject(struct call_media *media, int code, int volume, int dura
ch = codec_handler_get(media, pt, sink, NULL);
if (!ch)
continue;
// for DTMF delay, payload type will be -1 but the real payload type will be correct
// and as we're specifically injecting we want to make sure we end up checking the right pt
ch_pt = ch->real_dtmf_payload_type != -1 ? ch->real_dtmf_payload_type : ch->dtmf_payload_type;
// skip DTMF PTs
if (pt == ch->dtmf_payload_type)
if (pt == ch_pt)
continue;
if (ch->output_handler && ch->output_handler->ssrc_hash) // context switch if we have multiple inputs going to one output
ch = ch->output_handler;
@ -612,7 +616,7 @@ const char *dtmf_inject(struct call_media *media, int code, int volume, int dura
pt,
ch->source_pt.payload_type,
ch->dest_pt.payload_type,
ch->dtmf_payload_type,
ch_pt,
ssrc_in->parent->h.ssrc);
if (!ch->ssrc_hash)
@ -633,7 +637,7 @@ const char *dtmf_inject(struct call_media *media, int code, int volume, int dura
return "No matching codec SSRC handler";
// if we don't have a DTMF payload type, we have to generate PCM
if (ch->dtmf_payload_type == -1 && ch->dtmf_injector)
if (ch_pt == -1 && ch->dtmf_injector)
return dtmf_inject_pcm(media, sink, monologue, ps, ssrc_in, ch, csh, code, volume, duration,
pause);

Loading…
Cancel
Save