RTCRtpTransceiver.direction - Web API 接口参考 编辑
The RTCRtpTransceiver
property direction
is a string which indicates the transceiver's preferred directionality. Its value must be one of the strings defined by the RTCRtpTransceiverDirection
enumeration.
The transceiver's current direction is indicated by the currentDirection
property.
Syntax
var direction = RTCRtpTransceiver.direction
Value
A DOMString
whose value is one of the strings which are a member of the RTCRtpTransceiverDirection
enumerated type, indicating the transceiver's preferred direction.
The RTCRtpTransceiverDirection
type is an enumeration of string values. Each describes how the transceiver's associated RTCRtpSender
and RTCRtpReceiver
behave as shown in the table below.
Value | RTCRtpSender behavior | RTCRtpReceiver behavior |
---|---|---|
"sendrecv" | Offers to send RTP data, and will do so if the other peer accepts the connection and at least one of the sender's encodings is active1. | Offers to receive RTP data, and does so if the other peer accepts. |
"sendonly" | Offers to send RTP data, and will do so if the other peer accepts the connection and at least one of the sender's encodings is active1. | Does not offer to receive RTP data and will not do so. |
"recvonly" | Does not offer to send RTP data, and will not do so. | Offers to receive RTP data, and will do so if the other peer offers. |
"inactive" | Does not offer to send RTP data, and will not do so. | Does not offer to receive RTP data and will not do so. |
[1] To determine if a sender has at least one active encoding, the user agent gets its parameters using RTCRtpSender.getParameters()
, then looks at the parameters' encodings
property; if any of the listed encodings has its active
property set to true
, the sender has an active encoding.
Exceptions
When setting the value of direction
, the following exceptions can occur:
InvalidStateError
- Either the receiver's
RTCPeerConnection
is closed or theRTCRtpReceiver
is stopped.
Usage notes
Setting the direction
When you change the value of direction
, an InvalidStateError
exception will occur if the connection is closed or the receiver is stopped.
If the new value of direction
is in fact different from the existing value, renegotiation of the connection is required, so a negotiationneeded
event is sent to the RTCPeerConnection
.
Effect on offers and answers
The value of direction
is used by RTCPeerConnection.createOffer()
or RTCPeerConnection.createAnswer()
in order to generate the SDP generated by each of those methods. The SDP contains an a-line which specifies the directionality. For example, if the direction
is specified as "sendrecv"
, the corresponding SDP a-line is:
a=sendrecv
Specifications
Specification | Status | Comment |
---|---|---|
WebRTC 1.0: Real-time Communication Between Browsers RTCRtpTransceiver.direction | Candidate Recommendation |
Browser compatibility
BCD tables only load in the browser
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.See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论