From b60a5ab91c361e643ed6982cb8dad7f550d6ca6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Mon, 3 Feb 2025 12:25:50 +0100 Subject: [PATCH] Choose RTX codec PT in lower range if codec is in lower range MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pc1 video mline without this change (and the previous one): 96 97 107 108 109 114 115 116 117 118 119 120 37 121 40 124 98 99 100 101 127 42 43 with this change: 96 97 103 104 107 108 109 114 115 116 117 118 39 40 45 46 98 99 100 101 119 120 121 BUG=webrtc:360058654 Change-Id: I4021daf1c62f0edf9650e12a74619035040291a8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/376022 Reviewed-by: Henrik Boström Commit-Queue: Henrik Boström Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#43838} --- call/BUILD.gn | 1 + call/payload_type_picker.cc | 10 ++++++++++ call/payload_type_picker_unittest.cc | 8 +++++++- 3 files changed, 18 insertions(+), 1 deletion(-) 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) {