From f9ddf7fed6617c21f8be6f32737953751fb5701b Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Wed, 24 Jul 2024 08:48:49 +0200 Subject: [PATCH] Replace test frame capturer wanted_fps_ by target_capture_fps_. wanted_fps_ seems redundant with target_capture_fps_. The problem with wanted_fps_ is that it lowers the capture fps but does not decimate frames so that a 30 fps stream played at 5 fps is played slowly instead of played at the normal speed with dropped frames. Change-Id: I1440953f9909ad1d4a102a0671fe933d95498a1f Bug: b/355120692 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/357780 Reviewed-by: Mirko Bonadei Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#42670} --- test/frame_generator_capturer.cc | 28 +++++++++------------------- test/frame_generator_capturer.h | 2 -- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/test/frame_generator_capturer.cc b/test/frame_generator_capturer.cc index d30909d8ed..b53085b7c4 100644 --- a/test/frame_generator_capturer.cc +++ b/test/frame_generator_capturer.cc @@ -94,7 +94,7 @@ void FrameGeneratorCapturer::InsertFrame() { if (sending_) { FrameGeneratorInterface::VideoFrameData frame_data = frame_generator_->NextFrame(); - // TODO(srte): Use more advanced frame rate control to allow arbritrary + // TODO(srte): Use more advanced frame rate control to allow arbitrary // fractions. int decimation = std::round(static_cast(source_fps_) / target_capture_fps_); @@ -189,28 +189,20 @@ void FrameGeneratorCapturer::AddOrUpdateSink( rtc::VideoSinkInterface* sink, const rtc::VideoSinkWants& wants) { TestVideoCapturer::AddOrUpdateSink(sink, wants); - MutexLock lock(&lock_); - if (sink_wants_observer_) { - // Tests need to observe unmodified sink wants. - sink_wants_observer_->OnSinkWantsChanged(sink, wants); + { + MutexLock lock(&lock_); + if (sink_wants_observer_) { + // Tests need to observe unmodified sink wants. + sink_wants_observer_->OnSinkWantsChanged(sink, wants); + } } - UpdateFps(GetSinkWants().max_framerate_fps); + ChangeFramerate(GetSinkWants().max_framerate_fps); } void FrameGeneratorCapturer::RemoveSink( rtc::VideoSinkInterface* sink) { TestVideoCapturer::RemoveSink(sink); - - MutexLock lock(&lock_); - UpdateFps(GetSinkWants().max_framerate_fps); -} - -void FrameGeneratorCapturer::UpdateFps(int max_fps) { - if (max_fps < target_capture_fps_) { - wanted_fps_.emplace(max_fps); - } else { - wanted_fps_.reset(); - } + ChangeFramerate(GetSinkWants().max_framerate_fps); } void FrameGeneratorCapturer::ForceFrame() { @@ -220,8 +212,6 @@ void FrameGeneratorCapturer::ForceFrame() { int FrameGeneratorCapturer::GetCurrentConfiguredFramerate() { MutexLock lock(&lock_); - if (wanted_fps_ && *wanted_fps_ < target_capture_fps_) - return *wanted_fps_; return target_capture_fps_; } diff --git a/test/frame_generator_capturer.h b/test/frame_generator_capturer.h index 0a46a2f283..c1d01300d2 100644 --- a/test/frame_generator_capturer.h +++ b/test/frame_generator_capturer.h @@ -86,7 +86,6 @@ class FrameGeneratorCapturer : public TestVideoCapturer { void InsertFrame(); static bool Run(void* obj); int GetCurrentConfiguredFramerate(); - void UpdateFps(int max_fps) RTC_EXCLUSIVE_LOCKS_REQUIRED(&lock_); Clock* const clock_; RepeatingTaskHandle frame_task_; @@ -98,7 +97,6 @@ class FrameGeneratorCapturer : public TestVideoCapturer { int source_fps_ RTC_GUARDED_BY(&lock_); int target_capture_fps_ RTC_GUARDED_BY(&lock_); - absl::optional wanted_fps_ RTC_GUARDED_BY(&lock_); VideoRotation fake_rotation_ = kVideoRotation_0; absl::optional fake_color_space_ RTC_GUARDED_BY(&lock_);