Skip to content

Commit 3c9d3c5

Browse files
authored
feat: Add a stat for endpoints with suspended sources. (#1910)
* feat: Add a stat for endpoints with suspended sources.
1 parent eec0775 commit 3c9d3c5

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

jvb/src/main/java/org/jitsi/videobridge/cc/allocation/BandwidthAllocator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ private List<String> getSelectedSources()
388388
targetBps += sourceBitrateAllocation.getTargetBitrate();
389389
idealBps += sourceBitrateAllocation.getIdealBitrate();
390390
}
391-
return new BandwidthAllocation(allocations, oversending, idealBps, targetBps);
391+
return new BandwidthAllocation(allocations, oversending, idealBps, targetBps, !suspendedIds.isEmpty());
392392
}
393393

394394
/**
@@ -461,7 +461,7 @@ private List<String> getSelectedSources()
461461
targetBps += sourceBitrateAllocation.getTargetBitrate();
462462
idealBps += sourceBitrateAllocation.getIdealBitrate();
463463
}
464-
return new BandwidthAllocation(allocations, oversending, idealBps, targetBps);
464+
return new BandwidthAllocation(allocations, oversending, idealBps, targetBps, !suspendedIds.isEmpty());
465465
}
466466

467467
/**

jvb/src/main/java/org/jitsi/videobridge/stats/VideobridgeStatistics.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ private void generate0()
258258
int numOversending = 0;
259259
int endpointsWithHighOutgoingLoss = 0;
260260
int numLocalActiveEndpoints = 0;
261+
int endpointsWithSuspendedSources = 0;
261262

262263
for (Conference conference : videobridge.getConferences())
263264
{
@@ -322,6 +323,10 @@ private void generate0()
322323
{
323324
receiveOnlyEndpoints++;
324325
}
326+
if (endpoint.hasSuspendedSources())
327+
{
328+
endpointsWithSuspendedSources++;
329+
}
325330
TransceiverStats transceiverStats = endpoint.getTransceiver().getTransceiverStats();
326331
IncomingStatisticsSnapshot incomingStats = transceiverStats.getRtpReceiverStats().getIncomingStats();
327332
PacketStreamStats.Snapshot incomingPacketStreamStats
@@ -585,6 +590,7 @@ private void generate0()
585590
unlockedSetStat(OCTO_SEND_BITRATE, relayBitrateOutgoingBps);
586591
unlockedSetStat(OCTO_SEND_PACKET_RATE, relayPacketRateOutgoing);
587592
unlockedSetStat(TOTAL_DOMINANT_SPEAKER_CHANGES, jvbStats.totalDominantSpeakerChanges.sum());
593+
unlockedSetStat("endpoints_with_suspended_sources", endpointsWithSuspendedSources);
588594

589595
unlockedSetStat(TIMESTAMP, timestampFormat.format(new Date()));
590596
if (relayId != null)

jvb/src/main/kotlin/org/jitsi/videobridge/Endpoint.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ class Endpoint @JvmOverloads constructor(
214214
isUsingSourceNames
215215
)
216216

217+
/** Whether any sources are suspended from being sent to this endpoint because of BWE. */
218+
fun hasSuspendedSources() = bitrateController.hasSuspendedSources()
219+
217220
/**
218221
* The instance which manages the Colibri messaging (over a data channel
219222
* or web sockets).

jvb/src/main/kotlin/org/jitsi/videobridge/cc/allocation/BandwidthAllocation.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class BandwidthAllocation @JvmOverloads constructor(
2828
val oversending: Boolean = false,
2929
val idealBps: Long = -1,
3030
val targetBps: Long = -1,
31+
/** Whether any of the requested sources were suspended (no layer at all was selected) due to BWE. */
32+
val hasSuspendedSources: Boolean = false
3133
) {
3234
val forwardedEndpoints: Set<String> =
3335
allocations.filter { it.isForwarded() }.map { it.endpointId }.toSet()
@@ -64,6 +66,8 @@ class BandwidthAllocation @JvmOverloads constructor(
6466
get() = JSONObject().apply {
6567
put("idealBps", idealBps)
6668
put("targetBps", targetBps)
69+
put("oversending", oversending.toString())
70+
put("has_suspended_sources", hasSuspendedSources.toString())
6771
}
6872
}
6973

jvb/src/main/kotlin/org/jitsi/videobridge/cc/allocation/BitrateController.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class BitrateController<T : MediaSourceContainer> @JvmOverloads constructor(
9696
diagnosticContext,
9797
clock
9898
)
99+
fun hasSuspendedSources() = bandwidthAllocator.allocation.hasSuspendedSources
99100

100101
private val allocationSettingsWrapper = AllocationSettingsWrapper(useSourceNames)
101102
val allocationSettings

0 commit comments

Comments
 (0)