Skip to content

Commit

Permalink
Merge pull request #2847 from Orphis/codec_match
Browse files Browse the repository at this point in the history
Add a codec match algorithm for setCodecPreferences
  • Loading branch information
henbos authored Mar 30, 2023
2 parents c18d9b8 + 2c6f622 commit ed6a216
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 10 deletions.
9 changes: 9 additions & 0 deletions amendments.json
Original file line number Diff line number Diff line change
Expand Up @@ -440,5 +440,14 @@
"status": "candidate",
"id": 30
}
],
"setcodecparameters-algorithm": [
{
"description": "Fix ambiguities in the setCodecPreferences() algorithm",
"pr": 2847,
"type": "correction",
"status": "candidate",
"id": 31
}
]
}
57 changes: 47 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>
[= codec match | not matching =] 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 [= codec match | not match any codec =]
in <var>codecCapabilities</var>, throw {{InvalidModificationError}}.
</p>
</li>
</ol>
</li>
Expand All @@ -11209,6 +11205,47 @@ <h2>
</p>
</li>
</ol>
<p>
The <dfn class="export">codec match</dfn> algorithm given two {{RTCRtpCodec}}
<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 either (but not both) of <var>first</var>.{{RTCRtpCodec/channels}}
and <var>second</var>.{{RTCRtpCodec/channels}} are [= map/exist | missing =],
or if they both [= map/exist =] and <var>first</var>.{{RTCRtpCodec/channels}}
is different from <var>second</var>.{{RTCRtpCodec/channels}}, return
<code>false</code>.
</p>
</li>
<li>
<p>
If either (but not both) of <var>first</var>.{{RTCRtpCodec/sdpFmtpLine}}
and <var>second</var>.{{RTCRtpCodec/sdpFmtpLine}} are [= map/exist | missing =],
or if they both [=map/exist=] and <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 ed6a216

Please sign in to comment.