The RTCRtpTransceiver
method setCodecPreferences()
configures the transceiver's codecs given a list of RTCRtpCodecParameters
objects specifying the new preferences for each codec. The specified set of codecs and configurations will be used for all future connections including this transceiver until this method is called again.
When preparing to open an RTCPeerConnection
, you can change the codec parameters from the user agent's default configuration by calling setCodecParameters()
before calling either RTCPeerConnection.createOffer()
or createAnswer()
.
RTCRtpTransceiver.setCodecPreferences(codecs)
codecs
RTCRtpCodecParameters
objects, in order of preference, each providing the parameters for one of the transceiver's supported codecs. If codecs
is empty, the codec configurations are all returned to the user agent's defaults. codecs
will not be considered during the process of negotiating a connection. This lets you prevent the use of codecs you don't wish to use.undefined
InvalidAccessError
codecs
list includes one or more codecs which are not supported by the transceiver.You can only include in the codecs
list codecs which the transceiver actually supports. That means that either the associated RTCRtpSender
or the RTCRtpReceiver
needs to support every codec in the list. If any unsupported codecs are listed, the browser will throw an InvalidAccessError
exception when you call this method.
To determine which codecs are supported by the transceiver, call the sender's getCapabilities()
and the receiver's getCapabilities()
methods and get the codecs
list from the results of each.
This code shows how to get the lists of supported codecs for both sender and receiver:
var availSendCodecs = transceiver.sender.getCapabilities("video").codecs; var availReceiveCodecs = transceiver.receiver.getCapabilities("video").codecs;
Specification | Status | Comment |
---|---|---|
WebRTC 1.0: Real-time Communication Between Browsers The definition of 'RTCRtpTransceiver.setCodecPreferences()' in that specification. | Candidate Recommendation |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | No | ? | No | No | No | ? |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | No | No | ? | No | No | ? | No |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/setCodecPreferences