Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: content/renderer/media/media_stream_constraints_util_unittest.cc

Issue 2777703002: Introduce SelectSettings algorithm for MediaStream video tracks. (Closed)
Patch Set: merge Content and Device result classes Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_video_source.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"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace {
14
15 const int kSourceHeight = 1000;
16 const int kSourceWidth = 1500;
17 constexpr double kSourceAspectRatio =
18 static_cast<double>(kSourceWidth) / static_cast<double>(kSourceHeight);
19 const double kSourceFrameRate = 100.0;
20
21 media::VideoCaptureFormat SourceFormat() {
22 return media::VideoCaptureFormat(gfx::Size(kSourceWidth, kSourceHeight),
23 kSourceFrameRate, media::PIXEL_FORMAT_I420);
24 }
25
26 } // namespace
27
13 namespace content { 28 namespace content {
14 29
15 class MediaStreamConstraintsUtilTest : public testing::Test { 30 class MediaStreamConstraintsUtilTest : public testing::Test {
31 protected:
32 using DoubleRangeSet = NumericRangeSet<double>;
16 }; 33 };
17 34
18 TEST_F(MediaStreamConstraintsUtilTest, BooleanConstraints) { 35 TEST_F(MediaStreamConstraintsUtilTest, BooleanConstraints) {
19 static const std::string kValueTrue = "true"; 36 static const std::string kValueTrue = "true";
20 static const std::string kValueFalse = "false"; 37 static const std::string kValueFalse = "false";
21 38
22 MockConstraintFactory constraint_factory; 39 MockConstraintFactory constraint_factory;
23 // Mandatory constraints. 40 // Mandatory constraints.
24 constraint_factory.basic().echoCancellation.setExact(true); 41 constraint_factory.basic().echoCancellation.setExact(true);
25 constraint_factory.basic().googEchoCancellation.setExact(false); 42 constraint_factory.basic().googEchoCancellation.setExact(false);
(...skipping 30 matching lines...) Expand all
56 constraint_factory.basic().echoCancellation.setExact(true); 73 constraint_factory.basic().echoCancellation.setExact(true);
57 constraints = constraint_factory.CreateWebMediaConstraints(); 74 constraints = constraint_factory.CreateWebMediaConstraints();
58 EXPECT_TRUE(GetConstraintValueAsBoolean( 75 EXPECT_TRUE(GetConstraintValueAsBoolean(
59 constraints, &blink::WebMediaTrackConstraintSet::echoCancellation, 76 constraints, &blink::WebMediaTrackConstraintSet::echoCancellation,
60 &value_true)); 77 &value_true));
61 EXPECT_TRUE(value_true); 78 EXPECT_TRUE(value_true);
62 } 79 }
63 80
64 TEST_F(MediaStreamConstraintsUtilTest, DoubleConstraints) { 81 TEST_F(MediaStreamConstraintsUtilTest, DoubleConstraints) {
65 MockConstraintFactory constraint_factory; 82 MockConstraintFactory constraint_factory;
66 const double test_value= 0.01f; 83 const double test_value = 0.01f;
67 84
68 constraint_factory.basic().aspectRatio.setExact(test_value); 85 constraint_factory.basic().aspectRatio.setExact(test_value);
69 blink::WebMediaConstraints constraints = 86 blink::WebMediaConstraints constraints =
70 constraint_factory.CreateWebMediaConstraints(); 87 constraint_factory.CreateWebMediaConstraints();
71 88
72 double value; 89 double value;
73 EXPECT_FALSE(GetConstraintValueAsDouble( 90 EXPECT_FALSE(GetConstraintValueAsDouble(
74 constraints, &blink::WebMediaTrackConstraintSet::frameRate, &value)); 91 constraints, &blink::WebMediaTrackConstraintSet::frameRate, &value));
75 EXPECT_TRUE(GetConstraintValueAsDouble( 92 EXPECT_TRUE(GetConstraintValueAsDouble(
76 constraints, &blink::WebMediaTrackConstraintSet::aspectRatio, &value)); 93 constraints, &blink::WebMediaTrackConstraintSet::aspectRatio, &value));
(...skipping 15 matching lines...) Expand all
92 109
93 // An exact value should also be reflected as min and max. 110 // An exact value should also be reflected as min and max.
94 EXPECT_TRUE(GetConstraintMaxAsInteger( 111 EXPECT_TRUE(GetConstraintMaxAsInteger(
95 constraints, &blink::WebMediaTrackConstraintSet::width, &value)); 112 constraints, &blink::WebMediaTrackConstraintSet::width, &value));
96 EXPECT_EQ(test_value, value); 113 EXPECT_EQ(test_value, value);
97 EXPECT_TRUE(GetConstraintMinAsInteger( 114 EXPECT_TRUE(GetConstraintMinAsInteger(
98 constraints, &blink::WebMediaTrackConstraintSet::width, &value)); 115 constraints, &blink::WebMediaTrackConstraintSet::width, &value));
99 EXPECT_EQ(test_value, value); 116 EXPECT_EQ(test_value, value);
100 } 117 }
101 118
119 TEST_F(MediaStreamConstraintsUtilTest, VideoTrackAdapterSettingsUnconstrained) {
120 ResolutionSet resolution_set;
121 DoubleRangeSet frame_rate_set;
122
123 // No ideal values.
124 {
125 MockConstraintFactory constraint_factory;
126 auto result = SelectVideoTrackAdapterSettings(
127 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
128 frame_rate_set, SourceFormat());
129 EXPECT_EQ(kSourceHeight, result.max_height);
130 EXPECT_EQ(kSourceWidth, result.max_width);
131 EXPECT_EQ(0.0, result.min_aspect_ratio);
132 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio);
133 EXPECT_EQ(0.0, result.max_frame_rate);
134 }
135
136 // Ideal height.
137 {
138 int kIdealHeight = 400;
hbos_chromium 2017/03/28 12:52:53 If you use this naming convention make it const in
Guido Urdaneta 2017/03/28 18:35:43 Done. That's what I originally intended :)
139 MockConstraintFactory constraint_factory;
140 constraint_factory.basic().height.setIdeal(kIdealHeight);
141 auto result = SelectVideoTrackAdapterSettings(
142 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
143 frame_rate_set, SourceFormat());
144 EXPECT_EQ(kIdealHeight, result.max_height);
145 EXPECT_EQ(std::round(kIdealHeight * kSourceAspectRatio), result.max_width);
146 EXPECT_EQ(0.0, result.min_aspect_ratio);
147 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio);
148 EXPECT_EQ(0.0, result.max_frame_rate);
149 }
150
151 // Ideal width.
152 {
153 int kIdealWidth = 400;
154 MockConstraintFactory constraint_factory;
155 constraint_factory.basic().width.setIdeal(kIdealWidth);
156 auto result = SelectVideoTrackAdapterSettings(
157 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
158 frame_rate_set, SourceFormat());
159 EXPECT_EQ(std::round(kIdealWidth / kSourceAspectRatio), result.max_height);
160 EXPECT_EQ(kIdealWidth, result.max_width);
161 EXPECT_EQ(0.0, result.min_aspect_ratio);
162 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio);
163 EXPECT_EQ(0.0, result.max_frame_rate);
164 }
165
166 // Ideal aspect ratio.
167 {
168 double kIdealAspectRatio = 2.0;
169 MockConstraintFactory constraint_factory;
170 constraint_factory.basic().aspectRatio.setIdeal(kIdealAspectRatio);
171 auto result = SelectVideoTrackAdapterSettings(
172 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
173 frame_rate_set, SourceFormat());
174 EXPECT_EQ(kSourceHeight, result.max_height);
175 EXPECT_EQ(std::round(kSourceHeight * kIdealAspectRatio), result.max_width);
176 EXPECT_EQ(0.0, result.min_aspect_ratio);
177 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio);
178 EXPECT_EQ(0.0, result.max_frame_rate);
179 }
180
181 // Ideal frame rate.
182 {
183 double kIdealFrameRate = 33;
184 MockConstraintFactory constraint_factory;
185 constraint_factory.basic().frameRate.setIdeal(kIdealFrameRate);
186 auto result = SelectVideoTrackAdapterSettings(
187 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
188 frame_rate_set, SourceFormat());
189 EXPECT_EQ(kSourceHeight, result.max_height);
190 EXPECT_EQ(kSourceWidth, result.max_width);
191 EXPECT_EQ(0.0, result.min_aspect_ratio);
192 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio);
193 EXPECT_EQ(kIdealFrameRate, result.max_frame_rate);
194 }
195
196 // All ideals supplied.
197 {
198 int kIdealHeight = 400;
199 int kIdealWidth = 600;
200 int kIdealAspectRatio = 2.0;
201 double kIdealFrameRate = 33;
202 MockConstraintFactory constraint_factory;
203 constraint_factory.basic().height.setIdeal(kIdealHeight);
204 constraint_factory.basic().width.setIdeal(kIdealWidth);
205 // Ideal aspect ratio is ignored if ideal width and height are supplied.
206 constraint_factory.basic().aspectRatio.setIdeal(kIdealAspectRatio);
207 constraint_factory.basic().frameRate.setIdeal(kIdealFrameRate);
208 auto result = SelectVideoTrackAdapterSettings(
209 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
210 frame_rate_set, SourceFormat());
211 EXPECT_EQ(kIdealHeight, result.max_height);
212 EXPECT_EQ(kIdealWidth, result.max_width);
213 EXPECT_EQ(0.0, result.min_aspect_ratio);
214 EXPECT_EQ(HUGE_VAL, result.max_aspect_ratio);
215 EXPECT_EQ(kIdealFrameRate, result.max_frame_rate);
216 }
217 }
218
219 TEST_F(MediaStreamConstraintsUtilTest, VideoTrackAdapterSettingsConstrained) {
220 const int kMinHeight = 500;
221 const int kMaxHeight = 1200;
222 const int kMinWidth = 1000;
223 const int kMaxWidth = 2000;
224 const double kMinAspectRatio = 1.0;
225 const double kMaxAspectRatio = 2.0;
226 const double kMinFrameRate = 20.0;
227 const double kMaxFrameRate = 44.0;
228 ResolutionSet resolution_set(kMinHeight, kMaxHeight, kMinWidth, kMaxWidth,
229 kMinAspectRatio, kMaxAspectRatio);
230 DoubleRangeSet frame_rate_set(kMinFrameRate, kMaxFrameRate);
231
232 // No ideal values.
233 {
234 MockConstraintFactory constraint_factory;
235 auto result = SelectVideoTrackAdapterSettings(
236 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
237 frame_rate_set, SourceFormat());
238 EXPECT_EQ(kSourceHeight, result.max_height);
239 EXPECT_EQ(kSourceWidth, result.max_width);
240 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
241 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
242 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate);
243 }
244
245 // Ideal height < min.
hbos_chromium 2017/03/28 12:52:53 You could static_assert these type of things.
Guido Urdaneta 2017/03/28 18:35:43 Done.
246 {
247 int kIdealHeight = 400;
248 MockConstraintFactory constraint_factory;
249 constraint_factory.basic().height.setIdeal(kIdealHeight);
250 auto result = SelectVideoTrackAdapterSettings(
251 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
252 frame_rate_set, SourceFormat());
253 EXPECT_EQ(kMinHeight, result.max_height);
254 // kMinWidth > kMinHeight * kNativeAspectRatio
255 EXPECT_EQ(kMinWidth, result.max_width);
256 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
257 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
258 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate);
259 }
260
261 // min < Ideal height < max.
262 {
263 int kIdealHeight = 1100;
264 MockConstraintFactory constraint_factory;
265 constraint_factory.basic().height.setIdeal(kIdealHeight);
266 auto result = SelectVideoTrackAdapterSettings(
267 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
268 frame_rate_set, SourceFormat());
269 EXPECT_EQ(kIdealHeight, result.max_height);
270 EXPECT_EQ(std::round(kIdealHeight * kSourceAspectRatio), result.max_width);
271 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
272 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
273 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate);
274 }
275
276 // Ideal height > max.
277 {
278 int kIdealHeight = 2000;
279 MockConstraintFactory constraint_factory;
280 constraint_factory.basic().height.setIdeal(kIdealHeight);
281 auto result = SelectVideoTrackAdapterSettings(
282 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
283 frame_rate_set, SourceFormat());
284 EXPECT_EQ(kMaxHeight, result.max_height);
285 EXPECT_EQ(std::round(kMaxHeight * kSourceAspectRatio), result.max_width);
286 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
287 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
288 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate);
289 }
290
291 // Ideal width < min.
292 {
293 int kIdealWidth = 800;
294 MockConstraintFactory constraint_factory;
295 constraint_factory.basic().width.setIdeal(kIdealWidth);
296 auto result = SelectVideoTrackAdapterSettings(
297 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
298 frame_rate_set, SourceFormat());
299 EXPECT_EQ(std::round(kMinWidth / kSourceAspectRatio), result.max_height);
300 EXPECT_EQ(kMinWidth, result.max_width);
301 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
302 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
303 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate);
304 }
305
306 // min < Ideal width < max.
307 {
308 int kIdealWidth = 1800;
309 MockConstraintFactory constraint_factory;
310 constraint_factory.basic().width.setIdeal(kIdealWidth);
311 auto result = SelectVideoTrackAdapterSettings(
312 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
313 frame_rate_set, SourceFormat());
314 EXPECT_EQ(std::round(kIdealWidth / kSourceAspectRatio), result.max_height);
315 EXPECT_EQ(kIdealWidth, result.max_width);
316 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
317 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
318 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate);
319 }
320
321 // Ideal width > max.
322 {
323 int kIdealWidth = 3000;
324 MockConstraintFactory constraint_factory;
325 constraint_factory.basic().width.setIdeal(kIdealWidth);
326 auto result = SelectVideoTrackAdapterSettings(
327 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
328 frame_rate_set, SourceFormat());
329 // kMaxHeight < kMaxWidth / kNativeAspectRatio
330 EXPECT_EQ(kMaxHeight, result.max_height);
331 EXPECT_EQ(kMaxWidth, result.max_width);
332 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
333 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
334 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate);
335 }
336
337 // Ideal aspect ratio < min.
338 {
339 double kIdealAspectRatio = 0.5;
340 MockConstraintFactory constraint_factory;
341 constraint_factory.basic().aspectRatio.setIdeal(kIdealAspectRatio);
342 auto result = SelectVideoTrackAdapterSettings(
343 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
344 frame_rate_set, SourceFormat());
345 // Desired point is (kNativeWidth/kMinAspectRatio, kNativeWidth), but it
346 // is outside the size constraints. Closest to that while maintaining the
347 // same aspect ratio is (kMaxHeight, kMaxHeight * kMinAspectRatio).
348 EXPECT_EQ(kMaxHeight, result.max_height);
349 EXPECT_EQ(std::round(kMaxHeight * kMinAspectRatio), result.max_width);
350 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
351 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
352 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate);
353 }
354
355 // min < Ideal aspect ratio < max.
356 {
357 double kIdealAspectRatio = 1.25;
358 MockConstraintFactory constraint_factory;
359 constraint_factory.basic().aspectRatio.setIdeal(kIdealAspectRatio);
360 auto result = SelectVideoTrackAdapterSettings(
361 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
362 frame_rate_set, SourceFormat());
363 EXPECT_EQ(std::round(kSourceWidth / kIdealAspectRatio), result.max_height);
364 EXPECT_EQ(kSourceWidth, result.max_width);
365 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
366 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
367 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate);
368 }
369
370 // Ideal aspect ratio > max.
371 {
372 double kIdealAspectRatio = 3.0;
373 MockConstraintFactory constraint_factory;
374 constraint_factory.basic().aspectRatio.setIdeal(kIdealAspectRatio);
375 auto result = SelectVideoTrackAdapterSettings(
376 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
377 frame_rate_set, SourceFormat());
378 EXPECT_EQ(kSourceHeight, result.max_height);
379 EXPECT_EQ(std::round(kSourceHeight * kMaxAspectRatio), result.max_width);
380 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
381 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
382 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate);
383 }
384
385 // Ideal frame rate < min.
386 {
387 double kIdealFrameRate = 3.0;
388 MockConstraintFactory constraint_factory;
389 constraint_factory.basic().frameRate.setIdeal(kIdealFrameRate);
390 auto result = SelectVideoTrackAdapterSettings(
391 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
392 frame_rate_set, SourceFormat());
393 EXPECT_EQ(kSourceHeight, result.max_height);
394 EXPECT_EQ(kSourceWidth, result.max_width);
395 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
396 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
397 EXPECT_EQ(kMinFrameRate, result.max_frame_rate);
398 }
399
400 // min < Ideal frame rate < max.
401 {
402 double kIdealFrameRate = 31.0;
403 MockConstraintFactory constraint_factory;
404 constraint_factory.basic().frameRate.setIdeal(kIdealFrameRate);
405 auto result = SelectVideoTrackAdapterSettings(
406 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
407 frame_rate_set, SourceFormat());
408 EXPECT_EQ(kSourceHeight, result.max_height);
409 EXPECT_EQ(kSourceWidth, result.max_width);
410 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
411 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
412 EXPECT_EQ(kIdealFrameRate, result.max_frame_rate);
413 }
414
415 // Ideal frame rate > max.
416 {
417 double kIdealFrameRate = 1000.0;
418 MockConstraintFactory constraint_factory;
419 constraint_factory.basic().frameRate.setIdeal(kIdealFrameRate);
420 auto result = SelectVideoTrackAdapterSettings(
421 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
422 frame_rate_set, SourceFormat());
423 EXPECT_EQ(kSourceHeight, result.max_height);
424 EXPECT_EQ(kSourceWidth, result.max_width);
425 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
426 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
427 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate);
428 }
429
430 // Ideal values inside constraints.
431 {
432 int kIdealHeight = 900;
433 int kIdealWidth = 1600;
434 double kIdealFrameRate = 35.0;
435 MockConstraintFactory constraint_factory;
436 constraint_factory.basic().height.setIdeal(kIdealHeight);
437 constraint_factory.basic().width.setIdeal(kIdealWidth);
438 constraint_factory.basic().frameRate.setIdeal(kIdealFrameRate);
439 auto result = SelectVideoTrackAdapterSettings(
440 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
441 frame_rate_set, SourceFormat());
442 EXPECT_EQ(kIdealHeight, result.max_height);
443 EXPECT_EQ(kIdealWidth, result.max_width);
444 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
445 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
446 EXPECT_EQ(kIdealFrameRate, result.max_frame_rate);
447 }
448
449 // Ideal values outside constraints.
450 {
451 int kIdealHeight = 2900;
452 int kIdealWidth = 3600;
453 double kIdealFrameRate = 350.0;
454 MockConstraintFactory constraint_factory;
455 constraint_factory.basic().height.setIdeal(kIdealHeight);
456 constraint_factory.basic().width.setIdeal(kIdealWidth);
457 constraint_factory.basic().frameRate.setIdeal(kIdealFrameRate);
458 auto result = SelectVideoTrackAdapterSettings(
459 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
460 frame_rate_set, SourceFormat());
461 EXPECT_EQ(kMaxHeight, result.max_height);
462 EXPECT_EQ(kMaxWidth, result.max_width);
463 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
464 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
465 EXPECT_EQ(kMaxFrameRate, result.max_frame_rate);
466 }
467
468 // Source frame rate.
469 {
470 DoubleRangeSet frame_rate_set(kMinFrameRate, kSourceFrameRate);
471 MockConstraintFactory constraint_factory;
472 auto result = SelectVideoTrackAdapterSettings(
473 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
474 frame_rate_set, SourceFormat());
475 EXPECT_EQ(kSourceHeight, result.max_height);
476 EXPECT_EQ(kSourceWidth, result.max_width);
477 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
478 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
479 // No frame-rate adjustment because the track will use the same frame rate
480 // as the source.
hbos_chromium 2017/03/28 12:52:53 In the larger context of sources and settings: ...
Guido Urdaneta 2017/03/28 18:35:43 0.0 is a special value that VideoTrackAdapter inte
hbos_chromium 2017/03/29 14:54:53 Acknowledged.
481 EXPECT_EQ(0.0, result.max_frame_rate);
482 }
483
484 // High frame rate.
485 {
486 const double kHighFrameRate = 400.0; // Greater than source.
487 DoubleRangeSet frame_rate_set(kMinFrameRate, kHighFrameRate);
488 MockConstraintFactory constraint_factory;
489 auto result = SelectVideoTrackAdapterSettings(
490 constraint_factory.CreateWebMediaConstraints().basic(), resolution_set,
491 frame_rate_set, SourceFormat());
492 EXPECT_EQ(kSourceHeight, result.max_height);
493 EXPECT_EQ(kSourceWidth, result.max_width);
494 EXPECT_EQ(kMinAspectRatio, result.min_aspect_ratio);
495 EXPECT_EQ(kMaxAspectRatio, result.max_aspect_ratio);
496 // No frame-rate adjustment because the track will use a frame rate that is
497 // greater than the source's.
498 EXPECT_EQ(0.0, result.max_frame_rate);
499 }
500 }
501
102 } // namespace content 502 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698