make setCodecPreferences retain position of rtx/red
close to the codec they relate to as it is done by video_engine. This does not change functionality but improves readability of the SDP BUG=webrtc:13287 Change-Id: I9b03cd3131eaa932ffed3fb4e66cbf55faedcdd6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235665 Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Philipp Hancke <philipp.hancke@googlemail.com> Cr-Commit-Position: refs/heads/main@{#35311}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
97597c0f51
commit
c13e786c8f
@ -741,10 +741,16 @@ static Codecs MatchCodecPreference(
|
|||||||
const Codecs& codecs,
|
const Codecs& codecs,
|
||||||
const Codecs& supported_codecs) {
|
const Codecs& supported_codecs) {
|
||||||
Codecs filtered_codecs;
|
Codecs filtered_codecs;
|
||||||
std::set<std::string> kept_codecs_ids;
|
|
||||||
bool want_rtx = false;
|
bool want_rtx = false;
|
||||||
bool want_red = false;
|
bool want_red = false;
|
||||||
|
|
||||||
|
for (const auto& codec_preference : codec_preferences) {
|
||||||
|
if (IsRtxCodec(codec_preference)) {
|
||||||
|
want_rtx = true;
|
||||||
|
} else if (IsRedCodec(codec_preference)) {
|
||||||
|
want_red = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (const auto& codec_preference : codec_preferences) {
|
for (const auto& codec_preference : codec_preferences) {
|
||||||
auto found_codec = absl::c_find_if(
|
auto found_codec = absl::c_find_if(
|
||||||
supported_codecs,
|
supported_codecs,
|
||||||
@ -764,23 +770,16 @@ static Codecs MatchCodecPreference(
|
|||||||
if (FindMatchingCodec(supported_codecs, codecs, *found_codec,
|
if (FindMatchingCodec(supported_codecs, codecs, *found_codec,
|
||||||
&found_codec_with_correct_pt)) {
|
&found_codec_with_correct_pt)) {
|
||||||
filtered_codecs.push_back(found_codec_with_correct_pt);
|
filtered_codecs.push_back(found_codec_with_correct_pt);
|
||||||
kept_codecs_ids.insert(std::to_string(found_codec_with_correct_pt.id));
|
std::string id = rtc::ToString(found_codec_with_correct_pt.id);
|
||||||
}
|
// Search for the matching rtx or red codec.
|
||||||
} else if (IsRtxCodec(codec_preference)) {
|
if (want_red || want_rtx) {
|
||||||
want_rtx = true;
|
|
||||||
} else if (IsRedCodec(codec_preference)) {
|
|
||||||
want_red = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (want_rtx || want_red) {
|
|
||||||
for (const auto& codec : codecs) {
|
for (const auto& codec : codecs) {
|
||||||
if (IsRtxCodec(codec)) {
|
if (IsRtxCodec(codec)) {
|
||||||
const auto apt =
|
const auto apt =
|
||||||
codec.params.find(cricket::kCodecParamAssociatedPayloadType);
|
codec.params.find(cricket::kCodecParamAssociatedPayloadType);
|
||||||
if (apt != codec.params.end() &&
|
if (apt != codec.params.end() && apt->second == id) {
|
||||||
kept_codecs_ids.count(apt->second) > 0) {
|
|
||||||
filtered_codecs.push_back(codec);
|
filtered_codecs.push_back(codec);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if (IsRedCodec(codec)) {
|
} else if (IsRedCodec(codec)) {
|
||||||
const auto fmtp =
|
const auto fmtp =
|
||||||
@ -789,8 +788,12 @@ static Codecs MatchCodecPreference(
|
|||||||
std::vector<std::string> redundant_payloads;
|
std::vector<std::string> redundant_payloads;
|
||||||
rtc::split(fmtp->second, '/', &redundant_payloads);
|
rtc::split(fmtp->second, '/', &redundant_payloads);
|
||||||
if (redundant_payloads.size() > 0 &&
|
if (redundant_payloads.size() > 0 &&
|
||||||
kept_codecs_ids.count(redundant_payloads[0]) > 0) {
|
redundant_payloads[0] == id) {
|
||||||
filtered_codecs.push_back(codec);
|
filtered_codecs.push_back(codec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user