@@ -51,6 +51,24 @@ class Bridge
5151 */
5252 private static final String STAT_NAME_VIDEO_STREAMS = "videostreams" ;
5353
54+ /**
55+ * The name of the stat used by jitsi-videobridge to indicate the current
56+ * upload bitrate in Kbps.
57+ * video streams. This should match
58+ * {@code VideobridgeStatistics.BITRATE_UPLOAD}, but is defined separately
59+ * to avoid depending on the {@code jitsi-videobridge} maven package.
60+ */
61+ private static final String STAT_NAME_BITRATE_UP = "bit_rate_upload" ;
62+
63+ /**
64+ * The name of the stat used by jitsi-videobridge to indicate the current
65+ * download bitrate in Kbps.
66+ * video streams. This should match
67+ * {@code VideobridgeStatistics.BITRATE_DOWNLOAD}, but is defined separately
68+ * to avoid depending on the {@code jitsi-videobridge} maven package.
69+ */
70+ private static final String STAT_NAME_BITRATE_DOWN = "bit_rate_download" ;
71+
5472 /**
5573 * The name of the stat used by jitsi-videobridge to indicate its region.
5674 * This should match {@code VideobridgeStatistics.REGION}, but is defined
@@ -101,6 +119,11 @@ class Bridge
101119 */
102120 private int videoStreamCountDiff = 0 ;
103121
122+ /**
123+ * The last reported bitrate in Kbps.
124+ */
125+ private int lastReportedBitrateKbps = 0 ;
126+
104127 /**
105128 * Holds bridge version (if known - not all bridge version are capable of
106129 * reporting it).
@@ -154,6 +177,13 @@ void setStats(ColibriStatsExtension stats)
154177 setVideoStreamCount (videoStreamCount );
155178 }
156179
180+ Integer bitrateUpKbps = stats .getValueAsInt (STAT_NAME_BITRATE_UP );
181+ Integer bitrateDownKbps = stats .getValueAsInt (STAT_NAME_BITRATE_DOWN );
182+ if (bitrateUpKbps != null && bitrateDownKbps != null )
183+ {
184+ lastReportedBitrateKbps = bitrateDownKbps + bitrateUpKbps ;
185+ }
186+
157187 setIsOperational (!Boolean .valueOf (stats .getValueAsString (
158188 JigasiDetector .STAT_NAME_SHUTDOWN_IN_PROGRESS )));
159189 }
@@ -249,7 +279,8 @@ private void verifyFailureThreshold()
249279 }
250280
251281 /**
252- * The least value is returned the least the bridge is loaded.
282+ * The least value is returned the least the bridge is loaded. Currently
283+ * we use the bitrate to estimate load.
253284 * <p>
254285 * {@inheritDoc}
255286 */
@@ -268,8 +299,7 @@ else if (!meOperational && otherOperational)
268299 return 1 ;
269300 }
270301
271- return this .getEstimatedVideoStreamCount ()
272- - o .getEstimatedVideoStreamCount ();
302+ return this .lastReportedBitrateKbps - o .lastReportedBitrateKbps ;
273303 }
274304
275305 private int getEstimatedVideoStreamCount ()
0 commit comments