| 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 FakeConstraints constraints; | 327 FakeConstraints constraints; |
| 328 constraints.AddOptional("weird key", 640); | 328 constraints.AddOptional("weird key", 640); |
| 329 | 329 |
| 330 CreateVideoCapturerSource(&constraints); | 330 CreateVideoCapturerSource(&constraints); |
| 331 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 331 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 332 kMaxWaitMs); | 332 kMaxWaitMs); |
| 333 } | 333 } |
| 334 | 334 |
| 335 TEST_F(VideoCapturerTrackSourceTest, SetValidDenoisingConstraint) { | 335 TEST_F(VideoCapturerTrackSourceTest, SetValidDenoisingConstraint) { |
| 336 FakeConstraints constraints; | 336 FakeConstraints constraints; |
| 337 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, "true"); | 337 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, "false"); |
| 338 | 338 |
| 339 CreateVideoCapturerSource(&constraints); | 339 CreateVideoCapturerSource(&constraints); |
| 340 | 340 |
| 341 EXPECT_TRUE(source_->needs_denoising()); | 341 EXPECT_EQ(rtc::Optional<bool>(false), source_->needs_denoising()); |
| 342 } | 342 } |
| 343 | 343 |
| 344 TEST_F(VideoCapturerTrackSourceTest, NoiseReductionConstraintNotSet) { | 344 TEST_F(VideoCapturerTrackSourceTest, NoiseReductionConstraintNotSet) { |
| 345 FakeConstraints constraints; | 345 FakeConstraints constraints; |
| 346 CreateVideoCapturerSource(&constraints); | 346 CreateVideoCapturerSource(&constraints); |
| 347 EXPECT_FALSE(source_->needs_denoising()); | 347 EXPECT_EQ(rtc::Optional<bool>(), source_->needs_denoising()); |
| 348 } | 348 } |
| 349 | 349 |
| 350 TEST_F(VideoCapturerTrackSourceTest, | 350 TEST_F(VideoCapturerTrackSourceTest, |
| 351 MandatoryDenoisingConstraintOverridesOptional) { | 351 MandatoryDenoisingConstraintOverridesOptional) { |
| 352 FakeConstraints constraints; | 352 FakeConstraints constraints; |
| 353 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, false); | 353 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, false); |
| 354 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, true); | 354 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, true); |
| 355 | 355 |
| 356 CreateVideoCapturerSource(&constraints); | 356 CreateVideoCapturerSource(&constraints); |
| 357 | 357 |
| 358 EXPECT_FALSE(source_->needs_denoising()); | 358 EXPECT_EQ(rtc::Optional<bool>(false), source_->needs_denoising()); |
| 359 } | 359 } |
| 360 | 360 |
| 361 TEST_F(VideoCapturerTrackSourceTest, NoiseReductionAndInvalidKeyOptional) { | 361 TEST_F(VideoCapturerTrackSourceTest, NoiseReductionAndInvalidKeyOptional) { |
| 362 FakeConstraints constraints; | 362 FakeConstraints constraints; |
| 363 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, true); | 363 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, true); |
| 364 constraints.AddOptional("invalidKey", false); | 364 constraints.AddOptional("invalidKey", false); |
| 365 | 365 |
| 366 CreateVideoCapturerSource(&constraints); | 366 CreateVideoCapturerSource(&constraints); |
| 367 | 367 |
| 368 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 368 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 369 kMaxWaitMs); | 369 kMaxWaitMs); |
| 370 EXPECT_TRUE(source_->needs_denoising()); | 370 EXPECT_EQ(rtc::Optional<bool>(true), source_->needs_denoising()); |
| 371 } | 371 } |
| 372 | 372 |
| 373 TEST_F(VideoCapturerTrackSourceTest, NoiseReductionAndInvalidKeyMandatory) { | 373 TEST_F(VideoCapturerTrackSourceTest, NoiseReductionAndInvalidKeyMandatory) { |
| 374 FakeConstraints constraints; | 374 FakeConstraints constraints; |
| 375 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, false); | 375 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, false); |
| 376 constraints.AddMandatory("invalidKey", false); | 376 constraints.AddMandatory("invalidKey", false); |
| 377 | 377 |
| 378 CreateVideoCapturerSource(&constraints); | 378 CreateVideoCapturerSource(&constraints); |
| 379 | 379 |
| 380 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), | 380 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), |
| 381 kMaxWaitMs); | 381 kMaxWaitMs); |
| 382 EXPECT_FALSE(source_->needs_denoising()); | 382 EXPECT_EQ(rtc::Optional<bool>(), source_->needs_denoising()); |
| 383 } | 383 } |
| 384 | 384 |
| 385 TEST_F(VideoCapturerTrackSourceTest, InvalidDenoisingValueOptional) { | 385 TEST_F(VideoCapturerTrackSourceTest, InvalidDenoisingValueOptional) { |
| 386 FakeConstraints constraints; | 386 FakeConstraints constraints; |
| 387 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, | 387 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, |
| 388 "not a boolean"); | 388 "not a boolean"); |
| 389 | 389 |
| 390 CreateVideoCapturerSource(&constraints); | 390 CreateVideoCapturerSource(&constraints); |
| 391 | 391 |
| 392 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 392 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 393 kMaxWaitMs); | 393 kMaxWaitMs); |
| 394 EXPECT_FALSE(source_->needs_denoising()); | 394 |
| 395 EXPECT_EQ(rtc::Optional<bool>(), source_->needs_denoising()); |
| 395 } | 396 } |
| 396 | 397 |
| 397 TEST_F(VideoCapturerTrackSourceTest, InvalidDenoisingValueMandatory) { | 398 TEST_F(VideoCapturerTrackSourceTest, InvalidDenoisingValueMandatory) { |
| 398 FakeConstraints constraints; | 399 FakeConstraints constraints; |
| 399 // Optional constraints should be ignored if the mandatory constraints fail. | 400 // Optional constraints should be ignored if the mandatory constraints fail. |
| 400 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, "false"); | 401 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, "false"); |
| 401 // Values are case-sensitive and must be all lower-case. | 402 // Values are case-sensitive and must be all lower-case. |
| 402 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, "True"); | 403 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, "True"); |
| 403 | 404 |
| 404 CreateVideoCapturerSource(&constraints); | 405 CreateVideoCapturerSource(&constraints); |
| 405 | 406 |
| 406 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), | 407 EXPECT_EQ_WAIT(MediaSourceInterface::kEnded, state_observer_->state(), |
| 407 kMaxWaitMs); | 408 kMaxWaitMs); |
| 408 EXPECT_FALSE(source_->needs_denoising()); | 409 EXPECT_EQ(rtc::Optional<bool>(), source_->needs_denoising()); |
| 409 } | 410 } |
| 410 | 411 |
| 411 TEST_F(VideoCapturerTrackSourceTest, MixedOptionsAndConstraints) { | 412 TEST_F(VideoCapturerTrackSourceTest, MixedOptionsAndConstraints) { |
| 412 FakeConstraints constraints; | 413 FakeConstraints constraints; |
| 413 constraints.AddMandatory(MediaConstraintsInterface::kMaxWidth, 352); | 414 constraints.AddMandatory(MediaConstraintsInterface::kMaxWidth, 352); |
| 414 constraints.AddMandatory(MediaConstraintsInterface::kMaxHeight, 288); | 415 constraints.AddMandatory(MediaConstraintsInterface::kMaxHeight, 288); |
| 415 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 5); | 416 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 5); |
| 416 | 417 |
| 417 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, false); | 418 constraints.AddMandatory(MediaConstraintsInterface::kNoiseReduction, false); |
| 418 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, true); | 419 constraints.AddOptional(MediaConstraintsInterface::kNoiseReduction, true); |
| 419 | 420 |
| 420 CreateVideoCapturerSource(&constraints); | 421 CreateVideoCapturerSource(&constraints); |
| 421 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 422 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 422 kMaxWaitMs); | 423 kMaxWaitMs); |
| 423 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); | 424 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); |
| 424 ASSERT_TRUE(format != NULL); | 425 ASSERT_TRUE(format != NULL); |
| 425 EXPECT_EQ(352, format->width); | 426 EXPECT_EQ(352, format->width); |
| 426 EXPECT_EQ(288, format->height); | 427 EXPECT_EQ(288, format->height); |
| 427 EXPECT_EQ(30, format->framerate()); | 428 EXPECT_EQ(30, format->framerate()); |
| 428 | 429 |
| 429 EXPECT_FALSE(source_->needs_denoising()); | 430 EXPECT_EQ(rtc::Optional<bool>(false), source_->needs_denoising()); |
| 430 } | 431 } |
| 431 | 432 |
| 432 // Tests that the source starts video with the default resolution for | 433 // Tests that the source starts video with the default resolution for |
| 433 // screencast if no constraint is set. | 434 // screencast if no constraint is set. |
| 434 TEST_F(VideoCapturerTrackSourceTest, ScreencastResolutionNoConstraint) { | 435 TEST_F(VideoCapturerTrackSourceTest, ScreencastResolutionNoConstraint) { |
| 435 InitScreencast(); | 436 InitScreencast(); |
| 436 capturer_->TestWithoutCameraFormats(); | 437 capturer_->TestWithoutCameraFormats(); |
| 437 | 438 |
| 438 CreateVideoCapturerSource(); | 439 CreateVideoCapturerSource(); |
| 439 ASSERT_TRUE(source_->is_screencast()); | 440 ASSERT_TRUE(source_->is_screencast()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 FakeConstraints constraints; | 482 FakeConstraints constraints; |
| 482 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5); | 483 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5); |
| 483 | 484 |
| 484 CreateVideoCapturerSource(&constraints); | 485 CreateVideoCapturerSource(&constraints); |
| 485 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 486 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 486 kMaxWaitMs); | 487 kMaxWaitMs); |
| 487 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); | 488 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); |
| 488 ASSERT_TRUE(format != NULL); | 489 ASSERT_TRUE(format != NULL); |
| 489 EXPECT_EQ(30, format->framerate()); | 490 EXPECT_EQ(30, format->framerate()); |
| 490 } | 491 } |
| OLD | NEW |