[mediacapture-main] Spec-inherent capabilities of one differ from other capabilities of one, an unnecessary variant (#941)

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

== Spec-inherent capabilities of one differ from other capabilities of one, an unnecessary variant ==
I'm raising this as promised in https://github.com/w3c/mediacapture-main/issues/915#issuecomment-1302634199:
> ... consider how constraints with only one valid value would look. This comes up both for non-inherent constraints like [channelCount](https://w3c.github.io/mediacapture-main/#def-constraint-channelCount) on a mono mic (`[1]`), as well as inherent ones like deviceId.
> 
> Having the latter be `"mydeviceIdString1234"` rather than `["mydeviceIdString1234"]` was [an editor's mistake](https://github.com/w3c/mediacapture-main/commit/059a9211d1622094dd8857db9beb477976f971dd) IMHO, but I never complained about it (I'm regretting that right now).
> 
> I'd support changing it (back) to a sequence of one. ... But this would need to be raised in mediacapture-main.

If we look at [MediaTrackCapabilities](https://w3c.github.io/mediacapture-main/#dom-mediatrackcapabilities) today, we see that every member is a range, except for [deviceId](https://w3c.github.io/mediacapture-main/#dom-mediatrackcapabilities-deviceid) and [groupId](https://w3c.github.io/mediacapture-main/#dom-mediatrackcapabilities-groupid):

<img width="790" alt="image" src="https://user-images.githubusercontent.com/3136226/227554124-0f736453-614f-4914-b686-093c5d8c3a93.png">

If we dig into why, it's from the commit https://github.com/w3c/mediacapture-main/commit/059a9211d1622094dd8857db9beb477976f971dd, which (outside the scope of its title) removes ranges from `facingMode`, `echoCancellation`, `deviceId`, and `groupId` — `echoCancellation` and `facingMode` were restored later in https://github.com/w3c/mediacapture-main/commit/d5820e22cb76b2b2d3a455c4ad9e723d37378360 & https://github.com/w3c/mediacapture-main/pull/286.

I suppose an argument for this anomaly would be that unlike the others, `deviceId` and `groupId` can _never_ have more than one value, and that therefore it doesn't _need_ to be represented as an array. But this breaks the [Constrainable Pattern](https://www.w3.org/TR/mediacapture-streams/#constrainable-interface).

To the extent that pattern makes any sense at all, we should at least follow it. [applyConstraints with its own exact deviceId succeeds in all browsers](https://jsfiddle.net/jib1/03yg28b9/).

Please view or discuss this issue at https://github.com/w3c/mediacapture-main/issues/941 using your GitHub account


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

Received on Friday, 24 March 2023 16:40:20 UTC