From c2cc4d305a7c05a5de2cc957ffc94806a45d54a8 Mon Sep 17 00:00:00 2001 From: Ilya Nikolaevskiy Date: Wed, 26 Aug 2020 16:50:44 +0200 Subject: [PATCH] [adaptation] Expose target pixels and max framerate in VideoAdapter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will enable wiring up these signals to the platform specific capturers Bug: chromium:1116430 Change-Id: I6cdab61eab202a24fa56167da57c389a5b1880c2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/182683 Reviewed-by: Erik Språng Commit-Queue: Ilya Nikolaevskiy Cr-Commit-Position: refs/heads/master@{#32017} --- media/base/video_adapter.cc | 18 ++++++++++++++++++ media/base/video_adapter.h | 10 +++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/media/base/video_adapter.cc b/media/base/video_adapter.cc index 73e77cc37e..ddcf4cac89 100644 --- a/media/base/video_adapter.cc +++ b/media/base/video_adapter.cc @@ -349,4 +349,22 @@ void VideoAdapter::OnSinkWants(const rtc::VideoSinkWants& sink_wants) { source_resolution_alignment_, sink_wants.resolution_alignment); } +int VideoAdapter::GetTargetPixels() const { + webrtc::MutexLock lock(&mutex_); + return resolution_request_target_pixel_count_; +} + +float VideoAdapter::GetMaxFramerate() const { + webrtc::MutexLock lock(&mutex_); + // Minimum of |max_fps_| and |max_framerate_request_| is used to throttle + // frame-rate. + int framerate = std::min(max_framerate_request_, + max_fps_.value_or(max_framerate_request_)); + if (framerate == std::numeric_limits::max()) { + return std::numeric_limits::infinity(); + } else { + return max_framerate_request_; + } +} + } // namespace cricket diff --git a/media/base/video_adapter.h b/media/base/video_adapter.h index 2c42632762..3f9f281e30 100644 --- a/media/base/video_adapter.h +++ b/media/base/video_adapter.h @@ -97,6 +97,14 @@ class VideoAdapter { void OnSinkWants(const rtc::VideoSinkWants& sink_wants) RTC_LOCKS_EXCLUDED(mutex_); + // Returns maximum image area, which shouldn't impose any adaptations. + // Can return |numeric_limits::max()| if no limit is set. + int GetTargetPixels() const; + + // Returns current frame-rate limit. + // Can return |numeric_limits::infinity()| if no limit is set. + float GetMaxFramerate() const; + private: // Determine if frame should be dropped based on input fps and requested fps. bool KeepFrame(int64_t in_timestamp_ns) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); @@ -136,7 +144,7 @@ class VideoAdapter { int max_framerate_request_ RTC_GUARDED_BY(mutex_); // The critical section to protect the above variables. - webrtc::Mutex mutex_; + mutable webrtc::Mutex mutex_; RTC_DISALLOW_COPY_AND_ASSIGN(VideoAdapter); };