# RTCRtpTransceiver

The pair of a sender and a receiver that share a media section of the SDP.

### *class* webrtc.interfaces.rtc_rtp_transceiver.RTCRtpTransceiver(native_obj=None)

A sender and a receiver that share one media section of the SDP, with its direction and codecs.

Created by [`webrtc.RTCPeerConnection.add_transceiver()`](rtc_peer_connection.md#webrtc.interfaces.rtc_peer_connection.RTCPeerConnection.add_transceiver), [`webrtc.RTCPeerConnection.add_track()`](rtc_peer_connection.md#webrtc.interfaces.rtc_peer_connection.RTCPeerConnection.add_track) and
remote offers, and listed by [`webrtc.RTCPeerConnection.get_transceivers()`](rtc_peer_connection.md#webrtc.interfaces.rtc_peer_connection.RTCPeerConnection.get_transceivers). See [MDN: RTCRtpTransceiver](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver).

#### *property* mid *: [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None)*

The media ID (`a=mid`) of the media section of the transceiver.

[`None`](https://docs.python.org/3/builtins/constants.html#None) until a description with the section is set. See [MDN: RTCRtpTransceiver/mid](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/mid).

* **Type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional

#### *property* receiver *: [RTCRtpReceiver](rtc_rtp_receiver.md#webrtc.interfaces.rtc_rtp_receiver.RTCRtpReceiver)*

Receives and decodes the media of the transceiver. It’s always the same object.

See [MDN: RTCRtpTransceiver/receiver](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/receiver).

* **Type:**
  [`webrtc.RTCRtpReceiver`](rtc_rtp_receiver.md#webrtc.interfaces.rtc_rtp_receiver.RTCRtpReceiver)

#### *property* sender *: [RTCRtpSender](rtc_rtp_sender.md#webrtc.interfaces.rtc_rtp_sender.RTCRtpSender)*

Encodes and sends the media of the transceiver. It’s always the same object.

See [MDN: RTCRtpTransceiver/sender](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/sender).

* **Type:**
  [`webrtc.RTCRtpSender`](rtc_rtp_sender.md#webrtc.interfaces.rtc_rtp_sender.RTCRtpSender)

#### *property* stopped *: [bool](https://docs.python.org/3/builtins/functions.html#bool)*

Whether the transceiver was stopped, by [`stop()`](#webrtc.interfaces.rtc_rtp_transceiver.RTCRtpTransceiver.stop) or by a negotiation.

See [MDN: RTCRtpTransceiver/stopped](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/stopped).

#### WARNING
Deprecated. Compare [`current_direction`](#webrtc.interfaces.rtc_rtp_transceiver.RTCRtpTransceiver.current_direction) with [`webrtc.RTCRtpTransceiverDirection.stopped`](../enums.md#webrtc.enums.RTCRtpTransceiverDirection.stopped).

* **Type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

#### *property* direction *: [RTCRtpTransceiverDirection](../enums.md#webrtc.enums.RTCRtpTransceiverDirection)*

The preferred direction, which the next negotiation offers.

It can be set with a member or its value. A change leads to a `negotiationneeded` event, and the negotiated
direction is [`current_direction`](#webrtc.interfaces.rtc_rtp_transceiver.RTCRtpTransceiver.current_direction). Setting it on a stopped transceiver raises
[`webrtc.InvalidStateError`](../exceptions.md#webrtc.exceptions.InvalidStateError). Setting it to `stopped` raises [`TypeError`](https://docs.python.org/3/builtins/exceptions.html#TypeError), so use [`stop()`](#webrtc.interfaces.rtc_rtp_transceiver.RTCRtpTransceiver.stop) for
that. See [MDN: RTCRtpTransceiver/direction](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/direction).

* **Type:**
  [`webrtc.RTCRtpTransceiverDirection`](../enums.md#webrtc.enums.RTCRtpTransceiverDirection)

#### *property* current_direction *: [RTCRtpTransceiverDirection](../enums.md#webrtc.enums.RTCRtpTransceiverDirection) | [None](https://docs.python.org/3/builtins/constants.html#None)*

The direction of the last negotiation.

[`None`](https://docs.python.org/3/builtins/constants.html#None) until the transceiver is negotiated. See [MDN: RTCRtpTransceiver/currentDirection](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/currentDirection).

* **Type:**
  [`webrtc.RTCRtpTransceiverDirection`](../enums.md#webrtc.enums.RTCRtpTransceiverDirection), optional

#### stop()

Stops the transceiver for good. Its sender stops sending and the track of its receiver ends.

The next negotiation removes its media section. See [MDN: RTCRtpTransceiver/stop](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/stop).

* **Raises:**
  [**webrtc.InvalidStateError**](../exceptions.md#webrtc.exceptions.InvalidStateError) – If the connection is closed.

#### set_codec_preferences(codecs)

Sets the codecs to negotiate, in order of preference, from the next negotiation.

Codecs are matched to the supported ones by MIME type, clock rate, channels and SDP format parameters.
See [MDN: RTCRtpTransceiver/setCodecPreferences](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/setCodecPreferences).

* **Parameters:**
  **codecs** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`webrtc.RTCRtpCodec`](../models/rtp_parameters.md#webrtc.models.rtp_parameters.RTCRtpCodec)) – Codecs from the capabilities of
  [`webrtc.RTCRtpSender.get_capabilities()`](rtc_rtp_sender.md#webrtc.interfaces.rtc_rtp_sender.RTCRtpSender.get_capabilities) or [`webrtc.RTCRtpReceiver.get_capabilities()`](rtc_rtp_receiver.md#webrtc.interfaces.rtc_rtp_receiver.RTCRtpReceiver.get_capabilities)
  for the kind of the transceiver. An empty list restores the default preferences.
* **Raises:**
  [**webrtc.InvalidModificationError**](../exceptions.md#webrtc.exceptions.InvalidModificationError) – If a codec isn’t supported, or only resiliency codecs
      (like RTX or FEC) are given.

#### get_header_extensions_to_negotiate()

Returns the header extensions offered or accepted in the next negotiation.

* **Returns:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`webrtc.RTCRtpHeaderExtensionCapability`](../models/rtp_parameters.md#webrtc.models.rtp_parameters.RTCRtpHeaderExtensionCapability) – The extensions and the direction each one
  is negotiated in. The ones that aren’t negotiated have [`webrtc.RTCRtpTransceiverDirection.stopped`](../enums.md#webrtc.enums.RTCRtpTransceiverDirection.stopped).
* **Return type:**
  [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[*RTCRtpHeaderExtensionCapability*](../models/rtp_parameters.md#webrtc.models.rtp_parameters.RTCRtpHeaderExtensionCapability)]

#### set_header_extensions_to_negotiate(extensions)

Changes the directions the header extensions are negotiated in, from the next negotiation.

* **Parameters:**
  **extensions** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`webrtc.RTCRtpHeaderExtensionCapability`](../models/rtp_parameters.md#webrtc.models.rtp_parameters.RTCRtpHeaderExtensionCapability)) – The list
  [`get_header_extensions_to_negotiate()`](#webrtc.interfaces.rtc_rtp_transceiver.RTCRtpTransceiver.get_header_extensions_to_negotiate) returns, with directions changed.
* **Raises:**
  * [**TypeError**](https://docs.python.org/3/builtins/exceptions.html#TypeError) – If an extension has an empty URI.
  * [**webrtc.InvalidModificationError**](../exceptions.md#webrtc.exceptions.InvalidModificationError) – If the extensions or their order differ, or a mandatory
        extension is stopped.

#### get_negotiated_header_extensions()

Returns the header extensions negotiated last, and their directions.

* **Returns:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list) of [`webrtc.RTCRtpHeaderExtensionCapability`](../models/rtp_parameters.md#webrtc.models.rtp_parameters.RTCRtpHeaderExtensionCapability) – Every extension that can be negotiated.
  The ones that weren’t negotiated have [`webrtc.RTCRtpTransceiverDirection.stopped`](../enums.md#webrtc.enums.RTCRtpTransceiverDirection.stopped).
* **Return type:**
  [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[*RTCRtpHeaderExtensionCapability*](../models/rtp_parameters.md#webrtc.models.rtp_parameters.RTCRtpHeaderExtensionCapability)]
