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 <mbonadei@webrtc.org>
Commit-Queue: Jeremy Leconte <jleconte@google.com>
Cr-Commit-Position: refs/heads/main@{#42670}
This commit is contained in:
Jeremy Leconte 2024-07-24 08:48:49 +02:00 committed by WebRTC LUCI CQ
parent 8089959877
commit f9ddf7fed6
2 changed files with 9 additions and 21 deletions

View File

@ -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<double>(source_fps_) / target_capture_fps_);
@ -189,28 +189,20 @@ void FrameGeneratorCapturer::AddOrUpdateSink(
rtc::VideoSinkInterface<VideoFrame>* 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<VideoFrame>* 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_;
}

View File

@ -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<int> wanted_fps_ RTC_GUARDED_BY(&lock_);
VideoRotation fake_rotation_ = kVideoRotation_0;
absl::optional<ColorSpace> fake_color_space_ RTC_GUARDED_BY(&lock_);