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

Side by Side Diff: media/cast/sender/h264_vt_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
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <queue> 7 #include <queue>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 void PushExpectation(uint32_t expected_frame_id, 90 void PushExpectation(uint32_t expected_frame_id,
91 uint32_t expected_last_referenced_frame_id, 91 uint32_t expected_last_referenced_frame_id,
92 RtpTimeTicks expected_rtp_timestamp, 92 RtpTimeTicks expected_rtp_timestamp,
93 const base::TimeTicks& expected_reference_time) { 93 const base::TimeTicks& expected_reference_time) {
94 expectations_.push(Expectation{expected_frame_id, 94 expectations_.push(Expectation{expected_frame_id,
95 expected_last_referenced_frame_id, 95 expected_last_referenced_frame_id,
96 expected_rtp_timestamp, 96 expected_rtp_timestamp,
97 expected_reference_time}); 97 expected_reference_time});
98 } 98 }
99 99
100 void CompareFrameWithExpected(scoped_ptr<SenderEncodedFrame> encoded_frame) { 100 void CompareFrameWithExpected(
101 std::unique_ptr<SenderEncodedFrame> encoded_frame) {
101 ASSERT_LT(0u, expectations_.size()); 102 ASSERT_LT(0u, expectations_.size());
102 auto e = expectations_.front(); 103 auto e = expectations_.front();
103 expectations_.pop(); 104 expectations_.pop();
104 if (e.expected_frame_id != e.expected_last_referenced_frame_id) { 105 if (e.expected_frame_id != e.expected_last_referenced_frame_id) {
105 EXPECT_EQ(EncodedFrame::DEPENDENT, encoded_frame->dependency); 106 EXPECT_EQ(EncodedFrame::DEPENDENT, encoded_frame->dependency);
106 } else { 107 } else {
107 EXPECT_EQ(EncodedFrame::KEY, encoded_frame->dependency); 108 EXPECT_EQ(EncodedFrame::KEY, encoded_frame->dependency);
108 } 109 }
109 EXPECT_EQ(e.expected_frame_id, encoded_frame->frame_id); 110 EXPECT_EQ(e.expected_frame_id, encoded_frame->frame_id);
110 EXPECT_EQ(e.expected_last_referenced_frame_id, 111 EXPECT_EQ(e.expected_last_referenced_frame_id,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 base::Bind(&EndToEndFrameChecker::CompareFrameWithExpected, 146 base::Bind(&EndToEndFrameChecker::CompareFrameWithExpected,
146 base::Unretained(this))); 147 base::Unretained(this)));
147 base::MessageLoop::current()->RunUntilIdle(); 148 base::MessageLoop::current()->RunUntilIdle();
148 EXPECT_TRUE(decoder_init_result); 149 EXPECT_TRUE(decoder_init_result);
149 } 150 }
150 151
151 void PushExpectation(const scoped_refptr<VideoFrame>& frame) { 152 void PushExpectation(const scoped_refptr<VideoFrame>& frame) {
152 expectations_.push(frame); 153 expectations_.push(frame);
153 } 154 }
154 155
155 void EncodeDone(scoped_ptr<SenderEncodedFrame> encoded_frame) { 156 void EncodeDone(std::unique_ptr<SenderEncodedFrame> encoded_frame) {
156 auto buffer = DecoderBuffer::CopyFrom(encoded_frame->bytes(), 157 auto buffer = DecoderBuffer::CopyFrom(encoded_frame->bytes(),
157 encoded_frame->data.size()); 158 encoded_frame->data.size());
158 decoder_.Decode(buffer, base::Bind(&EndToEndFrameChecker::DecodeDone, 159 decoder_.Decode(buffer, base::Bind(&EndToEndFrameChecker::DecodeDone,
159 base::Unretained(this))); 160 base::Unretained(this)));
160 } 161 }
161 162
162 void CompareFrameWithExpected(const scoped_refptr<VideoFrame>& frame) { 163 void CompareFrameWithExpected(const scoped_refptr<VideoFrame>& frame) {
163 ASSERT_LT(0u, expectations_.size()); 164 ASSERT_LT(0u, expectations_.size());
164 auto& e = expectations_.front(); 165 auto& e = expectations_.front();
165 expectations_.pop(); 166 expectations_.pop();
(...skipping 25 matching lines...) Expand all
191 ASSERT_TRUE(cv_pixel_buffer); 192 ASSERT_TRUE(cv_pixel_buffer);
192 CVPixelBufferLockBaseAddress(cv_pixel_buffer, 0); 193 CVPixelBufferLockBaseAddress(cv_pixel_buffer, 0);
193 auto ptr = CVPixelBufferGetBaseAddressOfPlane(cv_pixel_buffer, 0); 194 auto ptr = CVPixelBufferGetBaseAddressOfPlane(cv_pixel_buffer, 0);
194 ASSERT_TRUE(ptr); 195 ASSERT_TRUE(ptr);
195 memset(ptr, 0xfe, CVPixelBufferGetBytesPerRowOfPlane(cv_pixel_buffer, 0) * 196 memset(ptr, 0xfe, CVPixelBufferGetBytesPerRowOfPlane(cv_pixel_buffer, 0) *
196 CVPixelBufferGetHeightOfPlane(cv_pixel_buffer, 0)); 197 CVPixelBufferGetHeightOfPlane(cv_pixel_buffer, 0));
197 CVPixelBufferUnlockBaseAddress(cv_pixel_buffer, 0); 198 CVPixelBufferUnlockBaseAddress(cv_pixel_buffer, 0);
198 } 199 }
199 200
200 void NoopFrameEncodedCallback( 201 void NoopFrameEncodedCallback(
201 scoped_ptr<media::cast::SenderEncodedFrame> /*encoded_frame*/) { 202 std::unique_ptr<media::cast::SenderEncodedFrame> /*encoded_frame*/) {}
202 }
203 203
204 class TestPowerSource : public base::PowerMonitorSource { 204 class TestPowerSource : public base::PowerMonitorSource {
205 public: 205 public:
206 void GenerateSuspendEvent() { 206 void GenerateSuspendEvent() {
207 ProcessPowerEvent(SUSPEND_EVENT); 207 ProcessPowerEvent(SUSPEND_EVENT);
208 base::MessageLoop::current()->RunUntilIdle(); 208 base::MessageLoop::current()->RunUntilIdle();
209 } 209 }
210 void GenerateResumeEvent() { 210 void GenerateResumeEvent() {
211 ProcessPowerEvent(RESUME_EVENT); 211 ProcessPowerEvent(RESUME_EVENT);
212 base::MessageLoop::current()->RunUntilIdle(); 212 base::MessageLoop::current()->RunUntilIdle();
213 } 213 }
214 214
215 private: 215 private:
216 bool IsOnBatteryPowerImpl() final { return false; } 216 bool IsOnBatteryPowerImpl() final { return false; }
217 }; 217 };
218 218
219 class H264VideoToolboxEncoderTest : public ::testing::Test { 219 class H264VideoToolboxEncoderTest : public ::testing::Test {
220 protected: 220 protected:
221 H264VideoToolboxEncoderTest() = default; 221 H264VideoToolboxEncoderTest() = default;
222 222
223 void SetUp() final { 223 void SetUp() final {
224 clock_ = new base::SimpleTestTickClock(); 224 clock_ = new base::SimpleTestTickClock();
225 clock_->Advance(base::TimeTicks::Now() - base::TimeTicks()); 225 clock_->Advance(base::TimeTicks::Now() - base::TimeTicks());
226 226
227 power_source_ = new TestPowerSource(); 227 power_source_ = new TestPowerSource();
228 power_monitor_.reset( 228 power_monitor_.reset(new base::PowerMonitor(
229 new base::PowerMonitor(scoped_ptr<TestPowerSource>(power_source_))); 229 std::unique_ptr<TestPowerSource>(power_source_)));
230 230
231 cast_environment_ = new CastEnvironment( 231 cast_environment_ = new CastEnvironment(
232 scoped_ptr<base::TickClock>(clock_), message_loop_.task_runner(), 232 std::unique_ptr<base::TickClock>(clock_), message_loop_.task_runner(),
233 message_loop_.task_runner(), message_loop_.task_runner()); 233 message_loop_.task_runner(), message_loop_.task_runner());
234 encoder_.reset(new H264VideoToolboxEncoder( 234 encoder_.reset(new H264VideoToolboxEncoder(
235 cast_environment_, video_sender_config_, 235 cast_environment_, video_sender_config_,
236 base::Bind(&SaveOperationalStatus, &operational_status_))); 236 base::Bind(&SaveOperationalStatus, &operational_status_)));
237 message_loop_.RunUntilIdle(); 237 message_loop_.RunUntilIdle();
238 EXPECT_EQ(STATUS_INITIALIZED, operational_status_); 238 EXPECT_EQ(STATUS_INITIALIZED, operational_status_);
239 } 239 }
240 240
241 void TearDown() final { 241 void TearDown() final {
242 encoder_.reset(); 242 encoder_.reset();
(...skipping 18 matching lines...) Expand all
261 } 261 }
262 262
263 static void TearDownTestCase() { frame_ = nullptr; } 263 static void TearDownTestCase() { frame_ = nullptr; }
264 264
265 static scoped_refptr<media::VideoFrame> frame_; 265 static scoped_refptr<media::VideoFrame> frame_;
266 static VideoSenderConfig video_sender_config_; 266 static VideoSenderConfig video_sender_config_;
267 267
268 base::SimpleTestTickClock* clock_; // Owned by CastEnvironment. 268 base::SimpleTestTickClock* clock_; // Owned by CastEnvironment.
269 base::MessageLoop message_loop_; 269 base::MessageLoop message_loop_;
270 scoped_refptr<CastEnvironment> cast_environment_; 270 scoped_refptr<CastEnvironment> cast_environment_;
271 scoped_ptr<VideoEncoder> encoder_; 271 std::unique_ptr<VideoEncoder> encoder_;
272 OperationalStatus operational_status_; 272 OperationalStatus operational_status_;
273 TestPowerSource* power_source_; // Owned by the power monitor. 273 TestPowerSource* power_source_; // Owned by the power monitor.
274 scoped_ptr<base::PowerMonitor> power_monitor_; 274 std::unique_ptr<base::PowerMonitor> power_monitor_;
275 275
276 private: 276 private:
277 DISALLOW_COPY_AND_ASSIGN(H264VideoToolboxEncoderTest); 277 DISALLOW_COPY_AND_ASSIGN(H264VideoToolboxEncoderTest);
278 }; 278 };
279 279
280 // static 280 // static
281 scoped_refptr<media::VideoFrame> H264VideoToolboxEncoderTest::frame_; 281 scoped_refptr<media::VideoFrame> H264VideoToolboxEncoderTest::frame_;
282 VideoSenderConfig H264VideoToolboxEncoderTest::video_sender_config_; 282 VideoSenderConfig H264VideoToolboxEncoderTest::video_sender_config_;
283 283
284 TEST_F(H264VideoToolboxEncoderTest, CheckFrameMetadataSequence) { 284 TEST_F(H264VideoToolboxEncoderTest, CheckFrameMetadataSequence) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 gfx::Size(kVideoWidth, kVideoHeight), base::TimeDelta())); 409 gfx::Size(kVideoWidth, kVideoHeight), base::TimeDelta()));
410 410
411 // After a power resume event, the factory should produce frames right away 411 // After a power resume event, the factory should produce frames right away
412 // because the encoder re-initializes on its own. 412 // because the encoder re-initializes on its own.
413 power_source_->GenerateResumeEvent(); 413 power_source_->GenerateResumeEvent();
414 CreateFrameAndMemsetPlane(video_frame_factory.get()); 414 CreateFrameAndMemsetPlane(video_frame_factory.get());
415 } 415 }
416 416
417 } // namespace cast 417 } // namespace cast
418 } // namespace media 418 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/h264_vt_encoder.cc ('k') | media/cast/sender/size_adaptable_video_encoder_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698