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/h264_vt_encoder_unittest.cc

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years 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 <queue> 5 #include <queue>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/power_monitor/power_monitor.h" 10 #include "base/power_monitor/power_monitor.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 OperationalStatus in_status) { 77 OperationalStatus in_status) {
78 *out_status = in_status; 78 *out_status = in_status;
79 } 79 }
80 80
81 class MetadataRecorder : public base::RefCountedThreadSafe<MetadataRecorder> { 81 class MetadataRecorder : public base::RefCountedThreadSafe<MetadataRecorder> {
82 public: 82 public:
83 MetadataRecorder() : count_frames_delivered_(0) {} 83 MetadataRecorder() : count_frames_delivered_(0) {}
84 84
85 int count_frames_delivered() const { return count_frames_delivered_; } 85 int count_frames_delivered() const { return count_frames_delivered_; }
86 86
87 void PushExpectation(uint32 expected_frame_id, 87 void PushExpectation(uint32_t expected_frame_id,
88 uint32 expected_last_referenced_frame_id, 88 uint32_t expected_last_referenced_frame_id,
89 uint32 expected_rtp_timestamp, 89 uint32_t expected_rtp_timestamp,
90 const base::TimeTicks& expected_reference_time) { 90 const base::TimeTicks& expected_reference_time) {
91 expectations_.push(Expectation{expected_frame_id, 91 expectations_.push(Expectation{expected_frame_id,
92 expected_last_referenced_frame_id, 92 expected_last_referenced_frame_id,
93 expected_rtp_timestamp, 93 expected_rtp_timestamp,
94 expected_reference_time}); 94 expected_reference_time});
95 } 95 }
96 96
97 void CompareFrameWithExpected(scoped_ptr<SenderEncodedFrame> encoded_frame) { 97 void CompareFrameWithExpected(scoped_ptr<SenderEncodedFrame> encoded_frame) {
98 ASSERT_LT(0u, expectations_.size()); 98 ASSERT_LT(0u, expectations_.size());
99 auto e = expectations_.front(); 99 auto e = expectations_.front();
(...skipping 13 matching lines...) Expand all
113 ++count_frames_delivered_; 113 ++count_frames_delivered_;
114 } 114 }
115 115
116 private: 116 private:
117 friend class base::RefCountedThreadSafe<MetadataRecorder>; 117 friend class base::RefCountedThreadSafe<MetadataRecorder>;
118 virtual ~MetadataRecorder() {} 118 virtual ~MetadataRecorder() {}
119 119
120 int count_frames_delivered_; 120 int count_frames_delivered_;
121 121
122 struct Expectation { 122 struct Expectation {
123 uint32 expected_frame_id; 123 uint32_t expected_frame_id;
124 uint32 expected_last_referenced_frame_id; 124 uint32_t expected_last_referenced_frame_id;
125 uint32 expected_rtp_timestamp; 125 uint32_t expected_rtp_timestamp;
126 base::TimeTicks expected_reference_time; 126 base::TimeTicks expected_reference_time;
127 }; 127 };
128 std::queue<Expectation> expectations_; 128 std::queue<Expectation> expectations_;
129 129
130 DISALLOW_COPY_AND_ASSIGN(MetadataRecorder); 130 DISALLOW_COPY_AND_ASSIGN(MetadataRecorder);
131 }; 131 };
132 132
133 class EndToEndFrameChecker 133 class EndToEndFrameChecker
134 : public base::RefCountedThreadSafe<EndToEndFrameChecker> { 134 : public base::RefCountedThreadSafe<EndToEndFrameChecker> {
135 public: 135 public:
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 scoped_refptr<MetadataRecorder> metadata_recorder(new MetadataRecorder()); 285 scoped_refptr<MetadataRecorder> metadata_recorder(new MetadataRecorder());
286 VideoEncoder::FrameEncodedCallback cb = base::Bind( 286 VideoEncoder::FrameEncodedCallback cb = base::Bind(
287 &MetadataRecorder::CompareFrameWithExpected, metadata_recorder.get()); 287 &MetadataRecorder::CompareFrameWithExpected, metadata_recorder.get());
288 288
289 metadata_recorder->PushExpectation( 289 metadata_recorder->PushExpectation(
290 0, 0, TimeDeltaToRtpDelta(frame_->timestamp(), kVideoFrequency), 290 0, 0, TimeDeltaToRtpDelta(frame_->timestamp(), kVideoFrequency),
291 clock_->NowTicks()); 291 clock_->NowTicks());
292 EXPECT_TRUE(encoder_->EncodeVideoFrame(frame_, clock_->NowTicks(), cb)); 292 EXPECT_TRUE(encoder_->EncodeVideoFrame(frame_, clock_->NowTicks(), cb));
293 message_loop_.RunUntilIdle(); 293 message_loop_.RunUntilIdle();
294 294
295 for (uint32 frame_id = 1; frame_id < 10; ++frame_id) { 295 for (uint32_t frame_id = 1; frame_id < 10; ++frame_id) {
296 AdvanceClockAndVideoFrameTimestamp(); 296 AdvanceClockAndVideoFrameTimestamp();
297 metadata_recorder->PushExpectation( 297 metadata_recorder->PushExpectation(
298 frame_id, frame_id - 1, 298 frame_id, frame_id - 1,
299 TimeDeltaToRtpDelta(frame_->timestamp(), kVideoFrequency), 299 TimeDeltaToRtpDelta(frame_->timestamp(), kVideoFrequency),
300 clock_->NowTicks()); 300 clock_->NowTicks());
301 EXPECT_TRUE(encoder_->EncodeVideoFrame(frame_, clock_->NowTicks(), cb)); 301 EXPECT_TRUE(encoder_->EncodeVideoFrame(frame_, clock_->NowTicks(), cb));
302 } 302 }
303 303
304 encoder_.reset(); 304 encoder_.reset();
305 message_loop_.RunUntilIdle(); 305 message_loop_.RunUntilIdle();
306 306
307 EXPECT_EQ(10, metadata_recorder->count_frames_delivered()); 307 EXPECT_EQ(10, metadata_recorder->count_frames_delivered());
308 } 308 }
309 309
310 #if defined(USE_PROPRIETARY_CODECS) 310 #if defined(USE_PROPRIETARY_CODECS)
311 TEST_F(H264VideoToolboxEncoderTest, CheckFramesAreDecodable) { 311 TEST_F(H264VideoToolboxEncoderTest, CheckFramesAreDecodable) {
312 VideoDecoderConfig config(kCodecH264, H264PROFILE_MAIN, frame_->format(), 312 VideoDecoderConfig config(kCodecH264, H264PROFILE_MAIN, frame_->format(),
313 COLOR_SPACE_UNSPECIFIED, frame_->coded_size(), 313 COLOR_SPACE_UNSPECIFIED, frame_->coded_size(),
314 frame_->visible_rect(), frame_->natural_size(), 314 frame_->visible_rect(), frame_->natural_size(),
315 EmptyExtraData(), false); 315 EmptyExtraData(), false);
316 scoped_refptr<EndToEndFrameChecker> checker(new EndToEndFrameChecker(config)); 316 scoped_refptr<EndToEndFrameChecker> checker(new EndToEndFrameChecker(config));
317 317
318 VideoEncoder::FrameEncodedCallback cb = 318 VideoEncoder::FrameEncodedCallback cb =
319 base::Bind(&EndToEndFrameChecker::EncodeDone, checker.get()); 319 base::Bind(&EndToEndFrameChecker::EncodeDone, checker.get());
320 for (uint32 frame_id = 0; frame_id < 6; ++frame_id) { 320 for (uint32_t frame_id = 0; frame_id < 6; ++frame_id) {
321 checker->PushExpectation(frame_); 321 checker->PushExpectation(frame_);
322 EXPECT_TRUE(encoder_->EncodeVideoFrame(frame_, clock_->NowTicks(), cb)); 322 EXPECT_TRUE(encoder_->EncodeVideoFrame(frame_, clock_->NowTicks(), cb));
323 AdvanceClockAndVideoFrameTimestamp(); 323 AdvanceClockAndVideoFrameTimestamp();
324 } 324 }
325 325
326 encoder_.reset(); 326 encoder_.reset();
327 message_loop_.RunUntilIdle(); 327 message_loop_.RunUntilIdle();
328 328
329 EXPECT_EQ(5, checker->count_frames_checked()); 329 EXPECT_EQ(5, checker->count_frames_checked());
330 } 330 }
(...skipping 78 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

Powered by Google App Engine
This is Rietveld 408576698