Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Detection of muting, checks only audio source. #571

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading