W3C home > Mailing lists > Public > public-media-capture@w3.org > October 2016

[mediacapture-main] Remove unions in MediaTrackCapabilities

From: jan-ivar via GitHub <sysbot+gh@w3.org>
Date: Sat, 08 Oct 2016 00:05:26 +0000
To: public-media-capture@w3.org
Message-ID: <issues.opened-181790766-1475885124-sysbot+gh@w3.org>
jan-ivar has just created a new issue for 
https://github.com/w3c/mediacapture-main:

== Remove unions in MediaTrackCapabilities ==
Unions may be convenient in input, but add unnecessary variance 
tripping up code on output.

A parsing nightmare, even with destructuring:
```js
let {width, height} = track.getCapabilities();
let maxWidth = (typeof width == "object")? width.max : width;
let maxHeight = height.max || height; // works in some cases, not 
booleans though
```

We should remove all unions in 
[MediaTrackCapabilities](https://w3c.github.io/mediacapture-main/getusermedia.html#idl-def-mediatrackcapabilities)
 like this:

```js
dictionary MediaTrackCapabilities {
    LongRange           width;
    LongRange           height;
    DoubleRange         aspectRatio;
    DoubleRange         frameRate;
    sequence<DOMString> facingMode;
    DoubleRange         volume;
    LongRange           sampleRate;
    LongRange           sampleSize;
    sequence<boolean>   echoCancellation;
    DoubleRange         latency;
    LongRange           channelCount;
    DOMString           deviceId;
    DOMString           groupId;
};
```

For straight up parsing:
```js
let {width: {max: maxWidth}, height: {max: maxHeight}} = 
track.getCapabilities();
```


Please view or discuss this issue at 
https://github.com/w3c/mediacapture-main/issues/408 using your GitHub 
account
Received on Saturday, 8 October 2016 00:05:33 UTC

This archive was generated by hypermail 2.3.1 : Saturday, 8 October 2016 00:05:33 UTC