feat(audio): add memberId to VoiceStateEvent when applicable

We need the voiceUserId (memberId) in IN_CONFERENCE callState events so
that the SFU can bypass dialplan-level mute states when transferring
between breakout rooms.

Add memberId to VoiceCallStateEvent when applicable. For CHANNEL_STATE
events that do not carry it (RINGING, HANGUP), memberId is an empty
string.
This commit is contained in:
prlanzarin 2024-06-24 18:41:15 -03:00
parent d3e2d3965c
commit 631d5186e5
6 changed files with 27 additions and 0 deletions

View File

@ -109,6 +109,7 @@ public class FreeswitchConferenceEventListener implements ConferenceEventListene
evt.callSession, evt.callSession,
evt.clientSession, evt.clientSession,
evt.userId, evt.userId,
evt.getVoiceUserId(),
evt.callerName, evt.callerName,
evt.callState, evt.callState,
evt.origCallerIdName, evt.origCallerIdName,

View File

@ -59,6 +59,7 @@ public interface IVoiceConferenceService {
String callSession, String callSession,
String clientSession, String clientSession,
String userId, String userId,
String voiceUserId,
String callerName, String callerName,
String callState, String callState,
String origCallerIdName, String origCallerIdName,

View File

@ -4,6 +4,8 @@ public class VoiceCallStateEvent extends VoiceConferenceEvent {
public final String callSession; public final String callSession;
public final String clientSession; public final String clientSession;
public final String userId; public final String userId;
// AKA mod_conference memberId
public final String voiceUserId;
public final String callerName; public final String callerName;
public final String callState; public final String callState;
public final String origCallerIdName; public final String origCallerIdName;
@ -14,6 +16,7 @@ public class VoiceCallStateEvent extends VoiceConferenceEvent {
String callSession, String callSession,
String clientSession, String clientSession,
String userId, String userId,
String voiceUserId,
String callerName, String callerName,
String callState, String callState,
String origCallerIdName, String origCallerIdName,
@ -22,9 +25,14 @@ public class VoiceCallStateEvent extends VoiceConferenceEvent {
this.callSession = callSession; this.callSession = callSession;
this.clientSession = clientSession; this.clientSession = clientSession;
this.userId = userId; this.userId = userId;
this.voiceUserId = voiceUserId;
this.callerName = callerName; this.callerName = callerName;
this.callState = callState; this.callState = callState;
this.origCallerIdName = origCallerIdName; this.origCallerIdName = origCallerIdName;
this.origCalledDest = origCalledDest; this.origCalledDest = origCalledDest;
} }
public String getVoiceUserId() {
return voiceUserId;
}
} }

View File

@ -84,6 +84,7 @@ public class ESLEventListener implements IEslEventListener {
String origCallerIdName = headers.get("Caller-Caller-ID-Name"); String origCallerIdName = headers.get("Caller-Caller-ID-Name");
String origCallerDestNumber = headers.get("Caller-Destination-Number"); String origCallerDestNumber = headers.get("Caller-Destination-Number");
String clientSession = "0"; String clientSession = "0";
String memberIdStr = memberId != null ? memberId.toString() : "";
Matcher matcher = CALLERNAME_PATTERN.matcher(callerIdName); Matcher matcher = CALLERNAME_PATTERN.matcher(callerIdName);
Matcher callWithSess = CALLERNAME_WITH_SESS_INFO_PATTERN.matcher(callerIdName); Matcher callWithSess = CALLERNAME_WITH_SESS_INFO_PATTERN.matcher(callerIdName);
@ -106,6 +107,7 @@ public class ESLEventListener implements IEslEventListener {
coreuuid, coreuuid,
clientSession, clientSession,
voiceUserId, voiceUserId,
memberIdStr,
callerIdName, callerIdName,
callState, callState,
origCallerIdName, origCallerIdName,
@ -281,6 +283,7 @@ public class ESLEventListener implements IEslEventListener {
String varvBridge = (eventHeaders.get("variable_vbridge") == null) ? "" : eventHeaders.get("variable_vbridge"); String varvBridge = (eventHeaders.get("variable_vbridge") == null) ? "" : eventHeaders.get("variable_vbridge");
if ("echo".equalsIgnoreCase(application) && !varvBridge.isEmpty()) { if ("echo".equalsIgnoreCase(application) && !varvBridge.isEmpty()) {
Integer memberId = this.getMemberId(eventHeaders);
String origCallerIdName = eventHeaders.get("Caller-Caller-ID-Name"); String origCallerIdName = eventHeaders.get("Caller-Caller-ID-Name");
String origCallerDestNumber = eventHeaders.get("Caller-Destination-Number"); String origCallerDestNumber = eventHeaders.get("Caller-Destination-Number");
String coreuuid = eventHeaders.get("Core-UUID"); String coreuuid = eventHeaders.get("Core-UUID");
@ -291,6 +294,7 @@ public class ESLEventListener implements IEslEventListener {
String callerName = origCallerIdName; String callerName = origCallerIdName;
String clientSession = "0"; String clientSession = "0";
String callState = "IN_ECHO_TEST"; String callState = "IN_ECHO_TEST";
String memberIdStr = memberId != null ? memberId.toString() : "";
Matcher callerListenOnly = CALLERNAME_LISTENONLY_PATTERN.matcher(origCallerIdName); Matcher callerListenOnly = CALLERNAME_LISTENONLY_PATTERN.matcher(origCallerIdName);
Matcher callWithSess = CALLERNAME_WITH_SESS_INFO_PATTERN.matcher(origCallerIdName); Matcher callWithSess = CALLERNAME_WITH_SESS_INFO_PATTERN.matcher(origCallerIdName);
@ -314,6 +318,7 @@ public class ESLEventListener implements IEslEventListener {
coreuuid, coreuuid,
clientSession, clientSession,
voiceUserId, voiceUserId,
memberIdStr,
callerName, callerName,
callState, callState,
origCallerIdName, origCallerIdName,
@ -321,6 +326,7 @@ public class ESLEventListener implements IEslEventListener {
conferenceEventListener.handleConferenceEvent(csEvent); conferenceEventListener.handleConferenceEvent(csEvent);
} else if ("RINGING".equalsIgnoreCase(channelCallState) && !varvBridge.isEmpty()) { } else if ("RINGING".equalsIgnoreCase(channelCallState) && !varvBridge.isEmpty()) {
Integer memberId = this.getMemberId(eventHeaders);
String origCallerIdName = eventHeaders.get("Caller-Caller-ID-Name"); String origCallerIdName = eventHeaders.get("Caller-Caller-ID-Name");
String origCallerDestNumber = eventHeaders.get("Caller-Destination-Number"); String origCallerDestNumber = eventHeaders.get("Caller-Destination-Number");
String coreuuid = eventHeaders.get("Core-UUID"); String coreuuid = eventHeaders.get("Core-UUID");
@ -330,6 +336,7 @@ public class ESLEventListener implements IEslEventListener {
String callerName = origCallerIdName; String callerName = origCallerIdName;
String clientSession = "0"; String clientSession = "0";
String callState = "CALL_STARTED"; String callState = "CALL_STARTED";
String memberIdStr = memberId != null ? memberId.toString() : "";
Matcher callerListenOnly = CALLERNAME_LISTENONLY_PATTERN.matcher(origCallerIdName); Matcher callerListenOnly = CALLERNAME_LISTENONLY_PATTERN.matcher(origCallerIdName);
Matcher callWithSess = CALLERNAME_WITH_SESS_INFO_PATTERN.matcher(origCallerIdName); Matcher callWithSess = CALLERNAME_WITH_SESS_INFO_PATTERN.matcher(origCallerIdName);
@ -353,6 +360,7 @@ public class ESLEventListener implements IEslEventListener {
coreuuid, coreuuid,
clientSession, clientSession,
voiceUserId, voiceUserId,
memberIdStr,
callerName, callerName,
callState, callState,
origCallerIdName, origCallerIdName,
@ -365,6 +373,7 @@ public class ESLEventListener implements IEslEventListener {
String channelState = (eventHeaders.get("Channel-State") == null) ? "" : eventHeaders.get("Channel-State"); String channelState = (eventHeaders.get("Channel-State") == null) ? "" : eventHeaders.get("Channel-State");
if ("HANGUP".equalsIgnoreCase(channelCallState) && "CS_DESTROY".equalsIgnoreCase(channelState)) { if ("HANGUP".equalsIgnoreCase(channelCallState) && "CS_DESTROY".equalsIgnoreCase(channelState)) {
Integer memberId = this.getMemberId(eventHeaders);
String origCallerIdName = eventHeaders.get("Caller-Caller-ID-Name"); String origCallerIdName = eventHeaders.get("Caller-Caller-ID-Name");
String origCallerDestNumber = eventHeaders.get("Caller-Destination-Number"); String origCallerDestNumber = eventHeaders.get("Caller-Destination-Number");
String coreuuid = eventHeaders.get("Core-UUID"); String coreuuid = eventHeaders.get("Core-UUID");
@ -374,6 +383,7 @@ public class ESLEventListener implements IEslEventListener {
String callerName = origCallerIdName; String callerName = origCallerIdName;
String clientSession = "0"; String clientSession = "0";
String callState = "CALL_ENDED"; String callState = "CALL_ENDED";
String memberIdStr = memberId != null ? memberId.toString() : "";
Matcher callerListenOnly = CALLERNAME_LISTENONLY_PATTERN.matcher(origCallerIdName); Matcher callerListenOnly = CALLERNAME_LISTENONLY_PATTERN.matcher(origCallerIdName);
Matcher callWithSess = CALLERNAME_WITH_SESS_INFO_PATTERN.matcher(origCallerIdName); Matcher callWithSess = CALLERNAME_WITH_SESS_INFO_PATTERN.matcher(origCallerIdName);
@ -397,6 +407,7 @@ public class ESLEventListener implements IEslEventListener {
coreuuid, coreuuid,
clientSession, clientSession,
voiceUserId, voiceUserId,
memberIdStr,
callerName, callerName,
callState, callState,
origCallerIdName, origCallerIdName,
@ -405,6 +416,7 @@ public class ESLEventListener implements IEslEventListener {
conferenceEventListener.handleConferenceEvent(csEvent); conferenceEventListener.handleConferenceEvent(csEvent);
} else if ("RINGING".equalsIgnoreCase(channelCallState) && "CS_EXECUTE".equalsIgnoreCase(channelState)) { } else if ("RINGING".equalsIgnoreCase(channelCallState) && "CS_EXECUTE".equalsIgnoreCase(channelState)) {
Integer memberId = this.getMemberId(eventHeaders);
String origCallerIdName = eventHeaders.get("Caller-Caller-ID-Name"); String origCallerIdName = eventHeaders.get("Caller-Caller-ID-Name");
String origCallerDestNumber = eventHeaders.get("Caller-Destination-Number"); String origCallerDestNumber = eventHeaders.get("Caller-Destination-Number");
String coreuuid = eventHeaders.get("Core-UUID"); String coreuuid = eventHeaders.get("Core-UUID");
@ -414,6 +426,7 @@ public class ESLEventListener implements IEslEventListener {
String callerName = origCallerIdName; String callerName = origCallerIdName;
String clientSession = "0"; String clientSession = "0";
String callState = "CALL_STARTED"; String callState = "CALL_STARTED";
String memberIdStr = memberId != null ? memberId.toString() : "";
Matcher callerListenOnly = CALLERNAME_LISTENONLY_PATTERN.matcher(origCallerIdName); Matcher callerListenOnly = CALLERNAME_LISTENONLY_PATTERN.matcher(origCallerIdName);
Matcher callWithSess = CALLERNAME_WITH_SESS_INFO_PATTERN.matcher(origCallerIdName); Matcher callWithSess = CALLERNAME_WITH_SESS_INFO_PATTERN.matcher(origCallerIdName);
@ -437,6 +450,7 @@ public class ESLEventListener implements IEslEventListener {
coreuuid, coreuuid,
clientSession, clientSession,
voiceUserId, voiceUserId,
memberIdStr,
callerName, callerName,
callState, callState,
origCallerIdName, origCallerIdName,

View File

@ -229,6 +229,7 @@ class VoiceConferenceService(healthz: HealthzService,
callSession: String, callSession: String,
clientSession: String, clientSession: String,
userId: String, userId: String,
voiceUserId: String,
callerName: String, callerName: String,
callState: String, callState: String,
origCallerIdName: String, origCallerIdName: String,
@ -240,6 +241,7 @@ class VoiceConferenceService(healthz: HealthzService,
callSession = callSession, callSession = callSession,
clientSession = clientSession, clientSession = clientSession,
userId = userId, userId = userId,
voiceUserId = voiceUserId,
callerName = callerName, callerName = callerName,
callState = callState, callState = callState,
origCallerIdName = origCallerIdName, origCallerIdName = origCallerIdName,

View File

@ -555,6 +555,7 @@ case class VoiceConfCallStateEvtMsgBody(
callSession: String, callSession: String,
clientSession: String, clientSession: String,
userId: String, userId: String,
voiceUserId: String,
callerName: String, callerName: String,
callState: String, callState: String,
origCallerIdName: String, origCallerIdName: String,