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

Re: Fwd: Re: Syntax options for constraints structure

From: Anant Narayanan <anant@mozilla.com>
Date: Sun, 13 May 2012 08:59:24 -0700
Message-ID: <4FAFDA5C.2010004@mozilla.com>
To: public-media-capture@w3.org
On 5/12/2012 11:30 PM, Harald Alvestrand wrote:
> On 05/11/2012 09:46 PM, Anant Narayanan wrote:
>> navigator.getUserMedia({
>>   video: {
>>     mandatory: {},
>>     optional: [
>>       {
>>         minWidth: 640,
>>         minHeight: 480,
>>         minFramerate: 30
>>       },
>>       {
>>         minWidth: 320,
>>         minHeight: 240,
>>         minFramerate: 15
>>       }
>>     ]
>>   }
>> });
>
> Note my reaction to grouping is the same as Dan's: It's not clear what
> the semantics are.
>
> If you intend to comment on Dan's algorithm proposal, I think your
> example is wrong; if you're proposing an alternative evaluation
> algorithm for optional constraints, I don't understand what it is.
>
> Can you clarify?

Sorry, my first message wasn't very clear; I was proposing an 
alternative evaluation algorithm because I think the more common case 
would be for an app to work with a set of given constraints. The 
algorithm would be as follows:

- UA evaluates all constraints in the mandatory block, if any one of 
them could not be satisfied, onerror is called.

- UA evaluates each set in the optional block in order, starting from 
offset 0, as if it were a mandatory block. Except, if any one constraint 
in a set could not be satisfied, the next set is evaluated instead of 
calling onerror.

- If the UA was able to meet all constraints in the very first set in 
the optional block, for example, none of the others will be evaluated; 
and onsuccess is called immediately.

- If none of the optional constraints could be satisfied, onsuccess is 
called as normal.

In Dan's original proposal, I haven't seen any examples where many of 
the individual constraints could not be grouped together because they 
conflict with each other.

In other words, I don't see why a web developer would prioritize 
"aspectRatio" over "minFramerate"; they are two different things, why 
would one take priority over the other? On the other hand, I can see why 
a developer would prioritize 30fps over 15fps, and they belong in 
different sets.

It might be that I'm missing some key element, Tim also mentioned the 
possibility that JS doesn't know what is going to conflict in advance. A 
concrete example of when two constraints with different keys can't be in 
the same set will really help me in understanding this better.

-Anant
Received on Sunday, 13 May 2012 15:59:55 GMT

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