From 44071bb7fad261f5370af12fb5b3ec01e3a6612c Mon Sep 17 00:00:00 2001 From: Wenpeng Song <wenpeng.song@iopsys.eu> Date: Mon, 29 Apr 2024 15:02:48 +0000 Subject: [PATCH] Fix a regression that is introduced by RTP events generated by DSP For those internal calls that list in extension.conf like call-forward(*21*). The Read() function that used to get the target number could not retrieve the DTMF with the previous fix as it is not received by asterisk core. [sip0-direct] exten => _*21*,1, GoSub(sub-create_cfim,s,1(sip0)) ... [sub-create_cfim] exten => s,1, Read(input,,,,,300) --- src/channels/chan_voicemngr.c | 10 +++++++--- src/channels/chan_voicemngr.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/channels/chan_voicemngr.c b/src/channels/chan_voicemngr.c index 7254627..196913f 100644 --- a/src/channels/chan_voicemngr.c +++ b/src/channels/chan_voicemngr.c @@ -2581,11 +2581,13 @@ void handle_dtmf_calling(struct chan_voicemngr_subchannel *sub) int dtmfbuf_len = strlen(p->dtmfbuf); char dtmf_last_char = p->dtmfbuf[(dtmfbuf_len - 1)]; char dtmf_one_before_last_char = p->dtmfbuf[(dtmfbuf_len > 1 ? dtmfbuf_len - 2 : 0)]; - + + sub->direct_extension = 0; if (ast_exists_extension(NULL, p->context_direct, p->dtmfbuf, 1, p->cid_num) && !ast_matchmore_extension(NULL, p->context_direct, p->dtmfbuf, 1, p->cid_num)) { //We have a full match in the "direct" context, so have asterisk place a call immediately ast_debug(9, "Direct extension matching %s found\n", p->dtmfbuf); + sub->direct_extension = 1; chan_voicemngr_start_calling(sub, p->context_direct); } @@ -3119,7 +3121,7 @@ static void handle_dtmf(enum LINE_EVENT event, if (p->dtmf_first < 0) { p->dtmf_first = dtmf_button; ast_debug(9,"Pressed DTMF %s\n", dtmfMap->name); - if (owner && chan_voicemngr_should_relay_dtmf(sub) && (sub->dtmf_mode == AST_SIP_DTMF_INFO || sub->conference_initiator == 1)) { + if (owner && chan_voicemngr_should_relay_dtmf(sub) && (sub->dtmf_mode == AST_SIP_DTMF_INFO || sub->conference_initiator == 1 || sub->direct_extension == 1)) { // INCALL send_outgoing_dtmf(owner, dtmf_button, AST_FRAME_DTMF_BEGIN); } @@ -3171,7 +3173,7 @@ static void handle_dtmf(enum LINE_EVENT event, ast_queue_frame(owner, &f); } } else { - if (owner && (sub->dtmf_mode == AST_SIP_DTMF_INFO || sub->conference_initiator == 1)) { + if (owner && (sub->dtmf_mode == AST_SIP_DTMF_INFO || sub->conference_initiator == 1 || sub->direct_extension)) { // INCALL send_outgoing_dtmf(owner, dtmf_button, AST_FRAME_DTMF_END); } @@ -3877,6 +3879,7 @@ static struct chan_voicemngr_pvt *chan_voicemngr_allocate_pvt(void) sub->sip_client_id = -1; sub->period = default_ptime; // 20 ms sub->dtmf_mode = AST_SIP_DTMF_RFC_4733; + sub->direct_extension = 0; sub->conference_initiator = 0; tmp->sub[i] = sub; sub->ingressRtcpPackets = 0; @@ -5764,6 +5767,7 @@ static int chan_voicemngr_close_connection(struct chan_voicemngr_subchannel *sub sub->codec = -1; sub->call_id = CALLID_INVALID; sub->updated_codec = 0; + sub->direct_extension = 0; ast_debug(1, "Virtual Asterisk connection %d/%d destroyed\n", p->line_id, sub->connection_id); } diff --git a/src/channels/chan_voicemngr.h b/src/channels/chan_voicemngr.h index a024544..1884723 100644 --- a/src/channels/chan_voicemngr.h +++ b/src/channels/chan_voicemngr.h @@ -189,6 +189,7 @@ struct chan_voicemngr_subchannel { int updated_codec; int sip_client_id; /* The SIP client used for the current call: -1 = not set, 0 = internal call, 1..MAX_SIP_CLIENTS = sip client id*/ int congestion_timer_id; + int direct_extension; }; struct chan_voicemngr_channel_tech { -- GitLab