Skip to content

Commit cda9e6b

Browse files
authored
fix: Sources with type NONE should not have effective constraints (#2292)
* fix: Sources with type NONE should not have effective constraints. When a source has video type NONE or DISABLED, it has been signaled but is not transmitted. For the purpose of generating effective constraints, it should be as if the source was not present. A change of effective constraints is the trigger for creating a new mapping for a receiver. If a receiver has effective constraints for a source with type NONE, and that source is later enabled, the effective constraints don't change, and the mapping is not created. This should fix #2288. * squash: Adjust unit tests.
1 parent 17b7e28 commit cda9e6b

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fun getEffectiveConstraints(
7474
var sourcesWithNonZeroConstraints = 0
7575

7676
return sources.associateWith { source ->
77-
if (sourcesWithNonZeroConstraints >= effectiveLastN) {
77+
if (!source.videoType.isEnabled() || sourcesWithNonZeroConstraints >= effectiveLastN) {
7878
VideoConstraints.NOTHING
7979
} else {
8080
allocationSettings.getConstraints(source.sourceName).also {

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

+7-12
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class EffectiveConstraintsTest : ShouldSpec() {
4141
val s3 = testSource("e1", "s3")
4242
val s4 = testSource("e1", "s4", videoType = VideoType.DISABLED)
4343
val s5 = testSource("e1", "s5", videoType = VideoType.DISABLED)
44-
val s6 = testSource("e1", "s6", videoType = VideoType.DISABLED)
44+
val s6 = testSource("e1", "s6", videoType = VideoType.NONE)
4545

4646
val defaultConstraints = VideoConstraints(180)
4747

@@ -97,9 +97,7 @@ class EffectiveConstraintsTest : ShouldSpec() {
9797
defaultConstraints = VideoConstraints.NOTHING,
9898
videoConstraints = mapOf("s4" to VideoConstraints(720))
9999
)
100-
getEffectiveConstraints(sources, allocationSettings) shouldBe zeroEffectiveConstraints.apply {
101-
put(s4, VideoConstraints(720))
102-
}
100+
getEffectiveConstraints(sources, allocationSettings) shouldBe zeroEffectiveConstraints
103101
}
104102
context("When the top sources have the video DISABLED") {
105103
// The top sources in speaker order have videoType = DISABLED
@@ -108,7 +106,7 @@ class EffectiveConstraintsTest : ShouldSpec() {
108106
context("With default settings") {
109107
val allocationSettings = AllocationSettings(lastN = 1, defaultConstraints = defaultConstraints)
110108
getEffectiveConstraints(sources, allocationSettings) shouldBe zeroEffectiveConstraints.apply {
111-
put(s4, VideoConstraints(180))
109+
put(s1, VideoConstraints(180))
112110
}
113111
}
114112
context("With default constraints 0 and non-zero constraints for a source with video DISABLED") {
@@ -117,9 +115,7 @@ class EffectiveConstraintsTest : ShouldSpec() {
117115
defaultConstraints = VideoConstraints.NOTHING,
118116
videoConstraints = mapOf("s5" to VideoConstraints(180))
119117
)
120-
getEffectiveConstraints(sources, allocationSettings) shouldBe zeroEffectiveConstraints.apply {
121-
put(s5, VideoConstraints(180))
122-
}
118+
getEffectiveConstraints(sources, allocationSettings) shouldBe zeroEffectiveConstraints
123119
}
124120
context("With default constraints 0 and non-zero constraints for a source with video enabled") {
125121
val allocationSettings = AllocationSettings(
@@ -159,9 +155,9 @@ class EffectiveConstraintsTest : ShouldSpec() {
159155
context("And default settings") {
160156
val allocationSettings = AllocationSettings(lastN = 3, defaultConstraints = defaultConstraints)
161157
getEffectiveConstraints(endpoints, allocationSettings) shouldBe zeroEffectiveConstraints.apply {
162-
put(s4, VideoConstraints(180))
163-
put(s5, VideoConstraints(180))
164-
put(s6, VideoConstraints(180))
158+
put(s1, VideoConstraints(180))
159+
put(s2, VideoConstraints(180))
160+
put(s3, VideoConstraints(180))
165161
}
166162
}
167163
context("And non-zero constraints for sources down the list") {
@@ -175,7 +171,6 @@ class EffectiveConstraintsTest : ShouldSpec() {
175171
)
176172
)
177173
getEffectiveConstraints(endpoints, allocationSettings) shouldBe zeroEffectiveConstraints.apply {
178-
put(s6, VideoConstraints(180))
179174
put(s2, VideoConstraints(180))
180175
put(s3, VideoConstraints(180))
181176
}

0 commit comments

Comments
 (0)