- From: cowwoc <cowwoc@bbs.darktech.org>
- Date: Fri, 13 Dec 2013 18:25:40 -0500
- To: Jan-Ivar Bruaroey <jib@mozilla.com>, Martin Thomson <martin.thomson@gmail.com>
- CC: "public-media-capture@w3.org" <public-media-capture@w3.org>
- Message-ID: <52AB9774.90106@bbs.darktech.org>
On 13/12/2013 4:06 PM, Jan-Ivar Bruaroey wrote:
> On 12/13/13 2:43 PM, cowwoc wrote:
>> I don't see how you could express the following constraints all at once:
>>
>> 1. For aspect ratio 4/3, require resolutions from 800x600 to
>> 1600x1200, prefer 1200x900
>> 2. For aspect ratio 16/9, require resolutions from 1280x720 to
>> 1920x1080, prefer 1600x900
>>
>
> Here you're saying "I must have these mandatory constraints OR these
> other mandatory constraints". That's way beyond what you can express
> today! That hardly seems fair. How come you didn't like my declarative
> syntax then?
It's not about playing "fair". It's about testing how legitimate
use-cases get expressed by the various proposals.
> With my original declarative syntax this is a piece of cake:
>
> [
> { width: 1200, height: 900 },
> { width: 1600, height: 900 },
> {
> aspect: { min: 1.33, max: 1.34 },
> width: { min: 800, max: 1600 },
> height: { min: 600, max: 1200 }
> },
> {
> aspect: { min: 1.77, max: 1.78 },
> width: { min: 1280, max: 1920 },
> height: { min: 720, max: 1080 }
> },
> ]
>
> Can I write you down as supporting it? ;-)
It's not clear to me how browser is meant to implement the above
dictionary. I mean, does it scan from top to bottom and stop on the
first match? From a readability point of view, I find the syntax ambiguous.
> The best you can do in our compromise proposal here based on the
> loveable optional-array algorithm, is make this optional-only and
> check the result from gUM() (because the optional-array algorithm is
> procedural in nature). That version looks identical to the above btw.
I'm still operating under the premise that fingerprinting is not a
problem. As such, I prefer the following code. Granted it's more
verbose, but it's much easier to read and is obviously more flexible.
You can also abstract common use-cases behind an API.
var modes = camera.getModes();
var resolution;
for (var i = 0; i<modes.length; ++i)
{
var mode = modes[i];
if (mode.aspectRatio > 1.33 && mode.aspectRatio < 1.34)
{
if (!mode.supportsResolution(800, 600) ||
!mode.supportsResolution(1600, 1200))
continue;
if (mode.supportsResolution(1200, 900))
resolution = { width: 1200, height: 900 };
else
resolution = mode.maximumResolution();
break;
}
else
{
if (!mode.supportsResolution(1280, 720) ||
!mode.supportsResolution(1920, 1080))
continue;
if (mode.supportsResolution(1600, 900))
resolution = [1600, 900];
else
resolution = mode.maximumResolution();
break;
}
}
if (!resolution)
{
failGracefully();
return;
}
var properties = { width: resolution.width, height: resolution.height,
frameRate: 20 };// specific values that the device must support (ranges
are not accepted)
getUserMedia(properties, onSuccess, onFailure);
Gili
Received on Friday, 13 December 2013 23:26:37 UTC