VideoAdapter: remove lock recursions.

This change removes lock recursions and adds thread annotations.

Bug: webrtc:11567
Change-Id: I984a0b7993b03c039c220206e2a930ff766e54b0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175125
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31323}
This commit is contained in:
Markus Handell 2020-05-14 14:59:55 +02:00 committed by Commit Bot
parent 41acdc6074
commit c5324fb7bd
2 changed files with 10 additions and 8 deletions

View File

@ -145,8 +145,6 @@ VideoAdapter::VideoAdapter() : VideoAdapter(1) {}
VideoAdapter::~VideoAdapter() {}
bool VideoAdapter::KeepFrame(int64_t in_timestamp_ns) {
rtc::CritScope cs(&critical_section_);
int max_fps = max_framerate_request_;
if (max_fps_)
max_fps = std::min(max_fps, *max_fps_);

View File

@ -46,7 +46,8 @@ class VideoAdapter {
int* cropped_width,
int* cropped_height,
int* out_width,
int* out_height);
int* out_height)
RTC_LOCKS_EXCLUDED(critical_section_);
// DEPRECATED. Please use OnOutputFormatRequest below.
// TODO(asapersson): Remove this once it is no longer used.
@ -57,7 +58,8 @@ class VideoAdapter {
// maintain the input orientation, so it doesn't matter if e.g. 1280x720 or
// 720x1280 is requested.
// Note: Should be called from the source only.
void OnOutputFormatRequest(const absl::optional<VideoFormat>& format);
void OnOutputFormatRequest(const absl::optional<VideoFormat>& format)
RTC_LOCKS_EXCLUDED(critical_section_);
// Requests output frame size and frame interval from |AdaptFrameResolution|.
// |target_aspect_ratio|: The input frame size will be cropped to match the
@ -70,7 +72,7 @@ class VideoAdapter {
void OnOutputFormatRequest(
const absl::optional<std::pair<int, int>>& target_aspect_ratio,
const absl::optional<int>& max_pixel_count,
const absl::optional<int>& max_fps);
const absl::optional<int>& max_fps) RTC_LOCKS_EXCLUDED(critical_section_);
// Same as above, but allows setting two different target aspect ratios
// depending on incoming frame orientation. This gives more fine-grained
@ -81,7 +83,7 @@ class VideoAdapter {
const absl::optional<int>& max_landscape_pixel_count,
const absl::optional<std::pair<int, int>>& target_portrait_aspect_ratio,
const absl::optional<int>& max_portrait_pixel_count,
const absl::optional<int>& max_fps);
const absl::optional<int>& max_fps) RTC_LOCKS_EXCLUDED(critical_section_);
// Requests the output frame size from |AdaptFrameResolution| to have as close
// as possible to |sink_wants.target_pixel_count| pixels (if set)
@ -93,11 +95,13 @@ class VideoAdapter {
// The sink resolution alignment requirement is given by
// |sink_wants.resolution_alignment|.
// Note: Should be called from the sink only.
void OnSinkWants(const rtc::VideoSinkWants& sink_wants);
void OnSinkWants(const rtc::VideoSinkWants& sink_wants)
RTC_LOCKS_EXCLUDED(critical_section_);
private:
// Determine if frame should be dropped based on input fps and requested fps.
bool KeepFrame(int64_t in_timestamp_ns);
bool KeepFrame(int64_t in_timestamp_ns)
RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_);
int frames_in_ RTC_GUARDED_BY(critical_section_); // Number of input frames.
int frames_out_