diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn index 0b6db8711d..4c91482afb 100644 --- a/api/video_codecs/BUILD.gn +++ b/api/video_codecs/BUILD.gn @@ -34,6 +34,7 @@ rtc_library("video_codecs_api") { "h264_profile_level_id.h", "sdp_video_format.cc", "sdp_video_format.h", + "simulcast_stream.cc", "simulcast_stream.h", "spatial_layer.cc", "spatial_layer.h", diff --git a/api/video_codecs/simulcast_stream.cc b/api/video_codecs/simulcast_stream.cc new file mode 100644 index 0000000000..aa3486dc5d --- /dev/null +++ b/api/video_codecs/simulcast_stream.cc @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "api/video_codecs/simulcast_stream.h" + +#include "rtc_base/checks.h" + +namespace webrtc { + +unsigned char SimulcastStream::GetNumberOfTemporalLayers() const { + return numberOfTemporalLayers; +} + +ScalabilityMode SimulcastStream::GetScalabilityMode() const { + RTC_CHECK_GE(numberOfTemporalLayers, 1); + RTC_CHECK_LE(numberOfTemporalLayers, 3); + static const ScalabilityMode scalability_modes[3] = { + ScalabilityMode::kL1T1, + ScalabilityMode::kL1T2, + ScalabilityMode::kL1T3, + }; + return scalability_modes[numberOfTemporalLayers - 1]; +} + +} // namespace webrtc diff --git a/api/video_codecs/simulcast_stream.h b/api/video_codecs/simulcast_stream.h index 578275b852..8e55a9532d 100644 --- a/api/video_codecs/simulcast_stream.h +++ b/api/video_codecs/simulcast_stream.h @@ -11,11 +11,18 @@ #ifndef API_VIDEO_CODECS_SIMULCAST_STREAM_H_ #define API_VIDEO_CODECS_SIMULCAST_STREAM_H_ +#include "api/video_codecs/scalability_mode.h" + namespace webrtc { // TODO(bugs.webrtc.org/6883): Unify with struct VideoStream, part of // VideoEncoderConfig. struct SimulcastStream { + // Temporary utility methods for transition from numberOfTemporalLayers + // setting to ScalabilityMode. + unsigned char GetNumberOfTemporalLayers() const; + ScalabilityMode GetScalabilityMode() const; + int width = 0; int height = 0; float maxFramerate = 0; // fps. diff --git a/api/video_codecs/video_codec.h b/api/video_codecs/video_codec.h index 068b09d27a..10bceda0d2 100644 --- a/api/video_codecs/video_codec.h +++ b/api/video_codecs/video_codec.h @@ -44,6 +44,11 @@ struct VideoCodecVP8 { bool operator!=(const VideoCodecVP8& other) const { return !(*this == other); } + // Temporary utility method for transition deleting numberOfTemporalLayers + // setting (replaced by ScalabilityMode). + void SetNumberOfTemporalLayers(unsigned char n) { + numberOfTemporalLayers = n; + } unsigned char numberOfTemporalLayers; bool denoisingOn; bool automaticResizeOn; @@ -62,6 +67,11 @@ struct VideoCodecVP9 { bool operator!=(const VideoCodecVP9& other) const { return !(*this == other); } + // Temporary utility method for transition deleting numberOfTemporalLayers + // setting (replaced by ScalabilityMode). + void SetNumberOfTemporalLayers(unsigned char n) { + numberOfTemporalLayers = n; + } unsigned char numberOfTemporalLayers; bool denoisingOn; int keyFrameInterval; @@ -78,6 +88,11 @@ struct VideoCodecH264 { bool operator!=(const VideoCodecH264& other) const { return !(*this == other); } + // Temporary utility method for transition deleting numberOfTemporalLayers + // setting (replaced by ScalabilityMode). + void SetNumberOfTemporalLayers(unsigned char n) { + numberOfTemporalLayers = n; + } int keyFrameInterval; uint8_t numberOfTemporalLayers; };