这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

RTCSessionDescription interface describes one end of a connection—or potential connection—and how it's configured. 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, 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.

特性

RTCSessionDescription interface doesn't inherit any properties.

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

常量

RTCSdpType

This enum defines strings that describe the current state of the session description, as used in the type property. The session description's type will be specified using one of these values.

描述
answer The SDP contained in the sdp property is the definitive choice in the exchange. In other words, this session description describes the agreed-upon configuration, and is being sent to finalize negotiation.
offer The session description object describes the initial proposal in an offer/answer exchange. The session negotiation process begins with an offer being sent from the caller to the callee.
pranswer The session description object describes a provisional answer; that is, a response to a previous offer that is not the final answer. It is usually employed by legacy hardware.
rollback This special type with an empty session description is used to roll back to the previous stable state.

方法

RTCSessionDescription doesn't inherit any methods.

RTCSessionDescription()
This constructor returns a new RTCSessionDescription . The parameter is a RTCSessionDescriptionInit dictionary containing the values to assign the two properties.
RTCSessionDescription.toJSON()
返回 JSON description of the object. The values of both properties, type and sdp , are contained in the generated JSON.

范例

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

规范

规范 状态 注释
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCSessionDescription' in that specification.
候选推荐 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
RTCSessionDescription Chrome Yes Edge ≤18 Firefox Yes Prefixed
Yes Prefixed
Prefixed Implemented with the vendor prefix: moz
IE No Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
RTCSessionDescription() 构造函数 弃用 Chrome Yes Edge ≤18 Firefox Yes Prefixed
Yes Prefixed
Prefixed Implemented with the vendor prefix: moz
IE No Opera ? Safari ? WebView Android Yes Chrome Android Yes Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android Yes
sdp Chrome Yes Edge 15 Firefox Yes Prefixed
Yes Prefixed
Prefixed Implemented with the vendor prefix: moz
IE No Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
toJSON Chrome Yes Edge 15 Firefox Yes Prefixed
Yes Prefixed
Prefixed Implemented with the vendor prefix: moz
IE No Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
type Chrome Yes Edge 15 Firefox Yes Prefixed
Yes Prefixed
Prefixed Implemented with the vendor prefix: moz
IE No Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

弃用。不要用于新网站。

弃用。不要用于新网站。

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

另请参阅

元数据

  • 最后修改: