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

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

Issue 1515433002: Replace uses of raw uint32's with a type-checked RtpTimeTicks data type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Speculative workaround fix for win8_chromium_ng compile error. Created 4 years, 11 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/audio_encoder.cc ('k') | media/cast/sender/audio_sender.cc » ('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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <sstream> 8 #include <sstream>
9 #include <string> 9 #include <string>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "media/base/audio_bus.h" 16 #include "media/base/audio_bus.h"
17 #include "media/base/media.h" 17 #include "media/base/media.h"
18 #include "media/cast/cast_config.h" 18 #include "media/cast/cast_config.h"
19 #include "media/cast/cast_environment.h" 19 #include "media/cast/cast_environment.h"
20 #include "media/cast/common/rtp_time.h"
20 #include "media/cast/sender/audio_encoder.h" 21 #include "media/cast/sender/audio_encoder.h"
21 #include "media/cast/test/fake_single_thread_task_runner.h" 22 #include "media/cast/test/fake_single_thread_task_runner.h"
22 #include "media/cast/test/utility/audio_utility.h" 23 #include "media/cast/test/utility/audio_utility.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 25
25 namespace media { 26 namespace media {
26 namespace cast { 27 namespace cast {
27 28
28 static const int kNumChannels = 2; 29 static const int kNumChannels = 2;
29 30
30 namespace { 31 namespace {
31 32
32 class TestEncodedAudioFrameReceiver { 33 class TestEncodedAudioFrameReceiver {
33 public: 34 public:
34 TestEncodedAudioFrameReceiver() : frames_received_(0), rtp_lower_bound_(0) {} 35 TestEncodedAudioFrameReceiver() : frames_received_(0) {}
35 virtual ~TestEncodedAudioFrameReceiver() {} 36 virtual ~TestEncodedAudioFrameReceiver() {}
36 37
37 int frames_received() const { return frames_received_; } 38 int frames_received() const { return frames_received_; }
38 39
39 void SetCaptureTimeBounds(const base::TimeTicks& lower_bound, 40 void SetCaptureTimeBounds(const base::TimeTicks& lower_bound,
40 const base::TimeTicks& upper_bound) { 41 const base::TimeTicks& upper_bound) {
41 lower_bound_ = lower_bound; 42 lower_bound_ = lower_bound;
42 upper_bound_ = upper_bound; 43 upper_bound_ = upper_bound;
43 } 44 }
44 45
45 void SetSamplesPerFrame(int samples_per_frame) { 46 void SetSamplesPerFrame(int samples_per_frame) {
46 samples_per_frame_ = samples_per_frame; 47 samples_per_frame_ = samples_per_frame;
47 } 48 }
48 49
49 void FrameEncoded(scoped_ptr<SenderEncodedFrame> encoded_frame, 50 void FrameEncoded(scoped_ptr<SenderEncodedFrame> encoded_frame,
50 int samples_skipped) { 51 int samples_skipped) {
51 EXPECT_EQ(encoded_frame->dependency, EncodedFrame::KEY); 52 EXPECT_EQ(encoded_frame->dependency, EncodedFrame::KEY);
52 EXPECT_EQ(static_cast<uint8_t>(frames_received_ & 0xff), 53 EXPECT_EQ(static_cast<uint8_t>(frames_received_ & 0xff),
53 encoded_frame->frame_id); 54 encoded_frame->frame_id);
54 EXPECT_EQ(encoded_frame->frame_id, encoded_frame->referenced_frame_id); 55 EXPECT_EQ(encoded_frame->frame_id, encoded_frame->referenced_frame_id);
55 // RTP timestamps should be monotonically increasing and integer multiples 56 // RTP timestamps should be monotonically increasing and integer multiples
56 // of the fixed frame size. 57 // of the fixed frame size.
57 EXPECT_LE(rtp_lower_bound_, encoded_frame->rtp_timestamp); 58 EXPECT_LE(rtp_lower_bound_, encoded_frame->rtp_timestamp);
58 rtp_lower_bound_ = encoded_frame->rtp_timestamp; 59 rtp_lower_bound_ = encoded_frame->rtp_timestamp;
59 EXPECT_EQ(0u, encoded_frame->rtp_timestamp % samples_per_frame_); 60 EXPECT_EQ(RtpTimeDelta(), (encoded_frame->rtp_timestamp - RtpTimeTicks()) %
61 RtpTimeDelta::FromTicks(samples_per_frame_));
60 EXPECT_TRUE(!encoded_frame->data.empty()); 62 EXPECT_TRUE(!encoded_frame->data.empty());
61 63
62 EXPECT_LE(lower_bound_, encoded_frame->reference_time); 64 EXPECT_LE(lower_bound_, encoded_frame->reference_time);
63 lower_bound_ = encoded_frame->reference_time; 65 lower_bound_ = encoded_frame->reference_time;
64 EXPECT_GT(upper_bound_, encoded_frame->reference_time); 66 EXPECT_GT(upper_bound_, encoded_frame->reference_time);
65 67
66 EXPECT_LE(0.0, encoded_frame->deadline_utilization); 68 EXPECT_LE(0.0, encoded_frame->deadline_utilization);
67 EXPECT_EQ(-1.0, encoded_frame->lossy_utilization); 69 EXPECT_EQ(-1.0, encoded_frame->lossy_utilization);
68 70
69 ++frames_received_; 71 ++frames_received_;
70 } 72 }
71 73
72 private: 74 private:
73 int frames_received_; 75 int frames_received_;
74 uint32_t rtp_lower_bound_; 76 RtpTimeTicks rtp_lower_bound_;
75 int samples_per_frame_; 77 int samples_per_frame_;
76 base::TimeTicks lower_bound_; 78 base::TimeTicks lower_bound_;
77 base::TimeTicks upper_bound_; 79 base::TimeTicks upper_bound_;
78 80
79 DISALLOW_COPY_AND_ASSIGN(TestEncodedAudioFrameReceiver); 81 DISALLOW_COPY_AND_ASSIGN(TestEncodedAudioFrameReceiver);
80 }; 82 };
81 83
82 struct TestScenario { 84 struct TestScenario {
83 const int64_t* durations_in_ms; 85 const int64_t* durations_in_ms;
84 size_t num_durations; 86 size_t num_durations;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 TestScenario(kManyCalls_Mixed2, arraysize(kManyCalls_Mixed2)), 247 TestScenario(kManyCalls_Mixed2, arraysize(kManyCalls_Mixed2)),
246 TestScenario(kManyCalls_Mixed3, arraysize(kManyCalls_Mixed3)), 248 TestScenario(kManyCalls_Mixed3, arraysize(kManyCalls_Mixed3)),
247 TestScenario(kManyCalls_Mixed4, arraysize(kManyCalls_Mixed4)), 249 TestScenario(kManyCalls_Mixed4, arraysize(kManyCalls_Mixed4)),
248 TestScenario(kManyCalls_Mixed5, arraysize(kManyCalls_Mixed5)), 250 TestScenario(kManyCalls_Mixed5, arraysize(kManyCalls_Mixed5)),
249 TestScenario(kOneBigUnderrun, arraysize(kOneBigUnderrun)), 251 TestScenario(kOneBigUnderrun, arraysize(kOneBigUnderrun)),
250 TestScenario(kTwoBigUnderruns, arraysize(kTwoBigUnderruns)), 252 TestScenario(kTwoBigUnderruns, arraysize(kTwoBigUnderruns)),
251 TestScenario(kMixedUnderruns, arraysize(kMixedUnderruns)))); 253 TestScenario(kMixedUnderruns, arraysize(kMixedUnderruns))));
252 254
253 } // namespace cast 255 } // namespace cast
254 } // namespace media 256 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/audio_encoder.cc ('k') | media/cast/sender/audio_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698