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
RTCRtpSendParametersdictionary, specifying options for theRTCRtpSender; these include potential codecs that could be use for encoding the sender'strack. 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
RTCDegradationPreferenceenumerated string type, and the default isbalanced. encodings- An array of
RTCRtpEncodingParametersobjects, each specifying the parameters for a single codec that could be used to encode the track's media. priority- A string from the
RTCPriorityTypeenumerated type which indicates the encoding's priority. The default value islow. 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 togetParameters().
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
parametersobject'sencodingsproperty does not match the number of encodings currently listed for theRTCRtpSender. You cannot change the number of encoding options once the sender has been created. - The order of the specified
encodingshas 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.
- The number of encodings specified in the
InvalidStateError- The transceiver of which the
RTCRtpSenderis 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
scaleResolutionDownByis 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'maxFrameratevalues 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
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
setParameters() | Chrome Full support Yes | Edge Full support ≤79 | Firefox
Full support
64
| IE No support No | Opera Full support Yes | Safari ? | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android
Full support
64
| Opera Android Full support Yes | Safari 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.
