files/en-us/web/api/rtcpeerconnection/addtransceiver/index.md
{{APIRef("WebRTC")}}
The addTransceiver() method of the {{domxref("RTCPeerConnection")}} interface creates a new {{domxref("RTCRtpTransceiver")}} and adds it to the set of transceivers associated with the RTCPeerConnection.
Each transceiver represents a bidirectional stream, with both an {{domxref("RTCRtpSender")}} and an {{domxref("RTCRtpReceiver")}} associated with it.
addTransceiver(trackOrKind)
addTransceiver(trackOrKind, init)
trackOrKind
init {{optional_inline}}
direction {{optional_inline}}
sendEncodings {{optional_inline}}
parameter.encodings array passed to {{domxref("RTCRtpSender.setParameters()")}}.streams {{optional_inline}}
The {{domxref("RTCRtpTransceiver")}} object which will be used to exchange the media data.
{{jsxref("TypeError")}}
: Thrown if trackOrKind was not either "audio" or "video".
If the sendEncodings argument is used, this error may also be thrown if there is a badly formatted rid member, some but not all encodings contain a rid member, or different encodings have the same rid value.
{{jsxref("RangeError")}}
sendEncodings encodings have a maxFramerate value less than 0.0, or a scaleResolutionDownBy value of less than 1.0.InvalidStateError {{domxref("DOMException")}}
InvalidAccessError {{domxref("DOMException")}}
sendEncodings argument is used, and contains a read-only parameter other than rid.{{Specifications}}
{{Compat}}