From 8ddd49c215b04078eb673b1dc889ac6f35990a7f Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Mon, 27 Mar 2023 18:02:55 +0200 Subject: [PATCH] Add a codec match algorithm for setCodecPreferences Also remove impossible to implement steps in setCodecPreferences, as it's always possible to modify a dictionary. Fixes #2845. --- webrtc.html | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/webrtc.html b/webrtc.html index fee0e333b..6390b8ee1 100644 --- a/webrtc.html +++ b/webrtc.html @@ -11110,17 +11110,14 @@

The codecs sequence passed into - {{setCodecPreferences}} can only contain codecs that are - returned by + {{setCodecPreferences}} can only contain + {{RTCRtpCodec}} values that match values using the [= codec match =] + algorithm that are returned by {{RTCRtpSender}}.{{RTCRtpSender/getCapabilities}}(kind) or {{RTCRtpReceiver}}.{{RTCRtpReceiver/getCapabilities}}(kind), where kind is the kind of the {{RTCRtpTransceiver}} on which the method is called. - Additionally, the {{RTCRtpCodecCapability}} dictionary - members cannot be modified. If codecs does not - fulfill these requirements, the user agent MUST [= - exception/throw =] an {{InvalidModificationError}}.

Due to a recommendation in [[!SDP]], calls to @@ -11196,8 +11193,7 @@

For each codec in codecs,

    -
  1. If codec is not in - codecCapabilities, throw +
  2. If the result of the [= codec match =] algorithm between codec and each of codecCapabilities items is false, throw {{InvalidModificationError}}.
@@ -11209,6 +11205,36 @@

+

+ The codec match algorithm given two {{RTCRtpCodec}} or compatible dictionaries first and second is as follows: +

+
    +
  1. +

    + If first.{{RTCRtpCodec/mimeType}} is different from second.{{RTCRtpCodec/mimeType}}, return false. +

    +
  2. +
  3. +

    + If first.{{RTCRtpCodec/clockRate}} is different from second.{{RTCRtpCodec/clockRate}}, return false. +

    +
  4. +
  5. +

    + If first.{{RTCRtpCodec/channels}} is different from second.{{RTCRtpCodec/channels}}, return false. +

    +
  6. +
  7. +

    + If first.{{RTCRtpCodec/sdpFmtpLine}} is different from second.{{RTCRtpCodec/sdpFmtpLine}}, return false. +

    +
  8. +
  9. +

    + Return true. +

    +
  10. +

If set, the offerer's codec preferences will decide the order of the codecs in the offer. If the answerer does not have any