Skip to content

Commit

Permalink
Make setCodecPreferences only look at receive codecs
Browse files Browse the repository at this point in the history
which is what is noted in JSEP:
  https://www.rfc-editor.org/rfc/rfc8829.html#name-setcodecpreferences

Some W3C spec modifications are required since the W3C specification
currently takes into account send codecs as well.

Spec issue:
  w3c/webrtc-pc#2888
Spec PR:
 w3c/webrtc-pc#2926

setCodecPreferences continues to modify the codecs in an offer.

Also rename RtpSender::SetCodecPreferences to RtpSender::SetSendCodecs for consistent semantics.

BUG=webrtc:15396

Change-Id: I1e8fbe77cb2670575578a777ed1336567a1e4031
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/328780
Reviewed-by: Henrik Boström <[email protected]>
Commit-Queue: Philipp Hancke <[email protected]>
Reviewed-by: Harald Alvestrand <[email protected]>
Cr-Commit-Position: refs/heads/main@{#41719}
  • Loading branch information
fippo authored and WebRTC LUCI CQ committed Feb 12, 2024
1 parent cd81d55 commit 1cce1d7
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 218 deletions.
18 changes: 8 additions & 10 deletions media/base/media_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ std::vector<webrtc::RtpExtension> GetDefaultEnabledRtpHeaderExtensions(

webrtc::RTCError CheckScalabilityModeValues(
const webrtc::RtpParameters& rtp_parameters,
rtc::ArrayView<cricket::Codec> codec_preferences,
rtc::ArrayView<cricket::Codec> send_codecs,
absl::optional<cricket::Codec> send_codec) {
using webrtc::RTCErrorType;

if (codec_preferences.empty()) {
if (send_codecs.empty()) {
// This is an audio sender or an extra check in the stack where the codec
// list is not available and we can't check the scalability_mode values.
return webrtc::RTCError::OK();
Expand All @@ -80,7 +80,7 @@ webrtc::RTCError CheckScalabilityModeValues(
for (size_t i = 0; i < rtp_parameters.encodings.size(); ++i) {
if (rtp_parameters.encodings[i].codec) {
bool codecFound = false;
for (const cricket::VideoCodec& codec : codec_preferences) {
for (const cricket::Codec& codec : send_codecs) {
if (codec.MatchesRtpCodec(*rtp_parameters.encodings[i].codec)) {
codecFound = true;
send_codec = codec;
Expand All @@ -97,7 +97,7 @@ webrtc::RTCError CheckScalabilityModeValues(
if (rtp_parameters.encodings[i].scalability_mode) {
if (!send_codec) {
bool scalabilityModeFound = false;
for (const cricket::VideoCodec& codec : codec_preferences) {
for (const cricket::Codec& codec : send_codecs) {
for (const auto& scalability_mode : codec.scalability_modes) {
if (ScalabilityModeToString(scalability_mode) ==
*rtp_parameters.encodings[i].scalability_mode) {
Expand Down Expand Up @@ -139,7 +139,7 @@ webrtc::RTCError CheckScalabilityModeValues(

webrtc::RTCError CheckRtpParametersValues(
const webrtc::RtpParameters& rtp_parameters,
rtc::ArrayView<cricket::Codec> codec_preferences,
rtc::ArrayView<cricket::Codec> send_codecs,
absl::optional<cricket::Codec> send_codec) {
using webrtc::RTCErrorType;

Expand Down Expand Up @@ -196,8 +196,7 @@ webrtc::RTCError CheckRtpParametersValues(
}
}

return CheckScalabilityModeValues(rtp_parameters, codec_preferences,
send_codec);
return CheckScalabilityModeValues(rtp_parameters, send_codecs, send_codec);
}

webrtc::RTCError CheckRtpParametersInvalidModificationAndValues(
Expand All @@ -210,7 +209,7 @@ webrtc::RTCError CheckRtpParametersInvalidModificationAndValues(
webrtc::RTCError CheckRtpParametersInvalidModificationAndValues(
const webrtc::RtpParameters& old_rtp_parameters,
const webrtc::RtpParameters& rtp_parameters,
rtc::ArrayView<cricket::Codec> codec_preferences,
rtc::ArrayView<cricket::Codec> send_codecs,
absl::optional<cricket::Codec> send_codec) {
using webrtc::RTCErrorType;
if (rtp_parameters.encodings.size() != old_rtp_parameters.encodings.size()) {
Expand Down Expand Up @@ -246,8 +245,7 @@ webrtc::RTCError CheckRtpParametersInvalidModificationAndValues(
"Attempted to set RtpParameters with modified SSRC");
}

return CheckRtpParametersValues(rtp_parameters, codec_preferences,
send_codec);
return CheckRtpParametersValues(rtp_parameters, send_codecs, send_codec);
}

CompositeMediaEngine::CompositeMediaEngine(
Expand Down
6 changes: 3 additions & 3 deletions media/base/media_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ namespace cricket {
// least one video codec of the list. If the list is empty, no check is done.
webrtc::RTCError CheckScalabilityModeValues(
const webrtc::RtpParameters& new_parameters,
rtc::ArrayView<cricket::Codec> codec_preferences,
rtc::ArrayView<cricket::Codec> send_codecs,
absl::optional<cricket::Codec> send_codec);

// Checks the parameters have valid and supported values, and checks parameters
// with CheckScalabilityModeValues().
webrtc::RTCError CheckRtpParametersValues(
const webrtc::RtpParameters& new_parameters,
rtc::ArrayView<cricket::Codec> codec_preferences,
rtc::ArrayView<cricket::Codec> send_codecs,
absl::optional<cricket::Codec> send_codec);

// Checks that the immutable values have not changed in new_parameters and
// checks all parameters with CheckRtpParametersValues().
webrtc::RTCError CheckRtpParametersInvalidModificationAndValues(
const webrtc::RtpParameters& old_parameters,
const webrtc::RtpParameters& new_parameters,
rtc::ArrayView<cricket::Codec> codec_preferences,
rtc::ArrayView<cricket::Codec> send_codecs,
absl::optional<cricket::Codec> send_codec);

// Checks that the immutable values have not changed in new_parameters and
Expand Down
Loading

0 comments on commit 1cce1d7

Please sign in to comment.