Re: unknown mandatory constraints and making mandatory harder to use

On 11/14/2013 07:19 AM, Jim Barnett wrote:
>
> Off the top of my head:  suppose make applyConstraints and 
> getUserMedia take _/only/_ a list of optional constraints as an 
> argument  (that makes them easier to use).  Then we add a 
> queueMandatoryConstraint call, which queues up a single mandatory 
> constraint to be applied the next time applyConstraints or gUM is 
> called.  This call could return an error if the UA doesn’t 
> recognize/support the constraint (note: this error tells you only 
> about the browser, not about the devices attached to it.)
>
> So this makes the mandatory constraints harder to use (you have to 
> call the queue function multiple times to add multiple mandatory 
> constraints).  And it also gives the app the information about what 
> mandatory constraints are supported.
>

I don't like it; it adds state in a place where state doesn't have to be.
IE if you fire off five queueMandatoryConstraints and then decide that 
you don't want them after all, how do you get rid of them so that they 
don't mess up your next getUserMedia call?

If you want to follow a pattern like this, I'd rather consider making 
the Constraints object a platform object (really, it would be a Builder 
pattern) with an AddMandatoryConstraint method that checked that the 
constraint was actually supported by the platform before adding it to 
the constraint set.

> Of course there will be other ways to do this.
>
> -Jim
>

Received on Friday, 15 November 2013 14:03:22 UTC