Choose RTX codec PT in lower range if codec is in lower range

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 <hbos@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43838}
This commit is contained in:
Henrik Boström 2025-02-03 12:25:50 +01:00 committed by WebRTC LUCI CQ
parent 1181edda58
commit b60a5ab91c
3 changed files with 18 additions and 1 deletions

View File

@ -396,6 +396,7 @@ rtc_library("payload_type_picker") {
"../media:media_constants", "../media:media_constants",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:stringutils",
"../rtc_base:strong_alias", "../rtc_base:strong_alias",
"//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings",
] ]

View File

@ -25,6 +25,7 @@
#include "media/base/media_constants.h" #include "media/base/media_constants.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/string_encode.h"
namespace webrtc { namespace webrtc {
@ -80,6 +81,15 @@ bool CodecPrefersLowerRange(const cricket::Codec& codec) {
return true; 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; return false;
} }

View File

@ -10,6 +10,7 @@
#include "call/payload_type_picker.h" #include "call/payload_type_picker.h"
#include "api/video_codecs/sdp_video_format.h"
#include "call/payload_type.h" #include "call/payload_type.h"
#include "media/base/codec.h" #include "media/base/codec.h"
#include "media/base/media_constants.h" #include "media/base/media_constants.h"
@ -205,9 +206,14 @@ TEST(PayloadTypePicker, VideoGetsTreatedSpecially) {
// Valid for high range only. // Valid for high range only.
EXPECT_THAT(picker.SuggestMapping(h264_constrained, nullptr).value(), Ge(96)); EXPECT_THAT(picker.SuggestMapping(h264_constrained, nullptr).value(), Ge(96));
EXPECT_THAT(picker.SuggestMapping(vp9_profile_2, 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(h264_yuv444, nullptr).value(), Lt(63));
EXPECT_THAT(picker.SuggestMapping(vp9_profile_3, 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) { TEST(PayloadTypePicker, ChoosingH264Profiles) {