Skip to content

Commit

Permalink
feat: Adds notification for conference audio recordings. (#564)
Browse files Browse the repository at this point in the history
* feat: Adds notification for conference audio recordings.

* squash: Fixes comments and updates the dependency.

* squash: Fix jibri on check.

* squash: Update src/main/java/org/jitsi/jigasi/sounds/SoundNotificationManager.java

Co-authored-by: bgrozev <[email protected]>

---------

Co-authored-by: bgrozev <[email protected]>
  • Loading branch information
damencho and bgrozev authored Nov 4, 2024
1 parent c0617b8 commit dc190a0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jitsi-xmpp-extensions</artifactId>
<version>1.0-78-g62d03d4</version>
<version>1.0-82-ge8aacab</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/jitsi/jigasi/JigasiBundleActivator.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,17 @@ public void startWithServices(final BundleContext bundleContext)
new DefaultPacketExtensionProvider<>(RecordingStatus.class)
);

ProviderManager.addExtensionProvider(
ConferenceProperties.ELEMENT,
ConferenceProperties.NAMESPACE,
new DefaultPacketExtensionProvider<>(ConferenceProperties.class)
);
ProviderManager.addExtensionProvider(
ConferenceProperties.ConferenceProperty.ELEMENT,
ConferenceProperties.NAMESPACE,
new DefaultPacketExtensionProvider<>(ConferenceProperties.ConferenceProperty.class)
);

logger.info("initialized SipGateway");
sipGateway = new SipGateway(bundleContext)
{
Expand Down
42 changes: 31 additions & 11 deletions src/main/java/org/jitsi/jigasi/sounds/SoundNotificationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.jitsi.utils.*;
import org.jitsi.utils.logging.Logger;
import org.jitsi.xmpp.extensions.jibri.*;
import org.jitsi.xmpp.extensions.jitsimeet.*;
import org.jivesoftware.smack.packet.*;

import java.util.*;
Expand Down Expand Up @@ -232,13 +233,37 @@ private CallContext getCallContext()
*/
public void process(Presence presence)
{
RecordingStatus rs = presence.getExtension(RecordingStatus.class);

if (rs != null
&& gatewaySession.getFocusResourceAddr().equals(
presence.getFrom().getResourceOrEmpty().toString()))
if (gatewaySession.getFocusResourceAddr().equals(presence.getFrom().getResourceOrEmpty().toString()))
{
notifyRecordingStatusChanged(rs.getRecordingMode(), rs.getStatus());
boolean isJibriRecordingOn = false;
RecordingStatus rs = presence.getExtension(RecordingStatus.class);
if (rs != null)
{
isJibriRecordingOn = rs.getStatus() == JibriIq.Status.ON;
}

boolean isAudioRecordingOn = false;
ConferenceProperties props = presence.getExtension(ConferenceProperties.class);

if (props != null)
{
ConferenceProperties.ConferenceProperty prop
= props.getProperties().stream()
.filter(p -> ConferenceProperties.KEY_AUDIO_RECORDING_ENABLED.equals(p.getKey()))
.findFirst().orElse(null);

isAudioRecordingOn = prop != null && Boolean.parseBoolean(prop.getValue());
}

JibriIq.Status newStatus
= isJibriRecordingOn || isAudioRecordingOn ? JibriIq.Status.ON : JibriIq.Status.OFF;

if (currentJibriStatus.equals(newStatus))
{
return;
}

notifyRecordingStatusChanged(rs != null ? rs.getRecordingMode() : JibriIq.RecordingMode.FILE, newStatus);
}
}

Expand All @@ -251,11 +276,6 @@ public void process(Presence presence)
private void notifyRecordingStatusChanged(
JibriIq.RecordingMode mode, JibriIq.Status status)
{
// not a change, ignore
if (currentJibriStatus.equals(status))
{
return;
}
currentJibriStatus = status;

String offSound;
Expand Down

0 comments on commit dc190a0

Please sign in to comment.