diff --git a/call/BUILD.gn b/call/BUILD.gn index 8f37af0be1..484b772e49 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -396,6 +396,7 @@ rtc_library("payload_type_picker") { "../media:media_constants", "../rtc_base:checks", "../rtc_base:logging", + "../rtc_base:stringutils", "../rtc_base:strong_alias", "//third_party/abseil-cpp/absl/strings", ] diff --git a/call/payload_type_picker.cc b/call/payload_type_picker.cc index eb8ed45762..c7983ce172 100644 --- a/call/payload_type_picker.cc +++ b/call/payload_type_picker.cc @@ -25,6 +25,7 @@ #include "media/base/media_constants.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/string_encode.h" namespace webrtc { @@ -80,6 +81,15 @@ bool CodecPrefersLowerRange(const cricket::Codec& codec) { return true; } } + } else if (absl::EqualsIgnoreCase(codec.name, cricket::kRtxCodecName)) { + // For RTX prefer lower range if the associated codec is in that range. + std::string associated_pt_str; + int associated_pt; + return codec.GetParam(cricket::kCodecParamAssociatedPayloadType, + &associated_pt_str) && + rtc::FromString(associated_pt_str, &associated_pt) && + associated_pt >= kFirstDynamicPayloadTypeLowerRange && + associated_pt <= kLastDynamicPayloadTypeLowerRange; } return false; } diff --git a/call/payload_type_picker_unittest.cc b/call/payload_type_picker_unittest.cc index fd64923b84..5a3e39bb5b 100644 --- a/call/payload_type_picker_unittest.cc +++ b/call/payload_type_picker_unittest.cc @@ -10,6 +10,7 @@ #include "call/payload_type_picker.h" +#include "api/video_codecs/sdp_video_format.h" #include "call/payload_type.h" #include "media/base/codec.h" #include "media/base/media_constants.h" @@ -205,9 +206,14 @@ TEST(PayloadTypePicker, VideoGetsTreatedSpecially) { // Valid for high range only. EXPECT_THAT(picker.SuggestMapping(h264_constrained, nullptr).value(), Ge(96)); EXPECT_THAT(picker.SuggestMapping(vp9_profile_2, nullptr).value(), Ge(96)); - // Valud for lower range. + // Valid for lower range. EXPECT_THAT(picker.SuggestMapping(h264_yuv444, nullptr).value(), Lt(63)); EXPECT_THAT(picker.SuggestMapping(vp9_profile_3, nullptr).value(), Lt(63)); + + // RTX with a primary codec in the lower range is valid for lower range. + cricket::Codec lower_range_rtx = + cricket::CreateVideoRtxCodec(cricket::Codec::kIdNotSet, 63); + EXPECT_THAT(picker.SuggestMapping(lower_range_rtx, nullptr).value(), Lt(63)); } TEST(PayloadTypePicker, ChoosingH264Profiles) {