RTCSessionDescription

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use 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 spec changes.

The RTCSessionDescription interface represents the parameters of a session. Each RTCSessionDescription consists of a description type indicating which part of the offer/answer negotiation process it describes and of the SDP descriptor of the session.

The process of negotiating a connection between two peers involves exchanging RTCSessionDescription objects back and forth until the two peers agree upon a configuration for the connection.

Properties

The RTCSessionDescription interface doesn't inherit any properties.

RTCSessionDescription.type
An enum of type RTCSdpType describing the session description's type.
RTCSessionDescription.sdp
A DOMString containing the SDP format describing the session.

Constants

RTCSdpType

This enum defines strings that describe the current state of the session description The session description's type will be represented by one of these.

Value Description
offer The session description is the initial proposal in an offer/answer exchange. The session negotiation process begins with an offer being made.
pranswer The session description is a provisional answer; that is, it's a response to a previous offer or provisional answer.
answer The session description is the definitive choice in the exchange. In other words, this response indicates that agreement has been reached, and is sent to let the other peer know how to configure itself. Negotiations are complete.
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.

Methods

The RTCSessionDescription doesn't inherit any methods.

RTCSessionDescription()
This constructor returns a new RTCSessionDescription. The parameter is a RTCSessionDescriptionInit dictionary containing the (optional) values for the two properties. Any values not specified in the dictionary will be initialized to null.
RTCSessionDescription.toJSON()
Returns a JSON description of the object. The values of both properties, type and sdp, are contained in the generated JSON.

Example

signalingChannel.onmessage = function (evt) {
    if (!pc)
        start(false);

    var message = JSON.parse(evt.data);
    if (message.sdp)
        pc.setRemoteDescription(new RTCSessionDescription(message.sdp), function () {
            // if we received an offer, we need to answer
            if (pc.remoteDescription.type == "offer")
                pc.createAnswer(localDescCreated, logError);
        }, logError);
    else
        pc.addIceCandidate(new RTCIceCandidate(message.candidate),
            function () {}, logError);
};

Specifications

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

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) -moz- Not supported (Yes) ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? ? Not supported ? ?

See also

Document Tags and Contributors

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