Skip to content

Commit

Permalink
fix: Sources with type NONE should not have effective constraints (#2292
Browse files Browse the repository at this point in the history
)

* 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.
  • Loading branch information
bgrozev authored Feb 21, 2025
1 parent 17b7e28 commit cda9e6b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fun getEffectiveConstraints(
var sourcesWithNonZeroConstraints = 0

return sources.associateWith { source ->
if (sourcesWithNonZeroConstraints >= effectiveLastN) {
if (!source.videoType.isEnabled() || sourcesWithNonZeroConstraints >= effectiveLastN) {
VideoConstraints.NOTHING
} else {
allocationSettings.getConstraints(source.sourceName).also {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class EffectiveConstraintsTest : ShouldSpec() {
val s3 = testSource("e1", "s3")
val s4 = testSource("e1", "s4", videoType = VideoType.DISABLED)
val s5 = testSource("e1", "s5", videoType = VideoType.DISABLED)
val s6 = testSource("e1", "s6", videoType = VideoType.DISABLED)
val s6 = testSource("e1", "s6", videoType = VideoType.NONE)

val defaultConstraints = VideoConstraints(180)

Expand Down Expand Up @@ -97,9 +97,7 @@ class EffectiveConstraintsTest : ShouldSpec() {
defaultConstraints = VideoConstraints.NOTHING,
videoConstraints = mapOf("s4" to VideoConstraints(720))
)
getEffectiveConstraints(sources, allocationSettings) shouldBe zeroEffectiveConstraints.apply {
put(s4, VideoConstraints(720))
}
getEffectiveConstraints(sources, allocationSettings) shouldBe zeroEffectiveConstraints
}
context("When the top sources have the video DISABLED") {
// The top sources in speaker order have videoType = DISABLED
Expand All @@ -108,7 +106,7 @@ class EffectiveConstraintsTest : ShouldSpec() {
context("With default settings") {
val allocationSettings = AllocationSettings(lastN = 1, defaultConstraints = defaultConstraints)
getEffectiveConstraints(sources, allocationSettings) shouldBe zeroEffectiveConstraints.apply {
put(s4, VideoConstraints(180))
put(s1, VideoConstraints(180))
}
}
context("With default constraints 0 and non-zero constraints for a source with video DISABLED") {
Expand All @@ -117,9 +115,7 @@ class EffectiveConstraintsTest : ShouldSpec() {
defaultConstraints = VideoConstraints.NOTHING,
videoConstraints = mapOf("s5" to VideoConstraints(180))
)
getEffectiveConstraints(sources, allocationSettings) shouldBe zeroEffectiveConstraints.apply {
put(s5, VideoConstraints(180))
}
getEffectiveConstraints(sources, allocationSettings) shouldBe zeroEffectiveConstraints
}
context("With default constraints 0 and non-zero constraints for a source with video enabled") {
val allocationSettings = AllocationSettings(
Expand Down Expand Up @@ -159,9 +155,9 @@ class EffectiveConstraintsTest : ShouldSpec() {
context("And default settings") {
val allocationSettings = AllocationSettings(lastN = 3, defaultConstraints = defaultConstraints)
getEffectiveConstraints(endpoints, allocationSettings) shouldBe zeroEffectiveConstraints.apply {
put(s4, VideoConstraints(180))
put(s5, VideoConstraints(180))
put(s6, VideoConstraints(180))
put(s1, VideoConstraints(180))
put(s2, VideoConstraints(180))
put(s3, VideoConstraints(180))
}
}
context("And non-zero constraints for sources down the list") {
Expand All @@ -175,7 +171,6 @@ class EffectiveConstraintsTest : ShouldSpec() {
)
)
getEffectiveConstraints(endpoints, allocationSettings) shouldBe zeroEffectiveConstraints.apply {
put(s6, VideoConstraints(180))
put(s2, VideoConstraints(180))
put(s3, VideoConstraints(180))
}
Expand Down

0 comments on commit cda9e6b

Please sign in to comment.