Ensure that the first active layer isn't disabled by too low input resolution

If e.g. CPU adaptation reduces input video size too much, video pipeline would
reduce the number of used simulcast streams/spatial layers. This may result in
disabled video if some streams are disabled by Rtp encoding parameters API.

Bug: webrtc:11319
Change-Id: Id7f157255599dcb6f494129b83477cda4bea982a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168480
Reviewed-by: Evan Shrubsole <eshr@google.com>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30498}
This commit is contained in:
Ilya Nikolaevskiy
2020-02-11 12:50:38 +01:00
committed by Commit Bot
parent ccd49d9af6
commit 03d909634b
12 changed files with 152 additions and 47 deletions

View File

@ -179,9 +179,19 @@ VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec(
// Layering is set explicitly.
spatial_layers = config.spatial_layers;
} else {
size_t min_required_layers = 0;
// Need at least enough layers for the first active one to be present.
for (size_t spatial_idx = 0;
spatial_idx < config.simulcast_layers.size(); ++spatial_idx) {
if (config.simulcast_layers[spatial_idx].active) {
min_required_layers = spatial_idx + 1;
break;
}
}
spatial_layers = GetSvcConfig(
video_codec.width, video_codec.height, video_codec.maxFramerate,
video_codec.VP9()->numberOfSpatialLayers,
min_required_layers, video_codec.VP9()->numberOfSpatialLayers,
video_codec.VP9()->numberOfTemporalLayers,
video_codec.mode == VideoCodecMode::kScreensharing);