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 24 matching lines...) Expand all Loading... | |
35 | 35 |
36 } // anonymous namespace | 36 } // anonymous namespace |
37 | 37 |
38 | 38 |
39 // TestVideoCapturer extends cricket::FakeVideoCapturer so it can be used for | 39 // TestVideoCapturer extends cricket::FakeVideoCapturer so it can be used for |
40 // testing without known camera formats. | 40 // testing without known camera formats. |
41 // It keeps its own lists of cricket::VideoFormats for the unit tests in this | 41 // It keeps its own lists of cricket::VideoFormats for the unit tests in this |
42 // file. | 42 // file. |
43 class TestVideoCapturer : public cricket::FakeVideoCapturer { | 43 class TestVideoCapturer : public cricket::FakeVideoCapturer { |
44 public: | 44 public: |
45 TestVideoCapturer() : test_without_formats_(false) { | 45 TestVideoCapturer(bool is_screencast) |
46 : FakeVideoCapturer(is_screencast), | |
47 test_without_formats_(false) { | |
46 std::vector<cricket::VideoFormat> formats; | 48 std::vector<cricket::VideoFormat> formats; |
47 formats.push_back(cricket::VideoFormat(1280, 720, | 49 formats.push_back(cricket::VideoFormat(1280, 720, |
48 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); | 50 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); |
49 formats.push_back(cricket::VideoFormat(640, 480, | 51 formats.push_back(cricket::VideoFormat(640, 480, |
50 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); | 52 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); |
51 formats.push_back(cricket::VideoFormat(640, 400, | 53 formats.push_back(cricket::VideoFormat(640, 400, |
52 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); | 54 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); |
53 formats.push_back(cricket::VideoFormat(320, 240, | 55 formats.push_back(cricket::VideoFormat(320, 240, |
54 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); | 56 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); |
55 formats.push_back(cricket::VideoFormat(352, 288, | 57 formats.push_back(cricket::VideoFormat(352, 288, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 MediaSourceInterface::SourceState state() const { return state_; } | 105 MediaSourceInterface::SourceState state() const { return state_; } |
104 | 106 |
105 private: | 107 private: |
106 MediaSourceInterface::SourceState state_; | 108 MediaSourceInterface::SourceState state_; |
107 rtc::scoped_refptr<VideoSourceInterface> source_; | 109 rtc::scoped_refptr<VideoSourceInterface> source_; |
108 }; | 110 }; |
109 | 111 |
110 class VideoSourceTest : public testing::Test { | 112 class VideoSourceTest : public testing::Test { |
111 protected: | 113 protected: |
112 VideoSourceTest() | 114 VideoSourceTest() |
113 : capturer_cleanup_(new TestVideoCapturer()), | 115 : channel_manager_(new cricket::ChannelManager( |
114 capturer_(capturer_cleanup_.get()), | |
115 channel_manager_(new cricket::ChannelManager( | |
116 new cricket::FakeMediaEngine(), rtc::Thread::Current())) { | 116 new cricket::FakeMediaEngine(), rtc::Thread::Current())) { |
117 InitScreencast(false); | |
118 } | |
119 void InitScreencast(bool is_screencast) { | |
pthatcher1
2016/02/20 08:32:59
Why isn't this just called Init?
perkj_webrtc
2016/02/21 18:09:06
or CreateVideoCapturer
nisse-webrtc
2016/02/22 07:52:34
Only because when calling it, InitScreencast(true)
| |
120 capturer_cleanup_ = rtc::scoped_ptr<TestVideoCapturer>( | |
121 new TestVideoCapturer(is_screencast)); | |
122 capturer_ = capturer_cleanup_.get(); | |
117 } | 123 } |
118 | 124 |
119 void SetUp() { | 125 void SetUp() { |
120 ASSERT_TRUE(channel_manager_->Init()); | 126 ASSERT_TRUE(channel_manager_->Init()); |
121 } | 127 } |
122 | 128 |
123 void CreateVideoSource() { | 129 void CreateVideoSource() { |
124 CreateVideoSource(NULL); | 130 CreateVideoSource(NULL); |
125 } | 131 } |
126 | 132 |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 EXPECT_EQ(288, format->height); | 472 EXPECT_EQ(288, format->height); |
467 EXPECT_EQ(30, format->framerate()); | 473 EXPECT_EQ(30, format->framerate()); |
468 | 474 |
469 EXPECT_EQ(rtc::Optional<bool>(false), | 475 EXPECT_EQ(rtc::Optional<bool>(false), |
470 source_->options()->video_noise_reduction); | 476 source_->options()->video_noise_reduction); |
471 } | 477 } |
472 | 478 |
473 // Tests that the source starts video with the default resolution for | 479 // Tests that the source starts video with the default resolution for |
474 // screencast if no constraint is set. | 480 // screencast if no constraint is set. |
475 TEST_F(VideoSourceTest, ScreencastResolutionNoConstraint) { | 481 TEST_F(VideoSourceTest, ScreencastResolutionNoConstraint) { |
482 InitScreencast(true); | |
476 capturer_->TestWithoutCameraFormats(); | 483 capturer_->TestWithoutCameraFormats(); |
477 capturer_->SetScreencast(true); | |
478 | 484 |
479 CreateVideoSource(); | 485 CreateVideoSource(); |
480 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 486 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
481 kMaxWaitMs); | 487 kMaxWaitMs); |
482 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); | 488 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); |
483 ASSERT_TRUE(format != NULL); | 489 ASSERT_TRUE(format != NULL); |
484 EXPECT_EQ(640, format->width); | 490 EXPECT_EQ(640, format->width); |
485 EXPECT_EQ(480, format->height); | 491 EXPECT_EQ(480, format->height); |
486 EXPECT_EQ(30, format->framerate()); | 492 EXPECT_EQ(30, format->framerate()); |
487 } | 493 } |
488 | 494 |
489 // Tests that the source starts video with the max width and height set by | 495 // Tests that the source starts video with the max width and height set by |
490 // constraints for screencast. | 496 // constraints for screencast. |
491 TEST_F(VideoSourceTest, ScreencastResolutionWithConstraint) { | 497 TEST_F(VideoSourceTest, ScreencastResolutionWithConstraint) { |
492 FakeConstraints constraints; | 498 FakeConstraints constraints; |
493 constraints.AddMandatory(MediaConstraintsInterface::kMaxWidth, 480); | 499 constraints.AddMandatory(MediaConstraintsInterface::kMaxWidth, 480); |
494 constraints.AddMandatory(MediaConstraintsInterface::kMaxHeight, 270); | 500 constraints.AddMandatory(MediaConstraintsInterface::kMaxHeight, 270); |
495 | 501 |
502 InitScreencast(true); | |
496 capturer_->TestWithoutCameraFormats(); | 503 capturer_->TestWithoutCameraFormats(); |
497 capturer_->SetScreencast(true); | |
498 | 504 |
499 CreateVideoSource(&constraints); | 505 CreateVideoSource(&constraints); |
500 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 506 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
501 kMaxWaitMs); | 507 kMaxWaitMs); |
502 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); | 508 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); |
503 ASSERT_TRUE(format != NULL); | 509 ASSERT_TRUE(format != NULL); |
504 EXPECT_EQ(480, format->width); | 510 EXPECT_EQ(480, format->width); |
505 EXPECT_EQ(270, format->height); | 511 EXPECT_EQ(270, format->height); |
506 EXPECT_EQ(30, format->framerate()); | 512 EXPECT_EQ(30, format->framerate()); |
507 } | 513 } |
(...skipping 12 matching lines...) Expand all Loading... | |
520 FakeConstraints constraints; | 526 FakeConstraints constraints; |
521 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5); | 527 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5); |
522 | 528 |
523 CreateVideoSource(&constraints); | 529 CreateVideoSource(&constraints); |
524 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 530 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
525 kMaxWaitMs); | 531 kMaxWaitMs); |
526 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); | 532 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); |
527 ASSERT_TRUE(format != NULL); | 533 ASSERT_TRUE(format != NULL); |
528 EXPECT_EQ(30, format->framerate()); | 534 EXPECT_EQ(30, format->framerate()); |
529 } | 535 } |
OLD | NEW |