From b02ca7d5bf79ca4b81bf8aedb4b66976ac366165 Mon Sep 17 00:00:00 2001
From: Wenpeng Song <wenpeng.song@iopsys.eu>
Date: Fri, 16 Feb 2024 10:20:37 +0000
Subject: [PATCH] Fix an issue that codec is not synchronised when switching
 between two calls

The issue happened when caller and callee had different codec priorities.
---
 src/channels/chan_voicemngr.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/channels/chan_voicemngr.c b/src/channels/chan_voicemngr.c
index 0c2ee00..973da86 100644
--- a/src/channels/chan_voicemngr.c
+++ b/src/channels/chan_voicemngr.c
@@ -946,6 +946,9 @@ static int chan_voicemngr_indicate(struct ast_channel *ast, int condition, const
 			} else {
 				ast_log(LOG_ERROR, "can't get the peer channel, unattended call transfer will not be proceeded\n");
 			}
+		} else if(sub->channel_state == INCALL && sub_peer->channel_state == ONHOLD) {
+			/* pjsip send this indication when switching between two calls, update rtp peer to have codec updated */
+			ast_indicate(sub->owner, AST_CONTROL_UPDATE_RTP_PEER);
 		}
 		break;
 	case AST_CONTROL_TRANSFER:
-- 
GitLab