OLD | NEW |
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 <sstream> | 7 #include <sstream> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 upper_bound_ = upper_bound; | 39 upper_bound_ = upper_bound; |
40 } | 40 } |
41 | 41 |
42 void SetSamplesPerFrame(int samples_per_frame) { | 42 void SetSamplesPerFrame(int samples_per_frame) { |
43 samples_per_frame_ = samples_per_frame; | 43 samples_per_frame_ = samples_per_frame; |
44 } | 44 } |
45 | 45 |
46 void FrameEncoded(scoped_ptr<SenderEncodedFrame> encoded_frame, | 46 void FrameEncoded(scoped_ptr<SenderEncodedFrame> encoded_frame, |
47 int samples_skipped) { | 47 int samples_skipped) { |
48 EXPECT_EQ(encoded_frame->dependency, EncodedFrame::KEY); | 48 EXPECT_EQ(encoded_frame->dependency, EncodedFrame::KEY); |
49 EXPECT_EQ(static_cast<uint8>(frames_received_ & 0xff), | 49 EXPECT_EQ(static_cast<uint8_t>(frames_received_ & 0xff), |
50 encoded_frame->frame_id); | 50 encoded_frame->frame_id); |
51 EXPECT_EQ(encoded_frame->frame_id, encoded_frame->referenced_frame_id); | 51 EXPECT_EQ(encoded_frame->frame_id, encoded_frame->referenced_frame_id); |
52 // RTP timestamps should be monotonically increasing and integer multiples | 52 // RTP timestamps should be monotonically increasing and integer multiples |
53 // of the fixed frame size. | 53 // of the fixed frame size. |
54 EXPECT_LE(rtp_lower_bound_, encoded_frame->rtp_timestamp); | 54 EXPECT_LE(rtp_lower_bound_, encoded_frame->rtp_timestamp); |
55 rtp_lower_bound_ = encoded_frame->rtp_timestamp; | 55 rtp_lower_bound_ = encoded_frame->rtp_timestamp; |
56 EXPECT_EQ(0u, encoded_frame->rtp_timestamp % samples_per_frame_); | 56 EXPECT_EQ(0u, encoded_frame->rtp_timestamp % samples_per_frame_); |
57 EXPECT_TRUE(!encoded_frame->data.empty()); | 57 EXPECT_TRUE(!encoded_frame->data.empty()); |
58 | 58 |
59 EXPECT_LE(lower_bound_, encoded_frame->reference_time); | 59 EXPECT_LE(lower_bound_, encoded_frame->reference_time); |
60 lower_bound_ = encoded_frame->reference_time; | 60 lower_bound_ = encoded_frame->reference_time; |
61 EXPECT_GT(upper_bound_, encoded_frame->reference_time); | 61 EXPECT_GT(upper_bound_, encoded_frame->reference_time); |
62 | 62 |
63 EXPECT_LE(0.0, encoded_frame->deadline_utilization); | 63 EXPECT_LE(0.0, encoded_frame->deadline_utilization); |
64 EXPECT_EQ(-1.0, encoded_frame->lossy_utilization); | 64 EXPECT_EQ(-1.0, encoded_frame->lossy_utilization); |
65 | 65 |
66 ++frames_received_; | 66 ++frames_received_; |
67 } | 67 } |
68 | 68 |
69 private: | 69 private: |
70 int frames_received_; | 70 int frames_received_; |
71 uint32 rtp_lower_bound_; | 71 uint32_t rtp_lower_bound_; |
72 int samples_per_frame_; | 72 int samples_per_frame_; |
73 base::TimeTicks lower_bound_; | 73 base::TimeTicks lower_bound_; |
74 base::TimeTicks upper_bound_; | 74 base::TimeTicks upper_bound_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(TestEncodedAudioFrameReceiver); | 76 DISALLOW_COPY_AND_ASSIGN(TestEncodedAudioFrameReceiver); |
77 }; | 77 }; |
78 | 78 |
79 struct TestScenario { | 79 struct TestScenario { |
80 const int64* durations_in_ms; | 80 const int64_t* durations_in_ms; |
81 size_t num_durations; | 81 size_t num_durations; |
82 | 82 |
83 TestScenario(const int64* d, size_t n) | 83 TestScenario(const int64_t* d, size_t n) |
84 : durations_in_ms(d), num_durations(n) {} | 84 : durations_in_ms(d), num_durations(n) {} |
85 | 85 |
86 std::string ToString() const { | 86 std::string ToString() const { |
87 std::ostringstream out; | 87 std::ostringstream out; |
88 for (size_t i = 0; i < num_durations; ++i) { | 88 for (size_t i = 0; i < num_durations; ++i) { |
89 if (i > 0) | 89 if (i > 0) |
90 out << ", "; | 90 out << ", "; |
91 out << durations_in_ms[i]; | 91 out << durations_in_ms[i]; |
92 } | 92 } |
93 return out.str(); | 93 return out.str(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 TEST_P(AudioEncoderTest, EncodePcm16) { | 184 TEST_P(AudioEncoderTest, EncodePcm16) { |
185 RunTestForCodec(CODEC_AUDIO_PCM16); | 185 RunTestForCodec(CODEC_AUDIO_PCM16); |
186 } | 186 } |
187 | 187 |
188 #if defined(OS_MACOSX) | 188 #if defined(OS_MACOSX) |
189 TEST_P(AudioEncoderTest, EncodeAac) { | 189 TEST_P(AudioEncoderTest, EncodeAac) { |
190 RunTestForCodec(CODEC_AUDIO_AAC); | 190 RunTestForCodec(CODEC_AUDIO_AAC); |
191 } | 191 } |
192 #endif | 192 #endif |
193 | 193 |
194 static const int64 kOneCall_3Millis[] = {3}; | 194 static const int64_t kOneCall_3Millis[] = {3}; |
195 static const int64 kOneCall_10Millis[] = {10}; | 195 static const int64_t kOneCall_10Millis[] = {10}; |
196 static const int64 kOneCall_13Millis[] = {13}; | 196 static const int64_t kOneCall_13Millis[] = {13}; |
197 static const int64 kOneCall_20Millis[] = {20}; | 197 static const int64_t kOneCall_20Millis[] = {20}; |
198 | 198 |
199 static const int64 kTwoCalls_3Millis[] = {3, 3}; | 199 static const int64_t kTwoCalls_3Millis[] = {3, 3}; |
200 static const int64 kTwoCalls_10Millis[] = {10, 10}; | 200 static const int64_t kTwoCalls_10Millis[] = {10, 10}; |
201 static const int64 kTwoCalls_Mixed1[] = {3, 10}; | 201 static const int64_t kTwoCalls_Mixed1[] = {3, 10}; |
202 static const int64 kTwoCalls_Mixed2[] = {10, 3}; | 202 static const int64_t kTwoCalls_Mixed2[] = {10, 3}; |
203 static const int64 kTwoCalls_Mixed3[] = {3, 17}; | 203 static const int64_t kTwoCalls_Mixed3[] = {3, 17}; |
204 static const int64 kTwoCalls_Mixed4[] = {17, 3}; | 204 static const int64_t kTwoCalls_Mixed4[] = {17, 3}; |
205 | 205 |
206 static const int64 kManyCalls_3Millis[] = {3, 3, 3, 3, 3, 3, 3, 3, | 206 static const int64_t kManyCalls_3Millis[] = {3, 3, 3, 3, 3, 3, 3, 3, |
207 3, 3, 3, 3, 3, 3, 3}; | 207 3, 3, 3, 3, 3, 3, 3}; |
208 static const int64 kManyCalls_10Millis[] = {10, 10, 10, 10, 10, 10, 10, 10, | 208 static const int64_t kManyCalls_10Millis[] = {10, 10, 10, 10, 10, 10, 10, 10, |
209 10, 10, 10, 10, 10, 10, 10}; | 209 10, 10, 10, 10, 10, 10, 10}; |
210 static const int64 kManyCalls_Mixed1[] = {3, 10, 3, 10, 3, 10, 3, 10, 3, | 210 static const int64_t kManyCalls_Mixed1[] = {3, 10, 3, 10, 3, 10, 3, 10, 3, |
211 10, 3, 10, 3, 10, 3, 10, 3, 10}; | 211 10, 3, 10, 3, 10, 3, 10, 3, 10}; |
212 static const int64 kManyCalls_Mixed2[] = {10, 3, 10, 3, 10, 3, 10, 3, 10, 3, | 212 static const int64_t kManyCalls_Mixed2[] = {10, 3, 10, 3, 10, 3, 10, 3, 10, 3, |
213 10, 3, 10, 3, 10, 3, 10, 3, 10, 3}; | 213 10, 3, 10, 3, 10, 3, 10, 3, 10, 3}; |
214 static const int64 kManyCalls_Mixed3[] = {3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, | 214 static const int64_t kManyCalls_Mixed3[] = {3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, |
215 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4}; | 215 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4}; |
216 static const int64 kManyCalls_Mixed4[] = {31, 4, 15, 9, 26, 53, 5, 8, 9, | 216 static const int64_t kManyCalls_Mixed4[] = {31, 4, 15, 9, 26, 53, 5, 8, 9, |
217 7, 9, 32, 38, 4, 62, 64, 3}; | 217 7, 9, 32, 38, 4, 62, 64, 3}; |
218 static const int64 kManyCalls_Mixed5[] = {3, 14, 15, 9, 26, 53, 58, 9, 7, | 218 static const int64_t kManyCalls_Mixed5[] = {3, 14, 15, 9, 26, 53, 58, 9, 7, |
219 9, 3, 23, 8, 4, 6, 2, 6, 43}; | 219 9, 3, 23, 8, 4, 6, 2, 6, 43}; |
220 | 220 |
221 static const int64 kOneBigUnderrun[] = {10, 10, 10, 10, -1000, 10, 10, 10}; | 221 static const int64_t kOneBigUnderrun[] = {10, 10, 10, 10, -1000, 10, 10, 10}; |
222 static const int64 kTwoBigUnderruns[] = {10, 10, 10, 10, -712, 10, 10, 10, | 222 static const int64_t kTwoBigUnderruns[] = {10, 10, 10, 10, -712, 10, |
223 -1311, 10, 10, 10}; | 223 10, 10, -1311, 10, 10, 10}; |
224 static const int64 kMixedUnderruns[] = {31, -64, 4, 15, 9, 26, -53, 5, 8, -9, | 224 static const int64_t kMixedUnderruns[] = {31, -64, 4, 15, 9, 26, -53, 5, 8, |
225 7, 9, 32, 38, -4, 62, -64, 3}; | 225 -9, 7, 9, 32, 38, -4, 62, -64, 3}; |
226 | 226 |
227 INSTANTIATE_TEST_CASE_P( | 227 INSTANTIATE_TEST_CASE_P( |
228 AudioEncoderTestScenarios, | 228 AudioEncoderTestScenarios, |
229 AudioEncoderTest, | 229 AudioEncoderTest, |
230 ::testing::Values( | 230 ::testing::Values( |
231 TestScenario(kOneCall_3Millis, arraysize(kOneCall_3Millis)), | 231 TestScenario(kOneCall_3Millis, arraysize(kOneCall_3Millis)), |
232 TestScenario(kOneCall_10Millis, arraysize(kOneCall_10Millis)), | 232 TestScenario(kOneCall_10Millis, arraysize(kOneCall_10Millis)), |
233 TestScenario(kOneCall_13Millis, arraysize(kOneCall_13Millis)), | 233 TestScenario(kOneCall_13Millis, arraysize(kOneCall_13Millis)), |
234 TestScenario(kOneCall_20Millis, arraysize(kOneCall_20Millis)), | 234 TestScenario(kOneCall_20Millis, arraysize(kOneCall_20Millis)), |
235 TestScenario(kTwoCalls_3Millis, arraysize(kTwoCalls_3Millis)), | 235 TestScenario(kTwoCalls_3Millis, arraysize(kTwoCalls_3Millis)), |
236 TestScenario(kTwoCalls_10Millis, arraysize(kTwoCalls_10Millis)), | 236 TestScenario(kTwoCalls_10Millis, arraysize(kTwoCalls_10Millis)), |
237 TestScenario(kTwoCalls_Mixed1, arraysize(kTwoCalls_Mixed1)), | 237 TestScenario(kTwoCalls_Mixed1, arraysize(kTwoCalls_Mixed1)), |
238 TestScenario(kTwoCalls_Mixed2, arraysize(kTwoCalls_Mixed2)), | 238 TestScenario(kTwoCalls_Mixed2, arraysize(kTwoCalls_Mixed2)), |
239 TestScenario(kTwoCalls_Mixed3, arraysize(kTwoCalls_Mixed3)), | 239 TestScenario(kTwoCalls_Mixed3, arraysize(kTwoCalls_Mixed3)), |
240 TestScenario(kTwoCalls_Mixed4, arraysize(kTwoCalls_Mixed4)), | 240 TestScenario(kTwoCalls_Mixed4, arraysize(kTwoCalls_Mixed4)), |
241 TestScenario(kManyCalls_3Millis, arraysize(kManyCalls_3Millis)), | 241 TestScenario(kManyCalls_3Millis, arraysize(kManyCalls_3Millis)), |
242 TestScenario(kManyCalls_10Millis, arraysize(kManyCalls_10Millis)), | 242 TestScenario(kManyCalls_10Millis, arraysize(kManyCalls_10Millis)), |
243 TestScenario(kManyCalls_Mixed1, arraysize(kManyCalls_Mixed1)), | 243 TestScenario(kManyCalls_Mixed1, arraysize(kManyCalls_Mixed1)), |
244 TestScenario(kManyCalls_Mixed2, arraysize(kManyCalls_Mixed2)), | 244 TestScenario(kManyCalls_Mixed2, arraysize(kManyCalls_Mixed2)), |
245 TestScenario(kManyCalls_Mixed3, arraysize(kManyCalls_Mixed3)), | 245 TestScenario(kManyCalls_Mixed3, arraysize(kManyCalls_Mixed3)), |
246 TestScenario(kManyCalls_Mixed4, arraysize(kManyCalls_Mixed4)), | 246 TestScenario(kManyCalls_Mixed4, arraysize(kManyCalls_Mixed4)), |
247 TestScenario(kManyCalls_Mixed5, arraysize(kManyCalls_Mixed5)), | 247 TestScenario(kManyCalls_Mixed5, arraysize(kManyCalls_Mixed5)), |
248 TestScenario(kOneBigUnderrun, arraysize(kOneBigUnderrun)), | 248 TestScenario(kOneBigUnderrun, arraysize(kOneBigUnderrun)), |
249 TestScenario(kTwoBigUnderruns, arraysize(kTwoBigUnderruns)), | 249 TestScenario(kTwoBigUnderruns, arraysize(kTwoBigUnderruns)), |
250 TestScenario(kMixedUnderruns, arraysize(kMixedUnderruns)))); | 250 TestScenario(kMixedUnderruns, arraysize(kMixedUnderruns)))); |
251 | 251 |
252 } // namespace cast | 252 } // namespace cast |
253 } // namespace media | 253 } // namespace media |
OLD | NEW |