diff --git a/daemon/codec.c b/daemon/codec.c index d65cb31db..63871fffd 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -2574,7 +2574,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); diff --git a/daemon/dtmf.c b/daemon/dtmf.c index c6f5d3612..d73b9a0d1 100644 --- a/daemon/dtmf.c +++ b/daemon/dtmf.c @@ -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);