RTCRtpSender
The sender that encodes and sends the media of a track.
- class webrtc.interfaces.rtc_rtp_sender.RTCRtpSender(native_obj=None)
Encodes the media of a track and sends it to the remote peer, and controls how it’s sent.
Each
webrtc.RTCRtpTransceiverof anwebrtc.RTCPeerConnectionhas one.See MDN: RTCRtpSender.
- property track: MediaStreamTrack | None
The track being sent, or
Noneif nothing is.Change it with
replace_track().- Type:
webrtc.MediaStreamTrack, optional
- property transport: RTCDtlsTransport | None
The transport the packets go over.
It’s
Noneuntil there’s one. See MDN: RTCRtpSender/transport.- Type:
webrtc.RTCDtlsTransport, optional
- property dtmf: RTCDTMFSender | None
Sends DTMF tones, or is
Nonefor a video sender.- Type:
webrtc.RTCDTMFSender, optional
- property transform: RTCRtpScriptTransform | RTCRtpSFrameEncryptor | None
The frame transform.
It changes the encoded frames before they’re sent. With
None, frames are sent as encoded. A transform serves one sender or receiver for its lifetime, so once attached it can’t be set elsewhere.See MDN: RTCRtpSender/transform.
- Raises:
TypeError – If the value set isn’t a transform of a sender.
webrtc.InvalidStateError – If the transform set had a sender or receiver.
- Type:
webrtc.RTCRtpScriptTransformorwebrtc.RTCRtpSFrameEncryptor, optional
- get_parameters()
Returns the parameters the sender sends with.
To change them, modify the result and pass it to
set_parameters(), which takes the last ones returned until it succeeds. A later task of the event loop gets new ones. Video encodings withoutscale_resolution_down_byget the effective value filled in.See MDN: RTCRtpSender/getParameters.
- Returns:
webrtc.RTCRtpSendParameters– The parameters, with a newtransaction_id.- Return type:
- async set_parameters(parameters, set_parameter_options=None)
Changes the encodings and the degradation preference the sender sends with.
See MDN: RTCRtpSender/setParameters.
- Parameters:
parameters (
webrtc.RTCRtpSendParameters) – The parametersget_parameters()returned last, with the changes made.set_parameter_options (
webrtc.RTCSetParameterOptions, optional) – How to change the encodings, like sending a key frame right away.
- Raises:
webrtc.InvalidStateError – If
get_parameters()wasn’t called since parameters were last set, or the transceiver of the sender is stopped.webrtc.InvalidModificationError – If the
transaction_id, the codecs, the header extensions, the RTCP parameters, the number of encodings or theirridchanged, the codec of an encoding isn’t negotiated, orencoding_optionsisn’t empty or one per encoding.webrtc.InvalidRangeError – If a value is out of range, like
scale_resolution_down_bybelow 1.TypeError – If
max_bitrateisn’t an unsigned 32-bit integer, or a video value isn’t a finite number.
- async replace_track(with_track)
Replaces the track the sender sends, without renegotiating.
It runs in the operations chain of the connection, after the operations queued before it (like setting a description), and never before the calling code continues.
See MDN: RTCRtpSender/replaceTrack.
- Parameters:
with_track (
webrtc.MediaStreamTrack, optional) – The new track of the same kind, orNoneto stop sending.- Raises:
TypeError – If the track is of another kind.
webrtc.InvalidStateError – If the transceiver of the sender is stopped, or the connection is closed.
- set_streams(*streams)
Sets the streams the remote peer puts the track of the sender in, from the next negotiation.
Repeated streams count once.
See MDN: RTCRtpSender/setStreams.
- Parameters:
*streams (
webrtc.MediaStream) – The streams. Pass none to put the track in no stream.
- static get_capabilities(kind)
Returns the codecs and header extensions senders of a kind support.
See MDN: RTCRtpSender/getCapabilities_static.
- Parameters:
kind (
webrtc.MediaType) – Audio or video.- Returns:
webrtc.RTCRtpCapabilities, optional – The capabilities, orNonefor another kind.- Return type:
RTCRtpCapabilities | None
- async get_stats()
Collects the stats of the sender and of the objects they refer to.
See MDN: RTCRtpSender/getStats.
- Returns:
webrtc.RTCStatsReport– The stats.- Raises:
webrtc.InvalidStateError – If the connection is closed.
- Return type: