Add option to only request a frame interval change via OnOutputFormatRequest.

OnOutputFormatRequest(const absl::optional<VideoFormat>& format)
changed to
OnOutputFormatRequest(
      const absl::optional<std::pair<int, int>>& target_aspect_ratio,
      const absl::optional<int>& max_pixel_count,
      const absl::optional<int>& max_fps)

Decouples:
- Resolution and fps requests.
- Resolution requests from aspect ratio requests.

Bug: webrtc:9597
Change-Id: I6f44c91283cf5474c6531e55773d2257e2341063
Reviewed-on: https://webrtc-review.googlesource.com/95423
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Åsa Persson <asapersson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24623}
diff --git a/media/base/videoadapter.h b/media/base/videoadapter.h
index 4bb6574..bb9ab80 100644
--- a/media/base/videoadapter.h
+++ b/media/base/videoadapter.h
@@ -11,6 +11,8 @@
 #ifndef MEDIA_BASE_VIDEOADAPTER_H_
 #define MEDIA_BASE_VIDEOADAPTER_H_
 
+#include <utility>
+
 #include "absl/types/optional.h"
 #include "media/base/videocommon.h"
 #include "rtc_base/constructormagic.h"
@@ -42,14 +44,30 @@
                             int* out_width,
                             int* out_height);
 
+  // DEPRECATED. Please use OnOutputFormatRequest below.
+  // TODO(asapersson): Remove this once it is no longer used.
   // Requests the output frame size and frame interval from
   // |AdaptFrameResolution| to not be larger than |format|. Also, the input
   // frame size will be cropped to match the requested aspect ratio. The
   // requested aspect ratio is orientation agnostic and will be adjusted to
   // 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);
 
+  // Requests output frame size and frame interval from |AdaptFrameResolution|.
+  // |target_aspect_ratio|: The input frame size will be cropped to match the
+  // requested aspect ratio. The aspect ratio is orientation agnostic and will
+  // be adjusted to maintain the input orientation (i.e. it doesn't matter if
+  // e.g. <1280,720> or <720,1280> is requested).
+  // |max_pixel_count|: The maximum output frame size.
+  // |max_fps|: The maximum output framerate.
+  // Note: Should be called from the source only.
+  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);
+
   // Requests the output frame size from |AdaptFrameResolution| to have as close
   // as possible to |target_pixel_count| pixels (if set) but no more than
   // |max_pixel_count|.
@@ -57,6 +75,7 @@
   // framerate rather than resolution.
   // Set |max_pixel_count| and/or |max_framerate_fps| to
   // std::numeric_limit<int>::max() if no upper limit is desired.
+  // Note: Should be called from the sink only.
   void OnResolutionFramerateRequest(
       const absl::optional<int>& target_pixel_count,
       int max_pixel_count,
@@ -78,11 +97,13 @@
   absl::optional<int64_t> next_frame_timestamp_ns_
       RTC_GUARDED_BY(critical_section_);
 
-  // Max number of pixels requested via calls to OnOutputFormatRequest,
-  // OnResolutionRequest respectively.
+  // Max number of pixels/fps requested via calls to OnOutputFormatRequest,
+  // OnResolutionFramerateRequest respectively.
   // The adapted output format is the minimum of these.
-  absl::optional<VideoFormat> requested_format_
+  absl::optional<std::pair<int, int>> target_aspect_ratio_
       RTC_GUARDED_BY(critical_section_);
+  absl::optional<int> max_pixel_count_ RTC_GUARDED_BY(critical_section_);
+  absl::optional<int> max_fps_ RTC_GUARDED_BY(critical_section_);
   int resolution_request_target_pixel_count_ RTC_GUARDED_BY(critical_section_);
   int resolution_request_max_pixel_count_ RTC_GUARDED_BY(critical_section_);
   int max_framerate_request_ RTC_GUARDED_BY(critical_section_);