RTCRtpSender.setParameters()

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.

In other words, setParameters() updates the configuration of the RTP transmission as well as the encoding configuration for a specific media track on the WebRTC connection.

Syntax

var promise = rtcRtpSender.setParameters(parameters)

Parameters

parameters

An object conforming with the RTCRtpSendParameters dictionary, specifying options for the RTCRtpSender; these include potential codecs that could be use for encoding the sender's track. The available options are:

degradationPreference
Specifies the preferred way the WebRTC layer should handle optimizing bandwidth against quality in constrained-bandwidth situations; the value comes from the RTCDegradationPreference enumerated string type, and the default is balanced.
encodings
An array of RTCRtpEncodingParameters objects, each specifying the parameters for a single codec that could be used to encode the track's media.
priority
A string from the RTCPriorityType enumerated type which indicates the encoding's priority. The default value is low.
transactionId
A string containing a unique ID for the last set of parameters applied; this value is used to ensure that setParameters() can only be called to alter changes made by a specific previous call to getParameters().

Return value

A Promise that resolves when the RTCRtpSender.track property is updated with the given parameters.

Exceptions

If an error occurs, the returned promise is rejected with the appropriate exception from the list below.

InvalidModificationError
One of the following problems was detected:
  • The number of encodings specified in the parameters object's encodings property does not match the number of encodings currently listed for the RTCRtpSender. You cannot change the number of encoding options once the sender has been created.
  • The order of the specified encodings has changed from the current list's order.
  • An attempt has been made to alter a property that cannot be changed after the sender is first created.
InvalidStateError
The transceiver of which the RTCRtpSender is a part is not running, or has no parameters to set.
OperationError
Any error condition which occurs that isn't covered by one of the other error codes results in an OperationError.
RangeError
The value specified for scaleResolutionDownBy is less than 1.0, which would result in scaling up rather than down, which is not allowed; or one or more of the specified encodings' maxFramerate values is less than 0.0.

In addition, if a WebRTC error occurs while configuring or accessing the media, an RTCError is thrown with its errorDetail set to hardware-encoder-error.

Specifications

Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCRtpSender.setParameters()' in that specification.
Candidate Recommendation Initial definition.

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
setParameters()Chrome Full support YesEdge Full support ≤79Firefox Full support 64
Notes
Full support 64
Notes
Notes Changes to parameters that should update live now do so starting in Firefox 64.
Full support 46
IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 64
Notes
Full support 64
Notes
Notes Changes to parameters that should update live now do so starting in Firefox 64.
Full support 46
Opera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes

Legend

Full support
Full support
No support
No support
Compatibility unknown
Compatibility unknown
See implementation notes.
See implementation notes.

See also