| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 // Test that the source ignores an unknown optional constraint. | 347 // Test that the source ignores an unknown optional constraint. |
| 348 TEST_F(VideoCapturerTrackSourceTest, InvalidOptionalConstraint) { | 348 TEST_F(VideoCapturerTrackSourceTest, InvalidOptionalConstraint) { |
| 349 FakeConstraints constraints; | 349 FakeConstraints constraints; |
| 350 constraints.AddOptional("weird key", 640); | 350 constraints.AddOptional("weird key", 640); |
| 351 | 351 |
| 352 CreateVideoCapturerSource(&constraints); | 352 CreateVideoCapturerSource(&constraints); |
| 353 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 353 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 354 kMaxWaitMs); | 354 kMaxWaitMs); |
| 355 } | 355 } |
| 356 | 356 |
| 357 TEST_F(VideoCapturerTrackSourceTest, SetValidOptionValues) { | 357 TEST_F(VideoCapturerTrackSourceTest, SetValidDenoisingConstraint) { |
| 358 FakeConstraints constraints; | 358 FakeConstraints constraints; |
| 359 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, "false"); | 359 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, "true"); |
| 360 | 360 |
| 361 CreateVideoCapturerSource(&constraints); | 361 CreateVideoCapturerSource(&constraints); |
| 362 | 362 |
| 363 EXPECT_EQ(rtc::Optional<bool>(false), | 363 EXPECT_TRUE(source_->needs_denoising()); |
| 364 source_->options()->video_noise_reduction); | |
| 365 } | 364 } |
| 366 | 365 |
| 367 TEST_F(VideoCapturerTrackSourceTest, OptionNotSet) { | 366 TEST_F(VideoCapturerTrackSourceTest, NoiseReductionConstraintNotSet) { |
| 368 FakeConstraints constraints; | 367 FakeConstraints constraints; |
| 369 CreateVideoCapturerSource(&constraints); | 368 CreateVideoCapturerSource(&constraints); |
| 370 EXPECT_EQ(rtc::Optional<bool>(), source_->options()->video_noise_reduction); | 369 EXPECT_FALSE(source_->needs_denoising()); |
| 371 } | 370 } |
| 372 | 371 |
| 373 TEST_F(VideoCapturerTrackSourceTest, MandatoryOptionOverridesOptional) { | 372 TEST_F(VideoCapturerTrackSourceTest, |
| 373 MandatoryDenoisingConstraintOverridesOptional) { |
| 374 FakeConstraints constraints; | 374 FakeConstraints constraints; |
| 375 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, true); | 375 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, false); |
| 376 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, false); | 376 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, true); |
| 377 | 377 |
| 378 CreateVideoCapturerSource(&constraints); | 378 CreateVideoCapturerSource(&constraints); |
| 379 | 379 |
| 380 EXPECT_EQ(rtc::Optional<bool>(true), | 380 EXPECT_FALSE(source_->needs_denoising()); |
| 381 source_->options()->video_noise_reduction); | |
| 382 } | 381 } |
| 383 | 382 |
| 384 TEST_F(VideoCapturerTrackSourceTest, InvalidOptionKeyOptional) { | 383 TEST_F(VideoCapturerTrackSourceTest, NoiseReductionAndInvalidKeyOptional) { |
| 385 FakeConstraints constraints; | 384 FakeConstraints constraints; |
| 386 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, false); | 385 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, true); |
| 387 constraints.AddOptional("invalidKey", false); | 386 constraints.AddOptional("invalidKey", false); |
| 388 | 387 |
| 389 CreateVideoCapturerSource(&constraints); | 388 CreateVideoCapturerSource(&constraints); |
| 390 | 389 |
| 391 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 390 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 392 kMaxWaitMs); | 391 kMaxWaitMs); |
| 393 EXPECT_EQ(rtc::Optional<bool>(false), | 392 EXPECT_TRUE(source_->needs_denoising()); |
| 394 source_->options()->video_noise_reduction); | |
| 395 } | 393 } |
| 396 | 394 |
| 397 TEST_F(VideoCapturerTrackSourceTest, InvalidOptionKeyMandatory) { | 395 TEST_F(VideoCapturerTrackSourceTest, NoiseReductionAndInvalidKeyMandatory) { |
| 398 FakeConstraints constraints; | 396 FakeConstraints constraints; |
| 399 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, false); | 397 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, false); |
| 400 constraints.AddMandatory("invalidKey", false); | 398 constraints.AddMandatory("invalidKey", false); |
| 401 | 399 |
| 402 CreateVideoCapturerSource(&constraints); | 400 CreateVideoCapturerSource(&constraints); |
| 403 | 401 |
| 404 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), | 402 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), |
| 405 kMaxWaitMs); | 403 kMaxWaitMs); |
| 406 EXPECT_EQ(rtc::Optional<bool>(), source_->options()->video_noise_reduction); | 404 EXPECT_FALSE(source_->needs_denoising()); |
| 407 } | 405 } |
| 408 | 406 |
| 409 TEST_F(VideoCapturerTrackSourceTest, InvalidOptionValueOptional) { | 407 TEST_F(VideoCapturerTrackSourceTest, InvalidDenoisingValueOptional) { |
| 410 FakeConstraints constraints; | 408 FakeConstraints constraints; |
| 411 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, | 409 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, |
| 412 "not a boolean"); | 410 "not a boolean"); |
| 413 | 411 |
| 414 CreateVideoCapturerSource(&constraints); | 412 CreateVideoCapturerSource(&constraints); |
| 415 | 413 |
| 416 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 414 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 417 kMaxWaitMs); | 415 kMaxWaitMs); |
| 418 EXPECT_EQ(rtc::Optional<bool>(), source_->options()->video_noise_reduction); | 416 EXPECT_FALSE(source_->needs_denoising()); |
| 419 } | 417 } |
| 420 | 418 |
| 421 TEST_F(VideoCapturerTrackSourceTest, InvalidOptionValueMandatory) { | 419 TEST_F(VideoCapturerTrackSourceTest, InvalidDenoisingValueMandatory) { |
| 422 FakeConstraints constraints; | 420 FakeConstraints constraints; |
| 423 // Optional constraints should be ignored if the mandatory constraints fail. | 421 // Optional constraints should be ignored if the mandatory constraints fail. |
| 424 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, "false"); | 422 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, "false"); |
| 425 // Values are case-sensitive and must be all lower-case. | 423 // Values are case-sensitive and must be all lower-case. |
| 426 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, "True"); | 424 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, "True"); |
| 427 | 425 |
| 428 CreateVideoCapturerSource(&constraints); | 426 CreateVideoCapturerSource(&constraints); |
| 429 | 427 |
| 430 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), | 428 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), |
| 431 kMaxWaitMs); | 429 kMaxWaitMs); |
| 432 EXPECT_EQ(rtc::Optional<bool>(), source_->options()->video_noise_reduction); | 430 EXPECT_FALSE(source_->needs_denoising()); |
| 433 } | 431 } |
| 434 | 432 |
| 435 TEST_F(VideoCapturerTrackSourceTest, MixedOptionsAndConstraints) { | 433 TEST_F(VideoCapturerTrackSourceTest, MixedOptionsAndConstraints) { |
| 436 FakeConstraints constraints; | 434 FakeConstraints constraints; |
| 437 constraints.AddMandatory(MediaConstraintsInterface::kMaxWidth, 352); | 435 constraints.AddMandatory(MediaConstraintsInterface::kMaxWidth, 352); |
| 438 constraints.AddMandatory(MediaConstraintsInterface::kMaxHeight, 288); | 436 constraints.AddMandatory(MediaConstraintsInterface::kMaxHeight, 288); |
| 439 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 5); | 437 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 5); |
| 440 | 438 |
| 441 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, false); | 439 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, false); |
| 442 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, true); | 440 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, true); |
| 443 | 441 |
| 444 CreateVideoCapturerSource(&constraints); | 442 CreateVideoCapturerSource(&constraints); |
| 445 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 443 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 446 kMaxWaitMs); | 444 kMaxWaitMs); |
| 447 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); | 445 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); |
| 448 ASSERT_TRUE(format != NULL); | 446 ASSERT_TRUE(format != NULL); |
| 449 EXPECT_EQ(352, format->width); | 447 EXPECT_EQ(352, format->width); |
| 450 EXPECT_EQ(288, format->height); | 448 EXPECT_EQ(288, format->height); |
| 451 EXPECT_EQ(30, format->framerate()); | 449 EXPECT_EQ(30, format->framerate()); |
| 452 | 450 |
| 453 EXPECT_EQ(rtc::Optional<bool>(false), | 451 EXPECT_FALSE(source_->needs_denoising()); |
| 454 source_->options()->video_noise_reduction); | |
| 455 } | 452 } |
| 456 | 453 |
| 457 // Tests that the source starts video with the default resolution for | 454 // Tests that the source starts video with the default resolution for |
| 458 // screencast if no constraint is set. | 455 // screencast if no constraint is set. |
| 459 TEST_F(VideoCapturerTrackSourceTest, ScreencastResolutionNoConstraint) { | 456 TEST_F(VideoCapturerTrackSourceTest, ScreencastResolutionNoConstraint) { |
| 460 InitScreencast(); | 457 InitScreencast(); |
| 461 capturer_->TestWithoutCameraFormats(); | 458 capturer_->TestWithoutCameraFormats(); |
| 462 | 459 |
| 463 CreateVideoCapturerSource(); | 460 CreateVideoCapturerSource(); |
| 461 ASSERT_TRUE(source_->is_screencast()); |
| 464 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 462 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 465 kMaxWaitMs); | 463 kMaxWaitMs); |
| 466 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); | 464 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); |
| 467 ASSERT_TRUE(format != NULL); | 465 ASSERT_TRUE(format != NULL); |
| 468 EXPECT_EQ(640, format->width); | 466 EXPECT_EQ(640, format->width); |
| 469 EXPECT_EQ(480, format->height); | 467 EXPECT_EQ(480, format->height); |
| 470 EXPECT_EQ(30, format->framerate()); | 468 EXPECT_EQ(30, format->framerate()); |
| 471 } | 469 } |
| 472 | 470 |
| 473 // Tests that the source starts video with the max width and height set by | 471 // Tests that the source starts video with the max width and height set by |
| 474 // constraints for screencast. | 472 // constraints for screencast. |
| 475 TEST_F(VideoCapturerTrackSourceTest, ScreencastResolutionWithConstraint) { | 473 TEST_F(VideoCapturerTrackSourceTest, ScreencastResolutionWithConstraint) { |
| 476 FakeConstraints constraints; | 474 FakeConstraints constraints; |
| 477 constraints.AddMandatory(MediaConstraintsInterface::kMaxWidth, 480); | 475 constraints.AddMandatory(MediaConstraintsInterface::kMaxWidth, 480); |
| 478 constraints.AddMandatory(MediaConstraintsInterface::kMaxHeight, 270); | 476 constraints.AddMandatory(MediaConstraintsInterface::kMaxHeight, 270); |
| 479 | 477 |
| 480 InitScreencast(); | 478 InitScreencast(); |
| 481 capturer_->TestWithoutCameraFormats(); | 479 capturer_->TestWithoutCameraFormats(); |
| 482 | 480 |
| 483 CreateVideoCapturerSource(&constraints); | 481 CreateVideoCapturerSource(&constraints); |
| 482 ASSERT_TRUE(source_->is_screencast()); |
| 484 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 483 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 485 kMaxWaitMs); | 484 kMaxWaitMs); |
| 486 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); | 485 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); |
| 487 ASSERT_TRUE(format != NULL); | 486 ASSERT_TRUE(format != NULL); |
| 488 EXPECT_EQ(480, format->width); | 487 EXPECT_EQ(480, format->width); |
| 489 EXPECT_EQ(270, format->height); | 488 EXPECT_EQ(270, format->height); |
| 490 EXPECT_EQ(30, format->framerate()); | 489 EXPECT_EQ(30, format->framerate()); |
| 491 } | 490 } |
| 492 | 491 |
| 493 TEST_F(VideoCapturerTrackSourceTest, MandatorySubOneFpsConstraints) { | 492 TEST_F(VideoCapturerTrackSourceTest, MandatorySubOneFpsConstraints) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 504 FakeConstraints constraints; | 503 FakeConstraints constraints; |
| 505 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5); | 504 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5); |
| 506 | 505 |
| 507 CreateVideoCapturerSource(&constraints); | 506 CreateVideoCapturerSource(&constraints); |
| 508 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 507 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 509 kMaxWaitMs); | 508 kMaxWaitMs); |
| 510 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); | 509 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); |
| 511 ASSERT_TRUE(format != NULL); | 510 ASSERT_TRUE(format != NULL); |
| 512 EXPECT_EQ(30, format->framerate()); | 511 EXPECT_EQ(30, format->framerate()); |
| 513 } | 512 } |
| OLD | NEW |