aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorEvan Shrubsole <eshr@google.com>2020-04-06 11:23:06 +0200
committerCommit Bot <commit-bot@chromium.org>2020-04-06 13:27:28 +0000
commitc70b1028d47c1aee4892545190cd66e97d09cd55 (patch)
tree79f9d4595428e0091fad3bd5326da228be2d2f64 /api
parent2288256c9a7a5a23507e0662fb03d95c86f04368 (diff)
downloadwebrtc-c70b1028d47c1aee4892545190cd66e97d09cd55.tar.gz
Move AdaptationCounters from video/ to api/
- Rename AdaptationCounters to VideoAdaptationCounters - Move VideoAdaptationCounters to the api/ folder - Move related tests to api/test/ folder - Remove VideoAdaptationCounters::operator- Bug: webrtc:11392 Change-Id: I0de2537e9c8dd9cf29a2ecceee00f92a5b155c83 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172920 Commit-Queue: Evan Shrubsole <eshr@google.com> Reviewed-by: Henrik Boström <hbos@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31006}
Diffstat (limited to 'api')
-rw-r--r--api/video/BUILD.gn12
-rw-r--r--api/video/test/BUILD.gn2
-rw-r--r--api/video/test/video_adaptation_counters_unittest.cc32
-rw-r--r--api/video/video_adaptation_counters.cc33
-rw-r--r--api/video/video_adaptation_counters.h42
5 files changed, 120 insertions, 1 deletions
diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn
index c38e7bc947..401cee71f5 100644
--- a/api/video/BUILD.gn
+++ b/api/video/BUILD.gn
@@ -229,7 +229,17 @@ rtc_library("video_stream_decoder_create") {
]
}
-rtc_library("video_stream_encoder") {
+rtc_library("video_adaptation") {
+ visibility = [ "*" ]
+ sources = [
+ "video_adaptation_counters.cc",
+ "video_adaptation_counters.h",
+ ]
+
+ deps = [ "../../rtc_base:checks" ]
+}
+
+rtc_source_set("video_stream_encoder") {
visibility = [ "*" ]
sources = [
"video_stream_encoder_interface.h",
diff --git a/api/video/test/BUILD.gn b/api/video/test/BUILD.gn
index 3dcb90981e..5f697a081c 100644
--- a/api/video/test/BUILD.gn
+++ b/api/video/test/BUILD.gn
@@ -12,9 +12,11 @@ rtc_library("rtc_api_video_unittests") {
testonly = true
sources = [
"color_space_unittest.cc",
+ "video_adaptation_counters_unittest.cc",
"video_bitrate_allocation_unittest.cc",
]
deps = [
+ "..:video_adaptation",
"..:video_bitrate_allocation",
"..:video_frame",
"..:video_rtp_headers",
diff --git a/api/video/test/video_adaptation_counters_unittest.cc b/api/video/test/video_adaptation_counters_unittest.cc
new file mode 100644
index 0000000000..a7d0bda7d2
--- /dev/null
+++ b/api/video/test/video_adaptation_counters_unittest.cc
@@ -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.
+ */
+
+#include "api/video/video_adaptation_counters.h"
+
+#include "test/gtest.h"
+
+namespace webrtc {
+
+TEST(AdaptationCountersTest, Addition) {
+ VideoAdaptationCounters a{0, 0};
+ VideoAdaptationCounters b{1, 2};
+ VideoAdaptationCounters total = a + b;
+ EXPECT_EQ(1, total.resolution_adaptations);
+ EXPECT_EQ(2, total.fps_adaptations);
+}
+
+TEST(AdaptationCountersTest, Equality) {
+ VideoAdaptationCounters a{1, 2};
+ VideoAdaptationCounters b{2, 1};
+ EXPECT_EQ(a, a);
+ EXPECT_NE(a, b);
+}
+
+} // namespace webrtc
diff --git a/api/video/video_adaptation_counters.cc b/api/video/video_adaptation_counters.cc
new file mode 100644
index 0000000000..25e0bee1ff
--- /dev/null
+++ b/api/video/video_adaptation_counters.cc
@@ -0,0 +1,33 @@
+/*
+ * Copyright 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/video_adaptation_counters.h"
+
+namespace webrtc {
+
+bool VideoAdaptationCounters::operator==(
+ const VideoAdaptationCounters& rhs) const {
+ return fps_adaptations == rhs.fps_adaptations &&
+ resolution_adaptations == rhs.resolution_adaptations;
+}
+
+bool VideoAdaptationCounters::operator!=(
+ const VideoAdaptationCounters& rhs) const {
+ return !(rhs == *this);
+}
+
+VideoAdaptationCounters VideoAdaptationCounters::operator+(
+ const VideoAdaptationCounters& other) const {
+ return VideoAdaptationCounters(
+ resolution_adaptations + other.resolution_adaptations,
+ fps_adaptations + other.fps_adaptations);
+}
+
+} // namespace webrtc
diff --git a/api/video/video_adaptation_counters.h b/api/video/video_adaptation_counters.h
new file mode 100644
index 0000000000..eff0baaa21
--- /dev/null
+++ b/api/video/video_adaptation_counters.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright 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_VIDEO_ADAPTATION_COUNTERS_H_
+#define API_VIDEO_VIDEO_ADAPTATION_COUNTERS_H_
+
+#include "rtc_base/checks.h"
+
+namespace webrtc {
+
+// Counts the number of adaptations have resulted due to resource overuse.
+// Today we can adapt resolution and fps.
+struct VideoAdaptationCounters {
+ VideoAdaptationCounters() : resolution_adaptations(0), fps_adaptations(0) {}
+ VideoAdaptationCounters(int resolution_adaptations, int fps_adaptations)
+ : resolution_adaptations(resolution_adaptations),
+ fps_adaptations(fps_adaptations) {
+ RTC_DCHECK_GE(resolution_adaptations, 0);
+ RTC_DCHECK_GE(fps_adaptations, 0);
+ }
+
+ int Total() const { return fps_adaptations + resolution_adaptations; }
+
+ bool operator==(const VideoAdaptationCounters& rhs) const;
+ bool operator!=(const VideoAdaptationCounters& rhs) const;
+
+ VideoAdaptationCounters operator+(const VideoAdaptationCounters& other) const;
+
+ int resolution_adaptations;
+ int fps_adaptations;
+};
+
+} // namespace webrtc
+
+#endif // API_VIDEO_VIDEO_ADAPTATION_COUNTERS_H_