Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. RTCSessionDescription

RTCSessionDescription

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2017.

TheRTCSessionDescription interface describes one end of a connection—or potential connection—and how it's configured. EachRTCSessionDescription consists of a descriptiontype indicating which part of the offer/answer negotiation process it describes and of theSDP descriptor of the session.

The process of negotiating a connection between two peers involves exchangingRTCSessionDescription objects back and forth, with each description suggesting one combination of connection configuration options that the sender of the description supports. Once the two peers agree upon a configuration for the connection, negotiation is complete.

Constructor

RTCSessionDescription()Deprecated

Creates a newRTCSessionDescription by specifying thetype andsdp. All methods that acceptRTCSessionDescription objects also accept objects with the same properties, so you can use a plain object instead of creating anRTCSessionDescription instance.

Instance properties

TheRTCSessionDescription interface doesn't inherit any properties.

RTCSessionDescription.typeRead only

An enum describing the session description's type.

RTCSessionDescription.sdpRead only

A string containing theSDP describing the session.

Instance methods

TheRTCSessionDescription doesn't inherit any methods.

RTCSessionDescription.toJSON()

Returns aJSON description of the object. The values of both properties,type andsdp, are contained in the generated JSON.

Example

js
signalingChannel.onmessage = (evt) => {  if (!pc) start(false);  const message = JSON.parse(evt.data);  if (message.type && message.sdp) {    pc.setRemoteDescription(      new RTCSessionDescription(message),      () => {        // 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),      () => {},      logError,    );  }};

Specifications

Specification
WebRTC: Real-Time Communication in Browsers
# rtcsessiondescription-class

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp