Back to Content

RTCPeerConnection: getTransceivers() method

files/en-us/web/api/rtcpeerconnection/gettransceivers/index.md

latest1.2 KB
Original Source

{{APIRef("WebRTC")}}

The getTransceivers() method of the {{domxref("RTCPeerConnection")}} interface returns a list of the {{domxref("RTCRtpTransceiver")}} objects being used to send and receive data on the connection.

Syntax

js-nolint
getTransceivers()

Parameters

None.

Return value

An array of the {{domxref("RTCRtpTransceiver")}} objects representing the transceivers handling sending and receiving all media on the RTCPeerConnection. The array is in the order in which the transceivers were added to the connection. The array does not include transceivers that have already been stopped (following offer/answer).

Examples

The following snippet of code stops all transceivers associated with an RTCPeerConnection.

js
pc.getTransceivers().forEach((transceiver) => {
  transceiver.stop();
});

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also