OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/media_stream_constraints_util_video_content.h" | 5 #include "content/renderer/media/media_stream_constraints_util_video_content.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 kMinScreenCastDimension, kMaxScreenCastDimension, | 111 kMinScreenCastDimension, kMaxScreenCastDimension, |
112 kMinScreenCastAspectRatio, kMaxScreenCastAspectRatio); | 112 kMinScreenCastAspectRatio, kMaxScreenCastAspectRatio); |
113 } | 113 } |
114 | 114 |
115 // TODO(guidou): Update this policy to better match the way | 115 // TODO(guidou): Update this policy to better match the way |
116 // WebContentsCaptureMachine::ComputeOptimalViewSize() interprets | 116 // WebContentsCaptureMachine::ComputeOptimalViewSize() interprets |
117 // resolution-change policies. See http://crbug.com/701302. | 117 // resolution-change policies. See http://crbug.com/701302. |
118 media::ResolutionChangePolicy SelectResolutionPolicyFromCandidates( | 118 media::ResolutionChangePolicy SelectResolutionPolicyFromCandidates( |
119 const ResolutionSet& resolution_set) { | 119 const ResolutionSet& resolution_set) { |
120 ResolutionSet capabilities = ScreenCastResolutionCapabilities(); | 120 ResolutionSet capabilities = ScreenCastResolutionCapabilities(); |
| 121 // TODO(guidou): Since the real maximum screen resolution is not known, use |
| 122 // max_width and max_height from |resolution_set| as the actual capability, |
| 123 // if necessary, to decide the resolution policy. Update this to use the |
| 124 // actual capability once the actual screen resolution is used as default. |
| 125 // http://crbug.com/257097 |
| 126 int capabilities_max_height = |
| 127 std::min(resolution_set.max_height(), capabilities.max_height()); |
| 128 int capabilities_max_width = |
| 129 std::min(resolution_set.max_width(), capabilities.max_width()); |
| 130 double capabilities_min_aspect_ratio = |
| 131 static_cast<double>(capabilities.min_width()) / capabilities_max_height; |
| 132 double capabilities_max_aspect_ratio = |
| 133 static_cast<double>(capabilities_max_width) / capabilities.min_height(); |
121 bool can_adjust_resolution = | 134 bool can_adjust_resolution = |
122 resolution_set.min_height() <= capabilities.min_height() && | 135 resolution_set.min_height() <= capabilities.min_height() && |
123 resolution_set.max_height() >= capabilities.max_height() && | 136 resolution_set.max_height() >= capabilities_max_height && |
124 resolution_set.min_width() <= capabilities.min_width() && | 137 resolution_set.min_width() <= capabilities.min_width() && |
125 resolution_set.max_width() >= capabilities.max_width() && | 138 resolution_set.max_width() >= capabilities_max_width && |
126 resolution_set.min_aspect_ratio() <= capabilities.min_aspect_ratio() && | 139 resolution_set.min_aspect_ratio() <= capabilities_min_aspect_ratio && |
127 resolution_set.max_aspect_ratio() >= capabilities.max_aspect_ratio(); | 140 resolution_set.max_aspect_ratio() >= capabilities_max_aspect_ratio; |
128 | 141 |
129 return can_adjust_resolution ? media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT | 142 return can_adjust_resolution ? media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT |
130 : media::RESOLUTION_POLICY_FIXED_RESOLUTION; | 143 : media::RESOLUTION_POLICY_FIXED_RESOLUTION; |
131 } | 144 } |
132 | 145 |
133 int RoundToInt(double d) { | 146 int RoundToInt(double d) { |
134 return static_cast<int>(std::round(d)); | 147 return static_cast<int>(std::round(d)); |
135 } | 148 } |
136 | 149 |
137 gfx::Size ToGfxSize(const Point& point) { | 150 gfx::Size ToGfxSize(const Point& point) { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 candidates.Intersection(advanced_candidates); | 319 candidates.Intersection(advanced_candidates); |
307 if (!intersection.IsEmpty()) | 320 if (!intersection.IsEmpty()) |
308 candidates = std::move(intersection); | 321 candidates = std::move(intersection); |
309 } | 322 } |
310 | 323 |
311 DCHECK(!candidates.IsEmpty()); | 324 DCHECK(!candidates.IsEmpty()); |
312 return SelectResultFromCandidates(candidates, constraints.Basic()); | 325 return SelectResultFromCandidates(candidates, constraints.Basic()); |
313 } | 326 } |
314 | 327 |
315 } // namespace content | 328 } // namespace content |
OLD | NEW |