RTCSessionDescription()

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

Deprecated
This feature has been removed from the Web standards. Though some browsers may still support it, it is in the process of being dropped. Avoid using it and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

The RTCSessionDescription() constructor creates a new RTCSessionDescription with its properties initialized as described in the specified object.

This constructor has been deprecated because RTCPeerConnection.setLocalDescription() and other methods which take SDP as input now directly accept an object conforming to the RTCSessionDescriptionInit dictionary, so you don't have to instantiate an RTCSessionDescription yourself.

Syntax

 sessionDescription = new RTCSessionDescription(rtcSessionDescriptionInit);

Values

rtcSessionDescriptionInit Optional
An object providing the default values for the session description; the object conforms to the RTCSessionDescriptionInit dictionary. That dictionary has the following properties:
type
Required. A string which is a member of the RTCSdpType enum; it must have one of the following values:

This enum defines strings that describe the current state of the session description, as used in the type property. The session description's type will be specified using one of these values.

Value Description
answer The SDP contained in the sdp property is the definitive choice in the exchange. In other words, this session description describes the agreed-upon configuration, and is being sent to finalize negotiation.
offer The session description object describes the initial proposal in an offer/answer exchange. The session negotiation process begins with an offer being sent from the caller to the callee.
pranswer The session description object describe a provisional answer; that is, it's a response to a previous offer or provisional answer.
rollback This session description is used to allow one peer to tell the other, in essence, that an impasse has been reached, and to roll back to the previous state and try again.
sdp
A string containing a SDP message describing the session. This value is an empty string ("") by default and may not be null.

Example

This example uses the constructor to convert an SDP offer into an RTCSessionDescription object.

This is no longer necessary, however; RTCPeerConnection.setLocalDescription() and other methods which take SDP as input now directly accept an object conforming to the RTCSessionDescriptionInit dictionary, so you don't have to instantiate an RTCSessionDescription yourself.

navigator.getUserMedia({video: true}, function(stream) {
  pc.onaddstream({stream: stream});
  // Adding a local stream won't trigger the onaddstream callback
  pc.addStream(stream);
  pc.createOffer(function(offer) {
    pc.setLocalDescription(new RTCSessionDescription(offer), function() {
      // send the offer to a server to be forwarded to the friend you're calling.
    }, error);
  }, error);
}

Specifications

Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCSessionDescription()' in that specification.
Working Draft Initial specification.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) [1] No support (Yes) ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? ? No support ? ?

[1] Though this property is not prefixed, the interface it belongs to is.

See also

Document Tags and Contributors

 Contributors to this page: Sheppy, teoli
 Last updated by: Sheppy,