Re: Syntax options for constraints structure

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 UTC