From 05600265e62c0b86c2df836cd92251fa84c7b3a6 Mon Sep 17 00:00:00 2001
From: Grzegorz Sluja <grzegorz.sluja@iopsys.eu>
Date: Fri, 17 Jan 2025 13:02:04 +0100
Subject: [PATCH] Fix for sending multiple '180 Ringing' messages, REF 15988

It occured that changing the condition for AST_CONTROL_RINGING
in a fix for REF 15850 introduced a degrade so the '180 RINGING'
SIP event is sent many times for the incoming call processed to DUT.
Restore the previous condition and fix the issue of early-media with
reset the flag 'pa->sentringing' in other place makes the issue of
early-media REF 15850 is fixed and there is no longer multiple
'180 Ringing' SIP messages sent to the Caller.
---
 apps/app_dial.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/apps/app_dial.c b/apps/app_dial.c
index 81384a716f..0d30ebf418 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -1550,7 +1550,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
 							&& CAN_EARLY_BRIDGE(peerflags, in, c)) {
 							ast_channel_early_bridge(in, c);
 						}
-						if (!ast_test_flag64(outgoing, OPT_MUSICBACK) && ast_strlen_zero(opt_args[OPT_ARG_RINGBACK])) {
+						if (!(pa->sentringing) && !ast_test_flag64(outgoing, OPT_MUSICBACK) && ast_strlen_zero(opt_args[OPT_ARG_RINGBACK])) {
 
                                                        ast_indicate(in, f->subclass.integer);
 
@@ -1587,6 +1587,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
 						if (single || (!single && !pa->sentringing)) {
 							ast_channel_codec_set(in, ast_channel_codec_get(c)); //for early media codec sync
 							ast_indicate(in, AST_CONTROL_PROGRESS);
+							pa->sentringing = 0;
 						}
 					}
 					if (!sent_progress) {
-- 
GitLab