Move definition of SpatialLayer to api/video_codecs/spatial_layer.h
Bug: webrtc:7660
Change-Id: I54009ebc5f65b6875a8c079ab5264e0c5ce9f654
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/181500
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31942}
diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn
index 597478b..848008f 100644
--- a/api/video_codecs/BUILD.gn
+++ b/api/video_codecs/BUILD.gn
@@ -17,6 +17,8 @@
sources = [
"sdp_video_format.cc",
"sdp_video_format.h",
+ "spatial_layer.cc",
+ "spatial_layer.h",
"video_codec.cc",
"video_codec.h",
"video_decoder.cc",
diff --git a/api/video_codecs/spatial_layer.cc b/api/video_codecs/spatial_layer.cc
new file mode 100644
index 0000000..25ccdfe
--- /dev/null
+++ b/api/video_codecs/spatial_layer.cc
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2020 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/spatial_layer.h"
+
+namespace webrtc {
+
+bool SpatialLayer::operator==(const SpatialLayer& other) const {
+ return (width == other.width && height == other.height &&
+ maxFramerate == other.maxFramerate &&
+ numberOfTemporalLayers == other.numberOfTemporalLayers &&
+ maxBitrate == other.maxBitrate &&
+ targetBitrate == other.targetBitrate &&
+ minBitrate == other.minBitrate && qpMax == other.qpMax &&
+ active == other.active);
+}
+
+} // namespace webrtc
diff --git a/api/video_codecs/spatial_layer.h b/api/video_codecs/spatial_layer.h
new file mode 100644
index 0000000..5a1b425
--- /dev/null
+++ b/api/video_codecs/spatial_layer.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2020 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.
+ */
+
+#ifndef API_VIDEO_CODECS_SPATIAL_LAYER_H_
+#define API_VIDEO_CODECS_SPATIAL_LAYER_H_
+
+namespace webrtc {
+
+struct SpatialLayer {
+ bool operator==(const SpatialLayer& other) const;
+ bool operator!=(const SpatialLayer& other) const { return !(*this == other); }
+
+ unsigned short width; // NOLINT(runtime/int)
+ unsigned short height; // NOLINT(runtime/int)
+ float maxFramerate; // fps.
+ unsigned char numberOfTemporalLayers;
+ unsigned int maxBitrate; // kilobits/sec.
+ unsigned int targetBitrate; // kilobits/sec.
+ unsigned int minBitrate; // kilobits/sec.
+ unsigned int qpMax; // minimum quality
+ bool active; // encoded and sent.
+};
+
+} // namespace webrtc
+#endif // API_VIDEO_CODECS_SPATIAL_LAYER_H_
diff --git a/api/video_codecs/video_codec.cc b/api/video_codecs/video_codec.cc
index 92da338..490eced 100644
--- a/api/video_codecs/video_codec.cc
+++ b/api/video_codecs/video_codec.cc
@@ -56,16 +56,6 @@
numberOfTemporalLayers == other.numberOfTemporalLayers);
}
-bool SpatialLayer::operator==(const SpatialLayer& other) const {
- return (width == other.width && height == other.height &&
- maxFramerate == other.maxFramerate &&
- numberOfTemporalLayers == other.numberOfTemporalLayers &&
- maxBitrate == other.maxBitrate &&
- targetBitrate == other.targetBitrate &&
- minBitrate == other.minBitrate && qpMax == other.qpMax &&
- active == other.active);
-}
-
VideoCodec::VideoCodec()
: codecType(kVideoCodecGeneric),
width(0),
diff --git a/api/video_codecs/video_codec.h b/api/video_codecs/video_codec.h
index d783390..48e72ed 100644
--- a/api/video_codecs/video_codec.h
+++ b/api/video_codecs/video_codec.h
@@ -19,7 +19,7 @@
#include "absl/types/optional.h"
#include "api/video/video_bitrate_allocation.h"
#include "api/video/video_codec_type.h"
-#include "common_types.h" // NOLINT(build/include_directory)
+#include "api/video_codecs/spatial_layer.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
@@ -120,7 +120,7 @@
unsigned int qpMax;
unsigned char numberOfSimulcastStreams;
- SimulcastStream simulcastStream[kMaxSimulcastStreams];
+ SpatialLayer simulcastStream[kMaxSimulcastStreams];
SpatialLayer spatialLayers[kMaxSpatialLayers];
VideoCodecMode mode;
diff --git a/common_types.h b/common_types.h
index 1bf92bf..de1a5fd 100644
--- a/common_types.h
+++ b/common_types.h
@@ -31,29 +31,6 @@
uint32_t ssrc) = 0;
};
-// ==================================================================
-// Video specific types
-// ==================================================================
-
-struct SpatialLayer {
- bool operator==(const SpatialLayer& other) const;
- bool operator!=(const SpatialLayer& other) const { return !(*this == other); }
-
- unsigned short width;
- unsigned short height;
- float maxFramerate; // fps.
- unsigned char numberOfTemporalLayers;
- unsigned int maxBitrate; // kilobits/sec.
- unsigned int targetBitrate; // kilobits/sec.
- unsigned int minBitrate; // kilobits/sec.
- unsigned int qpMax; // minimum quality
- bool active; // encoded and sent.
-};
-
-// Simulcast is when the same stream is encoded multiple times with different
-// settings such as resolution.
-typedef SpatialLayer SimulcastStream;
-
// Minimum and maximum playout delay values from capture to render.
// These are best effort values.
//
diff --git a/media/engine/simulcast_encoder_adapter.cc b/media/engine/simulcast_encoder_adapter.cc
index 60baed9..0f96dc2 100644
--- a/media/engine/simulcast_encoder_adapter.cc
+++ b/media/engine/simulcast_encoder_adapter.cc
@@ -103,8 +103,8 @@
return WEBRTC_VIDEO_CODEC_OK;
}
-bool StreamResolutionCompare(const webrtc::SimulcastStream& a,
- const webrtc::SimulcastStream& b) {
+bool StreamResolutionCompare(const webrtc::SpatialLayer& a,
+ const webrtc::SpatialLayer& b) {
return std::tie(a.height, a.width, a.maxBitrate, a.maxFramerate) <
std::tie(b.height, b.width, b.maxBitrate, b.maxFramerate);
}
diff --git a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc
index 990db54..ee6301b 100644
--- a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc
+++ b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc
@@ -67,7 +67,7 @@
/* is_screenshare = */ false, true);
for (size_t i = 0; i < streams.size(); ++i) {
- SimulcastStream* ss = &codec_settings->simulcastStream[i];
+ SpatialLayer* ss = &codec_settings->simulcastStream[i];
ss->width = static_cast<uint16_t>(streams[i].width);
ss->height = static_cast<uint16_t>(streams[i].height);
ss->numberOfTemporalLayers =
@@ -277,8 +277,7 @@
if (codec_settings.numberOfSimulcastStreams > 1) {
for (int i = 0; i < codec_settings.numberOfSimulcastStreams; ++i) {
ss << "\n\n--> codec_settings.simulcastStream[" << i << "]";
- const SimulcastStream& simulcast_stream =
- codec_settings.simulcastStream[i];
+ const SpatialLayer& simulcast_stream = codec_settings.simulcastStream[i];
ss << "\nwidth: " << simulcast_stream.width;
ss << "\nheight: " << simulcast_stream.height;
ss << "\nnum_temporal_layers: "
diff --git a/modules/video_coding/codecs/vp9/svc_config.h b/modules/video_coding/codecs/vp9/svc_config.h
index 9bd8b0e..f6b562e 100644
--- a/modules/video_coding/codecs/vp9/svc_config.h
+++ b/modules/video_coding/codecs/vp9/svc_config.h
@@ -14,7 +14,7 @@
#include <vector>
-#include "common_types.h" // NOLINT(build/include)
+#include "api/video_codecs/spatial_layer.h"
namespace webrtc {
diff --git a/modules/video_coding/utility/simulcast_rate_allocator.cc b/modules/video_coding/utility/simulcast_rate_allocator.cc
index 13de875..3427676 100644
--- a/modules/video_coding/utility/simulcast_rate_allocator.cc
+++ b/modules/video_coding/utility/simulcast_rate_allocator.cc
@@ -151,7 +151,7 @@
size_t top_active_layer = active_layer;
// Allocate up to the target bitrate for each active simulcast layer.
for (; active_layer < codec_.numberOfSimulcastStreams; ++active_layer) {
- const SimulcastStream& stream =
+ const SpatialLayer& stream =
codec_.simulcastStream[layer_index[active_layer]];
if (!stream.active) {
stream_enabled_[layer_index[active_layer]] = false;
@@ -194,7 +194,7 @@
// TODO(sprang): Allocate up to max bitrate for all layers once we have a
// better idea of possible performance implications.
if (left_in_total_allocation > DataRate::Zero()) {
- const SimulcastStream& stream = codec_.simulcastStream[top_active_layer];
+ const SpatialLayer& stream = codec_.simulcastStream[top_active_layer];
DataRate initial_layer_rate = DataRate::BitsPerSec(
allocated_bitrates->GetSpatialLayerSum(top_active_layer));
DataRate additional_allocation = std::min(
diff --git a/modules/video_coding/utility/simulcast_test_fixture_impl.cc b/modules/video_coding/utility/simulcast_test_fixture_impl.cc
index 93d6fb7..a0abd96 100644
--- a/modules/video_coding/utility/simulcast_test_fixture_impl.cc
+++ b/modules/video_coding/utility/simulcast_test_fixture_impl.cc
@@ -196,7 +196,7 @@
int min_bitrate,
int target_bitrate,
float max_framerate,
- SimulcastStream* stream,
+ SpatialLayer* stream,
int num_temporal_layers) {
assert(stream);
stream->width = width;
diff --git a/modules/video_coding/video_codec_initializer.cc b/modules/video_coding/video_codec_initializer.cc
index 2859dd0..777056f 100644
--- a/modules/video_coding/video_codec_initializer.cc
+++ b/modules/video_coding/video_codec_initializer.cc
@@ -95,7 +95,7 @@
int max_framerate = 0;
for (size_t i = 0; i < streams.size(); ++i) {
- SimulcastStream* sim_stream = &video_codec.simulcastStream[i];
+ SpatialLayer* sim_stream = &video_codec.simulcastStream[i];
RTC_DCHECK_GT(streams[i].width, 0);
RTC_DCHECK_GT(streams[i].height, 0);
RTC_DCHECK_GT(streams[i].max_framerate, 0);
diff --git a/test/fake_encoder.cc b/test/fake_encoder.cc
index 219dafc..f33d3e8 100644
--- a/test/fake_encoder.cc
+++ b/test/fake_encoder.cc
@@ -92,7 +92,7 @@
const std::vector<VideoFrameType>* frame_types) {
unsigned char max_framerate;
unsigned char num_simulcast_streams;
- SimulcastStream simulcast_streams[kMaxSimulcastStreams];
+ SpatialLayer simulcast_streams[kMaxSimulcastStreams];
EncodedImageCallback* callback;
RateControlParameters rates;
VideoCodecMode mode;
@@ -168,7 +168,7 @@
bool keyframe,
uint8_t num_simulcast_streams,
const VideoBitrateAllocation& target_bitrate,
- SimulcastStream simulcast_streams[kMaxSimulcastStreams],
+ SpatialLayer simulcast_streams[kMaxSimulcastStreams],
int framerate) {
FrameInfo frame_info;
frame_info.keyframe = keyframe;
diff --git a/test/fake_encoder.h b/test/fake_encoder.h
index 22c7723..6808256 100644
--- a/test/fake_encoder.h
+++ b/test/fake_encoder.h
@@ -80,7 +80,7 @@
bool keyframe,
uint8_t num_simulcast_streams,
const VideoBitrateAllocation& target_bitrate,
- SimulcastStream simulcast_streams[kMaxSimulcastStreams],
+ SpatialLayer simulcast_streams[kMaxSimulcastStreams],
int framerate) RTC_LOCKS_EXCLUDED(mutex_);
// Called before the frame is passed to callback_->OnEncodedImage, to let