| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/test/simple_test_tick_clock.h" | 13 #include "base/test/simple_test_tick_clock.h" |
| 14 #include "media/base/fake_single_thread_task_runner.h" |
| 14 #include "media/base/video_frame.h" | 15 #include "media/base/video_frame.h" |
| 15 #include "media/cast/cast_environment.h" | 16 #include "media/cast/cast_environment.h" |
| 16 #include "media/cast/constants.h" | 17 #include "media/cast/constants.h" |
| 17 #include "media/cast/logging/simple_event_subscriber.h" | 18 #include "media/cast/logging/simple_event_subscriber.h" |
| 18 #include "media/cast/net/cast_transport_config.h" | 19 #include "media/cast/net/cast_transport_config.h" |
| 19 #include "media/cast/net/cast_transport_sender_impl.h" | 20 #include "media/cast/net/cast_transport_sender_impl.h" |
| 20 #include "media/cast/net/pacing/paced_sender.h" | 21 #include "media/cast/net/pacing/paced_sender.h" |
| 21 #include "media/cast/sender/fake_video_encode_accelerator_factory.h" | 22 #include "media/cast/sender/fake_video_encode_accelerator_factory.h" |
| 22 #include "media/cast/sender/video_frame_factory.h" | 23 #include "media/cast/sender/video_frame_factory.h" |
| 23 #include "media/cast/sender/video_sender.h" | 24 #include "media/cast/sender/video_sender.h" |
| 24 #include "media/cast/test/fake_single_thread_task_runner.h" | |
| 25 #include "media/cast/test/utility/default_config.h" | 25 #include "media/cast/test/utility/default_config.h" |
| 26 #include "media/cast/test/utility/video_utility.h" | 26 #include "media/cast/test/utility/video_utility.h" |
| 27 #include "media/video/fake_video_encode_accelerator.h" | 27 #include "media/video/fake_video_encode_accelerator.h" |
| 28 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 30 | 30 |
| 31 namespace media { | 31 namespace media { |
| 32 namespace cast { | 32 namespace cast { |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 DISALLOW_COPY_AND_ASSIGN(TransportClient); | 142 DISALLOW_COPY_AND_ASSIGN(TransportClient); |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 } // namespace | 145 } // namespace |
| 146 | 146 |
| 147 class VideoSenderTest : public ::testing::Test { | 147 class VideoSenderTest : public ::testing::Test { |
| 148 protected: | 148 protected: |
| 149 VideoSenderTest() | 149 VideoSenderTest() |
| 150 : testing_clock_(new base::SimpleTestTickClock()), | 150 : testing_clock_(new base::SimpleTestTickClock()), |
| 151 task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)), | 151 task_runner_(new FakeSingleThreadTaskRunner(testing_clock_)), |
| 152 cast_environment_( | 152 cast_environment_( |
| 153 new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_), | 153 new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_), |
| 154 task_runner_, | 154 task_runner_, |
| 155 task_runner_, | 155 task_runner_, |
| 156 task_runner_)), | 156 task_runner_)), |
| 157 operational_status_(STATUS_UNINITIALIZED), | 157 operational_status_(STATUS_UNINITIALIZED), |
| 158 vea_factory_(task_runner_) { | 158 vea_factory_(task_runner_) { |
| 159 testing_clock_->Advance(base::TimeTicks::Now() - base::TimeTicks()); | 159 testing_clock_->Advance(base::TimeTicks::Now() - base::TimeTicks()); |
| 160 vea_factory_.SetAutoRespond(true); | 160 vea_factory_.SetAutoRespond(true); |
| 161 last_pixel_value_ = kPixelValue; | 161 last_pixel_value_ = kPixelValue; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 testing_clock_->NowTicks() - first_frame_timestamp_); | 227 testing_clock_->NowTicks() - first_frame_timestamp_); |
| 228 PopulateVideoFrameWithNoise(video_frame.get()); | 228 PopulateVideoFrameWithNoise(video_frame.get()); |
| 229 return video_frame; | 229 return video_frame; |
| 230 } | 230 } |
| 231 | 231 |
| 232 void RunTasks(int during_ms) { | 232 void RunTasks(int during_ms) { |
| 233 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(during_ms)); | 233 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(during_ms)); |
| 234 } | 234 } |
| 235 | 235 |
| 236 base::SimpleTestTickClock* const testing_clock_; // Owned by CastEnvironment. | 236 base::SimpleTestTickClock* const testing_clock_; // Owned by CastEnvironment. |
| 237 const scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; | 237 const scoped_refptr<FakeSingleThreadTaskRunner> task_runner_; |
| 238 const scoped_refptr<CastEnvironment> cast_environment_; | 238 const scoped_refptr<CastEnvironment> cast_environment_; |
| 239 OperationalStatus operational_status_; | 239 OperationalStatus operational_status_; |
| 240 FakeVideoEncodeAcceleratorFactory vea_factory_; | 240 FakeVideoEncodeAcceleratorFactory vea_factory_; |
| 241 TestPacketSender* transport_; // Owned by CastTransportSender. | 241 TestPacketSender* transport_; // Owned by CastTransportSender. |
| 242 scoped_ptr<CastTransportSenderImpl> transport_sender_; | 242 scoped_ptr<CastTransportSenderImpl> transport_sender_; |
| 243 scoped_ptr<PeerVideoSender> video_sender_; | 243 scoped_ptr<PeerVideoSender> video_sender_; |
| 244 int last_pixel_value_; | 244 int last_pixel_value_; |
| 245 base::TimeTicks first_frame_timestamp_; | 245 base::TimeTicks first_frame_timestamp_; |
| 246 | 246 |
| 247 private: | 247 private: |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 video_frame, | 634 video_frame, |
| 635 testing_clock_->NowTicks() + base::TimeDelta::FromMilliseconds(1000)); | 635 testing_clock_->NowTicks() + base::TimeDelta::FromMilliseconds(1000)); |
| 636 RunTasks(33); | 636 RunTasks(33); |
| 637 transport_->SetPause(false); | 637 transport_->SetPause(false); |
| 638 RunTasks(33); | 638 RunTasks(33); |
| 639 EXPECT_EQ(2, transport_->number_of_rtp_packets()); | 639 EXPECT_EQ(2, transport_->number_of_rtp_packets()); |
| 640 } | 640 } |
| 641 | 641 |
| 642 } // namespace cast | 642 } // namespace cast |
| 643 } // namespace media | 643 } // namespace media |
| OLD | NEW |