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

Re: Remove numeric constants from WebRTC

From: Harald Alvestrand <harald@alvestrand.no>
Date: Sat, 17 Dec 2011 10:30:44 +0100
Message-ID: <4EEC6144.10807@alvestrand.no>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
CC: public-webrtc@w3.org, hta@google.com
On 12/16/2011 11:44 PM, Tab Atkins Jr. wrote:
> WebRTC currently defines numeric constants on a few of its interfaces 
> (specifically, MediaStream and PeerConnection).  These are verboten in 
> new JS APIs, as now noted in the WebIDL spec 
> <http://dev.w3.org/2006/webapi/WebIDL/#idl-constants>.  Instead, the 
> appropriate properties should simply contain strings.
Tab,

can you point to the main arguments behind this decision, and where the 
consensus was recorded?
As someone who comes from different programming languages, the decision 
to move from a mechanism that makes verification and misspelling 
difficult because of Javascript's strange language rules (misspelled 
variables are created automagically, but it's easy for a programmer to 
see the intent) to making it impossible (because a string is not 
constrained at all, and there are no syntactical constructs for telling 
the programmer about the intended permitted values) seems to me like a 
bizarre decision.

The justifications don't seem to have made it into the WebIDL spec.

I note that the change was added to the WebIDL specification after the 
Last Call, and are still only in the editor's version, not the stable 
version, so presumably it occured as a result of Last Call discussion.

                     Harald


>
> The MediaStream interface should be changed to:
>
> [Constructor (MediaStreamTrackList? audioTracks, MediaStreamTrackList? 
> videoTracks)]
> interface MediaStream {
>     readonly attribute DOMString            label;
>     readonly attribute MediaStreamTrackList audioTracks;
>     readonly attribute MediaStreamTrackList videoTracks;
>     MediaStreamRecorder record ();
> -   const unsigned short LIVE = 1;
> -   const unsigned short ENDED = 2;
> -   readonly attribute unsigned short       readyState;
> +   readonly attribute DOMString            readyState;
>              attribute Function?            onended;
> };
>
> where readyState can be the values "live" or "ended".
>
> The PeerConnection interface should be changed to:
>
> [Constructor (DOMString configuration, SignalingCallback 
> signalingCallback)]
> interface PeerConnection {
>     void processSignalingMessage (DOMString message);
> -   const unsigned short NEW = 0;
> -   const unsigned short NEGOTIATING = 1;
> -   const unsigned short ACTIVE = 2;
> -   const unsigned short CLOSING = 4;
> -   const unsigned short CLOSED = 3;
> -   readonly attribute unsigned short readyState;
> +   readonly attribute DOMString readyState;
> -   const unsigned short ICE_GATHERING = 0x100;
> -   const unsigned short ICE_WAITING = 0x200;
> -   const unsigned short ICE_CHECKING = 0x300;
> -   const unsigned short ICE_CONNECTED = 0x400;
> -   const unsigned short ICE_COMPLETED = 0x500;
> -   const unsigned short ICE_FAILED = 0x600;
> -   const unsigned short ICE_CLOSED = 0x700;
> -   readonly attribute unsigned short iceState;
> +   readonly attribute DOMString iceState;
> -   const unsigned short SDP_IDLE = 0x1000;
> -   const unsigned short SDP_WAITING = 0x2000;
> -   const unsigned short SDP_GLARE = 0x3000;
> -   readonly attribute unsigned short sdpState;
> +   readonly attribute DOMString sdpState;
>     void addStream (MediaStream stream, MediaStreamHints hints);
>     void removeStream (MediaStream stream);
>     readonly attribute MediaStream[]  localStreams;
>     readonly attribute MediaStream[]  remoteStreams;
>     void close ();
>              attribute Function?      onconnecting;
>              attribute Function?      onopen;
>              attribute Function?      onstatechange;
>              attribute Function?      onaddstream;
>              attribute Function?      onremovestream;
> };
>
> where readyState can be the value "new", "negotiating", "active", 
> "closing", or "closed", iceState can be the values "gathering", 
> "waiting", "checking", "connected", "completed", "failed", or 
> "closed", and sdpState can be the values "idle", "waiting", or "glare".
>
> ~TJ
Received on Saturday, 17 December 2011 09:31:20 UTC

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