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

Side by Side Diff: webrtc/api/videosource_unittest.cc

Issue 1711763003: New flag is_screencast in VideoOptions. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix OnLoadUpdate is_screencast check. Don't set FakeVideoCapturer into screencast mode in the video… Created 4 years, 9 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
« no previous file with comments | « webrtc/api/videosource.cc ('k') | webrtc/media/base/fakevideocapturer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 InitCapturer(false);
117 } 118 }
119 void InitCapturer(bool is_screencast) {
120 capturer_cleanup_ = rtc::scoped_ptr<TestVideoCapturer>(
121 new TestVideoCapturer(is_screencast));
122 capturer_ = capturer_cleanup_.get();
123 }
124
125 void InitScreencast() { InitCapturer(true); }
118 126
119 void SetUp() { 127 void SetUp() {
120 ASSERT_TRUE(channel_manager_->Init()); 128 ASSERT_TRUE(channel_manager_->Init());
121 } 129 }
122 130
123 void CreateVideoSource() { 131 void CreateVideoSource() {
124 CreateVideoSource(NULL); 132 CreateVideoSource(NULL);
125 } 133 }
126 134
127 void CreateVideoSource( 135 void CreateVideoSource(
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 EXPECT_EQ(288, format->height); 474 EXPECT_EQ(288, format->height);
467 EXPECT_EQ(30, format->framerate()); 475 EXPECT_EQ(30, format->framerate());
468 476
469 EXPECT_EQ(rtc::Optional<bool>(false), 477 EXPECT_EQ(rtc::Optional<bool>(false),
470 source_->options()->video_noise_reduction); 478 source_->options()->video_noise_reduction);
471 } 479 }
472 480
473 // Tests that the source starts video with the default resolution for 481 // Tests that the source starts video with the default resolution for
474 // screencast if no constraint is set. 482 // screencast if no constraint is set.
475 TEST_F(VideoSourceTest, ScreencastResolutionNoConstraint) { 483 TEST_F(VideoSourceTest, ScreencastResolutionNoConstraint) {
484 InitScreencast();
476 capturer_->TestWithoutCameraFormats(); 485 capturer_->TestWithoutCameraFormats();
477 capturer_->SetScreencast(true);
478 486
479 CreateVideoSource(); 487 CreateVideoSource();
480 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), 488 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(),
481 kMaxWaitMs); 489 kMaxWaitMs);
482 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); 490 const cricket::VideoFormat* format = capturer_->GetCaptureFormat();
483 ASSERT_TRUE(format != NULL); 491 ASSERT_TRUE(format != NULL);
484 EXPECT_EQ(640, format->width); 492 EXPECT_EQ(640, format->width);
485 EXPECT_EQ(480, format->height); 493 EXPECT_EQ(480, format->height);
486 EXPECT_EQ(30, format->framerate()); 494 EXPECT_EQ(30, format->framerate());
487 } 495 }
488 496
489 // Tests that the source starts video with the max width and height set by 497 // Tests that the source starts video with the max width and height set by
490 // constraints for screencast. 498 // constraints for screencast.
491 TEST_F(VideoSourceTest, ScreencastResolutionWithConstraint) { 499 TEST_F(VideoSourceTest, ScreencastResolutionWithConstraint) {
492 FakeConstraints constraints; 500 FakeConstraints constraints;
493 constraints.AddMandatory(MediaConstraintsInterface::kMaxWidth, 480); 501 constraints.AddMandatory(MediaConstraintsInterface::kMaxWidth, 480);
494 constraints.AddMandatory(MediaConstraintsInterface::kMaxHeight, 270); 502 constraints.AddMandatory(MediaConstraintsInterface::kMaxHeight, 270);
495 503
504 InitScreencast();
496 capturer_->TestWithoutCameraFormats(); 505 capturer_->TestWithoutCameraFormats();
497 capturer_->SetScreencast(true);
498 506
499 CreateVideoSource(&constraints); 507 CreateVideoSource(&constraints);
500 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), 508 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(),
501 kMaxWaitMs); 509 kMaxWaitMs);
502 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); 510 const cricket::VideoFormat* format = capturer_->GetCaptureFormat();
503 ASSERT_TRUE(format != NULL); 511 ASSERT_TRUE(format != NULL);
504 EXPECT_EQ(480, format->width); 512 EXPECT_EQ(480, format->width);
505 EXPECT_EQ(270, format->height); 513 EXPECT_EQ(270, format->height);
506 EXPECT_EQ(30, format->framerate()); 514 EXPECT_EQ(30, format->framerate());
507 } 515 }
(...skipping 12 matching lines...) Expand all
520 FakeConstraints constraints; 528 FakeConstraints constraints;
521 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5); 529 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5);
522 530
523 CreateVideoSource(&constraints); 531 CreateVideoSource(&constraints);
524 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), 532 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(),
525 kMaxWaitMs); 533 kMaxWaitMs);
526 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); 534 const cricket::VideoFormat* format = capturer_->GetCaptureFormat();
527 ASSERT_TRUE(format != NULL); 535 ASSERT_TRUE(format != NULL);
528 EXPECT_EQ(30, format->framerate()); 536 EXPECT_EQ(30, format->framerate());
529 } 537 }
OLDNEW
« no previous file with comments | « webrtc/api/videosource.cc ('k') | webrtc/media/base/fakevideocapturer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698