Bug 18486 - Let RTCSessionDescription take a Dictionary parameter
Summary: Let RTCSessionDescription take a Dictionary parameter
Alias: None
Product: WebRTC Working Group
Classification: Unclassified
Component: WebRTC API (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Adam Bergkvist
QA Contact:
Depends on:
Reported: 2012-08-04 00:22 UTC by Harald Alvestrand
Modified: 2012-09-13 14:49 UTC (History)
3 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Harald Alvestrand 2012-08-04 00:22:02 UTC
From Tommy Widenflycht, July 31 (see mailing list for discussion):

Today I would like to propose a small change to RTCSessionDescription and RTCIceCandidate which would make the much more flexible:

[Constructor(optional Dictionary description)]
interface RTCSessionDescription {
             attribute RTCSdpType type;
             attribute DOMString  sdp;

In short the single constructor takes an Dictionary which is expected to mimic its members, and the stringifier method is removed.

This has the advantages of being extremely powerful:

sd = new RTCSessionDescription();
sd.sdp = ...;
sd.type = ...;

sd = new RTCSessionDescription({sdp:"..."});
sd.type = ...;

sd = new RTCSessionDescription({type:"answer", sdp:"..."});

sd = new RTCSessionDescription(JSON.parse(some_json_string));

sd2 = new RTCSessionDescription(sd);

and in the other direction

jsonified_sd = JSON.stringify(sd);

There's some precedence in using a constructor like this in some of the base Event classes.
Comment 1 Adam Bergkvist 2012-08-13 09:29:59 UTC
It's nice that the constructor takes an object rather than a string of JSON. I'll go ahead and add this to the spec.

I'm not sure this cloning functionality works though:
> sd2 = new RTCSessionDescription(sd);