W3C home > Mailing lists > Public > public-media-capture@w3.org > May 2012

Re: Syntax options for constraints structure

From: Dan Burnett <dburnett@voxeo.com>
Date: Fri, 11 May 2012 13:49:22 -0400
Cc: Anant Narayanan <anant@mozilla.com>, Harald Alvestrand <harald@alvestrand.no>, public-media-capture@w3.org
Message-Id: <2BC51CB3-99B9-4470-9738-19501E673947@voxeo.com>
To: Paul Neave <paul.neave@gmail.com>
Thanks for the comments, Paul.  I agree that the camel case needs fixing.  I will respond to your other comment below.

-- dan

On May 11, 2012, at 9:47 AM, Paul Neave wrote:

> Thank you Anant. I was not aware of the requirement to specify optional parameters in order.
> 
>> We could certainly make the optimization of grouping each "set" of 
>> constraints in one object instead of making a new object for each 
>> constraint, and I think Dan did have something like this in his original 
>> proposal in the form of a "Constraint Set", IIRC.
>> 
>> So, my preferred syntax is, as an example:
>> 
>> navigator.getUserMedia({
>> video: {
>> mandatory: {
>> videoMinHeight:600,
>> videoMaxBandwidth:500
>> },
>> optional: [
>> {
>> videoMaxAspectratio: 1.333333333333,
>> videoMinTimebetweenrefframes: 20,
>> videoMinFramerate: 30,
>> videoEnumAutowhitebalance: "on"
>> },
>> {
>> videoMinTimebetweenrefframes: 40,
>> videoMinFramerate: 10
>> },
>> ]
>> }
>> });
>> 
> 
> This approach seems much more sensible and is less verbose. Also in my opinion it makes more sense because the array is being used as an array should, not just as a placeholder to enforce order.

While this looks prettier, its interpretation is much less clear.  The goal here is to list all optional constraints in a priority ordering so the browser will know which constraint is more important when they cannot both be satisfied.  For example, the minFrameRate and minTimeBetweenRefFrames values may actually conflict.  What does it mean to specify both of them at the same priority level as Anant has done here?

I believe a strict priority ordering is the only thing that makes sense, even though the JS syntax is not conducive to having arrays/sequences of key/value pairs.  If you can suggest a syntax for the optional piece that is convenient to write and captures the strict ordering among constraints, I would *very* much love to see it!

I should point out, by the way, that the example above is not very realistic.  It does not make much sense to specify two different optional minFrameRate values; instead, just use the smaller of the two.  Minimum should mean minimum :)

> 
> Dan and Harald, would this be an acceptable structure?
> 
> Paul.
> 
> 
> 
Received on Friday, 11 May 2012 19:11:32 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:14:59 GMT