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

Side by Side Diff: media/cast/sender/video_encoder_unittest.cc

Issue 2113783002: Refactoring: Merge VideoSenderConfig and AudioSenderConfig. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
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 "media/cast/sender/video_encoder.h" 5 #include "media/cast/sender/video_encoder.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 vea_factory_.reset(new FakeVideoEncodeAcceleratorFactory(task_runner_)); 59 vea_factory_.reset(new FakeVideoEncodeAcceleratorFactory(task_runner_));
60 } 60 }
61 61
62 void TearDown() final { 62 void TearDown() final {
63 video_encoder_.reset(); 63 video_encoder_.reset();
64 RunTasksAndAdvanceClock(); 64 RunTasksAndAdvanceClock();
65 } 65 }
66 66
67 void CreateEncoder() { 67 void CreateEncoder() {
68 ASSERT_EQ(STATUS_UNINITIALIZED, operational_status_); 68 ASSERT_EQ(STATUS_UNINITIALIZED, operational_status_);
69 video_config_.max_number_of_video_buffers_used = 1; 69 video_config_.codec_specific_params.max_number_of_video_buffers_used = 1;
70 video_encoder_ = VideoEncoder::Create( 70 video_encoder_ = VideoEncoder::Create(
71 cast_environment_, video_config_, 71 cast_environment_, video_config_,
72 base::Bind(&VideoEncoderTest::OnOperationalStatusChange, 72 base::Bind(&VideoEncoderTest::OnOperationalStatusChange,
73 base::Unretained(this)), 73 base::Unretained(this)),
74 base::Bind( 74 base::Bind(
75 &FakeVideoEncodeAcceleratorFactory::CreateVideoEncodeAccelerator, 75 &FakeVideoEncodeAcceleratorFactory::CreateVideoEncodeAccelerator,
76 base::Unretained(vea_factory_.get())), 76 base::Unretained(vea_factory_.get())),
77 base::Bind(&FakeVideoEncodeAcceleratorFactory::CreateSharedMemory, 77 base::Bind(&FakeVideoEncodeAcceleratorFactory::CreateSharedMemory,
78 base::Unretained(vea_factory_.get()))); 78 base::Unretained(vea_factory_.get())));
79 RunTasksAndAdvanceClock(); 79 RunTasksAndAdvanceClock();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 void DestroyEncoder() { 115 void DestroyEncoder() {
116 video_encoder_.reset(); 116 video_encoder_.reset();
117 } 117 }
118 118
119 base::TimeTicks Now() const { 119 base::TimeTicks Now() const {
120 return testing_clock_->NowTicks(); 120 return testing_clock_->NowTicks();
121 } 121 }
122 122
123 void RunTasksAndAdvanceClock() const { 123 void RunTasksAndAdvanceClock() const {
124 DCHECK_GT(video_config_.max_frame_rate, 0);
124 const base::TimeDelta frame_duration = base::TimeDelta::FromMicroseconds( 125 const base::TimeDelta frame_duration = base::TimeDelta::FromMicroseconds(
125 1000000.0 / video_config_.max_frame_rate); 126 1000000.0 / video_config_.max_frame_rate);
126 #if defined(OS_MACOSX) 127 #if defined(OS_MACOSX)
127 if (is_testing_video_toolbox_encoder()) { 128 if (is_testing_video_toolbox_encoder()) {
128 // The H264VideoToolboxEncoder (on MAC_OSX and IOS) is not a faked 129 // The H264VideoToolboxEncoder (on MAC_OSX and IOS) is not a faked
129 // implementation in these tests, and performs its encoding asynchronously 130 // implementation in these tests, and performs its encoding asynchronously
130 // on an unknown set of threads. Therefore, sleep the current thread for 131 // on an unknown set of threads. Therefore, sleep the current thread for
131 // the real amount of time to avoid excessively spinning the CPU while 132 // the real amount of time to avoid excessively spinning the CPU while
132 // waiting for something to happen. 133 // waiting for something to happen.
133 base::PlatformThread::Sleep(frame_duration); 134 base::PlatformThread::Sleep(frame_duration);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 << "Platform encoder chose to emit a " 241 << "Platform encoder chose to emit a "
241 << (have_key_frame ? "key" : "delta") 242 << (have_key_frame ? "key" : "delta")
242 << " frame instead of the expected kind @ frame_id=" 243 << " frame instead of the expected kind @ frame_id="
243 << encoded_frame->frame_id; 244 << encoded_frame->frame_id;
244 LOG_IF(WARNING, encoded_frame->data.empty()) 245 LOG_IF(WARNING, encoded_frame->data.empty())
245 << "Platform encoder returned an empty frame @ frame_id=" 246 << "Platform encoder returned an empty frame @ frame_id="
246 << encoded_frame->frame_id; 247 << encoded_frame->frame_id;
247 } else { 248 } else {
248 if (expected_frame_id != expected_last_referenced_frame_id) { 249 if (expected_frame_id != expected_last_referenced_frame_id) {
249 EXPECT_EQ(EncodedFrame::DEPENDENT, encoded_frame->dependency); 250 EXPECT_EQ(EncodedFrame::DEPENDENT, encoded_frame->dependency);
250 } else if (video_config_.max_number_of_video_buffers_used == 1) { 251 } else if (video_config_.codec_specific_params
252 .max_number_of_video_buffers_used == 1) {
251 EXPECT_EQ(EncodedFrame::KEY, encoded_frame->dependency); 253 EXPECT_EQ(EncodedFrame::KEY, encoded_frame->dependency);
252 } 254 }
253 EXPECT_EQ(expected_last_referenced_frame_id, 255 EXPECT_EQ(expected_last_referenced_frame_id,
254 encoded_frame->referenced_frame_id); 256 encoded_frame->referenced_frame_id);
255 EXPECT_FALSE(encoded_frame->data.empty()); 257 EXPECT_FALSE(encoded_frame->data.empty());
256 ASSERT_TRUE(std::isfinite(encoded_frame->deadline_utilization)); 258 ASSERT_TRUE(std::isfinite(encoded_frame->deadline_utilization));
257 EXPECT_LE(0.0, encoded_frame->deadline_utilization); 259 EXPECT_LE(0.0, encoded_frame->deadline_utilization);
258 ASSERT_TRUE(std::isfinite(encoded_frame->lossy_utilization)); 260 ASSERT_TRUE(std::isfinite(encoded_frame->lossy_utilization));
259 EXPECT_LE(0.0, encoded_frame->lossy_utilization); 261 EXPECT_LE(0.0, encoded_frame->lossy_utilization);
260 } 262 }
261 263
262 ++count_frames_delivered_; 264 ++count_frames_delivered_;
263 } 265 }
264 266
265 base::SimpleTestTickClock* const testing_clock_; // Owned by CastEnvironment. 267 base::SimpleTestTickClock* const testing_clock_; // Owned by CastEnvironment.
266 const scoped_refptr<FakeSingleThreadTaskRunner> task_runner_; 268 const scoped_refptr<FakeSingleThreadTaskRunner> task_runner_;
267 const scoped_refptr<CastEnvironment> cast_environment_; 269 const scoped_refptr<CastEnvironment> cast_environment_;
268 VideoSenderConfig video_config_; 270 FrameSenderConfig video_config_;
269 std::unique_ptr<FakeVideoEncodeAcceleratorFactory> vea_factory_; 271 std::unique_ptr<FakeVideoEncodeAcceleratorFactory> vea_factory_;
270 base::TimeTicks first_frame_time_; 272 base::TimeTicks first_frame_time_;
271 OperationalStatus operational_status_; 273 OperationalStatus operational_status_;
272 std::unique_ptr<VideoEncoder> video_encoder_; 274 std::unique_ptr<VideoEncoder> video_encoder_;
273 std::unique_ptr<VideoFrameFactory> video_frame_factory_; 275 std::unique_ptr<VideoFrameFactory> video_frame_factory_;
274 276
275 int count_frames_delivered_; 277 int count_frames_delivered_;
276 278
277 DISALLOW_COPY_AND_ASSIGN(VideoEncoderTest); 279 DISALLOW_COPY_AND_ASSIGN(VideoEncoderTest);
278 }; 280 };
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 #endif 424 #endif
423 return values; 425 return values;
424 } 426 }
425 } // namespace 427 } // namespace
426 428
427 INSTANTIATE_TEST_CASE_P( 429 INSTANTIATE_TEST_CASE_P(
428 , VideoEncoderTest, ::testing::ValuesIn(DetermineEncodersToTest())); 430 , VideoEncoderTest, ::testing::ValuesIn(DetermineEncodersToTest()));
429 431
430 } // namespace cast 432 } // namespace cast
431 } // namespace media 433 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698