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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 void TearDown() final { | 176 void TearDown() final { |
177 video_sender_.reset(); | 177 video_sender_.reset(); |
178 task_runner_->RunTasks(); | 178 task_runner_->RunTasks(); |
179 } | 179 } |
180 | 180 |
181 static void UpdateCastTransportStatus(CastTransportStatus status) { | 181 static void UpdateCastTransportStatus(CastTransportStatus status) { |
182 EXPECT_EQ(TRANSPORT_VIDEO_INITIALIZED, status); | 182 EXPECT_EQ(TRANSPORT_VIDEO_INITIALIZED, status); |
183 } | 183 } |
184 | 184 |
185 // If |external| is true then external video encoder (VEA) is used. | 185 // If |external| is true then external video encoder (VEA) is used. |
186 // |expect_init_sucess| is true if initialization is expected to succeed. | 186 // |expect_init_success| is true if initialization is expected to succeed. |
187 void InitEncoder(bool external, bool expect_init_success) { | 187 void InitEncoder(bool external, bool expect_init_success) { |
188 VideoSenderConfig video_config = GetDefaultVideoSenderConfig(); | 188 VideoSenderConfig video_config = GetDefaultVideoSenderConfig(); |
189 video_config.use_external_encoder = external; | 189 video_config.use_external_encoder = external; |
190 | 190 |
191 ASSERT_EQ(operational_status_, STATUS_UNINITIALIZED); | 191 ASSERT_EQ(operational_status_, STATUS_UNINITIALIZED); |
192 | 192 |
193 if (external) { | 193 if (external) { |
194 vea_factory_.SetInitializationWillSucceed(expect_init_success); | 194 vea_factory_.SetInitializationWillSucceed(expect_init_success); |
195 video_sender_.reset(new PeerVideoSender( | 195 video_sender_.reset(new PeerVideoSender( |
196 cast_environment_, | 196 cast_environment_, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 const scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; | 246 const scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; |
247 const scoped_refptr<CastEnvironment> cast_environment_; | 247 const scoped_refptr<CastEnvironment> cast_environment_; |
248 OperationalStatus operational_status_; | 248 OperationalStatus operational_status_; |
249 FakeVideoEncodeAcceleratorFactory vea_factory_; | 249 FakeVideoEncodeAcceleratorFactory vea_factory_; |
250 TestPacketSender transport_; | 250 TestPacketSender transport_; |
251 scoped_ptr<CastTransportSenderImpl> transport_sender_; | 251 scoped_ptr<CastTransportSenderImpl> transport_sender_; |
252 scoped_ptr<PeerVideoSender> video_sender_; | 252 scoped_ptr<PeerVideoSender> video_sender_; |
253 int last_pixel_value_; | 253 int last_pixel_value_; |
254 base::TimeTicks first_frame_timestamp_; | 254 base::TimeTicks first_frame_timestamp_; |
255 | 255 |
| 256 private: |
256 DISALLOW_COPY_AND_ASSIGN(VideoSenderTest); | 257 DISALLOW_COPY_AND_ASSIGN(VideoSenderTest); |
257 }; | 258 }; |
258 | 259 |
259 TEST_F(VideoSenderTest, BuiltInEncoder) { | 260 TEST_F(VideoSenderTest, BuiltInEncoder) { |
260 InitEncoder(false, true); | 261 InitEncoder(false, true); |
261 ASSERT_EQ(STATUS_INITIALIZED, operational_status_); | 262 ASSERT_EQ(STATUS_INITIALIZED, operational_status_); |
262 | 263 |
263 scoped_refptr<media::VideoFrame> video_frame = GetNewVideoFrame(); | 264 scoped_refptr<media::VideoFrame> video_frame = GetNewVideoFrame(); |
264 | 265 |
265 const base::TimeTicks reference_time = testing_clock_->NowTicks(); | 266 const base::TimeTicks reference_time = testing_clock_->NowTicks(); |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 << ", hfr=" << kTestCases[i].high_frame_rate); | 657 << ", hfr=" << kTestCases[i].high_frame_rate); |
657 const scoped_refptr<VideoFrame> frame = | 658 const scoped_refptr<VideoFrame> frame = |
658 CreateFakeFrame(resolution, kTestCases[i].high_frame_rate); | 659 CreateFakeFrame(resolution, kTestCases[i].high_frame_rate); |
659 EXPECT_EQ(kTestCases[i].expected_bitrate, | 660 EXPECT_EQ(kTestCases[i].expected_bitrate, |
660 PeerVideoSender::GetMaximumTargetBitrateForFrame(*frame)); | 661 PeerVideoSender::GetMaximumTargetBitrateForFrame(*frame)); |
661 } | 662 } |
662 } | 663 } |
663 | 664 |
664 } // namespace cast | 665 } // namespace cast |
665 } // namespace media | 666 } // namespace media |
OLD | NEW |