diff options
Diffstat (limited to 'third_party/libwebrtc/video/video_stream_encoder_unittest.cc')
-rw-r--r-- | third_party/libwebrtc/video/video_stream_encoder_unittest.cc | 64 |
1 files changed, 62 insertions, 2 deletions
diff --git a/third_party/libwebrtc/video/video_stream_encoder_unittest.cc b/third_party/libwebrtc/video/video_stream_encoder_unittest.cc index fa28368d68..6fa99081cd 100644 --- a/third_party/libwebrtc/video/video_stream_encoder_unittest.cc +++ b/third_party/libwebrtc/video/video_stream_encoder_unittest.cc @@ -136,8 +136,8 @@ void PassAFrame( FrameCadenceAdapterInterface::Callback* video_stream_encoder_callback, int64_t ntp_time_ms) { encoder_queue->PostTask([video_stream_encoder_callback, ntp_time_ms] { - video_stream_encoder_callback->OnFrame(Timestamp::Millis(ntp_time_ms), 1, - CreateSimpleNV12Frame()); + video_stream_encoder_callback->OnFrame(Timestamp::Millis(ntp_time_ms), + false, CreateSimpleNV12Frame()); }); } @@ -783,6 +783,10 @@ class MockFrameCadenceAdapter : public FrameCadenceAdapterInterface { UpdateLayerStatus, (size_t spatial_index, bool enabled), (override)); + MOCK_METHOD(void, + UpdateVideoSourceRestrictions, + (absl::optional<double>), + (override)); MOCK_METHOD(void, ProcessKeyFrameRequest, (), (override)); }; @@ -9580,4 +9584,60 @@ TEST(VideoStreamEncoderFrameCadenceTest, kMaxFps); } +class VideoStreamEncoderFrameCadenceRestrictionTest : public ::testing::Test { + public: + VideoStreamEncoderFrameCadenceRestrictionTest() + : adapter_ptr_(adapter_.get()), + fake_resource_(FakeResource::Create("FakeResource")), + video_stream_encoder_( + factory_.Create(std::move(adapter_), &encoder_queue_)) {} + + ~VideoStreamEncoderFrameCadenceRestrictionTest() { + factory_.DepleteTaskQueues(); + } + + void UpdateVideoSourceRestrictions(VideoSourceRestrictions restrictions) { + encoder_queue_->PostTask([this, restrictions] { + RTC_DCHECK_RUN_ON(encoder_queue_); + video_stream_encoder_->OnVideoSourceRestrictionsUpdated( + restrictions, VideoAdaptationCounters(), fake_resource_, + VideoSourceRestrictions()); + }); + } + + protected: + SimpleVideoStreamEncoderFactory factory_; + std::unique_ptr<NiceMock<MockFrameCadenceAdapter>> adapter_{ + std::make_unique<NiceMock<MockFrameCadenceAdapter>>()}; + NiceMock<MockFrameCadenceAdapter>* adapter_ptr_; + TaskQueueBase* encoder_queue_{nullptr}; + rtc::scoped_refptr<FakeResource> fake_resource_; + VideoSourceRestrictions restrictions_; + std::unique_ptr<SimpleVideoStreamEncoderFactory::AdaptedVideoStreamEncoder> + video_stream_encoder_; +}; + +TEST_F(VideoStreamEncoderFrameCadenceRestrictionTest, + UpdatesVideoSourceRestrictionsUnRestricted) { + EXPECT_CALL(*adapter_ptr_, UpdateVideoSourceRestrictions(Eq(absl::nullopt))); + UpdateVideoSourceRestrictions(VideoSourceRestrictions()); +} + +TEST_F(VideoStreamEncoderFrameCadenceRestrictionTest, + UpdatesVideoSourceRestrictionsWithMaxFrameRateRestriction) { + restrictions_.set_max_frame_rate(20); + EXPECT_CALL(*adapter_ptr_, UpdateVideoSourceRestrictions(Optional(20))); + UpdateVideoSourceRestrictions(restrictions_); +} + +TEST_F(VideoStreamEncoderFrameCadenceRestrictionTest, + UpdatesVideoSourceRestrictionsWithoutMaxFrameRateRestriction) { + // Restrictions in resolution count as restriction updated, even though the + // FPS is unlimited. + restrictions_.set_max_pixels_per_frame(99); + restrictions_.set_target_pixels_per_frame(101); + EXPECT_CALL(*adapter_ptr_, UpdateVideoSourceRestrictions(Eq(absl::nullopt))); + UpdateVideoSourceRestrictions(restrictions_); +} + } // namespace webrtc |