diff --git a/jvb/src/main/java/org/jitsi/videobridge/Conference.java b/jvb/src/main/java/org/jitsi/videobridge/Conference.java index db0303d4ba..f769b94e26 100644 --- a/jvb/src/main/java/org/jitsi/videobridge/Conference.java +++ b/jvb/src/main/java/org/jitsi/videobridge/Conference.java @@ -69,6 +69,16 @@ public class Conference */ private final ConcurrentHashMap endpointsById = new ConcurrentHashMap<>(); + /** + * A boolean that indicates whether or not to include RTCStats for this call. + */ + private final boolean isRtcStatsEnabled; + + /** + * A boolean that indicates whether or not to report to CallStats for this call. + */ + private final boolean isCallStatsEnabled; + /** * A read-only cache of the endpoints in this conference. Note that it * contains only the {@link Endpoint} instances (local endpoints, not Octo endpoints). @@ -188,7 +198,9 @@ public Conference(Videobridge videobridge, String id, EntityBareJid conferenceName, long gid, - @Nullable String meetingId) + @Nullable String meetingId, + boolean isRtcStatsEnabled, + boolean isCallStatsEnabled) { if (gid != GID_NOT_SET && (gid < 0 || gid > 0xffff_ffffL)) { @@ -196,6 +208,8 @@ public Conference(Videobridge videobridge, } this.meetingId = meetingId; this.videobridge = Objects.requireNonNull(videobridge, "videobridge"); + this.isRtcStatsEnabled = isRtcStatsEnabled; + this.isCallStatsEnabled = isCallStatsEnabled; Map context = JMap.ofEntries( entry("confId", id), entry("gid", String.valueOf(gid)) @@ -789,6 +803,11 @@ public final String getID() return id; } + public final boolean isCallStatsEnabled() + { + return isCallStatsEnabled; + } + /** * Gets an Endpoint participating in this Conference which * has a specific identifier/ID. @@ -1174,6 +1193,8 @@ public JSONObject getDebugState(boolean full, String endpointId) { JSONObject debugState = new JSONObject(); debugState.put("id", id); + debugState.put("rtcstatsEnabled", isRtcStatsEnabled); + if (conferenceName != null) { debugState.put("name", conferenceName.toString()); diff --git a/jvb/src/main/java/org/jitsi/videobridge/Videobridge.java b/jvb/src/main/java/org/jitsi/videobridge/Videobridge.java index 9bcfde5e69..6033fa7d59 100644 --- a/jvb/src/main/java/org/jitsi/videobridge/Videobridge.java +++ b/jvb/src/main/java/org/jitsi/videobridge/Videobridge.java @@ -196,7 +196,9 @@ public Videobridge( * Generate conference IDs until one is found that isn't in use and create a new {@link Conference} * object using that ID */ - private @NotNull Conference doCreateConference(EntityBareJid name, long gid, String meetingId) + private @NotNull Conference doCreateConference( + EntityBareJid name, long gid, String meetingId, + boolean isRtcStatsEnabled, boolean isCallStatsEnabled) { Conference conference = null; do @@ -207,7 +209,7 @@ public Videobridge( { if (!conferencesById.containsKey(id)) { - conference = new Conference(this, id, name, gid, meetingId); + conference = new Conference(this, id, name, gid, meetingId, isRtcStatsEnabled, isCallStatsEnabled); conferencesById.put(id, conference); } } @@ -228,7 +230,8 @@ public Videobridge( */ public @NotNull Conference createConference(EntityBareJid name) { - return createConference(name, Conference.GID_NOT_SET, null); + // we default to rtcstatsEnabled=false and callstatsEnabled=false because this is only used for testing + return createConference(name, Conference.GID_NOT_SET, null, false, false); } /** @@ -243,9 +246,10 @@ public Videobridge( * @return a new Conference instance with an ID unique to the * Conference instances listed by this Videobridge */ - public @NotNull Conference createConference(EntityBareJid name, long gid, String meetingId) + public @NotNull Conference createConference( + EntityBareJid name, long gid, String meetingId, boolean isRtcStatsEnabled, boolean isCallStatsEnabled) { - final Conference conference = doCreateConference(name, gid, meetingId); + final Conference conference = doCreateConference(name, gid, meetingId, isRtcStatsEnabled, isCallStatsEnabled); logger.info(() -> "create_conf, id=" + conference.getID() + " gid=" + conference.getGid()); @@ -427,7 +431,9 @@ private void handleColibriRequest(XmppConnection.ColibriRequest request) return createConference( conferenceIq.getName(), ColibriUtil.parseGid(conferenceIq.getGID()), - conferenceIq.getMeetingId()); + conferenceIq.getMeetingId(), + conferenceIq.isRtcStatsEnabled(), + conferenceIq.isCallStatsEnabled()); } else { diff --git a/jvb/src/main/java/org/jitsi/videobridge/stats/callstats/CallstatsConferenceManager.java b/jvb/src/main/java/org/jitsi/videobridge/stats/callstats/CallstatsConferenceManager.java index bfa8c9ed18..b5119114cd 100644 --- a/jvb/src/main/java/org/jitsi/videobridge/stats/callstats/CallstatsConferenceManager.java +++ b/jvb/src/main/java/org/jitsi/videobridge/stats/callstats/CallstatsConferenceManager.java @@ -101,7 +101,7 @@ public void stop() @Override public void conferenceCreated(@NotNull Conference conference) { - if (conference.getName() != null) + if (conference.getName() != null && conference.isCallStatsEnabled()) { // Create a new PeriodicRunnable and start it. ConferencePeriodicRunnable cpr = new ConferencePeriodicRunnable( @@ -125,6 +125,11 @@ public void conferenceCreated(@NotNull Conference conference) @Override public void conferenceExpired(@NotNull Conference conference) { + if (!conference.isCallStatsEnabled()) + { + return; + } + ConferencePeriodicRunnable cpr = statisticsProcessors.remove(conference); if (cpr == null) diff --git a/jvb/src/test/kotlin/org/jitsi/videobridge/ConferenceTest.kt b/jvb/src/test/kotlin/org/jitsi/videobridge/ConferenceTest.kt index e2dc526424..c8fdf740da 100644 --- a/jvb/src/test/kotlin/org/jitsi/videobridge/ConferenceTest.kt +++ b/jvb/src/test/kotlin/org/jitsi/videobridge/ConferenceTest.kt @@ -41,7 +41,7 @@ class ConferenceTest : ConfigTest() { } context("Adding local endpoints should work") { - with(Conference(videobridge, "id", name, Conference.GID_NOT_SET, null)) { + with(Conference(videobridge, "id", name, Conference.GID_NOT_SET, null, false, false)) { endpointCount shouldBe 0 createLocalEndpoint("abcdabcd", true) endpointCount shouldBe 1 @@ -49,7 +49,7 @@ class ConferenceTest : ConfigTest() { } } context("Enabling octo should fail when the GID is not set") { - with(Conference(videobridge, "id", name, Conference.GID_NOT_SET, null)) { + with(Conference(videobridge, "id", name, Conference.GID_NOT_SET, null, false, false)) { isOctoEnabled shouldBe false shouldThrow { tentacle @@ -58,7 +58,7 @@ class ConferenceTest : ConfigTest() { } } context("Enabling octo should work") { - with(Conference(videobridge, "id", name, 1234, null)) { + with(Conference(videobridge, "id", name, 1234, null, false, false)) { isOctoEnabled shouldBe false tentacle isOctoEnabled shouldBe true diff --git a/pom.xml b/pom.xml index 5a01ec0120..7573b1c48a 100644 --- a/pom.xml +++ b/pom.xml @@ -112,7 +112,7 @@ ${project.groupId} jitsi-xmpp-extensions - 1.0-35-g090af0a + 1.0-36-gc8f4179 ${project.groupId}