Re: New version of constrainable section of getusermedia

On 2/3/14 5:46 PM, Cullen Jennings (fluffy) wrote:
> On Feb 3, 2014, at 2:41 PM, Jan-Ivar Bruaroey <jib@mozilla.com> wrote:
>
>> I can't believe this is intended, so my best-effort interpretation is that what we mean is for this to be a template, a pattern to repeat but not take literally. E.g:
>>
>> [NoInterfaceObject]
>> interface GumConstrainable {
>>      GumCapabilities getCapabilities ();
>>      GumConstraints  getConstraints ();
>>      GumSettings     getSettings ();
>>      void         applyConstraints (GumConstraints constraints, VoidFunction successCallback, ConstraintErrorCallback
>>   errorCallback);
>>                  attribute EventHandler onoverconstrained;
>> };
>>
>>
>> [NoInterfaceObject]
>> interface CCubeConstrainable {
>>      CCubeCapabilities getCapabilities ();
>>      CCubeConstraints  getConstraints ();
>>      CCubeSettings     getSettings ();
>>      void         applyConstraints (CCubeConstraints constraints, VoidFunction successCallback, ConstraintErrorCallback
>> errorCallback);
>>                  attribute EventHandler onoverconstrained;
>> };
> I’m not following you on how the names collide. Lets say there is a name called width which is used by CCube and Gum but mean totally differ things. How do they collide? I don’t think this was mean to be a template - the setting is just a list of names that can be used in keys - Constraints are a bunch of keys along with allowed range - and settings are keys along with their current value.

Lots of things may seem like they fit if we're imprecise. The spec says 
" A Setting is a dictionary containing one or more key-value pairs" [0], 
i.e. more than "just a list of names" it is a webidl dictionary, and 
dictionary members have types. Code-bindings are generated from webidl, 
which become the actual argument type-checking code in Firefox. So, if 
"width" is a long in one domain and a double (or string!) in another, 
then you have a conflict, nevermind a poorly vetted argument and a 
seriously loopy mixing of contexts.

The fact that this wasn't immediately clear, I think is a great example 
of where the spec would be much harder to misunderstand if we actually 
defined the MTI constraints in webidl in the spec instead of relying on 
examples, tables and hand-waving at some invented property registry 
nomenclature (what is a "list of" anyway?) - It would cut down on the 
prose a lot, a good thing, since English is a terrible language to 
describe software in. It would probably look like this:


dictionary GumConstraints {
     GumConstraintSet mandatory;
     seqeuence<GumConstraintSet> optional;
};

dictionary GumConstraintSet {
     (long orPropertyValueLongRange) width;
     (long orPropertyValueLongRange) height;
     (double orPropertyValueDoubleRange) frameRate;
     (double orPropertyValueDoubleRange) aspectRatio;
     (VideoFacingModeEnum or sequence<VideoFacingModeEnum>) facingMode;
};

dictionary CCubeConstraints {
     CCubeConstraintSet mandatory;
     seqeuence<CCubeConstraintSet> optional;
};

dictionary CCubeConstraintSet {
     (double orPropertyValueDoubleRange) width;
     (double orPropertyValueDoubleRange) weight;
     (double orPropertyValueDoubleRange) adorability;
     (CompanionCubeMoodEnum or sequence<CompanionCubeMood>) mood;
     booleaneuthanized;
};

If we don't separate things then we get:

dictionary ConstraintSet {
     any  width;  // conflict!
     (long orPropertyValueLongRange) height;
     (double orPropertyValueDoubleRange) frameRate;
     (double orPropertyValueDoubleRange) aspectRatio;
     (VideoFacingModeEnum or sequence<VideoFacingModeEnum>) facingMode;
     (double orPropertyValueDoubleRange) weight;
     (double orPropertyValueDoubleRange) adorability;
     (CompanionCubeMoodEnum or sequence<CompanionCubeMood>) mood;
     booleaneuthanized;
};


which would not only be inoptimal if we actually implemented it and 
cause poor type-checking, but be a confusing horrible mess by any measure.

.: Jan-Ivar :.

[0] This is actually a typo in the spec. It should say: "A *Settings* 
(plural) is a dictionary containing one or more key-value pairs. "

Received on Tuesday, 4 February 2014 03:20:22 UTC