files/en-us/web/api/rtcrtptransceiver/direction/index.md
{{APIRef("WebRTC")}}
The {{domxref("RTCRtpTransceiver")}} property direction is a string that indicates the transceiver's preferred directionality.
The directionality indicates whether the transceiver will offer to send and/or receive {{Glossary("RTP")}} data, or whether it is inactive or stopped (terminated). When setting the transceiver's direction, the value is not applied immediately. The current direction is indicated by the {{domxref("RTCRtpTransceiver.currentDirection", "currentDirection")}} property.
A string with one of the following values:
"sendrecv"
RTCRtpSender: Offers to send RTP data, and will do so if the remote peer accepts the connection and at least one of the sender's encodings is active.RTCRtpReceiver: Offers to receive RTP data, and does so if the remote peer accepts."sendonly"
RTCRtpSender: Offers to send RTP data, and will do so if the remote peer accepts the connection and at least one of the sender's encodings is active.RTCRtpReceiver: Does not offer to receive RTP data and will not do so."recvonly"
RTCRtpSender: Does not offer to send RTP data, and will not do so.RTCRtpReceiver: Offers to receive RTP data, and will do so if the remote peer offers."inactive"
RTCRtpSender: Does not offer to send RTP data, and will not do so.RTCRtpReceiver: Does not offer to receive RTP data and will not do so."stopped"
TypeError.
RTCRtpSender: Does not offer to send RTP data, and will not do so.RTCRtpReceiver: Does not offer to receive RTP data and will not do so.When setting the value of direction, the following exception can occur:
InvalidStateError {{domxref("DOMException")}}
TypeError
stopped when the current value is anything other than stopped.The direction property can be used to set or get the transceiver's preferred directionality.
Updating the directionality does not take effect immediately.
If the new value of direction is different from the existing value, renegotiation of the connection is required, so a {{domxref("RTCPeerConnection.negotiationneeded_event", "negotiationneeded")}} event is sent to the {{domxref("RTCPeerConnection")}}.
A direction value (other than stopped) is then used by {{domxref("RTCPeerConnection.createOffer()")}} or {{domxref("RTCPeerConnection.createAnswer()")}} in order to generate the {{glossary("SDP")}} message created those methods.
For example, if the direction is specified as "sendrecv", the corresponding SDP a-line indicates the directionality:
a=sendrecv
The new directionality takes effect once the negotiation process is completed and the new session description is successfully applied.
The transceiver's current direction is indicated by the {{domxref("RTCRtpTransceiver.currentDirection", "currentDirection")}} property.
{{Specifications}}
{{Compat}}