message: video_engine: allow allocating h264/yuv444 in lower payload type range
  Cr-Commit-Position: refs/heads/main@{#35222}
diff: @@ -110,6 +110,23 @@ void AddDefaultFeedbackParams(VideoCodec* codec,
  }
  }
  +// Helper function to determine whether a codec should use the [35, 63] range.
  +// Should be used when adding new codecs (or variants).
  +bool IsCodecValidForLowerRange(const VideoCodec& codec) {
  + if (absl::EqualsIgnoreCase(codec.name, kFlexfecCodecName) ||
  + absl::EqualsIgnoreCase(codec.name, kAv1CodecName) ||
  + absl::EqualsIgnoreCase(codec.name, kAv1xCodecName)) {
  + return true;
  + } else if (absl::EqualsIgnoreCase(codec.name, kH264CodecName)) {
  + std::string profileLevelId;
  + // H264 with YUV444.
  + if (codec.GetParam(kH264FmtpProfileLevelId, &profileLevelId)) {
  + return absl::StartsWithIgnoreCase(profileLevelId, "f400");
  + }
  + }
  + return false;
  +}
  +
  // This function will assign dynamic payload types (in the range [96, 127]
  // and then [35, 63]) to the input codecs, and also add ULPFEC, RED, FlexFEC,
  // and associated RTX codecs for recognized codecs (VP8, VP9, H264, and RED).
  @@ -170,10 +187,6 @@ std::vector<VideoCodec> GetPayloadTypesAndDefaultCodecs(
  std::vector<VideoCodec> output_codecs;
  for (const webrtc::SdpVideoFormat& format : supported_formats) {
  VideoCodec codec(format);
  - bool isCodecValidForLowerRange =
  - absl::EqualsIgnoreCase(codec.name, kFlexfecCodecName) ||
  - absl::EqualsIgnoreCase(codec.name, kAv1CodecName) ||
  - absl::EqualsIgnoreCase(codec.name, kAv1xCodecName);
  bool isFecCodec = absl::EqualsIgnoreCase(codec.name, kUlpfecCodecName) ||
  absl::EqualsIgnoreCase(codec.name, kFlexfecCodecName);
  @@ -189,7 +202,7 @@ std::vector<VideoCodec> GetPayloadTypesAndDefaultCodecs(
  // Lower range gets used for "new" codecs or when running out of payload
  // types in the upper range.
  - if (isCodecValidForLowerRange ||
  + if (IsCodecValidForLowerRange(codec) ||
  payload_type_upper >= kLastDynamicPayloadTypeUpperRange) {
  codec.id = payload_type_lower++;
  } else {
  @@ -209,7 +222,7 @@ std::vector<VideoCodec> GetPayloadTypesAndDefaultCodecs(
  RTC_DCHECK_EQ(payload_type_upper, kLastDynamicPayloadTypeUpperRange);
  break;
  }
  - if (isCodecValidForLowerRange ||
  + if (IsCodecValidForLowerRange(codec) ||
  payload_type_upper >= kLastDynamicPayloadTypeUpperRange) {
  output_codecs.push_back(
  VideoCodec::CreateRtxCodec(payload_type_lower++, codec.id));
  