[webrtc-pc] Inconsistent initialization of scaleResolutionDownBy (#2730)

jan-ivar has just created a new issue for https://github.com/w3c/webrtc-pc:

== Inconsistent initialization of scaleResolutionDownBy ==
[addTransceiver]() says: _"7. If the [scaleResolutionDownBy](https://w3c.github.io/webrtc-pc/#dom-rtcrtpencodingparameters-scaleresolutiondownby) attribues of sendEncodings are still undefined, initialize [them] ... 9. [Create an RTCRtpSender](https://w3c.github.io/webrtc-pc/#dfn-create-an-rtcrtpsender) with track, kind, streams and sendEncodings ..."_

[Create an RTCRtpSender](https://w3c.github.io/webrtc-pc/#dfn-create-an-rtcrtpsender) says: _"If sendEncodings is given as input to this algorithm, and is non-empty, set the [[[SendEncodings]]](https://w3c.github.io/webrtc-pc/#dfn-sendencodings) slot to sendEncodings. Otherwise, set it to a list containing a single [RTCRtpEncodingParameters](https://w3c.github.io/webrtc-pc/#dom-rtcrtpencodingparameters) with [active](https://w3c.github.io/webrtc-pc/#dom-rtcrtpencodingparameters-active) set to true."_

This means that (according to spec) the output of `sender.getParameters()` will differ in the following cases:
```js
pc.addTrack(track)                                    // {active: true}
pc.addTransceiver(track)                              // {active: true}
pc.addTransceiver(track, {sendEncodings: []})         // {active: true}
pc.addTransceiver(track, {sendEncodings: [{}]})       // {active: true, scaleResolutionDownBy: 1}
pc.addTransceiver(track, {sendEncodings: [{rid: 1}]}) // {active: true, scaleResolutionDownBy: 1}
```
A [quick test](https://jsfiddle.net/jib1/e19zur8k/) (working around #2729) shows Chrome _never_ initializes scaleResolutionDownBy, while Safari _always_ does.

I think we're better off always initializing scaleResolutionDownBy, or we need to fix [setParameters](https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-setparameters): _"Verify that each encoding in encodings has a [scaleResolutionDownBy](https://w3c.github.io/webrtc-pc/#dom-rtcrtpencodingparameters-scaleresolutiondownby) member whose value is greater than or equal to 1.0. If one of the scaleResolutionDownBy values does not meet this requirement, return a promise [rejected](https://w3c.github.io/webrtc-pc/#dfn-reject) with a newly [created](https://webidl.spec.whatwg.org/#dfn-create-exception) [RangeError](https://webidl.spec.whatwg.org/#exceptiondef-rangeerror)."_

Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/2730 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 6 May 2022 23:34:44 UTC