diff --git a/video/config/simulcast.cc b/video/config/simulcast.cc index 06a3bedb7d..4391d973f6 100644 --- a/video/config/simulcast.cc +++ b/video/config/simulcast.cc @@ -183,6 +183,22 @@ bool EnableLowresBitrateInterpolation(const webrtc::FieldTrialsView& trials) { trials.Lookup("WebRTC-LowresSimulcastBitrateInterpolation"), "Enabled"); } +int GetDefaultSimulcastTemporalLayers(webrtc::VideoCodecType codec) { + switch (codec) { + case webrtc::kVideoCodecVP8: + case webrtc::kVideoCodecVP9: + case webrtc::kVideoCodecAV1: + case webrtc::kVideoCodecH264: + case webrtc::kVideoCodecGeneric: + return kDefaultNumTemporalLayers; + // For codec type that has no software fallback, defaults to L1T1 for + // initial simulcast setup, as this is the only scalability mode secure to + // be supported. + case webrtc::kVideoCodecH265: + return 1; + } +} + std::vector GetSimulcastFormats( bool enable_lowres_bitrate_interpolation, webrtc::VideoCodecType codec) { @@ -275,7 +291,7 @@ std::vector GetNormalSimulcastLayers( const bool enable_lowres_bitrate_interpolation = EnableLowresBitrateInterpolation(trials); const int num_temporal_layers = - temporal_layers_supported ? kDefaultNumTemporalLayers : 1; + temporal_layers_supported ? GetDefaultSimulcastTemporalLayers(codec) : 1; // Add simulcast streams, from highest resolution (`s` = num_simulcast_layers // -1) to lowest resolution at `s` = 0. std::vector layers(resolutions.size()); diff --git a/video/config/simulcast_unittest.cc b/video/config/simulcast_unittest.cc index 6e000a4641..f538cd7de7 100644 --- a/video/config/simulcast_unittest.cc +++ b/video/config/simulcast_unittest.cc @@ -440,6 +440,22 @@ TEST(SimulcastTest, BitratesForH265) { EXPECT_NEAR(streams[2].target_bitrate_bps, 1524000, 20000); EXPECT_NEAR(streams[2].min_bitrate_bps, 481000, 20000); } + +// Test that for H.265, the simulcast layers are created with the correct +// default temporal layers, before that is overrided by application settings. +TEST(SimulcastTest, GetConfigForH265) { + const ExplicitKeyValueConfig trials(""); + + const size_t kMaxLayers = 3; + std::vector streams = cricket::GetSimulcastConfig( + CreateResolutions(1280, 720, kMaxLayers), !kScreenshare, true, trials, + webrtc::kVideoCodecH265); + + ASSERT_THAT(streams, SizeIs(kMaxLayers)); + for (size_t i = 0; i < streams.size(); ++i) { + EXPECT_EQ(1ul, streams[i].num_temporal_layers); + } +} #endif } // namespace webrtc