dom / latest / rtcrtptransceiver / direction.html /

RTCRtpTransceiver.direction

The RTCRtpTransceiver property direction is a string which indicates the transceiver's preferred directionality.

Its value must be one of the strings defined in the table below.

The transceiver's current direction is indicated by the currentDirection property.

Value

A DOMString whose value is one of the strings which are a member of the following values, indicating the transceiver's preferred direction.

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 active. 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 active. 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.

Exceptions

When setting the value of direction, the following exception can occur:

InvalidStateError DOMException

Thrown if either the receiver's RTCPeerConnection is closed or the RTCRtpReceiver 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

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
direction
69
79
59
No
56
11
69
69
59
48
11
10.0

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/direction