From 83e7537f87e266f997f36d35b9dccedf7bb2dd0c Mon Sep 17 00:00:00 2001
From: Hemlata <hemlata.bhatt@iopsys.eu>
Date: Thu, 15 Dec 2022 14:32:36 +0000
Subject: [PATCH] Play stutter dial tone if MWI is enabled

Before this commit, a normal dial tone is played if mwi_dialtone_state in "pjsip show endpoint" is
not "off", "congestion" or "special".
After this commit, in the above condition, a stutter dial tone is played if mwi_enable is 1, otherwise
a normal dial tone is played.
---
 channels/chan_brcm.c | 8 ++++++--
 channels/chan_brcm.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/channels/chan_brcm.c b/channels/chan_brcm.c
index 85de36a637..5a3de5e48b 100644
--- a/channels/chan_brcm.c
+++ b/channels/chan_brcm.c
@@ -3026,10 +3026,11 @@ static void brcm_process_event(struct endpt_event *ev)
 				/* EVENT_OFFHOOK changed endpoint state to OFFHOOK, apply dialtone */
 				if ( p->context[0] != '\0' && is_sip_account_registered(p->context)) {
 					ast_debug(9, "Resetting dial tones.\n");
-					p->dialtone = voicemail_messages_waiting(p->context) ? mwi_dialtone_state : DIALTONE_ON;
+					channel_settings *s = &channel_config[p->line_id];
+					p->dialtone = voicemail_messages_waiting(p->context) ? mwi_dialtone_state : s->mwi_enabled ? DIALTONE_SPECIAL_CONDITION: DIALTONE_ON;
 					brcm_signal_dialtone(p);
 					brcm_send_ubus_event("DIALTONE_ON", p->line_id);
-					channel_settings *s = &channel_config[p->line_id];
+
 					if (strlen(s->autodial_ext)) {
 						/* Schedule autodial timeout if autodial extension is set */
 						p->autodial_timer_id = ast_sched_add(sched, s->autodial_timeoutmsec, handle_autodial_timeout, p);
@@ -3941,6 +3942,9 @@ static void channel_settings_load(channel_settings *channel_config, struct ast_v
 			else
 				channel_config->flashSpec = FLASH_SPEC_UK;
                 }
+		else if (!strcasecmp(v->name, "mwi_enabled")) {
+			channel_config->mwi_enabled = ast_true(v->value)?1:0;
+		}
 		v = v->next;
 	}
 }
diff --git a/channels/chan_brcm.h b/channels/chan_brcm.h
index f0bdb5d0d7..32c3b22fc0 100644
--- a/channels/chan_brcm.h
+++ b/channels/chan_brcm.h
@@ -252,6 +252,7 @@ typedef struct {
         int calleridenable;
         int calleridnameenable;
 	flash_spec flashSpec;
+	int mwi_enabled;
 } channel_settings;
 
 
-- 
GitLab