W3C home > Mailing lists > Public > public-webrtc@w3.org > October 2011

Re: CHANGE: Use a JS Object as an argument to getUserMedia

From: ᛏᚮᛘᛘᚤ <tommyw@google.com>
Date: Tue, 4 Oct 2011 09:33:36 +0200
Message-ID: <CALLKCfNSx_mSPbhK9wTMzkS9JcwHZvyDDcrvV2d-HmC4=CA5FA@mail.gmail.com>
To: public-webrtc@w3.org
Whereas I have nothing against changing the configuration string to a JS
object, I don't like the conversion from asynchronous result to a
synchronous one. Opening a webcam can take many seconds, which means that
the JS world is stuck during that interval.


On Mon, Oct 3, 2011 at 21:39, Anant Narayanan <anant@mozilla.com> wrote:

> What
> --
> I'd like to propose that we use a JS Object instead of a string as the
> *only* argument to getUserMedia().
> Why
> --
> We're just now beginning with the implementation of the specification in
> Firefox and we'd rather not write a new string parser :) Parsing strings can
> be error prone, whereas JavaScript objects offer the same extensibility as
> strings (and can be stringified into JSON if required). Additionally, coming
> up with a new string format is extra work and will end up  very close to a
> structured object model anyway.
> In order to avoid developers from providing empty objects in case they want
> default behavior, it is also necessary to eliminate any other arguments to
> getUserMedia. This change  will also align getUserMedia to behave closer to
> other web APIs, where changes to state are notified either via event
> listeners or callbacks that have been explicitly assigned.
> How
> --
> It is proposed that getUserMedia takes only a single argument, a JavaScript
> object. To begin with, only two properties will be specified to be
> interpreted by the User-Agent:
> {
>  audio: true,
>  video: true
> }
> Both audio and video default to true, thus this call:
> var stream = navigator.media.getUserMedia();
> will return a MediaStream object that records both video and audio. Since
> getUserMedia() only takes 1 argument, the developer has to attach an event
> listener or callback:
> stream.onReadyStateChange = function() {} // Like XHR
> or
> stream.addEventListener("<event-name>", function() {}); // Event listener
> Would love to hear what everyone thinks.
> Regards,
> -Anant

Tommy Widenflycht, Senior Software Engineer
Google Sweden AB, Kungsbron 2, SE-11122 Stockholm, Sweden
Org. nr. 556656-6880
And yes, I have to include the above in every outgoing email according to EU
Received on Tuesday, 4 October 2011 07:34:10 UTC

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 15:19:25 UTC