OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "content/renderer/media/media_stream_audio_processor_options.h" | 7 #include "content/renderer/media/media_stream_audio_processor_options.h" |
8 #include "content/renderer/media/media_stream_constraints_util.h" | 8 #include "content/renderer/media/media_stream_constraints_util.h" |
9 #include "content/renderer/media/media_stream_constraints_util_sets.h" | 9 #include "content/renderer/media/media_stream_constraints_util_sets.h" |
10 #include "content/renderer/media/mock_constraint_factory.h" | 10 #include "content/renderer/media/mock_constraint_factory.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 TEST_F(MediaStreamConstraintsUtilTest, VideoTrackAdapterSettingsUnconstrained) { | 119 TEST_F(MediaStreamConstraintsUtilTest, VideoTrackAdapterSettingsUnconstrained) { |
120 ResolutionSet resolution_set; | 120 ResolutionSet resolution_set; |
121 DoubleRangeSet frame_rate_set; | 121 DoubleRangeSet frame_rate_set; |
122 | 122 |
123 // No ideal values. | 123 // No ideal values. |
124 { | 124 { |
125 MockConstraintFactory constraint_factory; | 125 MockConstraintFactory constraint_factory; |
126 auto result = SelectVideoTrackAdapterSettings( | 126 auto result = SelectVideoTrackAdapterSettings( |
127 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 127 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
128 frame_rate_set, SourceFormat()); | 128 frame_rate_set, SourceFormat(), false); |
129 EXPECT_EQ(kSourceHeight, result.max_height); | 129 EXPECT_EQ(kSourceHeight, result.max_height); |
130 EXPECT_EQ(kSourceWidth, result.max_width); | 130 EXPECT_EQ(kSourceWidth, result.max_width); |
131 EXPECT_EQ(0.0, result.min_aspect_ratio); | 131 EXPECT_EQ(0.0, result.min_aspect_ratio); |
132 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio); | 132 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio); |
133 EXPECT_EQ(0.0, result.max_frame_rate); | 133 EXPECT_EQ(0.0, result.max_frame_rate); |
134 } | 134 } |
135 | 135 |
136 // Ideal height. | 136 // Ideal height. |
137 { | 137 { |
138 const int kIdealHeight = 400; | 138 const int kIdealHeight = 400; |
139 MockConstraintFactory constraint_factory; | 139 MockConstraintFactory constraint_factory; |
140 constraint_factory.basic().height.SetIdeal(kIdealHeight); | 140 constraint_factory.basic().height.SetIdeal(kIdealHeight); |
141 auto result = SelectVideoTrackAdapterSettings( | 141 auto result = SelectVideoTrackAdapterSettings( |
142 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 142 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
143 frame_rate_set, SourceFormat()); | 143 frame_rate_set, SourceFormat(), false); |
144 EXPECT_EQ(kIdealHeight, result.max_height); | 144 EXPECT_EQ(kIdealHeight, result.max_height); |
145 EXPECT_EQ(std::round(kIdealHeight * kSourceAspectRatio), result.max_width); | 145 EXPECT_EQ(std::round(kIdealHeight * kSourceAspectRatio), result.max_width); |
146 EXPECT_EQ(0.0, result.min_aspect_ratio); | 146 EXPECT_EQ(0.0, result.min_aspect_ratio); |
147 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio); | 147 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio); |
148 EXPECT_EQ(0.0, result.max_frame_rate); | 148 EXPECT_EQ(0.0, result.max_frame_rate); |
149 } | 149 } |
150 | 150 |
151 // Ideal width. | 151 // Ideal width. |
152 { | 152 { |
153 const int kIdealWidth = 400; | 153 const int kIdealWidth = 400; |
154 MockConstraintFactory constraint_factory; | 154 MockConstraintFactory constraint_factory; |
155 constraint_factory.basic().width.SetIdeal(kIdealWidth); | 155 constraint_factory.basic().width.SetIdeal(kIdealWidth); |
156 auto result = SelectVideoTrackAdapterSettings( | 156 auto result = SelectVideoTrackAdapterSettings( |
157 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 157 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
158 frame_rate_set, SourceFormat()); | 158 frame_rate_set, SourceFormat(), false); |
159 EXPECT_EQ(std::round(kIdealWidth / kSourceAspectRatio), result.max_height); | 159 EXPECT_EQ(std::round(kIdealWidth / kSourceAspectRatio), result.max_height); |
160 EXPECT_EQ(kIdealWidth, result.max_width); | 160 EXPECT_EQ(kIdealWidth, result.max_width); |
161 EXPECT_EQ(0.0, result.min_aspect_ratio); | 161 EXPECT_EQ(0.0, result.min_aspect_ratio); |
162 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio); | 162 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio); |
163 EXPECT_EQ(0.0, result.max_frame_rate); | 163 EXPECT_EQ(0.0, result.max_frame_rate); |
164 } | 164 } |
165 | 165 |
166 // Ideal aspect ratio. | 166 // Ideal aspect ratio. |
167 { | 167 { |
168 const double kIdealAspectRatio = 2.0; | 168 const double kIdealAspectRatio = 2.0; |
169 MockConstraintFactory constraint_factory; | 169 MockConstraintFactory constraint_factory; |
170 constraint_factory.basic().aspect_ratio.SetIdeal(kIdealAspectRatio); | 170 constraint_factory.basic().aspect_ratio.SetIdeal(kIdealAspectRatio); |
171 auto result = SelectVideoTrackAdapterSettings( | 171 auto result = SelectVideoTrackAdapterSettings( |
172 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 172 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
173 frame_rate_set, SourceFormat()); | 173 frame_rate_set, SourceFormat(), false); |
174 EXPECT_EQ(kSourceHeight, result.max_height); | 174 EXPECT_EQ(kSourceHeight, result.max_height); |
175 EXPECT_EQ(std::round(kSourceHeight * kIdealAspectRatio), result.max_width); | 175 EXPECT_EQ(std::round(kSourceHeight * kIdealAspectRatio), result.max_width); |
176 EXPECT_EQ(0.0, result.min_aspect_ratio); | 176 EXPECT_EQ(0.0, result.min_aspect_ratio); |
177 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio); | 177 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio); |
178 EXPECT_EQ(0.0, result.max_frame_rate); | 178 EXPECT_EQ(0.0, result.max_frame_rate); |
179 } | 179 } |
180 | 180 |
181 // Ideal frame rate. | 181 // Ideal frame rate. |
182 { | 182 { |
183 const double kIdealFrameRate = 33; | 183 const double kIdealFrameRate = 33; |
184 MockConstraintFactory constraint_factory; | 184 MockConstraintFactory constraint_factory; |
185 constraint_factory.basic().frame_rate.SetIdeal(kIdealFrameRate); | 185 constraint_factory.basic().frame_rate.SetIdeal(kIdealFrameRate); |
186 auto result = SelectVideoTrackAdapterSettings( | 186 auto result = SelectVideoTrackAdapterSettings( |
187 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 187 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
188 frame_rate_set, SourceFormat()); | 188 frame_rate_set, SourceFormat(), false); |
189 EXPECT_EQ(kSourceHeight, result.max_height); | 189 EXPECT_EQ(kSourceHeight, result.max_height); |
190 EXPECT_EQ(kSourceWidth, result.max_width); | 190 EXPECT_EQ(kSourceWidth, result.max_width); |
191 EXPECT_EQ(0.0, result.min_aspect_ratio); | 191 EXPECT_EQ(0.0, result.min_aspect_ratio); |
192 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio); | 192 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio); |
193 EXPECT_EQ(kIdealFrameRate, result.max_frame_rate); | 193 EXPECT_EQ(kIdealFrameRate, result.max_frame_rate); |
194 } | 194 } |
195 | 195 |
196 // All ideals supplied. | 196 // All ideals supplied. |
197 { | 197 { |
198 const int kIdealHeight = 400; | 198 const int kIdealHeight = 400; |
199 const int kIdealWidth = 600; | 199 const int kIdealWidth = 600; |
200 const int kIdealAspectRatio = 2.0; | 200 const int kIdealAspectRatio = 2.0; |
201 const double kIdealFrameRate = 33; | 201 const double kIdealFrameRate = 33; |
202 MockConstraintFactory constraint_factory; | 202 MockConstraintFactory constraint_factory; |
203 constraint_factory.basic().height.SetIdeal(kIdealHeight); | 203 constraint_factory.basic().height.SetIdeal(kIdealHeight); |
204 constraint_factory.basic().width.SetIdeal(kIdealWidth); | 204 constraint_factory.basic().width.SetIdeal(kIdealWidth); |
205 // Ideal aspect ratio is ignored if ideal width and height are supplied. | 205 // Ideal aspect ratio is ignored if ideal width and height are supplied. |
206 constraint_factory.basic().aspect_ratio.SetIdeal(kIdealAspectRatio); | 206 constraint_factory.basic().aspect_ratio.SetIdeal(kIdealAspectRatio); |
207 constraint_factory.basic().frame_rate.SetIdeal(kIdealFrameRate); | 207 constraint_factory.basic().frame_rate.SetIdeal(kIdealFrameRate); |
208 auto result = SelectVideoTrackAdapterSettings( | 208 auto result = SelectVideoTrackAdapterSettings( |
209 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 209 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
210 frame_rate_set, SourceFormat()); | 210 frame_rate_set, SourceFormat(), false); |
211 EXPECT_EQ(kIdealHeight, result.max_height); | 211 EXPECT_EQ(kIdealHeight, result.max_height); |
212 EXPECT_EQ(kIdealWidth, result.max_width); | 212 EXPECT_EQ(kIdealWidth, result.max_width); |
213 EXPECT_EQ(0.0, result.min_aspect_ratio); | 213 EXPECT_EQ(0.0, result.min_aspect_ratio); |
214 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio); | 214 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio); |
215 EXPECT_EQ(kIdealFrameRate, result.max_frame_rate); | 215 EXPECT_EQ(kIdealFrameRate, result.max_frame_rate); |
216 } | 216 } |
217 } | 217 } |
218 | 218 |
219 TEST_F(MediaStreamConstraintsUtilTest, VideoTrackAdapterSettingsConstrained) { | 219 TEST_F(MediaStreamConstraintsUtilTest, VideoTrackAdapterSettingsConstrained) { |
220 const int kMinHeight = 500; | 220 const int kMinHeight = 500; |
221 const int kMaxHeight = 1200; | 221 const int kMaxHeight = 1200; |
222 const int kMinWidth = 1000; | 222 const int kMinWidth = 1000; |
223 const int kMaxWidth = 2000; | 223 const int kMaxWidth = 2000; |
224 constexpr double kMinAspectRatio = 1.0; | 224 constexpr double kMinAspectRatio = 1.0; |
225 constexpr double kMaxAspectRatio = 2.0; | 225 constexpr double kMaxAspectRatio = 2.0; |
226 constexpr double kMinFrameRate = 20.0; | 226 constexpr double kMinFrameRate = 20.0; |
227 constexpr double kMaxFrameRate = 44.0; | 227 constexpr double kMaxFrameRate = 44.0; |
228 ResolutionSet resolution_set(kMinHeight, kMaxHeight, kMinWidth, kMaxWidth, | 228 ResolutionSet resolution_set(kMinHeight, kMaxHeight, kMinWidth, kMaxWidth, |
229 kMinAspectRatio, kMaxAspectRatio); | 229 kMinAspectRatio, kMaxAspectRatio); |
230 DoubleRangeSet frame_rate_set(kMinFrameRate, kMaxFrameRate); | 230 DoubleRangeSet frame_rate_set(kMinFrameRate, kMaxFrameRate); |
231 | 231 |
232 // No ideal values. | 232 // No ideal values. |
233 { | 233 { |
234 MockConstraintFactory constraint_factory; | 234 MockConstraintFactory constraint_factory; |
235 auto result = SelectVideoTrackAdapterSettings( | 235 auto result = SelectVideoTrackAdapterSettings( |
236 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 236 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
237 frame_rate_set, SourceFormat()); | 237 frame_rate_set, SourceFormat(), false); |
238 EXPECT_EQ(kSourceHeight, result.max_height); | 238 EXPECT_EQ(kSourceHeight, result.max_height); |
239 EXPECT_EQ(kSourceWidth, result.max_width); | 239 EXPECT_EQ(kSourceWidth, result.max_width); |
240 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 240 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
241 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 241 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
242 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); | 242 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); |
243 } | 243 } |
244 | 244 |
245 // Ideal height < min. | 245 // Ideal height < min. |
246 { | 246 { |
247 const int kIdealHeight = 400; | 247 const int kIdealHeight = 400; |
248 static_assert(kIdealHeight < kMinHeight, | 248 static_assert(kIdealHeight < kMinHeight, |
249 "kIdealHeight must be less than kMinHeight"); | 249 "kIdealHeight must be less than kMinHeight"); |
250 MockConstraintFactory constraint_factory; | 250 MockConstraintFactory constraint_factory; |
251 constraint_factory.basic().height.SetIdeal(kIdealHeight); | 251 constraint_factory.basic().height.SetIdeal(kIdealHeight); |
252 auto result = SelectVideoTrackAdapterSettings( | 252 auto result = SelectVideoTrackAdapterSettings( |
253 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 253 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
254 frame_rate_set, SourceFormat()); | 254 frame_rate_set, SourceFormat(), false); |
255 EXPECT_EQ(kMinHeight, result.max_height); | 255 EXPECT_EQ(kMinHeight, result.max_height); |
256 // kMinWidth > kMinHeight * kNativeAspectRatio | 256 // kMinWidth > kMinHeight * kNativeAspectRatio |
257 EXPECT_EQ(kMinWidth, result.max_width); | 257 EXPECT_EQ(kMinWidth, result.max_width); |
258 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 258 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
259 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 259 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
260 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); | 260 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); |
261 } | 261 } |
262 | 262 |
263 // min < Ideal height < max. | 263 // min < Ideal height < max. |
264 { | 264 { |
265 const int kIdealHeight = 1100; | 265 const int kIdealHeight = 1100; |
266 static_assert(kIdealHeight > kMinHeight, | 266 static_assert(kIdealHeight > kMinHeight, |
267 "kIdealHeight must be greater than kMinHeight"); | 267 "kIdealHeight must be greater than kMinHeight"); |
268 static_assert(kIdealHeight < kMaxHeight, | 268 static_assert(kIdealHeight < kMaxHeight, |
269 "kIdealHeight must be less than kMaxHeight"); | 269 "kIdealHeight must be less than kMaxHeight"); |
270 MockConstraintFactory constraint_factory; | 270 MockConstraintFactory constraint_factory; |
271 constraint_factory.basic().height.SetIdeal(kIdealHeight); | 271 constraint_factory.basic().height.SetIdeal(kIdealHeight); |
272 auto result = SelectVideoTrackAdapterSettings( | 272 auto result = SelectVideoTrackAdapterSettings( |
273 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 273 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
274 frame_rate_set, SourceFormat()); | 274 frame_rate_set, SourceFormat(), false); |
275 EXPECT_EQ(kIdealHeight, result.max_height); | 275 EXPECT_EQ(kIdealHeight, result.max_height); |
276 EXPECT_EQ(std::round(kIdealHeight * kSourceAspectRatio), result.max_width); | 276 EXPECT_EQ(std::round(kIdealHeight * kSourceAspectRatio), result.max_width); |
277 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 277 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
278 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 278 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
279 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); | 279 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); |
280 } | 280 } |
281 | 281 |
282 // Ideal height > max. | 282 // Ideal height > max. |
283 { | 283 { |
284 const int kIdealHeight = 2000; | 284 const int kIdealHeight = 2000; |
285 static_assert(kIdealHeight > kMaxHeight, | 285 static_assert(kIdealHeight > kMaxHeight, |
286 "kIdealHeight must be greater than kMaxHeight"); | 286 "kIdealHeight must be greater than kMaxHeight"); |
287 MockConstraintFactory constraint_factory; | 287 MockConstraintFactory constraint_factory; |
288 constraint_factory.basic().height.SetIdeal(kIdealHeight); | 288 constraint_factory.basic().height.SetIdeal(kIdealHeight); |
289 auto result = SelectVideoTrackAdapterSettings( | 289 auto result = SelectVideoTrackAdapterSettings( |
290 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 290 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
291 frame_rate_set, SourceFormat()); | 291 frame_rate_set, SourceFormat(), false); |
292 EXPECT_EQ(kMaxHeight, result.max_height); | 292 EXPECT_EQ(kMaxHeight, result.max_height); |
293 EXPECT_EQ(std::round(kMaxHeight * kSourceAspectRatio), result.max_width); | 293 EXPECT_EQ(std::round(kMaxHeight * kSourceAspectRatio), result.max_width); |
294 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 294 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
295 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 295 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
296 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); | 296 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); |
297 } | 297 } |
298 | 298 |
299 // Ideal width < min. | 299 // Ideal width < min. |
300 { | 300 { |
301 const int kIdealWidth = 800; | 301 const int kIdealWidth = 800; |
302 static_assert(kIdealWidth < kMinWidth, | 302 static_assert(kIdealWidth < kMinWidth, |
303 "kIdealWidth must be less than kMinWidth"); | 303 "kIdealWidth must be less than kMinWidth"); |
304 MockConstraintFactory constraint_factory; | 304 MockConstraintFactory constraint_factory; |
305 constraint_factory.basic().width.SetIdeal(kIdealWidth); | 305 constraint_factory.basic().width.SetIdeal(kIdealWidth); |
306 auto result = SelectVideoTrackAdapterSettings( | 306 auto result = SelectVideoTrackAdapterSettings( |
307 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 307 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
308 frame_rate_set, SourceFormat()); | 308 frame_rate_set, SourceFormat(), false); |
309 EXPECT_EQ(std::round(kMinWidth / kSourceAspectRatio), result.max_height); | 309 EXPECT_EQ(std::round(kMinWidth / kSourceAspectRatio), result.max_height); |
310 EXPECT_EQ(kMinWidth, result.max_width); | 310 EXPECT_EQ(kMinWidth, result.max_width); |
311 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 311 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
312 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 312 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
313 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); | 313 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); |
314 } | 314 } |
315 | 315 |
316 // min < Ideal width < max. | 316 // min < Ideal width < max. |
317 { | 317 { |
318 const int kIdealWidth = 1800; | 318 const int kIdealWidth = 1800; |
319 static_assert(kIdealWidth > kMinWidth, | 319 static_assert(kIdealWidth > kMinWidth, |
320 "kIdealWidth must be greater than kMinWidth"); | 320 "kIdealWidth must be greater than kMinWidth"); |
321 static_assert(kIdealWidth < kMaxWidth, | 321 static_assert(kIdealWidth < kMaxWidth, |
322 "kIdealWidth must be less than kMaxWidth"); | 322 "kIdealWidth must be less than kMaxWidth"); |
323 MockConstraintFactory constraint_factory; | 323 MockConstraintFactory constraint_factory; |
324 constraint_factory.basic().width.SetIdeal(kIdealWidth); | 324 constraint_factory.basic().width.SetIdeal(kIdealWidth); |
325 auto result = SelectVideoTrackAdapterSettings( | 325 auto result = SelectVideoTrackAdapterSettings( |
326 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 326 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
327 frame_rate_set, SourceFormat()); | 327 frame_rate_set, SourceFormat(), false); |
328 EXPECT_EQ(std::round(kIdealWidth / kSourceAspectRatio), result.max_height); | 328 EXPECT_EQ(std::round(kIdealWidth / kSourceAspectRatio), result.max_height); |
329 EXPECT_EQ(kIdealWidth, result.max_width); | 329 EXPECT_EQ(kIdealWidth, result.max_width); |
330 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 330 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
331 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 331 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
332 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); | 332 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); |
333 } | 333 } |
334 | 334 |
335 // Ideal width > max. | 335 // Ideal width > max. |
336 { | 336 { |
337 const int kIdealWidth = 3000; | 337 const int kIdealWidth = 3000; |
338 static_assert(kIdealWidth > kMaxWidth, | 338 static_assert(kIdealWidth > kMaxWidth, |
339 "kIdealWidth must be greater than kMaxWidth"); | 339 "kIdealWidth must be greater than kMaxWidth"); |
340 MockConstraintFactory constraint_factory; | 340 MockConstraintFactory constraint_factory; |
341 constraint_factory.basic().width.SetIdeal(kIdealWidth); | 341 constraint_factory.basic().width.SetIdeal(kIdealWidth); |
342 auto result = SelectVideoTrackAdapterSettings( | 342 auto result = SelectVideoTrackAdapterSettings( |
343 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 343 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
344 frame_rate_set, SourceFormat()); | 344 frame_rate_set, SourceFormat(), false); |
345 // kMaxHeight < kMaxWidth / kNativeAspectRatio | 345 // kMaxHeight < kMaxWidth / kNativeAspectRatio |
346 EXPECT_EQ(kMaxHeight, result.max_height); | 346 EXPECT_EQ(kMaxHeight, result.max_height); |
347 EXPECT_EQ(kMaxWidth, result.max_width); | 347 EXPECT_EQ(kMaxWidth, result.max_width); |
348 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 348 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
349 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 349 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
350 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); | 350 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); |
351 } | 351 } |
352 | 352 |
353 // Ideal aspect ratio < min. | 353 // Ideal aspect ratio < min. |
354 { | 354 { |
355 constexpr double kIdealAspectRatio = 0.5; | 355 constexpr double kIdealAspectRatio = 0.5; |
356 static_assert(kIdealAspectRatio < kMinAspectRatio, | 356 static_assert(kIdealAspectRatio < kMinAspectRatio, |
357 "kIdealAspectRatio must be less than kMinAspectRatio"); | 357 "kIdealAspectRatio must be less than kMinAspectRatio"); |
358 MockConstraintFactory constraint_factory; | 358 MockConstraintFactory constraint_factory; |
359 constraint_factory.basic().aspect_ratio.SetIdeal(kIdealAspectRatio); | 359 constraint_factory.basic().aspect_ratio.SetIdeal(kIdealAspectRatio); |
360 auto result = SelectVideoTrackAdapterSettings( | 360 auto result = SelectVideoTrackAdapterSettings( |
361 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 361 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
362 frame_rate_set, SourceFormat()); | 362 frame_rate_set, SourceFormat(), false); |
363 // Desired point is (kNativeWidth/kMinAspectRatio, kNativeWidth), but it | 363 // Desired point is (kNativeWidth/kMinAspectRatio, kNativeWidth), but it |
364 // is outside the size constraints. Closest to that while maintaining the | 364 // is outside the size constraints. Closest to that while maintaining the |
365 // same aspect ratio is (kMaxHeight, kMaxHeight * kMinAspectRatio). | 365 // same aspect ratio is (kMaxHeight, kMaxHeight * kMinAspectRatio). |
366 EXPECT_EQ(kMaxHeight, result.max_height); | 366 EXPECT_EQ(kMaxHeight, result.max_height); |
367 EXPECT_EQ(std::round(kMaxHeight * kMinAspectRatio), result.max_width); | 367 EXPECT_EQ(std::round(kMaxHeight * kMinAspectRatio), result.max_width); |
368 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 368 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
369 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 369 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
370 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); | 370 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); |
371 } | 371 } |
372 | 372 |
373 // min < Ideal aspect ratio < max. | 373 // min < Ideal aspect ratio < max. |
374 { | 374 { |
375 constexpr double kIdealAspectRatio = 1.25; | 375 constexpr double kIdealAspectRatio = 1.25; |
376 static_assert(kIdealAspectRatio > kMinAspectRatio, | 376 static_assert(kIdealAspectRatio > kMinAspectRatio, |
377 "kIdealAspectRatio must be greater than kMinAspectRatio"); | 377 "kIdealAspectRatio must be greater than kMinAspectRatio"); |
378 static_assert(kIdealAspectRatio < kMaxAspectRatio, | 378 static_assert(kIdealAspectRatio < kMaxAspectRatio, |
379 "kIdealAspectRatio must be less than kMaxAspectRatio"); | 379 "kIdealAspectRatio must be less than kMaxAspectRatio"); |
380 MockConstraintFactory constraint_factory; | 380 MockConstraintFactory constraint_factory; |
381 constraint_factory.basic().aspect_ratio.SetIdeal(kIdealAspectRatio); | 381 constraint_factory.basic().aspect_ratio.SetIdeal(kIdealAspectRatio); |
382 auto result = SelectVideoTrackAdapterSettings( | 382 auto result = SelectVideoTrackAdapterSettings( |
383 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 383 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
384 frame_rate_set, SourceFormat()); | 384 frame_rate_set, SourceFormat(), false); |
385 EXPECT_EQ(std::round(kSourceWidth / kIdealAspectRatio), result.max_height); | 385 EXPECT_EQ(std::round(kSourceWidth / kIdealAspectRatio), result.max_height); |
386 EXPECT_EQ(kSourceWidth, result.max_width); | 386 EXPECT_EQ(kSourceWidth, result.max_width); |
387 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 387 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
388 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 388 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
389 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); | 389 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); |
390 } | 390 } |
391 | 391 |
392 // Ideal aspect ratio > max. | 392 // Ideal aspect ratio > max. |
393 { | 393 { |
394 constexpr double kIdealAspectRatio = 3.0; | 394 constexpr double kIdealAspectRatio = 3.0; |
395 static_assert(kIdealAspectRatio > kMaxAspectRatio, | 395 static_assert(kIdealAspectRatio > kMaxAspectRatio, |
396 "kIdealAspectRatio must be greater than kMaxAspectRatio"); | 396 "kIdealAspectRatio must be greater than kMaxAspectRatio"); |
397 MockConstraintFactory constraint_factory; | 397 MockConstraintFactory constraint_factory; |
398 constraint_factory.basic().aspect_ratio.SetIdeal(kIdealAspectRatio); | 398 constraint_factory.basic().aspect_ratio.SetIdeal(kIdealAspectRatio); |
399 auto result = SelectVideoTrackAdapterSettings( | 399 auto result = SelectVideoTrackAdapterSettings( |
400 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 400 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
401 frame_rate_set, SourceFormat()); | 401 frame_rate_set, SourceFormat(), false); |
402 EXPECT_EQ(kSourceHeight, result.max_height); | 402 EXPECT_EQ(kSourceHeight, result.max_height); |
403 EXPECT_EQ(std::round(kSourceHeight * kMaxAspectRatio), result.max_width); | 403 EXPECT_EQ(std::round(kSourceHeight * kMaxAspectRatio), result.max_width); |
404 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 404 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
405 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 405 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
406 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); | 406 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); |
407 } | 407 } |
408 | 408 |
409 // Ideal frame rate < min. | 409 // Ideal frame rate < min. |
410 { | 410 { |
411 constexpr double kIdealFrameRate = 3.0; | 411 constexpr double kIdealFrameRate = 3.0; |
412 static_assert(kIdealFrameRate < kMinFrameRate, | 412 static_assert(kIdealFrameRate < kMinFrameRate, |
413 "kIdealFrameRate must be less than kMinFrameRate"); | 413 "kIdealFrameRate must be less than kMinFrameRate"); |
414 MockConstraintFactory constraint_factory; | 414 MockConstraintFactory constraint_factory; |
415 constraint_factory.basic().frame_rate.SetIdeal(kIdealFrameRate); | 415 constraint_factory.basic().frame_rate.SetIdeal(kIdealFrameRate); |
416 auto result = SelectVideoTrackAdapterSettings( | 416 auto result = SelectVideoTrackAdapterSettings( |
417 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 417 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
418 frame_rate_set, SourceFormat()); | 418 frame_rate_set, SourceFormat(), false); |
419 EXPECT_EQ(kSourceHeight, result.max_height); | 419 EXPECT_EQ(kSourceHeight, result.max_height); |
420 EXPECT_EQ(kSourceWidth, result.max_width); | 420 EXPECT_EQ(kSourceWidth, result.max_width); |
421 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 421 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
422 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 422 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
423 EXPECT_EQ(kMinFrameRate, result.max_frame_rate); | 423 EXPECT_EQ(kMinFrameRate, result.max_frame_rate); |
424 } | 424 } |
425 | 425 |
426 // min < Ideal frame rate < max. | 426 // min < Ideal frame rate < max. |
427 { | 427 { |
428 constexpr double kIdealFrameRate = 31.0; | 428 constexpr double kIdealFrameRate = 31.0; |
429 static_assert(kIdealFrameRate > kMinFrameRate, | 429 static_assert(kIdealFrameRate > kMinFrameRate, |
430 "kIdealFrameRate must be greater than kMinFrameRate"); | 430 "kIdealFrameRate must be greater than kMinFrameRate"); |
431 static_assert(kIdealFrameRate < kMaxFrameRate, | 431 static_assert(kIdealFrameRate < kMaxFrameRate, |
432 "kIdealFrameRate must be less than kMaxFrameRate"); | 432 "kIdealFrameRate must be less than kMaxFrameRate"); |
433 MockConstraintFactory constraint_factory; | 433 MockConstraintFactory constraint_factory; |
434 constraint_factory.basic().frame_rate.SetIdeal(kIdealFrameRate); | 434 constraint_factory.basic().frame_rate.SetIdeal(kIdealFrameRate); |
435 auto result = SelectVideoTrackAdapterSettings( | 435 auto result = SelectVideoTrackAdapterSettings( |
436 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 436 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
437 frame_rate_set, SourceFormat()); | 437 frame_rate_set, SourceFormat(), false); |
438 EXPECT_EQ(kSourceHeight, result.max_height); | 438 EXPECT_EQ(kSourceHeight, result.max_height); |
439 EXPECT_EQ(kSourceWidth, result.max_width); | 439 EXPECT_EQ(kSourceWidth, result.max_width); |
440 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 440 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
441 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 441 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
442 EXPECT_EQ(kIdealFrameRate, result.max_frame_rate); | 442 EXPECT_EQ(kIdealFrameRate, result.max_frame_rate); |
443 } | 443 } |
444 | 444 |
445 // Ideal frame rate > max. | 445 // Ideal frame rate > max. |
446 { | 446 { |
447 constexpr double kIdealFrameRate = 1000.0; | 447 constexpr double kIdealFrameRate = 1000.0; |
448 static_assert(kIdealFrameRate > kMaxFrameRate, | 448 static_assert(kIdealFrameRate > kMaxFrameRate, |
449 "kIdealFrameRate must be greater than kMaxFrameRate"); | 449 "kIdealFrameRate must be greater than kMaxFrameRate"); |
450 MockConstraintFactory constraint_factory; | 450 MockConstraintFactory constraint_factory; |
451 constraint_factory.basic().frame_rate.SetIdeal(kIdealFrameRate); | 451 constraint_factory.basic().frame_rate.SetIdeal(kIdealFrameRate); |
452 auto result = SelectVideoTrackAdapterSettings( | 452 auto result = SelectVideoTrackAdapterSettings( |
453 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 453 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
454 frame_rate_set, SourceFormat()); | 454 frame_rate_set, SourceFormat(), false); |
455 EXPECT_EQ(kSourceHeight, result.max_height); | 455 EXPECT_EQ(kSourceHeight, result.max_height); |
456 EXPECT_EQ(kSourceWidth, result.max_width); | 456 EXPECT_EQ(kSourceWidth, result.max_width); |
457 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 457 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
458 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 458 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
459 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); | 459 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); |
460 } | 460 } |
461 | 461 |
462 // Ideal values inside constraints. | 462 // Ideal values inside constraints. |
463 { | 463 { |
464 const int kIdealHeight = 900; | 464 const int kIdealHeight = 900; |
(...skipping 10 matching lines...) Expand all Loading... |
475 static_assert(kIdealFrameRate > kMinFrameRate, | 475 static_assert(kIdealFrameRate > kMinFrameRate, |
476 "kIdealFrameRate must be greater than kMinFrameRate"); | 476 "kIdealFrameRate must be greater than kMinFrameRate"); |
477 static_assert(kIdealFrameRate < kMaxFrameRate, | 477 static_assert(kIdealFrameRate < kMaxFrameRate, |
478 "kIdealFrameRate must be less than kMaxFrameRate"); | 478 "kIdealFrameRate must be less than kMaxFrameRate"); |
479 MockConstraintFactory constraint_factory; | 479 MockConstraintFactory constraint_factory; |
480 constraint_factory.basic().height.SetIdeal(kIdealHeight); | 480 constraint_factory.basic().height.SetIdeal(kIdealHeight); |
481 constraint_factory.basic().width.SetIdeal(kIdealWidth); | 481 constraint_factory.basic().width.SetIdeal(kIdealWidth); |
482 constraint_factory.basic().frame_rate.SetIdeal(kIdealFrameRate); | 482 constraint_factory.basic().frame_rate.SetIdeal(kIdealFrameRate); |
483 auto result = SelectVideoTrackAdapterSettings( | 483 auto result = SelectVideoTrackAdapterSettings( |
484 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 484 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
485 frame_rate_set, SourceFormat()); | 485 frame_rate_set, SourceFormat(), false); |
486 EXPECT_EQ(kIdealHeight, result.max_height); | 486 EXPECT_EQ(kIdealHeight, result.max_height); |
487 EXPECT_EQ(kIdealWidth, result.max_width); | 487 EXPECT_EQ(kIdealWidth, result.max_width); |
488 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 488 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
489 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 489 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
490 EXPECT_EQ(kIdealFrameRate, result.max_frame_rate); | 490 EXPECT_EQ(kIdealFrameRate, result.max_frame_rate); |
491 } | 491 } |
492 | 492 |
493 // Ideal values outside constraints. | 493 // Ideal values outside constraints. |
494 { | 494 { |
495 const int kIdealHeight = 2900; | 495 const int kIdealHeight = 2900; |
496 const int kIdealWidth = 3600; | 496 const int kIdealWidth = 3600; |
497 constexpr double kIdealFrameRate = 350.0; | 497 constexpr double kIdealFrameRate = 350.0; |
498 static_assert(kIdealHeight > kMaxHeight, | 498 static_assert(kIdealHeight > kMaxHeight, |
499 "kMinHeight must be greater than kMaxHeight"); | 499 "kMinHeight must be greater than kMaxHeight"); |
500 static_assert(kIdealWidth > kMaxWidth, | 500 static_assert(kIdealWidth > kMaxWidth, |
501 "kIdealWidth must be greater than kMaxHeight"); | 501 "kIdealWidth must be greater than kMaxHeight"); |
502 static_assert(kIdealFrameRate > kMaxFrameRate, | 502 static_assert(kIdealFrameRate > kMaxFrameRate, |
503 "kIdealFrameRate must be greater than kMaxFrameRate"); | 503 "kIdealFrameRate must be greater than kMaxFrameRate"); |
504 MockConstraintFactory constraint_factory; | 504 MockConstraintFactory constraint_factory; |
505 constraint_factory.basic().height.SetIdeal(kIdealHeight); | 505 constraint_factory.basic().height.SetIdeal(kIdealHeight); |
506 constraint_factory.basic().width.SetIdeal(kIdealWidth); | 506 constraint_factory.basic().width.SetIdeal(kIdealWidth); |
507 constraint_factory.basic().frame_rate.SetIdeal(kIdealFrameRate); | 507 constraint_factory.basic().frame_rate.SetIdeal(kIdealFrameRate); |
508 auto result = SelectVideoTrackAdapterSettings( | 508 auto result = SelectVideoTrackAdapterSettings( |
509 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 509 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
510 frame_rate_set, SourceFormat()); | 510 frame_rate_set, SourceFormat(), false); |
511 EXPECT_EQ(kMaxHeight, result.max_height); | 511 EXPECT_EQ(kMaxHeight, result.max_height); |
512 EXPECT_EQ(kMaxWidth, result.max_width); | 512 EXPECT_EQ(kMaxWidth, result.max_width); |
513 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 513 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
514 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 514 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
515 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); | 515 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate); |
516 } | 516 } |
517 | 517 |
518 // Source frame rate. | 518 // Source frame rate. |
519 { | 519 { |
520 DoubleRangeSet frame_rate_set(kMinFrameRate, kSourceFrameRate); | 520 DoubleRangeSet frame_rate_set(kMinFrameRate, kSourceFrameRate); |
521 MockConstraintFactory constraint_factory; | 521 MockConstraintFactory constraint_factory; |
522 auto result = SelectVideoTrackAdapterSettings( | 522 auto result = SelectVideoTrackAdapterSettings( |
523 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 523 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
524 frame_rate_set, SourceFormat()); | 524 frame_rate_set, SourceFormat(), false); |
525 EXPECT_EQ(kSourceHeight, result.max_height); | 525 EXPECT_EQ(kSourceHeight, result.max_height); |
526 EXPECT_EQ(kSourceWidth, result.max_width); | 526 EXPECT_EQ(kSourceWidth, result.max_width); |
527 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 527 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
528 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 528 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
529 // No frame-rate adjustment because the track will use the same frame rate | 529 // No frame-rate adjustment because the track will use the same frame rate |
530 // as the source. | 530 // as the source. |
531 EXPECT_EQ(0.0, result.max_frame_rate); | 531 EXPECT_EQ(0.0, result.max_frame_rate); |
532 } | 532 } |
533 | 533 |
534 // High frame rate. | 534 // High frame rate. |
535 { | 535 { |
536 constexpr double kHighFrameRate = 400.0; // Greater than source. | 536 constexpr double kHighFrameRate = 400.0; // Greater than source. |
537 DoubleRangeSet frame_rate_set(kMinFrameRate, kHighFrameRate); | 537 DoubleRangeSet frame_rate_set(kMinFrameRate, kHighFrameRate); |
538 static_assert(kHighFrameRate > kSourceFrameRate, | 538 static_assert(kHighFrameRate > kSourceFrameRate, |
539 "kIdealFrameRate must be greater than kSourceFrameRate"); | 539 "kIdealFrameRate must be greater than kSourceFrameRate"); |
540 MockConstraintFactory constraint_factory; | 540 MockConstraintFactory constraint_factory; |
541 auto result = SelectVideoTrackAdapterSettings( | 541 auto result = SelectVideoTrackAdapterSettings( |
542 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, | 542 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
543 frame_rate_set, SourceFormat()); | 543 frame_rate_set, SourceFormat(), false); |
544 EXPECT_EQ(kSourceHeight, result.max_height); | 544 EXPECT_EQ(kSourceHeight, result.max_height); |
545 EXPECT_EQ(kSourceWidth, result.max_width); | 545 EXPECT_EQ(kSourceWidth, result.max_width); |
546 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); | 546 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio); |
547 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); | 547 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio); |
548 // No frame-rate adjustment because the track will use a frame rate that is | 548 // No frame-rate adjustment because the track will use a frame rate that is |
549 // greater than the source's. | 549 // greater than the source's. |
550 EXPECT_EQ(0.0, result.max_frame_rate); | 550 EXPECT_EQ(0.0, result.max_frame_rate); |
551 } | 551 } |
552 } | 552 } |
553 | 553 |
| 554 TEST_F(MediaStreamConstraintsUtilTest, |
| 555 VideoTrackAdapterSettingsExpectedNativeSize) { |
| 556 ResolutionSet resolution_set; |
| 557 DoubleRangeSet frame_rate_set; |
| 558 |
| 559 { |
| 560 MockConstraintFactory constraint_factory; |
| 561 auto result = SelectVideoTrackAdapterSettings( |
| 562 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
| 563 frame_rate_set, SourceFormat(), false); |
| 564 EXPECT_EQ(kSourceHeight, result.max_height); |
| 565 EXPECT_EQ(kSourceWidth, result.max_width); |
| 566 EXPECT_EQ(0.0, result.min_aspect_ratio); |
| 567 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio); |
| 568 EXPECT_EQ(0.0, result.max_frame_rate); |
| 569 EXPECT_FALSE(result.expected_native_size); |
| 570 } |
| 571 |
| 572 { |
| 573 MockConstraintFactory constraint_factory; |
| 574 auto result = SelectVideoTrackAdapterSettings( |
| 575 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
| 576 frame_rate_set, SourceFormat(), true); |
| 577 EXPECT_EQ(kSourceHeight, result.max_height); |
| 578 EXPECT_EQ(kSourceWidth, result.max_width); |
| 579 EXPECT_EQ(0.0, result.min_aspect_ratio); |
| 580 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio); |
| 581 EXPECT_EQ(0.0, result.max_frame_rate); |
| 582 EXPECT_TRUE(result.expected_native_size); |
| 583 EXPECT_EQ(gfx::Size(kSourceWidth, kSourceHeight), |
| 584 *result.expected_native_size); |
| 585 } |
| 586 |
| 587 // Ideals supplied. |
| 588 { |
| 589 const int kIdealHeight = 400; |
| 590 const int kIdealWidth = 600; |
| 591 const int kIdealAspectRatio = 2.0; |
| 592 const double kIdealFrameRate = 33; |
| 593 MockConstraintFactory constraint_factory; |
| 594 constraint_factory.basic().height.SetIdeal(kIdealHeight); |
| 595 constraint_factory.basic().width.SetIdeal(kIdealWidth); |
| 596 // Ideal aspect ratio is ignored if ideal width and height are supplied. |
| 597 constraint_factory.basic().aspect_ratio.SetIdeal(kIdealAspectRatio); |
| 598 constraint_factory.basic().frame_rate.SetIdeal(kIdealFrameRate); |
| 599 auto result = SelectVideoTrackAdapterSettings( |
| 600 constraint_factory.CreateWebMediaConstraints().Basic(), resolution_set, |
| 601 frame_rate_set, SourceFormat(), true); |
| 602 EXPECT_EQ(kIdealHeight, result.max_height); |
| 603 EXPECT_EQ(kIdealWidth, result.max_width); |
| 604 EXPECT_EQ(0.0, result.min_aspect_ratio); |
| 605 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio); |
| 606 EXPECT_EQ(kIdealFrameRate, result.max_frame_rate); |
| 607 EXPECT_TRUE(result.expected_native_size); |
| 608 EXPECT_EQ(gfx::Size(kSourceWidth, kSourceHeight), |
| 609 *result.expected_native_size); |
| 610 } |
| 611 } |
| 612 |
554 } // namespace content | 613 } // namespace content |
OLD | NEW |