这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
弃用
This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the
兼容性表格
at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
RTCSessionDescription()
构造函数创建新
RTCSessionDescription
with its properties initialized as described in the specified object.
This constructor has been deprecated because
RTCPeerConnection.setLocalDescription()
and other methods which take SDP as input now directly accept an object conforming to the
RTCSessionDescriptionInit
dictionary, so you don't have to instantiate an
RTCSessionDescription
yourself.
sessionDescription = new RTCSessionDescription(rtcSessionDescriptionInit);
rtcSessionDescriptionInit
可选
RTCSessionDescriptionInit
dictionary. That dictionary has the following properties:
type
RTCSdpType
enum; it must have one of the following values:
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. |
sdp
""
) by default and may not be
null
.
This example uses the constructor to convert an SDP offer into an
RTCSessionDescription
对象。
This is no longer necessary, however;
RTCPeerConnection.setLocalDescription()
and other methods which take SDP as input now directly accept an object conforming to the
RTCSessionDescriptionInit
dictionary, so you don't have to instantiate an
RTCSessionDescription
yourself.
navigator.getUserMedia({video: true}, function(stream) {
pc.onaddstream({stream: stream});
// Adding a local stream won't trigger the onaddstream callback
pc.addStream(stream);
pc.createOffer(function(offer) {
pc.setLocalDescription(new RTCSessionDescription(offer), function() {
// send the offer to a server to be forwarded to the friend you're calling.
}, error);
}, error);
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCSessionDescription()' in that specification. |
候选推荐 | 最初的规范。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
RTCSessionDescription()
构造函数
弃用
|
Chrome Yes | Edge ≤18 |
Firefox
Yes
Prefixed
|
IE No | Opera ? | Safari ? | WebView Android Yes | Chrome Android Yes | Firefox Android ? | Opera Android ? | Safari iOS ? | Samsung Internet Android Yes |
完整支持
不支持
兼容性未知
实验。期望将来行为有所改变。
弃用。不要用于新网站。
要求使用供应商前缀或不同名称。
RTCSessionDescription
RTCSessionDescription()
MediaDevices.getUserMedia()
Navigator.mediaDevices
RTCCertificate
RTCDTMFSender
RTCDTMFToneChangeEvent
RTCDataChannel
RTCDataChannelEvent
RTCDtlsTransport
RTCErrorEvent
RTCIceCandidate
RTCIceTransport
RTCPeerConnection
RTCPeerConnectionIceErrorEvent
RTCPeerConnectionIceEvent
RTCRtpReceiver
RTCRtpSender
RTCRtpTransceiver
RTCSctpTransport
RTCStatsEvent
RTCStatsReport
RTCTrackEvent