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

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

Issue 1905763002: Convert //media/cast from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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_frame_factory.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"
6
5 #include <stdint.h> 7 #include <stdint.h>
6 8
9 #include <memory>
7 #include <utility> 10 #include <utility>
8 #include <vector> 11 #include <vector>
9 12
10 #include "base/bind.h" 13 #include "base/bind.h"
11 #include "base/macros.h" 14 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "build/build_config.h" 16 #include "build/build_config.h"
15 #include "media/base/fake_single_thread_task_runner.h" 17 #include "media/base/fake_single_thread_task_runner.h"
16 #include "media/base/video_frame.h" 18 #include "media/base/video_frame.h"
17 #include "media/cast/cast_defines.h" 19 #include "media/cast/cast_defines.h"
18 #include "media/cast/cast_environment.h" 20 #include "media/cast/cast_environment.h"
19 #include "media/cast/common/rtp_time.h" 21 #include "media/cast/common/rtp_time.h"
20 #include "media/cast/sender/fake_video_encode_accelerator_factory.h" 22 #include "media/cast/sender/fake_video_encode_accelerator_factory.h"
21 #include "media/cast/sender/video_encoder.h"
22 #include "media/cast/sender/video_frame_factory.h" 23 #include "media/cast/sender/video_frame_factory.h"
23 #include "media/cast/test/utility/default_config.h" 24 #include "media/cast/test/utility/default_config.h"
24 #include "media/cast/test/utility/video_utility.h" 25 #include "media/cast/test/utility/video_utility.h"
25 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
26 27
27 #if defined(OS_MACOSX) 28 #if defined(OS_MACOSX)
28 #include "media/cast/sender/h264_vt_encoder.h" 29 #include "media/cast/sender/h264_vt_encoder.h"
29 #endif 30 #endif
30 31
31 namespace media { 32 namespace media {
32 namespace cast { 33 namespace cast {
33 34
34 class VideoEncoderTest 35 class VideoEncoderTest
35 : public ::testing::TestWithParam<std::pair<Codec, bool>> { 36 : public ::testing::TestWithParam<std::pair<Codec, bool>> {
36 protected: 37 protected:
37 VideoEncoderTest() 38 VideoEncoderTest()
38 : testing_clock_(new base::SimpleTestTickClock()), 39 : testing_clock_(new base::SimpleTestTickClock()),
39 task_runner_(new FakeSingleThreadTaskRunner(testing_clock_)), 40 task_runner_(new FakeSingleThreadTaskRunner(testing_clock_)),
40 cast_environment_( 41 cast_environment_(new CastEnvironment(
41 new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_), 42 std::unique_ptr<base::TickClock>(testing_clock_),
42 task_runner_, 43 task_runner_,
43 task_runner_, 44 task_runner_,
44 task_runner_)), 45 task_runner_)),
45 video_config_(GetDefaultVideoSenderConfig()), 46 video_config_(GetDefaultVideoSenderConfig()),
46 operational_status_(STATUS_UNINITIALIZED), 47 operational_status_(STATUS_UNINITIALIZED),
47 count_frames_delivered_(0) { 48 count_frames_delivered_(0) {
48 testing_clock_->Advance(base::TimeTicks::Now() - base::TimeTicks()); 49 testing_clock_->Advance(base::TimeTicks::Now() - base::TimeTicks());
49 first_frame_time_ = testing_clock_->NowTicks(); 50 first_frame_time_ = testing_clock_->NowTicks();
50 } 51 }
51 52
52 ~VideoEncoderTest() override {} 53 ~VideoEncoderTest() override {}
53 54
54 void SetUp() final { 55 void SetUp() final {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 operational_status_ == STATUS_INITIALIZED); 208 operational_status_ == STATUS_INITIALIZED);
208 209
209 // Create the VideoFrameFactory the first time status changes to 210 // Create the VideoFrameFactory the first time status changes to
210 // STATUS_INITIALIZED. 211 // STATUS_INITIALIZED.
211 if (operational_status_ == STATUS_INITIALIZED && !video_frame_factory_) 212 if (operational_status_ == STATUS_INITIALIZED && !video_frame_factory_)
212 video_frame_factory_ = video_encoder_->CreateVideoFrameFactory(); 213 video_frame_factory_ = video_encoder_->CreateVideoFrameFactory();
213 } 214 }
214 215
215 // Checks that |encoded_frame| matches expected values. This is the method 216 // Checks that |encoded_frame| matches expected values. This is the method
216 // bound in the callback returned from EncodeAndCheckDelivery(). 217 // bound in the callback returned from EncodeAndCheckDelivery().
217 void DeliverEncodedVideoFrame(uint32_t expected_frame_id, 218 void DeliverEncodedVideoFrame(
218 uint32_t expected_last_referenced_frame_id, 219 uint32_t expected_frame_id,
219 RtpTimeTicks expected_rtp_timestamp, 220 uint32_t expected_last_referenced_frame_id,
220 const base::TimeTicks& expected_reference_time, 221 RtpTimeTicks expected_rtp_timestamp,
221 scoped_ptr<SenderEncodedFrame> encoded_frame) { 222 const base::TimeTicks& expected_reference_time,
223 std::unique_ptr<SenderEncodedFrame> encoded_frame) {
222 EXPECT_TRUE(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 224 EXPECT_TRUE(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
223 225
224 EXPECT_EQ(expected_frame_id, encoded_frame->frame_id); 226 EXPECT_EQ(expected_frame_id, encoded_frame->frame_id);
225 EXPECT_EQ(expected_rtp_timestamp, encoded_frame->rtp_timestamp); 227 EXPECT_EQ(expected_rtp_timestamp, encoded_frame->rtp_timestamp);
226 EXPECT_EQ(expected_reference_time, encoded_frame->reference_time); 228 EXPECT_EQ(expected_reference_time, encoded_frame->reference_time);
227 229
228 // The platform encoders are "black boxes" and may choose to vend key frames 230 // The platform encoders are "black boxes" and may choose to vend key frames
229 // and/or empty data at any time. The software encoders, however, should 231 // and/or empty data at any time. The software encoders, however, should
230 // strictly adhere to expected behavior. 232 // strictly adhere to expected behavior.
231 if (is_testing_platform_encoder()) { 233 if (is_testing_platform_encoder()) {
(...skipping 26 matching lines...) Expand all
258 EXPECT_LE(0.0, encoded_frame->lossy_utilization); 260 EXPECT_LE(0.0, encoded_frame->lossy_utilization);
259 } 261 }
260 262
261 ++count_frames_delivered_; 263 ++count_frames_delivered_;
262 } 264 }
263 265
264 base::SimpleTestTickClock* const testing_clock_; // Owned by CastEnvironment. 266 base::SimpleTestTickClock* const testing_clock_; // Owned by CastEnvironment.
265 const scoped_refptr<FakeSingleThreadTaskRunner> task_runner_; 267 const scoped_refptr<FakeSingleThreadTaskRunner> task_runner_;
266 const scoped_refptr<CastEnvironment> cast_environment_; 268 const scoped_refptr<CastEnvironment> cast_environment_;
267 VideoSenderConfig video_config_; 269 VideoSenderConfig video_config_;
268 scoped_ptr<FakeVideoEncodeAcceleratorFactory> vea_factory_; 270 std::unique_ptr<FakeVideoEncodeAcceleratorFactory> vea_factory_;
269 base::TimeTicks first_frame_time_; 271 base::TimeTicks first_frame_time_;
270 OperationalStatus operational_status_; 272 OperationalStatus operational_status_;
271 scoped_ptr<VideoEncoder> video_encoder_; 273 std::unique_ptr<VideoEncoder> video_encoder_;
272 scoped_ptr<VideoFrameFactory> video_frame_factory_; 274 std::unique_ptr<VideoFrameFactory> video_frame_factory_;
273 275
274 int count_frames_delivered_; 276 int count_frames_delivered_;
275 277
276 DISALLOW_COPY_AND_ASSIGN(VideoEncoderTest); 278 DISALLOW_COPY_AND_ASSIGN(VideoEncoderTest);
277 }; 279 };
278 280
279 // A simple test to encode three frames of video, expecting to see one key frame 281 // A simple test to encode three frames of video, expecting to see one key frame
280 // followed by two delta frames. 282 // followed by two delta frames.
281 TEST_P(VideoEncoderTest, GeneratesKeyFrameThenOnlyDeltaFrames) { 283 TEST_P(VideoEncoderTest, GeneratesKeyFrameThenOnlyDeltaFrames) {
282 CreateEncoder(); 284 CreateEncoder();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 #endif 421 #endif
420 return values; 422 return values;
421 } 423 }
422 } // namespace 424 } // namespace
423 425
424 INSTANTIATE_TEST_CASE_P( 426 INSTANTIATE_TEST_CASE_P(
425 , VideoEncoderTest, ::testing::ValuesIn(DetermineEncodersToTest())); 427 , VideoEncoderTest, ::testing::ValuesIn(DetermineEncodersToTest()));
426 428
427 } // namespace cast 429 } // namespace cast
428 } // namespace media 430 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/video_encoder_impl.cc ('k') | media/cast/sender/video_frame_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698