Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

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 Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) -moz No support (Yes) ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? ? No support ? ?

See also

Метки документа и участники

 Внесли вклад в эту страницу: Sheppy, mappum, teoli, wesj
 Обновлялась последний раз: Sheppy,