diff --git a/call/adaptation/BUILD.gn b/call/adaptation/BUILD.gn index 94944d6820..d88e19acc2 100644 --- a/call/adaptation/BUILD.gn +++ b/call/adaptation/BUILD.gn @@ -12,8 +12,6 @@ rtc_library("resource_adaptation") { sources = [ "adaptation_constraint.cc", "adaptation_constraint.h", - "adaptation_listener.cc", - "adaptation_listener.h", "broadcast_resource_listener.cc", "broadcast_resource_listener.h", "degradation_preference_provider.cc", @@ -98,8 +96,6 @@ if (rtc_include_tests) { sources = [ "test/fake_adaptation_constraint.cc", "test/fake_adaptation_constraint.h", - "test/fake_adaptation_listener.cc", - "test/fake_adaptation_listener.h", "test/fake_frame_rate_provider.cc", "test/fake_frame_rate_provider.h", "test/fake_resource.cc", diff --git a/call/adaptation/adaptation_listener.cc b/call/adaptation/adaptation_listener.cc deleted file mode 100644 index acc1564f77..0000000000 --- a/call/adaptation/adaptation_listener.cc +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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/adaptation_listener.h" - -namespace webrtc { - -AdaptationListener::~AdaptationListener() {} - -} // namespace webrtc diff --git a/call/adaptation/adaptation_listener.h b/call/adaptation/adaptation_listener.h deleted file mode 100644 index 4a96baef8e..0000000000 --- a/call/adaptation/adaptation_listener.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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_ADAPTATION_LISTENER_H_ -#define CALL_ADAPTATION_ADAPTATION_LISTENER_H_ - -#include "api/adaptation/resource.h" -#include "api/scoped_refptr.h" -#include "call/adaptation/video_source_restrictions.h" -#include "call/adaptation/video_stream_input_state.h" - -namespace webrtc { - -// TODO(hbos): Can this be consolidated with -// ResourceAdaptationProcessorListener::OnVideoSourceRestrictionsUpdated()? Both -// listen to adaptations being applied, but on different layers with different -// arguments. -class AdaptationListener { - public: - virtual ~AdaptationListener(); - - // TODO(https://crbug.com/webrtc/11172): When we have multi-stream adaptation - // support, this interface needs to indicate which stream the adaptation - // applies to. - virtual void OnAdaptationApplied( - const VideoStreamInputState& input_state, - const VideoSourceRestrictions& restrictions_before, - const VideoSourceRestrictions& restrictions_after, - rtc::scoped_refptr reason_resource) = 0; -}; - -} // namespace webrtc - -#endif // CALL_ADAPTATION_ADAPTATION_LISTENER_H_ diff --git a/call/adaptation/resource_adaptation_processor_interface.h b/call/adaptation/resource_adaptation_processor_interface.h index 6b9afccf3f..de940c8590 100644 --- a/call/adaptation/resource_adaptation_processor_interface.h +++ b/call/adaptation/resource_adaptation_processor_interface.h @@ -22,7 +22,6 @@ #include "api/video/video_adaptation_counters.h" #include "api/video/video_frame.h" #include "call/adaptation/adaptation_constraint.h" -#include "call/adaptation/adaptation_listener.h" #include "call/adaptation/encoder_settings.h" #include "call/adaptation/video_source_restrictions.h" diff --git a/call/adaptation/resource_adaptation_processor_unittest.cc b/call/adaptation/resource_adaptation_processor_unittest.cc index 69b224e711..c27958c4fc 100644 --- a/call/adaptation/resource_adaptation_processor_unittest.cc +++ b/call/adaptation/resource_adaptation_processor_unittest.cc @@ -14,7 +14,6 @@ #include "api/scoped_refptr.h" #include "api/video/video_adaptation_counters.h" #include "call/adaptation/resource_adaptation_processor_interface.h" -#include "call/adaptation/test/fake_adaptation_listener.h" #include "call/adaptation/test/fake_frame_rate_provider.h" #include "call/adaptation/test/fake_resource.h" #include "call/adaptation/video_source_restrictions.h" @@ -89,7 +88,6 @@ class ResourceAdaptationProcessorTest : public ::testing::Test { input_state_provider_(&frame_rate_provider_), resource_(FakeResource::Create("FakeResource")), other_resource_(FakeResource::Create("OtherFakeResource")), - adaptation_listener_(), video_stream_adapter_( std::make_unique(&input_state_provider_)), processor_(std::make_unique( @@ -99,7 +97,6 @@ class ResourceAdaptationProcessorTest : public ::testing::Test { video_stream_adapter_->AddRestrictionsListener(&restrictions_listener_); processor_->AddResource(resource_); processor_->AddResource(other_resource_); - video_stream_adapter_->AddAdaptationListener(&adaptation_listener_); } ~ResourceAdaptationProcessorTest() override { if (processor_) { @@ -128,7 +125,6 @@ class ResourceAdaptationProcessorTest : public ::testing::Test { if (other_resource_) { processor_->RemoveResource(other_resource_); } - video_stream_adapter_->RemoveAdaptationListener(&adaptation_listener_); video_stream_adapter_->RemoveRestrictionsListener(&restrictions_listener_); processor_.reset(); } @@ -142,7 +138,6 @@ class ResourceAdaptationProcessorTest : public ::testing::Test { VideoStreamInputStateProvider input_state_provider_; rtc::scoped_refptr resource_; rtc::scoped_refptr other_resource_; - FakeAdaptationListener adaptation_listener_; std::unique_ptr video_stream_adapter_; std::unique_ptr processor_; VideoSourceRestrictionsListenerForTesting restrictions_listener_; @@ -404,14 +399,6 @@ TEST_F(ResourceAdaptationProcessorTest, EXPECT_EQ(last_total, restrictions_listener_.adaptation_counters().Total()); } -TEST_F(ResourceAdaptationProcessorTest, AdaptingTriggersOnAdaptationApplied) { - video_stream_adapter_->SetDegradationPreference( - DegradationPreference::MAINTAIN_FRAMERATE); - SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize); - resource_->SetUsageState(ResourceUsageState::kOveruse); - EXPECT_EQ(1u, adaptation_listener_.num_adaptations_applied()); -} - TEST_F(ResourceAdaptationProcessorTest, AdaptsDownWhenOtherResourceIsAlwaysUnderused) { video_stream_adapter_->SetDegradationPreference( diff --git a/call/adaptation/test/fake_adaptation_listener.cc b/call/adaptation/test/fake_adaptation_listener.cc deleted file mode 100644 index 7feecd6367..0000000000 --- a/call/adaptation/test/fake_adaptation_listener.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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_listener.h" - -namespace webrtc { - -FakeAdaptationListener::FakeAdaptationListener() - : num_adaptations_applied_(0) {} - -FakeAdaptationListener::~FakeAdaptationListener() {} - -size_t FakeAdaptationListener::num_adaptations_applied() const { - return num_adaptations_applied_; -} - -void FakeAdaptationListener::OnAdaptationApplied( - const VideoStreamInputState& input_state, - const VideoSourceRestrictions& restrictions_before, - const VideoSourceRestrictions& restrictions_after, - rtc::scoped_refptr reason_resource) { - ++num_adaptations_applied_; -} - -} // namespace webrtc diff --git a/call/adaptation/test/fake_adaptation_listener.h b/call/adaptation/test/fake_adaptation_listener.h deleted file mode 100644 index c60ba3089b..0000000000 --- a/call/adaptation/test/fake_adaptation_listener.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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_LISTENER_H_ -#define CALL_ADAPTATION_TEST_FAKE_ADAPTATION_LISTENER_H_ - -#include "call/adaptation/adaptation_listener.h" - -namespace webrtc { - -class FakeAdaptationListener : public AdaptationListener { - public: - FakeAdaptationListener(); - ~FakeAdaptationListener() override; - - size_t num_adaptations_applied() const; - - // AdaptationListener implementation. - void OnAdaptationApplied( - const VideoStreamInputState& input_state, - const VideoSourceRestrictions& restrictions_before, - const VideoSourceRestrictions& restrictions_after, - rtc::scoped_refptr reason_resource) override; - - private: - size_t num_adaptations_applied_; -}; - -} // namespace webrtc - -#endif // CALL_ADAPTATION_TEST_FAKE_ADAPTATION_LISTENER_H_ diff --git a/call/adaptation/video_stream_adapter.cc b/call/adaptation/video_stream_adapter.cc index ad63cc1d42..6209c05844 100644 --- a/call/adaptation/video_stream_adapter.cc +++ b/call/adaptation/video_stream_adapter.cc @@ -213,9 +213,6 @@ VideoStreamAdapter::VideoStreamAdapter( } VideoStreamAdapter::~VideoStreamAdapter() { - RTC_DCHECK(adaptation_listeners_.empty()) - << "There are listener(s) attached to a VideoStreamAdapter being " - "destroyed."; RTC_DCHECK(adaptation_constraints_.empty()) << "There are constaint(s) attached to a VideoStreamAdapter being " "destroyed."; @@ -261,24 +258,6 @@ void VideoStreamAdapter::RemoveRestrictionsListener( restrictions_listeners_.erase(it); } -void VideoStreamAdapter::AddAdaptationListener( - AdaptationListener* adaptation_listener) { - RTC_DCHECK_RUN_ON(&sequence_checker_); - RTC_DCHECK(std::find(adaptation_listeners_.begin(), - adaptation_listeners_.end(), - adaptation_listener) == adaptation_listeners_.end()); - adaptation_listeners_.push_back(adaptation_listener); -} - -void VideoStreamAdapter::RemoveAdaptationListener( - AdaptationListener* adaptation_listener) { - RTC_DCHECK_RUN_ON(&sequence_checker_); - auto it = std::find(adaptation_listeners_.begin(), - adaptation_listeners_.end(), adaptation_listener); - RTC_DCHECK(it != adaptation_listeners_.end()); - adaptation_listeners_.erase(it); -} - void VideoStreamAdapter::AddAdaptationConstraint( AdaptationConstraint* adaptation_constraint) { RTC_DCHECK_RUN_ON(&sequence_checker_); @@ -705,11 +684,6 @@ void VideoStreamAdapter::BroadcastVideoRestrictionsUpdate( filtered, current_restrictions_.counters, resource, source_restrictions()); } - for (auto* adaptation_listener : adaptation_listeners_) { - adaptation_listener->OnAdaptationApplied( - input_state, last_video_source_restrictions_, - current_restrictions_.restrictions, resource); - } last_video_source_restrictions_ = current_restrictions_.restrictions; last_filtered_restrictions_ = filtered; } diff --git a/call/adaptation/video_stream_adapter.h b/call/adaptation/video_stream_adapter.h index 5e54a65dff..1f6f252b33 100644 --- a/call/adaptation/video_stream_adapter.h +++ b/call/adaptation/video_stream_adapter.h @@ -21,7 +21,6 @@ #include "api/rtp_parameters.h" #include "api/video/video_adaptation_counters.h" #include "call/adaptation/adaptation_constraint.h" -#include "call/adaptation/adaptation_listener.h" #include "call/adaptation/degradation_preference_provider.h" #include "call/adaptation/video_source_restrictions.h" #include "call/adaptation/video_stream_input_state.h" @@ -139,8 +138,6 @@ class VideoStreamAdapter { VideoSourceRestrictionsListener* restrictions_listener); void RemoveRestrictionsListener( VideoSourceRestrictionsListener* restrictions_listener); - void AddAdaptationListener(AdaptationListener* adaptation_listener); - void RemoveAdaptationListener(AdaptationListener* adaptation_listener); void AddAdaptationConstraint(AdaptationConstraint* adaptation_constraint); void RemoveAdaptationConstraint(AdaptationConstraint* adaptation_constraint); @@ -263,8 +260,6 @@ class VideoStreamAdapter { std::vector restrictions_listeners_ RTC_GUARDED_BY(&sequence_checker_); - std::vector adaptation_listeners_ - RTC_GUARDED_BY(&sequence_checker_); std::vector adaptation_constraints_ RTC_GUARDED_BY(&sequence_checker_); diff --git a/call/adaptation/video_stream_adapter_unittest.cc b/call/adaptation/video_stream_adapter_unittest.cc index a6c8f6ece3..073ff825c5 100644 --- a/call/adaptation/video_stream_adapter_unittest.cc +++ b/call/adaptation/video_stream_adapter_unittest.cc @@ -20,9 +20,7 @@ #include "api/video_codecs/video_encoder.h" #include "api/video_codecs/video_encoder_config.h" #include "call/adaptation/adaptation_constraint.h" -#include "call/adaptation/adaptation_listener.h" #include "call/adaptation/encoder_settings.h" -#include "call/adaptation/test/fake_adaptation_listener.h" #include "call/adaptation/test/fake_resource.h" #include "call/adaptation/video_source_restrictions.h" #include "call/adaptation/video_stream_input_state.h" @@ -155,17 +153,6 @@ class FakeVideoStreamAdapterListner : public VideoSourceRestrictionsListener { VideoSourceRestrictions last_restrictions_; }; -class MockAdaptationListener : public AdaptationListener { - public: - MOCK_METHOD(void, - OnAdaptationApplied, - (const VideoStreamInputState& input_state, - const VideoSourceRestrictions& restrictions_before, - const VideoSourceRestrictions& restrictions_after, - rtc::scoped_refptr reason_resource), - (override)); -}; - class MockAdaptationConstraint : public AdaptationConstraint { public: MOCK_METHOD(bool, @@ -907,26 +894,6 @@ TEST_F(VideoStreamAdapterTest, adapter_.GetAdaptDownResolution().status()); } -TEST_F(VideoStreamAdapterTest, AdaptationListenerReceivesSignalOnAdaptation) { - testing::StrictMock adaptation_listener; - adapter_.SetDegradationPreference(DegradationPreference::MAINTAIN_FRAMERATE); - adapter_.AddAdaptationListener(&adaptation_listener); - input_state_provider_.SetInputState(1280 * 720, 30, - kDefaultMinPixelsPerFrame); - VideoSourceRestrictions restrictions_before; - VideoSourceRestrictions restrictions_after; - EXPECT_CALL(adaptation_listener, OnAdaptationApplied) - .WillOnce(DoAll(SaveArg<1>(&restrictions_before), - SaveArg<2>(&restrictions_after))); - auto adaptation = adapter_.GetAdaptationDown(); - adapter_.ApplyAdaptation(adaptation, nullptr); - EXPECT_EQ(VideoSourceRestrictions(), restrictions_before); - EXPECT_EQ(adaptation.restrictions(), restrictions_after); - - // Clean up. - adapter_.RemoveAdaptationListener(&adaptation_listener); -} - TEST_F(VideoStreamAdapterTest, AdaptationConstraintAllowsAdaptationsUp) { testing::StrictMock adaptation_constraint; adapter_.SetDegradationPreference(DegradationPreference::MAINTAIN_FRAMERATE); diff --git a/video/adaptation/quality_scaler_resource.h b/video/adaptation/quality_scaler_resource.h index 9317c79d8b..27c255567a 100644 --- a/video/adaptation/quality_scaler_resource.h +++ b/video/adaptation/quality_scaler_resource.h @@ -19,7 +19,6 @@ #include "api/scoped_refptr.h" #include "api/video/video_adaptation_reason.h" #include "api/video_codecs/video_encoder.h" -#include "call/adaptation/adaptation_listener.h" #include "call/adaptation/degradation_preference_provider.h" #include "call/adaptation/resource_adaptation_processor_interface.h" #include "modules/video_coding/utility/quality_scaler.h" diff --git a/video/adaptation/video_stream_encoder_resource.h b/video/adaptation/video_stream_encoder_resource.h index 08994c135d..f653cc9edf 100644 --- a/video/adaptation/video_stream_encoder_resource.h +++ b/video/adaptation/video_stream_encoder_resource.h @@ -18,7 +18,6 @@ #include "api/adaptation/resource.h" #include "api/task_queue/task_queue_base.h" #include "call/adaptation/adaptation_constraint.h" -#include "call/adaptation/adaptation_listener.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/synchronization/sequence_checker.h" diff --git a/video/video_stream_encoder.h b/video/video_stream_encoder.h index 43122e95a9..5761896e1d 100644 --- a/video/video_stream_encoder.h +++ b/video/video_stream_encoder.h @@ -28,7 +28,6 @@ #include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_encoder.h" #include "call/adaptation/adaptation_constraint.h" -#include "call/adaptation/adaptation_listener.h" #include "call/adaptation/resource_adaptation_processor.h" #include "call/adaptation/resource_adaptation_processor_interface.h" #include "call/adaptation/video_source_restrictions.h" diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc index 46104569c8..3007a6945e 100644 --- a/video/video_stream_encoder_unittest.cc +++ b/video/video_stream_encoder_unittest.cc @@ -27,7 +27,6 @@ #include "api/video_codecs/vp8_temporal_layers.h" #include "api/video_codecs/vp8_temporal_layers_factory.h" #include "call/adaptation/test/fake_adaptation_constraint.h" -#include "call/adaptation/test/fake_adaptation_listener.h" #include "call/adaptation/test/fake_resource.h" #include "common_video/h264/h264_common.h" #include "common_video/include/video_frame_buffer.h"