diff --git a/src/main/java/org/jitsi/jigasi/TranscriptionGatewaySession.java b/src/main/java/org/jitsi/jigasi/TranscriptionGatewaySession.java index 03b7c134..797f187f 100644 --- a/src/main/java/org/jitsi/jigasi/TranscriptionGatewaySession.java +++ b/src/main/java/org/jitsi/jigasi/TranscriptionGatewaySession.java @@ -19,7 +19,6 @@ import net.java.sip.communicator.impl.protocol.jabber.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.protocol.Message; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.media.*; import org.jitsi.utils.concurrent.*; @@ -38,6 +37,7 @@ import java.util.*; import java.util.concurrent.*; +import java.util.concurrent.atomic.*; /** * A TranscriptionGatewaySession is able to join a JVB conference and @@ -354,26 +354,32 @@ void notifyChatRoomMemberLeft(ChatRoomMember chatMember) **/ private void flushParticipantTranscriptionBufferOnMute(ChatRoomMember chatMember, Presence presence) { - boolean hasMuted = false; - StandardExtensionElement sourceInfo = (StandardExtensionElement) presence.getExtensionElement("SourceInfo", - "jabber:client"); + final AtomicBoolean muted = new AtomicBoolean(false); + StandardExtensionElement sourceInfo = + (StandardExtensionElement) presence.getExtensionElement("SourceInfo", "jabber:client"); if (sourceInfo != null) { String mutedText = sourceInfo.getText(); JSONParser jsonParser = new JSONParser(); try { - JSONObject jsonObject = (JSONObject) jsonParser.parse(mutedText); - String participantKey = jsonObject.keySet().toArray()[0].toString(); - JSONObject mutedJsonObject = (JSONObject) jsonParser.parse(jsonObject.get(participantKey).toString()); - hasMuted = (boolean) mutedJsonObject.get("muted"); + HashMap jsonObject = (HashMap) jsonParser.parse(mutedText); + jsonObject.forEach((key, value) -> + { + // check only audio source info + if (key.endsWith("a0")) + { + Object isMuted = value.get("muted"); + muted.set(isMuted != null && (boolean) isMuted); + } + }); } catch (Exception e) { logger.error(this.callContext + " Error parsing presence while checking if participant is muted", e); } - if (hasMuted) + if (muted.get()) { this.transcriber.flushParticipantAudioBuffer(getParticipantIdentifier(chatMember)); }