Class RTCRtpTransceiver
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The WebRTC interface RTCRtpTransceiver describes a permanent pairing of an RTCRtpSender and an RTCRtpReceiver, along with some shared state.
[Value("RTCRtpTransceiver")]
public class RTCRtpTransceiver
- Inheritance
-
RTCRtpTransceiver
- Inherited Members
Remarks
Each {{Glossary("SDP")}} media section describes one bidirectional SRTP ("Secure Real Time Protocol") stream (excepting the media section for RTCDataChannel, if present).
This pairing of send and receive SRTP streams is significant for some applications, so RTCRtpTransceiver is used to represent this pairing, along with other important state from the media section.
Each non-disabled SRTP media section is always represented by exactly one transceiver.
A transceiver is uniquely identified using its Mid property, which is the same as the media ID (mid) of its corresponding m-line. An RTCRtpTransceiver is associated with an m-line if its mid is non-null; otherwise it's considered disassociated.
-WebRTC API
-Introduction to the Real-time Transport Protocol (RTP)
-AddTrack(MediaStreamTrack, params MediaStream[]) and AddTransceiver(Union231, RTCRtpTransceiverInit) both create transceivers
-RTCRtpReceiver and RTCRtpSender
Constructors
RTCRtpTransceiver()
public RTCRtpTransceiver()
Properties
CurrentDirection
The read-only RTCRtpTransceiver property currentDirection is a string which indicates the current negotiated directionality of the transceiver.
[Value("currentDirection")]
public RTCRtpTransceiverDirection? CurrentDirection { get; }
Property Value
- RTCRtpTransceiverDirection?
The value is initially
null, prior to negotiation using an offer/answer.After negotiation the value is a string with one of the following values:
Remarks
The directionality indicates whether the transceiver will offer to send and/or receive RTP data, or whether it is inactive or stopped and won't send or receive data.
The transceiver's preferred directionality can be set and read using the Direction property.
Changing the direction triggers a renegotiation, which may eventually result in the currentDirection also changing.
Direction
The RTCRtpTransceiver property direction is a string that indicates the transceiver's preferred directionality.
[Value("direction")]
public RTCRtpTransceiverDirection Direction { get; set; }
Property Value
- RTCRtpTransceiverDirection
A string with one of the following values:
Remarks
The directionality indicates whether the transceiver will offer to send and/or receive RTP data, or whether it is inactive or stopped (terminated).
When setting the transceiver's direction, the value is not applied immediately.
The current direction is indicated by the CurrentDirection property.
Mid
The read-only RTCRtpTransceiver interface'smid property specifies the negotiated media ID
(mid) which the local and remote peers have agreed upon to uniquely
identify the stream's pairing of sender and receiver.
[Value("mid")]
public string? Mid { get; }
Property Value
- string
A string which uniquely identifies the pairing of source and
destination of the transceiver's stream. Its value is taken from the media ID of the SDP
m-line. This value isnullif negotiation has not completed.
Remarks
Receiver
The read-only receiver property
of WebRTC's RTCRtpTransceiver interface indicates the
RTCRtpReceiver responsible for receiving and decoding incoming media
data for the transceiver's stream.
[Value("receiver")]
public RTCRtpReceiver Receiver { get; }
Property Value
- RTCRtpReceiver
An RTCRtpReceiver object which is responsible for receiving and decoding
incoming media data whose media ID is the same as the current value of
Mid.
Remarks
Sender
The read-only sender property
of WebRTC's RTCRtpTransceiver interface indicates the
RTCRtpSender responsible for encoding and sending outgoing media data
for the transceiver's stream.
[Value("sender")]
public RTCRtpSender Sender { get; }
Property Value
- RTCRtpSender
An RTCRtpSender object used to encode and send media whose media ID
matches the current value of Mid.
Remarks
Methods
SetCodecPreferences(List<RTCRtpCodec>)
The setCodecPreferences() method of the RTCRtpTransceiver interface is used to set the codecs that the transceiver allows for decoding received data, in order of decreasing preference.
[Value("setCodecPreferences")]
public GlobalObject.Undefined SetCodecPreferences(List<RTCRtpCodec> codecs)
Parameters
codecsList<RTCRtpCodec>
Returns
Remarks
The preferences set using this method influence what codecs are negotiated with the remote peer for encoding the data that it sends, including those used for retransmission, redundancy, and forward error correction.
Codecs that are not included in the preferences list will not be part of the negotiation.
Note that the preferences used by this transceiver for sending content depend on the preferences of the remote peer.
The recommended way to set codec preferences is to first get the array of codecs that are actually supported for decoding received data, then reorder them your in decreasing preference order.
This ensures that the array is ordered as required, does not contain any unsupported codecs, and also that it also contains codecs that are needed for retransmission, redundancy, and forward error correction.
The specified set of codecs will be used for all future connections that include this transceiver until this method is called again.
When preparing to open an RTCPeerConnection the codecs should be set using setCodecPreferences() before calling either CreateOffer(RTCOfferOptions) or CreateAnswer(RTCAnswerOptions), as these initiate the negotiation (and will use codec parameters from the {{Glossary("user agent", "user agent's")}} default configuration by default).
The codecs can be changed when you have an ongoing communication, but you need to first call setCodecPreferences() and then kick off a new negotiation.
A WebRTC application will already have code for this in the negotiationneeded event handler.
Note however that at time of writing the event is not automatically fired when you call setCodecPreferences(), so you will have to call onnegotiationneeded yourself.
A guide to codecs supported by WebRTC—and each codec's positive and negative characteristics—can be found in Codecs used by WebRTC.
-setCodecPreferences is now in all browsers! on blog.mozilla.org (2024)
-WebRTC API
-Codecs used by WebRTC
-Introduction to the Real-time Transport Protocol (RTP)
-Web media technologies
Stop()
The stop() method in the RTCRtpTransceiver interface permanently stops the transceiver by stopping both the associated RTCRtpSender and
RTCRtpReceiver.
[Value("stop")]
public GlobalObject.Undefined Stop()