flexfec: improve readability
BUG=webrtc:8151
Change-Id: I9b301b4a4f14739bdbdee3ae55940c0911d5b4d4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/194144
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Reviewed-by: Christoffer Rodbro <crodbro@webrtc.org>
Commit-Queue: Christoffer Rodbro <crodbro@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32871}
diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc
index 855104a..d1b05d9 100644
--- a/media/engine/webrtc_video_engine.cc
+++ b/media/engine/webrtc_video_engine.cc
@@ -106,16 +106,34 @@
}
}
-// This function will assign dynamic payload types (in the range [96, 127] and
-// for new additions the [35, 65] range) to the input codecs, and also add
-// ULPFEC, RED, FlexFEC, and associated RTX codecs for recognized codecs (VP8,
-// VP9, H264 and RED). It will also add default feedback params to the codecs.
-std::vector<VideoCodec> AssignPayloadTypesAndDefaultCodecs(
- std::vector<webrtc::SdpVideoFormat> input_formats,
- const webrtc::WebRtcKeyValueConfig& trials,
- bool is_decoder_factory) {
- if (input_formats.empty())
+// This function will assign dynamic payload types (in the range [96, 127]) to
+// the input codecs, and also add ULPFEC, RED, FlexFEC, and associated RTX
+// codecs for recognized codecs (VP8, VP9, H264, and RED). It will also add
+// default feedback params to the codecs.
+// is_decoder_factory is needed to keep track of the implict assumption that any
+// H264 decoder also supports constrained base line profile.
+// Also, is_decoder_factory is used to decide whether FlexFEC video format
+// should be advertised as supported.
+// TODO(kron): Perhaps it is better to move the implicit knowledge to the place
+// where codecs are negotiated.
+template <class T>
+std::vector<VideoCodec> GetPayloadTypesAndDefaultCodecs(
+ const T* factory,
+ bool is_decoder_factory,
+ const webrtc::WebRtcKeyValueConfig& trials) {
+ if (!factory) {
+ return {};
+ }
+
+ std::vector<webrtc::SdpVideoFormat> supported_formats =
+ factory->GetSupportedFormats();
+ if (is_decoder_factory) {
+ AddH264ConstrainedBaselineProfileToSupportedFormats(&supported_formats);
+ }
+
+ if (supported_formats.empty())
return std::vector<VideoCodec>();
+
// Due to interoperability issues with old Chrome/WebRTC versions only use
// the lower range for new codecs.
static const int kFirstDynamicPayloadTypeLowerRange = 35;
@@ -126,8 +144,8 @@
int payload_type_upper = kFirstDynamicPayloadTypeUpperRange;
int payload_type_lower = kFirstDynamicPayloadTypeLowerRange;
- input_formats.push_back(webrtc::SdpVideoFormat(kRedCodecName));
- input_formats.push_back(webrtc::SdpVideoFormat(kUlpfecCodecName));
+ supported_formats.push_back(webrtc::SdpVideoFormat(kRedCodecName));
+ supported_formats.push_back(webrtc::SdpVideoFormat(kUlpfecCodecName));
// flexfec-03 is supported as
// - receive codec unless WebRTC-FlexFEC-03-Advertised is disabled
@@ -142,11 +160,11 @@
// we never use the actual value anywhere in our code however.
// TODO(brandtr): Consider honouring this value in the sender and receiver.
flexfec_format.parameters = {{kFlexfecFmtpRepairWindow, "10000000"}};
- input_formats.push_back(flexfec_format);
+ supported_formats.push_back(flexfec_format);
}
std::vector<VideoCodec> output_codecs;
- for (const webrtc::SdpVideoFormat& format : input_formats) {
+ for (const webrtc::SdpVideoFormat& format : supported_formats) {
VideoCodec codec(format);
bool isCodecValidForLowerRange =
absl::EqualsIgnoreCase(codec.name, kFlexfecCodecName);
@@ -203,31 +221,6 @@
return output_codecs;
}
-// is_decoder_factory is needed to keep track of the implict assumption that any
-// H264 decoder also supports constrained base line profile.
-// Also, is_decoder_factory is used to decide whether FlexFEC video format
-// should be advertised as supported.
-// TODO(kron): Perhaps it is better to move the implicit knowledge to the place
-// where codecs are negotiated.
-template <class T>
-std::vector<VideoCodec> GetPayloadTypesAndDefaultCodecs(
- const T* factory,
- bool is_decoder_factory,
- const webrtc::WebRtcKeyValueConfig& trials) {
- if (!factory) {
- return {};
- }
-
- std::vector<webrtc::SdpVideoFormat> supported_formats =
- factory->GetSupportedFormats();
- if (is_decoder_factory) {
- AddH264ConstrainedBaselineProfileToSupportedFormats(&supported_formats);
- }
-
- return AssignPayloadTypesAndDefaultCodecs(std::move(supported_formats),
- trials, is_decoder_factory);
-}
-
bool IsTemporalLayersSupported(const std::string& codec_name) {
return absl::EqualsIgnoreCase(codec_name, kVp8CodecName) ||
absl::EqualsIgnoreCase(codec_name, kVp9CodecName);