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

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

Issue 2133223003: Revert of 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
« no previous file with comments | « media/cast/sender/video_encoder_impl.cc ('k') | media/cast/sender/video_sender.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 // 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_.video_codec_params.max_number_of_video_buffers_used = 1; 69 video_config_.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);
125 const base::TimeDelta frame_duration = base::TimeDelta::FromMicroseconds( 124 const base::TimeDelta frame_duration = base::TimeDelta::FromMicroseconds(
126 1000000.0 / video_config_.max_frame_rate); 125 1000000.0 / video_config_.max_frame_rate);
127 #if defined(OS_MACOSX) 126 #if defined(OS_MACOSX)
128 if (is_testing_video_toolbox_encoder()) { 127 if (is_testing_video_toolbox_encoder()) {
129 // The H264VideoToolboxEncoder (on MAC_OSX and IOS) is not a faked 128 // The H264VideoToolboxEncoder (on MAC_OSX and IOS) is not a faked
130 // implementation in these tests, and performs its encoding asynchronously 129 // implementation in these tests, and performs its encoding asynchronously
131 // on an unknown set of threads. Therefore, sleep the current thread for 130 // on an unknown set of threads. Therefore, sleep the current thread for
132 // the real amount of time to avoid excessively spinning the CPU while 131 // the real amount of time to avoid excessively spinning the CPU while
133 // waiting for something to happen. 132 // waiting for something to happen.
134 base::PlatformThread::Sleep(frame_duration); 133 base::PlatformThread::Sleep(frame_duration);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 << "Platform encoder chose to emit a " 240 << "Platform encoder chose to emit a "
242 << (have_key_frame ? "key" : "delta") 241 << (have_key_frame ? "key" : "delta")
243 << " frame instead of the expected kind @ frame_id=" 242 << " frame instead of the expected kind @ frame_id="
244 << encoded_frame->frame_id; 243 << encoded_frame->frame_id;
245 LOG_IF(WARNING, encoded_frame->data.empty()) 244 LOG_IF(WARNING, encoded_frame->data.empty())
246 << "Platform encoder returned an empty frame @ frame_id=" 245 << "Platform encoder returned an empty frame @ frame_id="
247 << encoded_frame->frame_id; 246 << encoded_frame->frame_id;
248 } else { 247 } else {
249 if (expected_frame_id != expected_last_referenced_frame_id) { 248 if (expected_frame_id != expected_last_referenced_frame_id) {
250 EXPECT_EQ(EncodedFrame::DEPENDENT, encoded_frame->dependency); 249 EXPECT_EQ(EncodedFrame::DEPENDENT, encoded_frame->dependency);
251 } else if (video_config_.video_codec_params 250 } else if (video_config_.max_number_of_video_buffers_used == 1) {
252 .max_number_of_video_buffers_used == 1) {
253 EXPECT_EQ(EncodedFrame::KEY, encoded_frame->dependency); 251 EXPECT_EQ(EncodedFrame::KEY, encoded_frame->dependency);
254 } 252 }
255 EXPECT_EQ(expected_last_referenced_frame_id, 253 EXPECT_EQ(expected_last_referenced_frame_id,
256 encoded_frame->referenced_frame_id); 254 encoded_frame->referenced_frame_id);
257 EXPECT_FALSE(encoded_frame->data.empty()); 255 EXPECT_FALSE(encoded_frame->data.empty());
258 ASSERT_TRUE(std::isfinite(encoded_frame->encoder_utilization)); 256 ASSERT_TRUE(std::isfinite(encoded_frame->encoder_utilization));
259 EXPECT_LE(0.0, encoded_frame->encoder_utilization); 257 EXPECT_LE(0.0, encoded_frame->encoder_utilization);
260 ASSERT_TRUE(std::isfinite(encoded_frame->lossy_utilization)); 258 ASSERT_TRUE(std::isfinite(encoded_frame->lossy_utilization));
261 EXPECT_LE(0.0, encoded_frame->lossy_utilization); 259 EXPECT_LE(0.0, encoded_frame->lossy_utilization);
262 } 260 }
263 261
264 ++count_frames_delivered_; 262 ++count_frames_delivered_;
265 } 263 }
266 264
267 base::SimpleTestTickClock* const testing_clock_; // Owned by CastEnvironment. 265 base::SimpleTestTickClock* const testing_clock_; // Owned by CastEnvironment.
268 const scoped_refptr<FakeSingleThreadTaskRunner> task_runner_; 266 const scoped_refptr<FakeSingleThreadTaskRunner> task_runner_;
269 const scoped_refptr<CastEnvironment> cast_environment_; 267 const scoped_refptr<CastEnvironment> cast_environment_;
270 FrameSenderConfig video_config_; 268 VideoSenderConfig video_config_;
271 std::unique_ptr<FakeVideoEncodeAcceleratorFactory> vea_factory_; 269 std::unique_ptr<FakeVideoEncodeAcceleratorFactory> vea_factory_;
272 base::TimeTicks first_frame_time_; 270 base::TimeTicks first_frame_time_;
273 OperationalStatus operational_status_; 271 OperationalStatus operational_status_;
274 std::unique_ptr<VideoEncoder> video_encoder_; 272 std::unique_ptr<VideoEncoder> video_encoder_;
275 std::unique_ptr<VideoFrameFactory> video_frame_factory_; 273 std::unique_ptr<VideoFrameFactory> video_frame_factory_;
276 274
277 int count_frames_delivered_; 275 int count_frames_delivered_;
278 276
279 DISALLOW_COPY_AND_ASSIGN(VideoEncoderTest); 277 DISALLOW_COPY_AND_ASSIGN(VideoEncoderTest);
280 }; 278 };
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 std::vector<std::pair<Codec, bool>> DetermineEncodersToTest() { 407 std::vector<std::pair<Codec, bool>> DetermineEncodersToTest() {
410 std::vector<std::pair<Codec, bool>> values; 408 std::vector<std::pair<Codec, bool>> values;
411 // Fake encoder. 409 // Fake encoder.
412 values.push_back(std::make_pair(CODEC_VIDEO_FAKE, false)); 410 values.push_back(std::make_pair(CODEC_VIDEO_FAKE, false));
413 // Software VP8 encoder. 411 // Software VP8 encoder.
414 values.push_back(std::make_pair(CODEC_VIDEO_VP8, false)); 412 values.push_back(std::make_pair(CODEC_VIDEO_VP8, false));
415 // Hardware-accelerated encoder (faked). 413 // Hardware-accelerated encoder (faked).
416 values.push_back(std::make_pair(CODEC_VIDEO_VP8, true)); 414 values.push_back(std::make_pair(CODEC_VIDEO_VP8, true));
417 #if defined(OS_MACOSX) 415 #if defined(OS_MACOSX)
418 // VideoToolbox encoder (when VideoToolbox is present). 416 // VideoToolbox encoder (when VideoToolbox is present).
419 FrameSenderConfig video_config = GetDefaultVideoSenderConfig(); 417 VideoSenderConfig video_config = GetDefaultVideoSenderConfig();
420 video_config.use_external_encoder = false; 418 video_config.use_external_encoder = false;
421 video_config.codec = CODEC_VIDEO_H264; 419 video_config.codec = CODEC_VIDEO_H264;
422 if (H264VideoToolboxEncoder::IsSupported(video_config)) 420 if (H264VideoToolboxEncoder::IsSupported(video_config))
423 values.push_back(std::make_pair(CODEC_VIDEO_H264, false)); 421 values.push_back(std::make_pair(CODEC_VIDEO_H264, false));
424 #endif 422 #endif
425 return values; 423 return values;
426 } 424 }
427 } // namespace 425 } // namespace
428 426
429 INSTANTIATE_TEST_CASE_P( 427 INSTANTIATE_TEST_CASE_P(
430 , VideoEncoderTest, ::testing::ValuesIn(DetermineEncodersToTest())); 428 , VideoEncoderTest, ::testing::ValuesIn(DetermineEncodersToTest()));
431 429
432 } // namespace cast 430 } // namespace cast
433 } // namespace media 431 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/video_encoder_impl.cc ('k') | media/cast/sender/video_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698