| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 MediaSourceInterface::SourceState state_; | 104 MediaSourceInterface::SourceState state_; |
| 105 rtc::scoped_refptr<VideoTrackSourceInterface> source_; | 105 rtc::scoped_refptr<VideoTrackSourceInterface> source_; |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 class VideoCapturerTrackSourceTest : public testing::Test { | 108 class VideoCapturerTrackSourceTest : public testing::Test { |
| 109 protected: | 109 protected: |
| 110 VideoCapturerTrackSourceTest() { InitCapturer(false); } | 110 VideoCapturerTrackSourceTest() { InitCapturer(false); } |
| 111 void InitCapturer(bool is_screencast) { | 111 void InitCapturer(bool is_screencast) { |
| 112 capturer_cleanup_ = std::unique_ptr<TestVideoCapturer>( | 112 capturer_ = new TestVideoCapturer(is_screencast); |
| 113 new TestVideoCapturer(is_screencast)); | 113 capturer_cleanup_.reset(capturer_); |
| 114 capturer_ = capturer_cleanup_.get(); | |
| 115 } | 114 } |
| 116 | 115 |
| 117 void InitScreencast() { InitCapturer(true); } | 116 void InitScreencast() { InitCapturer(true); } |
| 118 | 117 |
| 119 void CreateVideoCapturerSource() { CreateVideoCapturerSource(NULL); } | 118 void CreateVideoCapturerSource() { CreateVideoCapturerSource(NULL); } |
| 120 | 119 |
| 121 void CreateVideoCapturerSource( | 120 void CreateVideoCapturerSource( |
| 122 const webrtc::MediaConstraintsInterface* constraints) { | 121 const webrtc::MediaConstraintsInterface* constraints) { |
| 123 // VideoSource take ownership of |capturer_| | |
| 124 source_ = VideoCapturerTrackSource::Create(rtc::Thread::Current(), | 122 source_ = VideoCapturerTrackSource::Create(rtc::Thread::Current(), |
| 125 capturer_cleanup_.release(), | 123 std::move(capturer_cleanup_), |
| 126 constraints, false); | 124 constraints, false); |
| 127 | 125 |
| 128 ASSERT_TRUE(source_.get() != NULL); | 126 ASSERT_TRUE(source_.get() != NULL); |
| 129 | 127 |
| 130 state_observer_.reset(new StateObserver(source_)); | 128 state_observer_.reset(new StateObserver(source_)); |
| 131 source_->RegisterObserver(state_observer_.get()); | 129 source_->RegisterObserver(state_observer_.get()); |
| 132 source_->AddOrUpdateSink(&renderer_, rtc::VideoSinkWants()); | 130 source_->AddOrUpdateSink(&renderer_, rtc::VideoSinkWants()); |
| 133 } | 131 } |
| 134 | 132 |
| 135 std::unique_ptr<TestVideoCapturer> capturer_cleanup_; | 133 std::unique_ptr<cricket::VideoCapturer> capturer_cleanup_; |
| 136 TestVideoCapturer* capturer_; | 134 TestVideoCapturer* capturer_; |
| 137 cricket::FakeVideoRenderer renderer_; | 135 cricket::FakeVideoRenderer renderer_; |
| 138 std::unique_ptr<StateObserver> state_observer_; | 136 std::unique_ptr<StateObserver> state_observer_; |
| 139 rtc::scoped_refptr<VideoTrackSourceInterface> source_; | 137 rtc::scoped_refptr<VideoTrackSourceInterface> source_; |
| 140 }; | 138 }; |
| 141 | 139 |
| 142 // Test that a VideoSource transition to kLive state when the capture | 140 // Test that a VideoSource transition to kLive state when the capture |
| 143 // device have started and kEnded if it is stopped. | 141 // device have started and kEnded if it is stopped. |
| 144 // It also test that an output can receive video frames. | 142 // It also test that an output can receive video frames. |
| 145 TEST_F(VideoCapturerTrackSourceTest, CapturerStartStop) { | 143 TEST_F(VideoCapturerTrackSourceTest, CapturerStartStop) { |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 FakeConstraints constraints; | 455 FakeConstraints constraints; |
| 458 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5); | 456 constraints.AddOptional(MediaConstraintsInterface::kMaxFrameRate, 0.5); |
| 459 | 457 |
| 460 CreateVideoCapturerSource(&constraints); | 458 CreateVideoCapturerSource(&constraints); |
| 461 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), | 459 EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(), |
| 462 kMaxWaitMs); | 460 kMaxWaitMs); |
| 463 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); | 461 const cricket::VideoFormat* format = capturer_->GetCaptureFormat(); |
| 464 ASSERT_TRUE(format != NULL); | 462 ASSERT_TRUE(format != NULL); |
| 465 EXPECT_EQ(1, format->framerate()); | 463 EXPECT_EQ(1, format->framerate()); |
| 466 } | 464 } |
| OLD | NEW |