Class RTCRtpSender
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The RTCRtpSender interface provides the ability to control and obtain details about how a particular MediaStreamTrack is encoded and sent to a remote peer.
[Value("RTCRtpSender")]
public class RTCRtpSender
- Inheritance
-
RTCRtpSender
- Inherited Members
Remarks
With it, you can configure the encoding used for the corresponding track, get information about the device's media capabilities, and so forth. You can also obtain access to an RTCDTMFSender which can be used to send {{Glossary("DTMF")}} codes (to simulate the user pressing buttons on a telephone's dial pad) to the remote peer.
-WebRTC API
-AddTrack(MediaStreamTrack, params MediaStream[])
-GetSenders()
-RTCRtpReceiver
Constructors
RTCRtpSender()
public RTCRtpSender()
Properties
Dtmf
The read-only dtmf property on the
RTCRtpSender interface returns a
RTCDTMFSender object which can be used to send {{Glossary("DTMF")}} tones
over the RTCPeerConnection. See Using DTMF for details on how to
make use of the returned RTCDTMFSender object.
[Value("dtmf")]
public RTCDTMFSender? Dtmf { get; }
Property Value
- RTCDTMFSender
An RTCDTMFSender which can be used to send DTMF over the RTP session, or
nullif the track being carried by the RTP session or the
RTCPeerConnection as a whole doesn't support DTMF.NOTE
Only audio tracks can support DTMF, and typically only one audio track perRTCPeerConnectionwill have an associated RTCDTMFSender
Remarks
Track
The track read-only property of
the RTCRtpSender interface returns the MediaStreamTrack
which is being handled by the RTCRtpSender.
[Value("track")]
public MediaStreamTrack? Track { get; }
Property Value
- MediaStreamTrack
A MediaStreamTrack object representing the media associated with the
RTCRtpSender. If no track is associated with the sender, this value isnull, in which case the sender transmits nothing.
Remarks
Transform
The transform property of the RTCRtpSender object is used to insert a transform stream (TransformStream) running in a worker thread into the sender pipeline.
This allows stream transforms to be applied to encoded video and audio frames after they are output by a codec, and before they are sent.
[Value("transform")]
public Union228? Transform { get; set; }
Property Value
- Union228?
A RTCRtpScriptTransform<!-- or {{domxref("SFrameTransform")}} -->, or
nullif the sender has no associated transform stream.
Remarks
The transform that is to be added is defined using an RTCRtpScriptTransform and its associated Worker.
If the transform is set synchronously immediately after creating the RTCRtpSender it will receive the first full frame generated by the sender's encoder.
Transport
The read-only transport property of an
RTCRtpSender object provides the RTCDtlsTransport object
used to interact with the underlying transport over which the sender is exchanging
Real-time Transport Control Protocol (RTCP) packets.
[Value("transport")]
public RTCDtlsTransport? Transport { get; }
Property Value
- RTCDtlsTransport
An RTCDtlsTransport object representing the underlying transport being
used by the sender to exchange packets with the remote peer, ornullif the
sender isn't yet connected to a transport.
Remarks
This transport is responsible for receiving the data for the media on the sender's
Track.
Methods
GenerateKeyFrame(List<string>)
[Value("generateKeyFrame")]
public Task<GlobalObject.Undefined> GenerateKeyFrame(List<string> rids = null)
Parameters
Returns
GetCapabilities(string)
The static method RTCRtpSender.getCapabilities() returns an object describing the codec and header extension capabilities supported by the RTCRtpSender.
[Value("getCapabilities")]
public static RTCRtpCapabilities? GetCapabilities(string kind)
Parameters
kindstring
Returns
- RTCRtpCapabilities
A new object that indicates what capabilities the browser has for sending the specified media kind over an RTCPeerConnection.
If the browser doesn't have any support for the given mediakind, the returned value isnull.The returned object has the following properties:
Remarks
You can, similarly, obtain the capabilities of RTCRtpReceiver objects on the device by calling the static function GetCapabilities(string).
GetParameters()
The getParameters() method of the RTCRtpSender interface returns an object describing the current configuration for how the sender's Track will be encoded and transmitted to a remote RTCRtpReceiver.
[Value("getParameters")]
public RTCRtpSendParameters GetParameters()
Returns
- RTCRtpSendParameters
An object indicating the current configuration of the sender. <!-- RTCRtpSendParameters, derived from RTCRtpParameters -->
Remarks
GetStats()
The RTCRtpSender method getStats() asynchronously requests an RTCStatsReport object which provides statistics about outgoing traffic on the RTCPeerConnection which owns the sender, returning a {{jsxref("Promise")}} which is fulfilled when the results are available.
[Value("getStats")]
public Task<RTCStatsReport> GetStats()
Returns
- Task<RTCStatsReport>
A JavaScript Promise which is fulfilled once the statistics are available.
The promise's fulfillment handler receives as a parameter a RTCStatsReport object containing the collected statistics.The returnedRTCStatsReportaccumulates the statistics for all of the streams being sent using theRTCRtpSender, as well as the statistics for any dependencies those streams have.These might include, for example, statistics with types:outbound-rtp,candidate-pair,local-candidate,remote-candidate.
Remarks
ReplaceTrack(MediaStreamTrack?)
The RTCRtpSender methodreplaceTrack() replaces the track currently being used
as the sender's source with a new MediaStreamTrack.
[Value("replaceTrack")]
public Task<GlobalObject.Undefined> ReplaceTrack(MediaStreamTrack? withTrack)
Parameters
withTrackMediaStreamTrack
Returns
- Task<GlobalObject.Undefined>
A Promise which is fulfilled once the track has been successfully
replaced. The promise is rejected if the track cannot be replaced for any reason; this
is commonly because the change would require renegotiation of the codec, which is not
allowed (see Things that require negotiation).IfnewTrackwas omitted or wasnull,replaceTrack()stops the sender. No negotiation is required in this case.When the promise is fulfilled, the fulfillment handler receives a value ofundefined.
Remarks
The new
track must be of the same media kind (audio, video, etc.) and switching the track should
not require negotiation.
Among the use cases for replaceTrack() is the common need to switch
between the rear- and front-facing cameras on a phone. With replaceTrack(),
you can have a track object for each camera and switch between the two as needed. See
the example switching video cameras below.
SetParameters(RTCRtpSendParameters, RTCSetParameterOptions)
The setParameters() method of the RTCRtpSender interface applies changes the configuration of sender's Track, which is the MediaStreamTrack for which the RTCRtpSender is responsible.
[Value("setParameters")]
public Task<GlobalObject.Undefined> SetParameters(RTCRtpSendParameters parameters, RTCSetParameterOptions setParameterOptions = null)
Parameters
parametersRTCRtpSendParameterssetParameterOptionsRTCSetParameterOptions
Returns
- Task<GlobalObject.Undefined>
A {{jsxref("Promise")}} that resolves when the Track property is updated with the given parameters.
Remarks
In other words, setParameters() updates the configuration of the RTP transmission as well as the encoding configuration for a specific outgoing media track on the WebRTC connection.
SetStreams(params MediaStream[])
The RTCRtpSender method setStreams() associates the sender's Track with the specified MediaStream objects.
[Value("setStreams")]
public GlobalObject.Undefined SetStreams(params MediaStream[] streams)
Parameters
streamsMediaStream[]