summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/call/adaptation/test
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libwebrtc/call/adaptation/test')
-rw-r--r--third_party/libwebrtc/call/adaptation/test/fake_adaptation_constraint.cc40
-rw-r--r--third_party/libwebrtc/call/adaptation/test/fake_adaptation_constraint.h42
-rw-r--r--third_party/libwebrtc/call/adaptation/test/fake_frame_rate_provider.cc27
-rw-r--r--third_party/libwebrtc/call/adaptation/test/fake_frame_rate_provider.h69
-rw-r--r--third_party/libwebrtc/call/adaptation/test/fake_resource.cc46
-rw-r--r--third_party/libwebrtc/call/adaptation/test/fake_resource.h45
-rw-r--r--third_party/libwebrtc/call/adaptation/test/fake_video_stream_input_state_provider.cc35
-rw-r--r--third_party/libwebrtc/call/adaptation/test/fake_video_stream_input_state_provider.h32
-rw-r--r--third_party/libwebrtc/call/adaptation/test/mock_resource_listener.h31
9 files changed, 367 insertions, 0 deletions
diff --git a/third_party/libwebrtc/call/adaptation/test/fake_adaptation_constraint.cc b/third_party/libwebrtc/call/adaptation/test/fake_adaptation_constraint.cc
new file mode 100644
index 0000000000..dbb31f0d3b
--- /dev/null
+++ b/third_party/libwebrtc/call/adaptation/test/fake_adaptation_constraint.cc
@@ -0,0 +1,40 @@
+/*
+ * 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 "call/adaptation/test/fake_adaptation_constraint.h"
+
+#include <utility>
+
+#include "absl/strings/string_view.h"
+
+namespace webrtc {
+
+FakeAdaptationConstraint::FakeAdaptationConstraint(absl::string_view name)
+ : name_(name), is_adaptation_up_allowed_(true) {}
+
+FakeAdaptationConstraint::~FakeAdaptationConstraint() = default;
+
+void FakeAdaptationConstraint::set_is_adaptation_up_allowed(
+ bool is_adaptation_up_allowed) {
+ is_adaptation_up_allowed_ = is_adaptation_up_allowed;
+}
+
+std::string FakeAdaptationConstraint::Name() const {
+ return name_;
+}
+
+bool FakeAdaptationConstraint::IsAdaptationUpAllowed(
+ const VideoStreamInputState& input_state,
+ const VideoSourceRestrictions& restrictions_before,
+ const VideoSourceRestrictions& restrictions_after) const {
+ return is_adaptation_up_allowed_;
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/call/adaptation/test/fake_adaptation_constraint.h b/third_party/libwebrtc/call/adaptation/test/fake_adaptation_constraint.h
new file mode 100644
index 0000000000..5c684335f2
--- /dev/null
+++ b/third_party/libwebrtc/call/adaptation/test/fake_adaptation_constraint.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 CALL_ADAPTATION_TEST_FAKE_ADAPTATION_CONSTRAINT_H_
+#define CALL_ADAPTATION_TEST_FAKE_ADAPTATION_CONSTRAINT_H_
+
+#include <string>
+
+#include "absl/strings/string_view.h"
+#include "call/adaptation/adaptation_constraint.h"
+
+namespace webrtc {
+
+class FakeAdaptationConstraint : public AdaptationConstraint {
+ public:
+ explicit FakeAdaptationConstraint(absl::string_view name);
+ ~FakeAdaptationConstraint() override;
+
+ void set_is_adaptation_up_allowed(bool is_adaptation_up_allowed);
+
+ // AdaptationConstraint implementation.
+ std::string Name() const override;
+ bool IsAdaptationUpAllowed(
+ const VideoStreamInputState& input_state,
+ const VideoSourceRestrictions& restrictions_before,
+ const VideoSourceRestrictions& restrictions_after) const override;
+
+ private:
+ const std::string name_;
+ bool is_adaptation_up_allowed_;
+};
+
+} // namespace webrtc
+
+#endif // CALL_ADAPTATION_TEST_FAKE_ADAPTATION_CONSTRAINT_H_
diff --git a/third_party/libwebrtc/call/adaptation/test/fake_frame_rate_provider.cc b/third_party/libwebrtc/call/adaptation/test/fake_frame_rate_provider.cc
new file mode 100644
index 0000000000..65fee6a7ba
--- /dev/null
+++ b/third_party/libwebrtc/call/adaptation/test/fake_frame_rate_provider.cc
@@ -0,0 +1,27 @@
+/*
+ * 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 "call/adaptation/test/fake_frame_rate_provider.h"
+
+#include "test/gmock.h"
+
+using ::testing::Return;
+
+namespace webrtc {
+
+FakeFrameRateProvider::FakeFrameRateProvider() {
+ set_fps(0);
+}
+
+void FakeFrameRateProvider::set_fps(int fps) {
+ EXPECT_CALL(*this, GetInputFrameRate()).WillRepeatedly(Return(fps));
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/call/adaptation/test/fake_frame_rate_provider.h b/third_party/libwebrtc/call/adaptation/test/fake_frame_rate_provider.h
new file mode 100644
index 0000000000..b8815f592a
--- /dev/null
+++ b/third_party/libwebrtc/call/adaptation/test/fake_frame_rate_provider.h
@@ -0,0 +1,69 @@
+/*
+ * 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 CALL_ADAPTATION_TEST_FAKE_FRAME_RATE_PROVIDER_H_
+#define CALL_ADAPTATION_TEST_FAKE_FRAME_RATE_PROVIDER_H_
+
+#include <string>
+#include <vector>
+
+#include "test/gmock.h"
+#include "video/video_stream_encoder_observer.h"
+
+namespace webrtc {
+
+class MockVideoStreamEncoderObserver : public VideoStreamEncoderObserver {
+ public:
+ MOCK_METHOD(void, OnEncodedFrameTimeMeasured, (int, int), (override));
+ MOCK_METHOD(void, OnIncomingFrame, (int, int), (override));
+ MOCK_METHOD(void,
+ OnSendEncodedImage,
+ (const EncodedImage&, const CodecSpecificInfo*),
+ (override));
+ MOCK_METHOD(void,
+ OnEncoderImplementationChanged,
+ (EncoderImplementation),
+ (override));
+ MOCK_METHOD(void, OnFrameDropped, (DropReason), (override));
+ MOCK_METHOD(void,
+ OnEncoderReconfigured,
+ (const VideoEncoderConfig&, const std::vector<VideoStream>&),
+ (override));
+ MOCK_METHOD(void,
+ OnAdaptationChanged,
+ (VideoAdaptationReason,
+ const VideoAdaptationCounters&,
+ const VideoAdaptationCounters&),
+ (override));
+ MOCK_METHOD(void, ClearAdaptationStats, (), (override));
+ MOCK_METHOD(void,
+ UpdateAdaptationSettings,
+ (AdaptationSettings, AdaptationSettings),
+ (override));
+ MOCK_METHOD(void, OnMinPixelLimitReached, (), (override));
+ MOCK_METHOD(void, OnInitialQualityResolutionAdaptDown, (), (override));
+ MOCK_METHOD(void, OnSuspendChange, (bool), (override));
+ MOCK_METHOD(void,
+ OnBitrateAllocationUpdated,
+ (const VideoCodec&, const VideoBitrateAllocation&),
+ (override));
+ MOCK_METHOD(void, OnEncoderInternalScalerUpdate, (bool), (override));
+ MOCK_METHOD(int, GetInputFrameRate, (), (const, override));
+};
+
+class FakeFrameRateProvider : public MockVideoStreamEncoderObserver {
+ public:
+ FakeFrameRateProvider();
+ void set_fps(int fps);
+};
+
+} // namespace webrtc
+
+#endif // CALL_ADAPTATION_TEST_FAKE_FRAME_RATE_PROVIDER_H_
diff --git a/third_party/libwebrtc/call/adaptation/test/fake_resource.cc b/third_party/libwebrtc/call/adaptation/test/fake_resource.cc
new file mode 100644
index 0000000000..48b4768550
--- /dev/null
+++ b/third_party/libwebrtc/call/adaptation/test/fake_resource.cc
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2019 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 "call/adaptation/test/fake_resource.h"
+
+#include <algorithm>
+#include <utility>
+
+#include "absl/strings/string_view.h"
+#include "api/make_ref_counted.h"
+
+namespace webrtc {
+
+// static
+rtc::scoped_refptr<FakeResource> FakeResource::Create(absl::string_view name) {
+ return rtc::make_ref_counted<FakeResource>(name);
+}
+
+FakeResource::FakeResource(absl::string_view name)
+ : Resource(), name_(name), listener_(nullptr) {}
+
+FakeResource::~FakeResource() {}
+
+void FakeResource::SetUsageState(ResourceUsageState usage_state) {
+ if (listener_) {
+ listener_->OnResourceUsageStateMeasured(rtc::scoped_refptr<Resource>(this),
+ usage_state);
+ }
+}
+
+std::string FakeResource::Name() const {
+ return name_;
+}
+
+void FakeResource::SetResourceListener(ResourceListener* listener) {
+ listener_ = listener;
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/call/adaptation/test/fake_resource.h b/third_party/libwebrtc/call/adaptation/test/fake_resource.h
new file mode 100644
index 0000000000..1119a9614f
--- /dev/null
+++ b/third_party/libwebrtc/call/adaptation/test/fake_resource.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2019 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 CALL_ADAPTATION_TEST_FAKE_RESOURCE_H_
+#define CALL_ADAPTATION_TEST_FAKE_RESOURCE_H_
+
+#include <string>
+#include <vector>
+
+#include "absl/strings/string_view.h"
+#include "absl/types/optional.h"
+#include "api/adaptation/resource.h"
+#include "api/scoped_refptr.h"
+
+namespace webrtc {
+
+// Fake resource used for testing.
+class FakeResource : public Resource {
+ public:
+ static rtc::scoped_refptr<FakeResource> Create(absl::string_view name);
+
+ explicit FakeResource(absl::string_view name);
+ ~FakeResource() override;
+
+ void SetUsageState(ResourceUsageState usage_state);
+
+ // Resource implementation.
+ std::string Name() const override;
+ void SetResourceListener(ResourceListener* listener) override;
+
+ private:
+ const std::string name_;
+ ResourceListener* listener_;
+};
+
+} // namespace webrtc
+
+#endif // CALL_ADAPTATION_TEST_FAKE_RESOURCE_H_
diff --git a/third_party/libwebrtc/call/adaptation/test/fake_video_stream_input_state_provider.cc b/third_party/libwebrtc/call/adaptation/test/fake_video_stream_input_state_provider.cc
new file mode 100644
index 0000000000..ce92dfb204
--- /dev/null
+++ b/third_party/libwebrtc/call/adaptation/test/fake_video_stream_input_state_provider.cc
@@ -0,0 +1,35 @@
+/*
+ * 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 "call/adaptation/test/fake_video_stream_input_state_provider.h"
+
+namespace webrtc {
+
+FakeVideoStreamInputStateProvider::FakeVideoStreamInputStateProvider()
+ : VideoStreamInputStateProvider(nullptr) {}
+
+FakeVideoStreamInputStateProvider::~FakeVideoStreamInputStateProvider() =
+ default;
+
+void FakeVideoStreamInputStateProvider::SetInputState(
+ int input_pixels,
+ int input_fps,
+ int min_pixels_per_frame) {
+ fake_input_state_.set_has_input(true);
+ fake_input_state_.set_frame_size_pixels(input_pixels);
+ fake_input_state_.set_frames_per_second(input_fps);
+ fake_input_state_.set_min_pixels_per_frame(min_pixels_per_frame);
+}
+
+VideoStreamInputState FakeVideoStreamInputStateProvider::InputState() {
+ return fake_input_state_;
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/call/adaptation/test/fake_video_stream_input_state_provider.h b/third_party/libwebrtc/call/adaptation/test/fake_video_stream_input_state_provider.h
new file mode 100644
index 0000000000..93f7dba7e6
--- /dev/null
+++ b/third_party/libwebrtc/call/adaptation/test/fake_video_stream_input_state_provider.h
@@ -0,0 +1,32 @@
+/*
+ * 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 CALL_ADAPTATION_TEST_FAKE_VIDEO_STREAM_INPUT_STATE_PROVIDER_H_
+#define CALL_ADAPTATION_TEST_FAKE_VIDEO_STREAM_INPUT_STATE_PROVIDER_H_
+
+#include "call/adaptation/video_stream_input_state_provider.h"
+
+namespace webrtc {
+
+class FakeVideoStreamInputStateProvider : public VideoStreamInputStateProvider {
+ public:
+ FakeVideoStreamInputStateProvider();
+ virtual ~FakeVideoStreamInputStateProvider();
+
+ void SetInputState(int input_pixels, int input_fps, int min_pixels_per_frame);
+ VideoStreamInputState InputState() override;
+
+ private:
+ VideoStreamInputState fake_input_state_;
+};
+
+} // namespace webrtc
+
+#endif // CALL_ADAPTATION_TEST_FAKE_VIDEO_STREAM_INPUT_STATE_PROVIDER_H_
diff --git a/third_party/libwebrtc/call/adaptation/test/mock_resource_listener.h b/third_party/libwebrtc/call/adaptation/test/mock_resource_listener.h
new file mode 100644
index 0000000000..f0f998f2e3
--- /dev/null
+++ b/third_party/libwebrtc/call/adaptation/test/mock_resource_listener.h
@@ -0,0 +1,31 @@
+/*
+ * 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 CALL_ADAPTATION_TEST_MOCK_RESOURCE_LISTENER_H_
+#define CALL_ADAPTATION_TEST_MOCK_RESOURCE_LISTENER_H_
+
+#include "api/adaptation/resource.h"
+
+#include "test/gmock.h"
+
+namespace webrtc {
+
+class MockResourceListener : public ResourceListener {
+ public:
+ MOCK_METHOD(void,
+ OnResourceUsageStateMeasured,
+ (rtc::scoped_refptr<Resource> resource,
+ ResourceUsageState usage_state),
+ (override));
+};
+
+} // namespace webrtc
+
+#endif // CALL_ADAPTATION_TEST_MOCK_RESOURCE_LISTENER_H_