W3cubDocs

/DOM

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.

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 Read only
An enum of type RTCSdpType describing the session description's type.
RTCSessionDescription.sdp Read only
A DOMString containing the SDP 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
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.
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.
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 Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) -moz No support (Yes) ?
Feature Android Chrome for Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? (Yes) ? No support ? ?

See also

© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription