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 #include "webrtc/modules/include/module_common_types.h" |
17 | 17 |
18 namespace webrtc { | 18 namespace webrtc { |
19 namespace test { | 19 namespace test { |
20 | 20 |
21 using ::testing::_; | 21 using ::testing::_; |
22 using ::testing::SetArgPointee; | 22 using ::testing::SetArgPointee; |
23 using ::testing::Return; | 23 using ::testing::Return; |
24 | 24 |
25 class MockAudioDecoder final : public AudioDecoder { | 25 class MockAudioDecoder final : public AudioDecoder { |
26 public: | 26 public: |
| 27 // TODO(nisse): Valid overrides commented out, because the gmock |
| 28 // methods don't use any override declarations, and we want to avoid |
| 29 // warnings from -Winconsistent-missing-override. See |
| 30 // http://crbug.com/428099. |
27 static const int kPacketDuration = 960; // 48 kHz * 20 ms | 31 static const int kPacketDuration = 960; // 48 kHz * 20 ms |
28 | 32 |
29 explicit MockAudioDecoder(size_t num_channels) | 33 explicit MockAudioDecoder(size_t num_channels) |
30 : num_channels_(num_channels), fec_enabled_(false) { | 34 : num_channels_(num_channels), fec_enabled_(false) { |
31 } | 35 } |
32 ~MockAudioDecoder() override { Die(); } | 36 ~MockAudioDecoder() /* override */ { Die(); } |
33 MOCK_METHOD0(Die, void()); | 37 MOCK_METHOD0(Die, void()); |
34 | 38 |
35 MOCK_METHOD0(Reset, void()); | 39 MOCK_METHOD0(Reset, void()); |
36 | 40 |
37 int PacketDuration(const uint8_t* encoded, | 41 int PacketDuration(const uint8_t* encoded, |
38 size_t encoded_len) const override { | 42 size_t encoded_len) const /* override */ { |
39 return kPacketDuration; | 43 return kPacketDuration; |
40 } | 44 } |
41 | 45 |
42 int PacketDurationRedundant(const uint8_t* encoded, | 46 int PacketDurationRedundant(const uint8_t* encoded, |
43 size_t encoded_len) const override { | 47 size_t encoded_len) const /* override */ { |
44 return kPacketDuration; | 48 return kPacketDuration; |
45 } | 49 } |
46 | 50 |
47 bool PacketHasFec(const uint8_t* encoded, size_t encoded_len) const override { | 51 bool PacketHasFec( |
| 52 const uint8_t* encoded, size_t encoded_len) const /* override */ { |
48 return fec_enabled_; | 53 return fec_enabled_; |
49 } | 54 } |
50 | 55 |
51 size_t Channels() const override { return num_channels_; } | 56 size_t Channels() const /* override */ { return num_channels_; } |
52 | 57 |
53 void set_fec_enabled(bool enable_fec) { fec_enabled_ = enable_fec; } | 58 void set_fec_enabled(bool enable_fec) { fec_enabled_ = enable_fec; } |
54 | 59 |
55 bool fec_enabled() const { return fec_enabled_; } | 60 bool fec_enabled() const { return fec_enabled_; } |
56 | 61 |
57 protected: | 62 protected: |
58 // Override the following methods such that no actual payload is needed. | 63 // Override the following methods such that no actual payload is needed. |
59 int DecodeInternal(const uint8_t* encoded, | 64 int DecodeInternal(const uint8_t* encoded, |
60 size_t encoded_len, | 65 size_t encoded_len, |
61 int /*sample_rate_hz*/, | 66 int /*sample_rate_hz*/, |
62 int16_t* decoded, | 67 int16_t* decoded, |
63 SpeechType* speech_type) override { | 68 SpeechType* speech_type) /* override */ { |
64 *speech_type = kSpeech; | 69 *speech_type = kSpeech; |
65 memset(decoded, 0, sizeof(int16_t) * kPacketDuration * Channels()); | 70 memset(decoded, 0, sizeof(int16_t) * kPacketDuration * Channels()); |
66 return kPacketDuration * Channels(); | 71 return kPacketDuration * Channels(); |
67 } | 72 } |
68 | 73 |
69 int DecodeRedundantInternal(const uint8_t* encoded, | 74 int DecodeRedundantInternal(const uint8_t* encoded, |
70 size_t encoded_len, | 75 size_t encoded_len, |
71 int sample_rate_hz, | 76 int sample_rate_hz, |
72 int16_t* decoded, | 77 int16_t* decoded, |
73 SpeechType* speech_type) override { | 78 SpeechType* speech_type) /* override */ { |
74 return DecodeInternal(encoded, encoded_len, sample_rate_hz, decoded, | 79 return DecodeInternal(encoded, encoded_len, sample_rate_hz, decoded, |
75 speech_type); | 80 speech_type); |
76 } | 81 } |
77 | 82 |
78 private: | 83 private: |
79 const size_t num_channels_; | 84 const size_t num_channels_; |
80 bool fec_enabled_; | 85 bool fec_enabled_; |
81 }; | 86 }; |
82 | 87 |
83 class NetEqNetworkStatsTest : public NetEqExternalDecoderTest { | 88 class NetEqNetworkStatsTest : public NetEqExternalDecoderTest { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 292 |
288 TEST(NetEqNetworkStatsTest, NoiseExpansionTest) { | 293 TEST(NetEqNetworkStatsTest, NoiseExpansionTest) { |
289 MockAudioDecoder decoder(1); | 294 MockAudioDecoder decoder(1); |
290 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, &decoder); | 295 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, &decoder); |
291 test.NoiseExpansionTest(); | 296 test.NoiseExpansionTest(); |
292 EXPECT_CALL(decoder, Die()).Times(1); | 297 EXPECT_CALL(decoder, Die()).Times(1); |
293 } | 298 } |
294 | 299 |
295 } // namespace test | 300 } // namespace test |
296 } // namespace webrtc | 301 } // namespace webrtc |
297 | |
298 | |
299 | |
300 | |
OLD | NEW |