[webrtc-pc] Unclear input validation steps in setCodecPreferences (#2805)

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

== Unclear input validation steps in setCodecPreferences ==
The normative steps in [setCodecPreferences](https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-setcodecpreferences) are unimplementable:

> 7. Let codecCapabilities be the union of [RTCRtpSender](https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender).[getCapabilities](https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-getcapabilities)(kind).[codecs](https://w3c.github.io/webrtc-pc/#dom-rtcrtpparameters-codecs) and [RTCRtpReceiver](https://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver).[getCapabilities](https://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver-getcapabilities)(kind).[codecs](https://w3c.github.io/webrtc-pc/#dom-rtcrtpparameters-codecs).
> 8. For each codec in codecs,
> > 1. If codec is not in codecCapabilities, throw [InvalidModificationError](https://webidl.spec.whatwg.org/#invalidmodificationerror).

"is not in" is meaningless when applied to dictionaries, which are passed by value. Presumably what is meant is that (either) all (or some subset of) _codec_'s dictionary members have values that match those of a dictionary found in _codecCapabilities_.

It's most likely "all", judging by this prose above:
> The codecs sequence passed into [setCodecPreferences](https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-setcodecpreferences) can only contain codecs that are returned by [RTCRtpSender](https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender).[getCapabilities](https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-getcapabilities)(kind) or [RTCRtpReceiver](https://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver).[getCapabilities](https://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver-getcapabilities)(kind), where kind is the kind of the [RTCRtpTransceiver](https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver) on which the method is called. Additionally, the [RTCRtpCodecCapability](https://w3c.github.io/webrtc-pc/#dom-rtcrtpcodeccapability) dictionary members cannot be modified. If codecs does not fulfill these requirements, the user agent MUST [throw](https://webidl.spec.whatwg.org/#dfn-throw) an [InvalidModificationError](https://webidl.spec.whatwg.org/#invalidmodificationerror).

Intent aside, this prose is also incorrect, because there's no way with dictionaries to ensure what it says it ensures.

We COULD ensure this, if that was the intent, by making [RTCRtpCodecCapability](https://w3c.github.io/webrtc-pc/#dom-rtcrtpcodeccapability) an interface instead. Then, the only way to get the necessary platform objects needed as input to setCodecPreferences would indeed be to call the correct getCapabilities methods first, and "is not in" would make sense.

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


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

Received on Monday, 5 December 2022 22:50:20 UTC