Skip to content

Commit

Permalink
fix: Detection of muting, checks only audio source.
Browse files Browse the repository at this point in the history
Fixes ArrayIndexOutOfBoundsException when participant is audio and video muted.
  • Loading branch information
damencho committed Nov 1, 2024
1 parent 8456fe8 commit c0617b8
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/main/java/org/jitsi/jigasi/TranscriptionGatewaySession.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -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
Expand Down Expand Up @@ -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<String, JSONObject> jsonObject = (HashMap<String, JSONObject>) 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));
}
Expand Down

0 comments on commit c0617b8

Please sign in to comment.