Skip to content

Commit 389b69f

Browse files
bbaldinobgrozev
andauthored
Update the BitrateController any time the active speaker changes (#1114)
Fixes an issue where we wouldn't forward the proper streams in last-n due to the BitrateController not getting the needed notifications of active speaker ordering changes. Co-authored-by: Boris Grozev <boris@jitsi.org>
1 parent e19690c commit 389b69f

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

src/main/java/org/jitsi/videobridge/Conference.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ void dominantSpeakerChanged()
447447
getVideobridge().getStatistics().totalDominantSpeakerChanges.increment();
448448
}
449449

450+
speechActivityEndpointsChanged(speechActivity.getEndpointIds());
451+
450452
if (dominantSpeaker != null)
451453
{
452454
broadcastMessage(
@@ -1068,11 +1070,10 @@ public void setLastKnownFocus(Jid jid)
10681070
/**
10691071
* Notifies this instance that the list of ordered endpoints has changed
10701072
*/
1071-
void speechActivityEndpointsChanged()
1073+
void speechActivityEndpointsChanged(List<String> newEndpointIds)
10721074
{
1073-
List<String> endpoints = speechActivity.getEndpointIds();
10741075
endpointsCache.forEach(
1075-
e -> e.speechActivityEndpointsChanged(endpoints));
1076+
e -> e.speechActivityEndpointsChanged(newEndpointIds));
10761077
}
10771078

10781079
/**

src/main/java/org/jitsi/videobridge/ConferenceSpeechActivity.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ public void endpointsChanged()
418418
{
419419
final boolean finalDominantSpeakerChanged = dominantSpeakerChanged;
420420
final boolean finalEndpointsChanged = endpointsListChanged;
421+
final List<String> finalNewEndpointIds = getEndpointIds();
421422
TaskPools.IO_POOL.submit(() -> {
422423
final Conference conference = this.conference;
423424
if (conference == null)
@@ -428,9 +429,10 @@ public void endpointsChanged()
428429
{
429430
conference.dominantSpeakerChanged();
430431
}
431-
if (finalEndpointsChanged)
432+
// Dominant speaker changed implies that the list changed.
433+
if (finalEndpointsChanged && !finalDominantSpeakerChanged)
432434
{
433-
conference.speechActivityEndpointsChanged();
435+
conference.speechActivityEndpointsChanged(finalNewEndpointIds);
434436
}
435437

436438
});

src/main/java/org/jitsi/videobridge/cc/BitrateController.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,14 @@ private TrackBitrateAllocation[] prioritize(
922922
// of the conference.
923923
adjustedLastN = Math.min(lastN, conferenceEndpoints.size() - 1);
924924
}
925+
if (logger.isDebugEnabled())
926+
{
927+
logger.debug("Prioritizing endpoints, adjusted last-n: " + adjustedLastN +
928+
", sorted endpoint list: " +
929+
conferenceEndpoints.stream().map(AbstractEndpoint::getID).collect(Collectors.joining(", ")) +
930+
". Selected endpoints: " + String.join(", ", selectedEndpointIds) +
931+
". Pinned endpoints: " + String.join(", ", pinnedEndpointIds));
932+
}
925933

926934
int endpointPriority = 0;
927935

@@ -935,6 +943,8 @@ private TrackBitrateAllocation[] prioritize(
935943
|| sourceEndpoint.getID().equals(destinationEndpoint.getID())
936944
|| !selectedEndpointIds.contains(sourceEndpoint.getID()))
937945
{
946+
logger.trace(() -> "Endpoint " + sourceEndpoint.getID() + " is expired, is this destination, or " +
947+
"is not selected; ignoring");
938948
continue;
939949
}
940950

@@ -954,6 +964,7 @@ private TrackBitrateAllocation[] prioritize(
954964
true /* selected */,
955965
maxRxFrameHeightPx));
956966
}
967+
logger.trace(() -> "Adding selected endpoint " + sourceEndpoint.getID() + " to allocations");
957968

958969
endpointPriority++;
959970
}
@@ -972,6 +983,8 @@ private TrackBitrateAllocation[] prioritize(
972983
|| sourceEndpoint.getID().equals(destinationEndpoint.getID())
973984
|| !pinnedEndpointIds.contains(sourceEndpoint.getID()))
974985
{
986+
logger.trace(() -> "Endpoint " + sourceEndpoint.getID() + " is expired, is this destination, or " +
987+
"is not pinned; ignoring");
975988
continue;
976989
}
977990

@@ -991,6 +1004,7 @@ endpointPriority, new TrackBitrateAllocation(
9911004
maxRxFrameHeightPx));
9921005
}
9931006

1007+
logger.trace(() -> "Adding pinned endpoint " + sourceEndpoint.getID() + " to allocations");
9941008
endpointPriority++;
9951009
}
9961010

@@ -1025,6 +1039,7 @@ endpointPriority, new TrackBitrateAllocation(
10251039
maxRxFrameHeightPx));
10261040
}
10271041

1042+
logger.trace(() -> "Adding endpoint " + sourceEndpoint.getID() + " to allocations");
10281043
endpointPriority++;
10291044
}
10301045
}

0 commit comments

Comments
 (0)