OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h" | 14 #include "webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h" |
15 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h" | 15 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h" |
| 16 #include "webrtc/modules/include/module_common_types.h" |
16 | 17 |
17 namespace webrtc { | 18 namespace webrtc { |
18 namespace test { | 19 namespace test { |
19 | 20 |
20 using ::testing::_; | 21 using ::testing::_; |
21 using ::testing::SetArgPointee; | 22 using ::testing::SetArgPointee; |
22 using ::testing::Return; | 23 using ::testing::Return; |
23 | 24 |
24 class MockAudioDecoder final : public AudioDecoder { | 25 class MockAudioDecoder final : public AudioDecoder { |
25 public: | 26 public: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 77 |
77 private: | 78 private: |
78 const size_t num_channels_; | 79 const size_t num_channels_; |
79 bool fec_enabled_; | 80 bool fec_enabled_; |
80 }; | 81 }; |
81 | 82 |
82 class NetEqNetworkStatsTest : public NetEqExternalDecoderTest { | 83 class NetEqNetworkStatsTest : public NetEqExternalDecoderTest { |
83 public: | 84 public: |
84 static const int kPayloadSizeByte = 30; | 85 static const int kPayloadSizeByte = 30; |
85 static const int kFrameSizeMs = 20; | 86 static const int kFrameSizeMs = 20; |
86 static const int kMaxOutputSize = 960; // 10 ms * 48 kHz * 2 channels. | |
87 | 87 |
88 enum logic { | 88 enum logic { |
89 kIgnore, | 89 kIgnore, |
90 kEqual, | 90 kEqual, |
91 kSmallerThan, | 91 kSmallerThan, |
92 kLargerThan, | 92 kLargerThan, |
93 }; | 93 }; |
94 | 94 |
95 struct NetEqNetworkStatsCheck { | 95 struct NetEqNetworkStatsCheck { |
96 logic current_buffer_size_ms; | 96 logic current_buffer_size_ms; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 for (int k = 0; k < num_loops; ++k) { | 188 for (int k = 0; k < num_loops; ++k) { |
189 // Delay by one frame such that the FEC can come in. | 189 // Delay by one frame such that the FEC can come in. |
190 while (time_now + kFrameSizeMs >= next_send_time) { | 190 while (time_now + kFrameSizeMs >= next_send_time) { |
191 next_send_time = rtp_generator_->GetRtpHeader(kPayloadType, | 191 next_send_time = rtp_generator_->GetRtpHeader(kPayloadType, |
192 frame_size_samples_, | 192 frame_size_samples_, |
193 &rtp_header_); | 193 &rtp_header_); |
194 if (!Lost(next_send_time)) { | 194 if (!Lost(next_send_time)) { |
195 InsertPacket(rtp_header_, payload_, next_send_time); | 195 InsertPacket(rtp_header_, payload_, next_send_time); |
196 } | 196 } |
197 } | 197 } |
198 GetOutputAudio(kMaxOutputSize, output_, &output_type); | 198 GetOutputAudio(&output_frame_, &output_type); |
199 time_now += kOutputLengthMs; | 199 time_now += kOutputLengthMs; |
200 } | 200 } |
201 CheckNetworkStatistics(expects); | 201 CheckNetworkStatistics(expects); |
202 neteq()->FlushBuffers(); | 202 neteq()->FlushBuffers(); |
203 } | 203 } |
204 | 204 |
205 void DecodeFecTest() { | 205 void DecodeFecTest() { |
206 external_decoder_->set_fec_enabled(false); | 206 external_decoder_->set_fec_enabled(false); |
207 NetEqNetworkStatsCheck expects = { | 207 NetEqNetworkStatsCheck expects = { |
208 kIgnore, // current_buffer_size_ms | 208 kIgnore, // current_buffer_size_ms |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 262 |
263 private: | 263 private: |
264 MockAudioDecoder* external_decoder_; | 264 MockAudioDecoder* external_decoder_; |
265 const int samples_per_ms_; | 265 const int samples_per_ms_; |
266 const size_t frame_size_samples_; | 266 const size_t frame_size_samples_; |
267 std::unique_ptr<test::RtpGenerator> rtp_generator_; | 267 std::unique_ptr<test::RtpGenerator> rtp_generator_; |
268 WebRtcRTPHeader rtp_header_; | 268 WebRtcRTPHeader rtp_header_; |
269 uint32_t last_lost_time_; | 269 uint32_t last_lost_time_; |
270 uint32_t packet_loss_interval_; | 270 uint32_t packet_loss_interval_; |
271 uint8_t payload_[kPayloadSizeByte]; | 271 uint8_t payload_[kPayloadSizeByte]; |
272 int16_t output_[kMaxOutputSize]; | 272 AudioFrame output_frame_; |
273 }; | 273 }; |
274 | 274 |
275 TEST(NetEqNetworkStatsTest, DecodeFec) { | 275 TEST(NetEqNetworkStatsTest, DecodeFec) { |
276 MockAudioDecoder decoder(1); | 276 MockAudioDecoder decoder(1); |
277 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, &decoder); | 277 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, &decoder); |
278 test.DecodeFecTest(); | 278 test.DecodeFecTest(); |
279 EXPECT_CALL(decoder, Die()).Times(1); | 279 EXPECT_CALL(decoder, Die()).Times(1); |
280 } | 280 } |
281 | 281 |
282 TEST(NetEqNetworkStatsTest, StereoDecodeFec) { | 282 TEST(NetEqNetworkStatsTest, StereoDecodeFec) { |
283 MockAudioDecoder decoder(2); | 283 MockAudioDecoder decoder(2); |
284 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, &decoder); | 284 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, &decoder); |
285 test.DecodeFecTest(); | 285 test.DecodeFecTest(); |
286 EXPECT_CALL(decoder, Die()).Times(1); | 286 EXPECT_CALL(decoder, Die()).Times(1); |
287 } | 287 } |
288 | 288 |
289 TEST(NetEqNetworkStatsTest, NoiseExpansionTest) { | 289 TEST(NetEqNetworkStatsTest, NoiseExpansionTest) { |
290 MockAudioDecoder decoder(1); | 290 MockAudioDecoder decoder(1); |
291 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, &decoder); | 291 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, &decoder); |
292 test.NoiseExpansionTest(); | 292 test.NoiseExpansionTest(); |
293 EXPECT_CALL(decoder, Die()).Times(1); | 293 EXPECT_CALL(decoder, Die()).Times(1); |
294 } | 294 } |
295 | 295 |
296 } // namespace test | 296 } // namespace test |
297 } // namespace webrtc | 297 } // namespace webrtc |
298 | 298 |
299 | 299 |
300 | 300 |
301 | 301 |
OLD | NEW |