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.

Revision 986821 of RTCSessionDescription

  • Revision slug: Web/API/RTCSessionDescription
  • Revision title: RTCSessionDescription
  • Revision id: 986821
  • Created:
  • Creator: mappum
  • Is current revision? No
  • Comment Fixed 'sdp' link

Revision Content

{{APIRef("WebRTC")}}{{SeeCompatTable}}

The RTCSessionDescription interface represents the parameters of a session. Each RTCSessionDescription consists of a description {{domxref("RTCSessionDescription.type", "type")}} indicating which part of the offer/answer negotiation process it describes and of the {{Glossary("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.

{{domxref("RTCSessionDescription.type")}}
An enum of type {{anch("RTCSdpType")}} describing the session description's type.
{{domxref("RTCSessionDescription.sdp")}}
A {{domxref("DOMString")}} containing the {{Glossary("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.

{{domxref("RTCSessionDescription.RTCSessionDescription", "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.
{{domxref("RTCSessionDescription.toJSON()")}}
Returns a {{Glossary("JSON")}} description of the object. The values of both properties, {{domxref("RTCSessionDescription.type", "type")}} and {{domxref("RTCSessionDescription.sdp", "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
{{ SpecName('WebRTC 1.0', '#rtcsessiondescription-class', 'RTCSessionDescription') }} {{Spec2('WebRTC 1.0')}} Initial definition.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatVersionUnknown() }} {{ CompatVersionUnknown }} {{property_prefix("-moz-")}} {{ CompatNo() }} {{ CompatVersionUnknown() }} {{ CompatUnknown() }}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatNo() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

See also

Revision Source

<p>{{APIRef("WebRTC")}}{{SeeCompatTable}}</p>

<p>The <strong><code>RTCSessionDescription</code></strong> interface represents the parameters of a session. Each <code>RTCSessionDescription</code> consists of a description {{domxref("RTCSessionDescription.type", "type")}} indicating which part of the offer/answer negotiation process it describes and of the {{Glossary("SDP")}} descriptor of the session.</p>

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

<h2 id="Properties">Properties</h2>

<p><em>The <code>RTCSessionDescription</code> interface doesn't inherit any properties.</em></p>

<dl>
 <dt>{{domxref("RTCSessionDescription.type")}}</dt>
 <dd>An enum of type <code>{{anch("RTCSdpType")}}</code> describing the session description's type.</dd>
</dl>

<dl>
 <dt>{{domxref("RTCSessionDescription.sdp")}}</dt>
 <dd>A {{domxref("DOMString")}} containing the {{Glossary("SDP")}} format describing the session.</dd>
</dl>

<h2 id="Constants">Constants</h2>

<h3 id="RTCSdpType">RTCSdpType</h3>

<p>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.</p>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Value</th>
   <th scope="col">Description</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td><code>offer</code></td>
   <td>The session description is the initial proposal in an offer/answer exchange. The session negotiation process begins with an offer being made.</td>
  </tr>
  <tr>
   <td><code>pranswer</code></td>
   <td>The session description is a provisional answer; that is, it's a response to a previous offer or provisional answer.</td>
  </tr>
  <tr>
   <td><code>answer</code></td>
   <td>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.</td>
  </tr>
  <tr>
   <td><code>rollback</code></td>
   <td>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.</td>
  </tr>
 </tbody>
</table>

<h2 id="Methods">Methods</h2>

<p><em>The <code>RTCSessionDescription</code> doesn't inherit any methods.</em></p>

<dl>
 <dt>{{domxref("RTCSessionDescription.RTCSessionDescription", "RTCSessionDescription()")}}</dt>
 <dd>This constructor returns a new <code>RTCSessionDescription</code>. The parameter is a <code>RTCSessionDescriptionInit</code> dictionary containing the (optional) values for the two properties. Any values not specified in the dictionary will be initialized to <code>null</code>.</dd>
 <dt>{{domxref("RTCSessionDescription.toJSON()")}}</dt>
 <dd>Returns a {{Glossary("JSON")}} description of the object. The values of both properties, {{domxref("RTCSessionDescription.type", "type")}} and {{domxref("RTCSessionDescription.sdp", "sdp")}}, are contained in the generated JSON.</dd>
</dl>

<h2 id="Example">Example<span id="cke_bm_72C" style="display:none">&nbsp;</span></h2>

<pre class="brush: js">
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);
};
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{ SpecName('WebRTC 1.0', '#rtcsessiondescription-class', 'RTCSessionDescription') }}</td>
   <td>{{Spec2('WebRTC 1.0')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{ CompatibilityTable() }}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatVersionUnknown }} {{property_prefix("-moz-")}}</td>
   <td>{{ CompatNo() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatNo() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li><a href="/en-US/docs/Web/Guide/API/WebRTC" title="/en-US/docs/CSS/Using_CSS_animations">WebRTC</a></li>
</ul>
Revert to this revision