Skip to content

Commit 7df2029

Browse files
Make the initial period to ignore BWE configurable. (#2324)
Don't allocate based on an uninitialized bwe.
1 parent f5b6c90 commit 7df2029

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ internal class BandwidthAllocator<T : MediaSourceContainer>(
377377
* @return true if the bandwidth has changed above the configured threshold, * false otherwise.
378378
*/
379379
private fun bweChangeIsLargerThanThreshold(previousBwe: Long, currentBwe: Long): Boolean {
380+
if (previousBwe == currentBwe) { // Even if we're "changing" -1 to -1
381+
return false
382+
}
380383
if (previousBwe == -1L || currentBwe == -1L) {
381384
return true
382385
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import org.jitsi.utils.logging.DiagnosticContext
2828
import org.jitsi.utils.logging.TimeSeriesLogger
2929
import org.jitsi.utils.logging2.Logger
3030
import org.jitsi.utils.logging2.createChildLogger
31-
import org.jitsi.utils.secs
3231
import org.jitsi.videobridge.cc.config.BitrateControllerConfig.Companion.config
3332
import org.jitsi.videobridge.message.ReceiverVideoConstraintsMessage
3433
import org.jitsi.videobridge.util.BooleanStateTimeTracker
@@ -104,13 +103,15 @@ class BitrateController<T : MediaSourceContainer> @JvmOverloads constructor(
104103
eventEmitter.addHandler(eventHandler)
105104
}
106105

106+
private var bweSet = false
107+
107108
/**
108-
* Ignore the bandwidth estimations in the first 10 seconds because the REMBs don't ramp up fast enough. This needs
109-
* to go but it's related to our GCC implementation that needs to be brought up to speed.
110-
* TODO: Is this comment still accurate?
109+
* Ignore the bandwidth estimations for some initial time because the REMBs don't ramp up fast enough.
110+
* This shouldn't be needed for other bandwidth estimation algorithms.
111111
*/
112112
private val trustBwe: Boolean
113-
get() = config.trustBwe && supportsRtx && packetHandler.timeSinceFirstMedia() >= 10.secs
113+
get() = config.trustBwe && supportsRtx && bweSet &&
114+
packetHandler.timeSinceFirstMedia() >= config.initialIgnoreBwePeriod
114115

115116
// Proxy to the allocator
116117
fun endpointOrderingChanged() = bandwidthAllocator.update()
@@ -129,6 +130,7 @@ class BitrateController<T : MediaSourceContainer> @JvmOverloads constructor(
129130
fun getTotalOversendingTime(): Duration = oversendingTimeTracker.totalTimeOn()
130131
fun isOversending() = oversendingTimeTracker.state
131132
fun bandwidthChanged(newBandwidthBps: Long) {
133+
bweSet = true
132134
timeSeriesLogger?.logBweChange(newBandwidthBps)
133135
bandwidthAllocator.bandwidthChanged(newBandwidthBps)
134136
}

jvb/src/main/kotlin/org/jitsi/videobridge/cc/config/BitrateControllerConfig.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ class BitrateControllerConfig private constructor() {
114114
"videobridge.cc.use-vla-target-bitrate".from(JitsiConfig.newConfig)
115115
}
116116

117+
/**
118+
* How long after first media to ignore bandwidth estimation. Needed for BWE
119+
* algorithms that ramp up slowly; should be set to zero if this isn't a problem.
120+
*/
121+
val initialIgnoreBwePeriod: Duration by config(
122+
"videobridge.cc.initial-ignore-bwe-period".from(JitsiConfig.newConfig)
123+
)
124+
117125
companion object {
118126
@JvmField
119127
val config = BitrateControllerConfig()

jvb/src/main/resources/reference.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ videobridge {
8181
# Whether to use the target bitrate signaled in the VLA extension for allocation. When disabled we use the measured
8282
# bitrate instead (preserving previous behavior).
8383
use-vla-target-bitrate = false
84+
85+
# How long after first media to ignore bandwidth estimation for the purposes of allocation. Needed
86+
# for bwe algorithms that ramp up slowly; should be set to zero if this isn't a problem.
87+
initial-ignore-bwe-period = 10 seconds
8488
}
8589
# Whether to indicate support for cryptex header extension encryption (RFC 9335)
8690
cryptex {

jvb/src/test/kotlin/org/jitsi/videobridge/cc/allocation/BitrateControllerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ class BitrateControllerWrapper(initialEndpoints: List<MediaSourceContainer>, val
14031403
DiagnosticContext(),
14041404
logger,
14051405
clock
1406-
)
1406+
).apply { bandwidthChanged(bwe.bps.toLong()) } // TODO: handle the -1 bps case better
14071407

14081408
fun setEndpointOrdering(vararg endpoints: TestEndpoint) {
14091409
logger.info("Set endpoints ${endpoints.map{ it.id }.joinToString(",")}")

0 commit comments

Comments
 (0)