Skip to content

Commit

Permalink
Add a codec match algorithm for setCodecPreferences
Browse files Browse the repository at this point in the history
Also remove impossible to implement steps in setCodecPreferences,
as it's always possible to modify a dictionary.

Fixes w3c#2845.
  • Loading branch information
Orphis committed Mar 29, 2023
1 parent 892d794 commit a332dcb
Showing 1 changed file with 42 additions and 10 deletions.
52 changes: 42 additions & 10 deletions webrtc.html
Original file line number Diff line number Diff line change
Expand Up @@ -11109,18 +11109,13 @@ <h2>
be removed from the mapping of payload types in the SDP.
</p>
<p>
The <var>codecs</var> sequence passed into
{{setCodecPreferences}} can only contain codecs that are
returned by
{{setCodecPreferences}} will reject attempts to set <var>codecs</var>
[=not matching | codec match=] codecs found in
{{RTCRtpSender}}.{{RTCRtpSender/getCapabilities}}(<var>kind</var>)
or
{{RTCRtpReceiver}}.{{RTCRtpReceiver/getCapabilities}}(<var>kind</var>),
where <var>kind</var> is the kind of the
{{RTCRtpTransceiver}} on which the method is called.
Additionally, the {{RTCRtpCodecCapability}} dictionary
members cannot be modified. If <var>codecs</var> does not
fulfill these requirements, the user agent MUST [=
exception/throw =] an {{InvalidModificationError}}.
</p>
<p class="note">
Due to a recommendation in [[!SDP]], calls to
Expand Down Expand Up @@ -11196,9 +11191,10 @@ <h2>
For each <var>codec</var> in <var>codecs</var>,
</p>
<ol>
<li>If <var>codec</var> is not in
<var>codecCapabilities</var>, throw
{{InvalidModificationError}}.
<li>
<p>If <var>codec</var> does [=not match any codec|codec match=]
in <var>codecCapabilities</var>, throw {{InvalidModificationError}}.
</p>
</li>
</ol>
</li>
Expand All @@ -11209,6 +11205,42 @@ <h2>
</p>
</li>
</ol>
<p>
The <dfn class="export">codec match</dfn> algorithm given two {{RTCRtpCodec}} or compatible dictionaries <var>first</var> and <var>second</var> is as follows:
</p>
<ol class=algorithm>
<li>
<p>
If <var>first</var>.{{RTCRtpCodec/mimeType}} is different from
<var>second</var>.{{RTCRtpCodec/mimeType}}, return <code>false</code>.
</p>
</li>
<li>
<p>
If <var>first</var>.{{RTCRtpCodec/clockRate}} is different from
<var>second</var>.{{RTCRtpCodec/clockRate}}, return <code>false</code>.
</p>
</li>
<li>
<p>
If <var>first</var>.{{RTCRtpCodec/channels}} and <var>second</var>.{{RTCRtpCodec/channels}}
are not both missing or if <var>first</var>.{{RTCRtpCodec/channels}} is different from
<var>second</var>.{{RTCRtpCodec/channels}}, return <code>false</code>.
</p>
</li>
<li>
<p>
If <var>first</var>.{{RTCRtpCodec/sdpFmtpLine}} and <var>second</var>.{{RTCRtpCodec/sdpFmtpLine}}
are not both missing or if <var>first</var>.{{RTCRtpCodec/sdpFmtpLine}} is different from
<var>second</var>.{{RTCRtpCodec/sdpFmtpLine}}, return <code>false</code>.
</p>
</li>
<li>
<p>
Return <code>true</code>.
</p>
</li>
</ol>
<p class="note">
If set, the offerer's codec preferences will decide the order
of the codecs in the offer. If the answerer does not have any
Expand Down

0 comments on commit a332dcb

Please sign in to comment.