From 5592e0525e22c9549918043ec9ac9873964d426d Mon Sep 17 00:00:00 2001 From: Suchith J N Date: Fri, 29 Sep 2023 14:03:01 +0530 Subject: [PATCH] pick maxFramerate, maxBitrate and priority parameters from the ChangePublishQuality message --- packages/client/src/rtc/Publisher.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/client/src/rtc/Publisher.ts b/packages/client/src/rtc/Publisher.ts index ec4c21f498..87de83f8f5 100644 --- a/packages/client/src/rtc/Publisher.ts +++ b/packages/client/src/rtc/Publisher.ts @@ -438,6 +438,26 @@ export class Publisher { } if (shouldEnable) { let layer = enabledLayers.find(vls => vls.name === enc.rid); + if (layer !== undefined) { + + // It is possible that the SDK changes are deployed before SFU. Older SFUs + // send 0 and it must not be considered. The minimum valid value is 1.0 + // because resolution scale up is not allowed + if (layer.scaleResolutionDownBy >= 1 && layer.scaleResolutionDownBy !== enc.scaleResolutionDownBy) { + enc.scaleResolutionDownBy = layer.scaleResolutionDownBy; + changed = true; + } + if (layer.maxBitrate > 0 && layer.maxBitrate !== enc.maxBitrate) { + enc.maxBitrate = layer.maxBitrate; + changed = true; + } + // Wait till it is merged in protocol repo (https://github.com/GetStream/protocol/pull/254) + // if (layer.maxFramerate > 0 && layer.maxFramerate !== enc.maxFramerate) { + // enc.maxFramerate = layer.maxFramerate; + // changed = true; + // } + // TODO: Set priority from the ChangePublishQuality message + } if (layer !== undefined && layer.scaleResolutionDownBy !== enc.scaleResolutionDownBy) { // TODO: Find a default scale down value if SFU specifies some nonsense or doesn't set it enc.scaleResolutionDownBy = Math.max(1.0, layer.scaleResolutionDownBy); // min should be 1.0