Account for codec type when accessing codec specific settings

Bug: none
Change-Id: Ic60414d7a8cd2e40f8c3855fd4ceed09ea4d7c07
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/305784
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40324}
This commit is contained in:
Sergey Silkin 2023-05-22 10:38:46 +02:00 committed by WebRTC LUCI CQ
parent 4e434c313e
commit d7c7b07c5d
2 changed files with 24 additions and 4 deletions

View File

@ -446,6 +446,7 @@ rtc_library("video_coding_utility") {
"../../rtc_base/task_utils:repeating_task",
"../../system_wrappers:field_trial",
"../rtp_rtcp:rtp_rtcp_format",
"svc:scalability_mode_util",
]
absl_deps = [
"//third_party/abseil-cpp/absl/numeric:bits",

View File

@ -13,6 +13,7 @@
#include <algorithm>
#include <cmath>
#include "modules/video_coding/svc/scalability_mode_util.h"
#include "rtc_base/checks.h"
namespace webrtc {
@ -79,15 +80,33 @@ bool SimulcastUtility::IsConferenceModeScreenshare(const VideoCodec& codec) {
int SimulcastUtility::NumberOfTemporalLayers(const VideoCodec& codec,
int spatial_id) {
uint8_t num_temporal_layers =
std::max<uint8_t>(1, codec.VP8().numberOfTemporalLayers);
int num_temporal_layers = 0;
if (auto scalability_mode = codec.GetScalabilityMode(); scalability_mode) {
num_temporal_layers = ScalabilityModeToNumTemporalLayers(*scalability_mode);
} else {
switch (codec.codecType) {
case kVideoCodecVP8:
num_temporal_layers = codec.VP8().numberOfTemporalLayers;
break;
case kVideoCodecVP9:
num_temporal_layers = codec.VP9().numberOfTemporalLayers;
break;
case kVideoCodecH264:
num_temporal_layers = codec.H264().numberOfTemporalLayers;
break;
default:
break;
}
}
if (codec.numberOfSimulcastStreams > 0) {
RTC_DCHECK_LT(spatial_id, codec.numberOfSimulcastStreams);
num_temporal_layers =
std::max(num_temporal_layers,
codec.simulcastStream[spatial_id].numberOfTemporalLayers);
static_cast<int>(
codec.simulcastStream[spatial_id].numberOfTemporalLayers));
}
return num_temporal_layers;
return std::max(1, num_temporal_layers);
}
} // namespace webrtc