Add support to adapt video without preserving aspect ratio

This is implemented by allowing users to set two different aspect
ratios, one for landscape input and one for portrait input. This extra
control might be useful in other scenarios as well.

Bug: webrtc:9903
Change-Id: I91676737f4aa1f5d94cfe79ac51d5f866779945b
Reviewed-on: https://webrtc-review.googlesource.com/c/108086
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25387}
diff --git a/media/base/videoadapter.h b/media/base/videoadapter.h
index bb9ab80..1864d5c 100644
--- a/media/base/videoadapter.h
+++ b/media/base/videoadapter.h
@@ -68,6 +68,17 @@
       const absl::optional<int>& max_pixel_count,
       const absl::optional<int>& max_fps);
 
+  // Same as above, but allows setting two different target aspect ratios
+  // depending on incoming frame orientation. This gives more fine-grained
+  // control and can e.g. be used to force landscape video to be cropped to
+  // portrait video.
+  void OnOutputFormatRequest(
+      const absl::optional<std::pair<int, int>>& target_landscape_aspect_ratio,
+      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);
+
   // 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|.
@@ -100,9 +111,14 @@
   // Max number of pixels/fps requested via calls to OnOutputFormatRequest,
   // OnResolutionFramerateRequest respectively.
   // The adapted output format is the minimum of these.
-  absl::optional<std::pair<int, int>> target_aspect_ratio_
+  absl::optional<std::pair<int, int>> target_landscape_aspect_ratio_
       RTC_GUARDED_BY(critical_section_);
-  absl::optional<int> max_pixel_count_ RTC_GUARDED_BY(critical_section_);
+  absl::optional<int> max_landscape_pixel_count_
+      RTC_GUARDED_BY(critical_section_);
+  absl::optional<std::pair<int, int>> target_portrait_aspect_ratio_
+      RTC_GUARDED_BY(critical_section_);
+  absl::optional<int> max_portrait_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_);