Remove VideoStreamEncoder::encoder_queue() The accessor existed only so that VideoStreamEncoderTest could post tasks to the encoder queue. The fixture creates that queue and already holds a pointer to it, so pass the pointer to the test encoder instead. VideoStreamEncoderFrameCadenceRestrictionTest already works this way. Bug: webrtc:42222804 Change-Id: I006224a619ce488918f06fa9aad28a6a189d80b2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/504382 Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Markus Handell <handellm@webrtc.org> Cr-Commit-Position: refs/heads/main@{#48653}
diff --git a/video/video_stream_encoder.h b/video/video_stream_encoder.h index 517ed79..ca4f6a4 100644 --- a/video/video_stream_encoder.h +++ b/video/video_stream_encoder.h
@@ -146,10 +146,6 @@ protected: friend class VideoStreamEncoderFrameCadenceRestrictionTest; - // Used for testing. For example the `ScalingObserverInterface` methods must - // be called on `encoder_queue_`. - TaskQueueBase* encoder_queue() { return encoder_queue_.get(); } - void OnVideoSourceRestrictionsUpdated( VideoSourceRestrictions restrictions, const VideoAdaptationCounters& adaptation_counters,
diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc index 6c8ed3c..ade1207 100644 --- a/video/video_stream_encoder_unittest.cc +++ b/video/video_stream_encoder_unittest.cc
@@ -424,6 +424,10 @@ TimeController* time_controller, std::unique_ptr<FrameCadenceAdapterInterface> cadence_adapter, std::unique_ptr<TaskQueueBase, TaskQueueDeleter> encoder_queue, + // Points at `encoder_queue`, which is owned by VideoStreamEncoder. Passed + // separately because it has been moved by the time the members below are + // initialized. + TaskQueueBase* encoder_queue_ptr, SendStatisticsProxy* stats_proxy, VideoStreamEncoderSettings settings, VideoStreamEncoder::BitrateAllocationCallbackType @@ -444,6 +448,7 @@ nullptr, // encoder_selector std::move(encoder_switch_request_callback)), time_controller_(time_controller), + encoder_queue_ptr_(encoder_queue_ptr), fake_cpu_resource_(FakeResource::Create("FakeResource[CPU]")), fake_quality_resource_(FakeResource::Create("FakeResource[QP]")), fake_adaptation_constraint_("FakeAdaptationConstraint") { @@ -488,14 +493,14 @@ // Triggers resource usage measurements on the fake CPU resource. void TriggerCpuOveruse() { - encoder_queue()->PostTask([this] { + encoder_queue_ptr_->PostTask([this] { fake_cpu_resource_->SetUsageState(ResourceUsageState::kOveruse); }); WaitUntilTaskQueueIsIdle(); } void TriggerCpuUnderuse() { - encoder_queue()->PostTask([this] { + encoder_queue_ptr_->PostTask([this] { fake_cpu_resource_->SetUsageState(ResourceUsageState::kUnderuse); }); WaitUntilTaskQueueIsIdle(); @@ -503,20 +508,21 @@ // Triggers resource usage measurements on the fake quality resource. void TriggerQualityLow() { - encoder_queue()->PostTask([this] { + encoder_queue_ptr_->PostTask([this] { fake_quality_resource_->SetUsageState(ResourceUsageState::kOveruse); }); WaitUntilTaskQueueIsIdle(); } void TriggerQualityHigh() { - encoder_queue()->PostTask([this] { + encoder_queue_ptr_->PostTask([this] { fake_quality_resource_->SetUsageState(ResourceUsageState::kUnderuse); }); WaitUntilTaskQueueIsIdle(); } TimeController* const time_controller_; + TaskQueueBase* const encoder_queue_ptr_; CpuOveruseDetectorProxy* overuse_detector_proxy_; scoped_refptr<FakeResource> fake_cpu_resource_; scoped_refptr<FakeResource> fake_quality_resource_; @@ -926,8 +932,8 @@ VideoStreamEncoderSettings settings = video_send_config_.encoder_settings; video_stream_encoder_ = std::make_unique<VideoStreamEncoderUnderTest>( env_, &time_controller_, std::move(cadence_adapter), - std::move(encoder_queue), stats_proxy_.get(), std::move(settings), - allocation_callback_type, num_cores, + std::move(encoder_queue), encoder_queue_ptr, stats_proxy_.get(), + std::move(settings), allocation_callback_type, num_cores, std::move(encoder_switch_request_callback_)); video_stream_encoder_->SetSink(&sink_, /*rotation_applied=*/false); video_stream_encoder_->SetSource(&video_source_,