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(),webrtc.RTCPeerConnection.add_track()and remote offers, and listed bywebrtc.RTCPeerConnection.get_transceivers(). See MDN: RTCRtpTransceiver.- property mid: str | None
The media ID (
a=mid) of the media section of the transceiver.Noneuntil a description with the section is set. See MDN: RTCRtpTransceiver/mid.- Type:
str, optional
- property receiver: RTCRtpReceiver
Receives and decodes the media of the transceiver. Itβs always the same object.
See MDN: RTCRtpTransceiver/receiver.
- Type:
- property sender: RTCRtpSender
Encodes and sends the media of the transceiver. Itβs always the same object.
See MDN: RTCRtpTransceiver/sender.
- Type:
- property stopped: bool
Whether the transceiver was stopped, by
stop()or by a negotiation.See MDN: RTCRtpTransceiver/stopped.
Warning
Deprecated. Compare
current_directionwithwebrtc.RTCRtpTransceiverDirection.stopped.- Type:
- property direction: RTCRtpTransceiverDirection
The preferred direction, which the next negotiation offers.
It can be set with a member or its value. A change leads to a
negotiationneededevent, and the negotiated direction iscurrent_direction. Setting it on a stopped transceiver raiseswebrtc.InvalidStateError. Setting it tostoppedraisesTypeError, so usestop()for that. See MDN: RTCRtpTransceiver/direction.
- property current_direction: RTCRtpTransceiverDirection | None
The direction of the last negotiation.
Noneuntil the transceiver is negotiated. See MDN: RTCRtpTransceiver/currentDirection.- Type:
webrtc.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.
- Raises:
webrtc.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.
- Parameters:
codecs (
listofwebrtc.RTCRtpCodec) β Codecs from the capabilities ofwebrtc.RTCRtpSender.get_capabilities()orwebrtc.RTCRtpReceiver.get_capabilities()for the kind of the transceiver. An empty list restores the default preferences.- Raises:
webrtc.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:
listofwebrtc.RTCRtpHeaderExtensionCapabilityβ The extensions and the direction each one is negotiated in. The ones that arenβt negotiated havewebrtc.RTCRtpTransceiverDirection.stopped.- Return type:
- set_header_extensions_to_negotiate(extensions)
Changes the directions the header extensions are negotiated in, from the next negotiation.
- Parameters:
extensions (
listofwebrtc.RTCRtpHeaderExtensionCapability) β The listget_header_extensions_to_negotiate()returns, with directions changed.- Raises:
TypeError β If an extension has an empty URI.
webrtc.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:
listofwebrtc.RTCRtpHeaderExtensionCapabilityβ Every extension that can be negotiated. The ones that werenβt negotiated havewebrtc.RTCRtpTransceiverDirection.stopped.- Return type: