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

Side by Side Diff: webrtc/modules/audio_coding/neteq/neteq_network_stats_unittest.cc

Issue 2029543002: AudioDecoder: Remove the default implementation of SampleRateHz (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@samprate0
Patch Set: rebase Created 4 years, 6 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 | « webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 12 matching lines...) Expand all
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 27 // TODO(nisse): Valid overrides commented out, because the gmock
28 // methods don't use any override declarations, and we want to avoid 28 // methods don't use any override declarations, and we want to avoid
29 // warnings from -Winconsistent-missing-override. See 29 // warnings from -Winconsistent-missing-override. See
30 // http://crbug.com/428099. 30 // http://crbug.com/428099.
31 static const int kPacketDuration = 960; // 48 kHz * 20 ms 31 static const int kPacketDuration = 960; // 48 kHz * 20 ms
32 32
33 explicit MockAudioDecoder(size_t num_channels) 33 MockAudioDecoder(int sample_rate_hz, size_t num_channels)
34 : num_channels_(num_channels), fec_enabled_(false) { 34 : sample_rate_hz_(sample_rate_hz),
35 } 35 num_channels_(num_channels),
36 fec_enabled_(false) {}
36 ~MockAudioDecoder() /* override */ { Die(); } 37 ~MockAudioDecoder() /* override */ { Die(); }
37 MOCK_METHOD0(Die, void()); 38 MOCK_METHOD0(Die, void());
38 39
39 MOCK_METHOD0(Reset, void()); 40 MOCK_METHOD0(Reset, void());
40 41
41 int PacketDuration(const uint8_t* encoded, 42 int PacketDuration(const uint8_t* encoded,
42 size_t encoded_len) const /* override */ { 43 size_t encoded_len) const /* override */ {
43 return kPacketDuration; 44 return kPacketDuration;
44 } 45 }
45 46
46 int PacketDurationRedundant(const uint8_t* encoded, 47 int PacketDurationRedundant(const uint8_t* encoded,
47 size_t encoded_len) const /* override */ { 48 size_t encoded_len) const /* override */ {
48 return kPacketDuration; 49 return kPacketDuration;
49 } 50 }
50 51
51 bool PacketHasFec( 52 bool PacketHasFec(
52 const uint8_t* encoded, size_t encoded_len) const /* override */ { 53 const uint8_t* encoded, size_t encoded_len) const /* override */ {
53 return fec_enabled_; 54 return fec_enabled_;
54 } 55 }
55 56
57 int SampleRateHz() const /* override */ { return sample_rate_hz_; }
58
56 size_t Channels() const /* override */ { return num_channels_; } 59 size_t Channels() const /* override */ { return num_channels_; }
57 60
58 void set_fec_enabled(bool enable_fec) { fec_enabled_ = enable_fec; } 61 void set_fec_enabled(bool enable_fec) { fec_enabled_ = enable_fec; }
59 62
60 bool fec_enabled() const { return fec_enabled_; } 63 bool fec_enabled() const { return fec_enabled_; }
61 64
62 protected: 65 protected:
63 // Override the following methods such that no actual payload is needed. 66 // Override the following methods such that no actual payload is needed.
64 int DecodeInternal(const uint8_t* encoded, 67 int DecodeInternal(const uint8_t* encoded,
65 size_t encoded_len, 68 size_t encoded_len,
66 int /*sample_rate_hz*/, 69 int /*sample_rate_hz*/,
67 int16_t* decoded, 70 int16_t* decoded,
68 SpeechType* speech_type) /* override */ { 71 SpeechType* speech_type) /* override */ {
69 *speech_type = kSpeech; 72 *speech_type = kSpeech;
70 memset(decoded, 0, sizeof(int16_t) * kPacketDuration * Channels()); 73 memset(decoded, 0, sizeof(int16_t) * kPacketDuration * Channels());
71 return kPacketDuration * Channels(); 74 return kPacketDuration * Channels();
72 } 75 }
73 76
74 int DecodeRedundantInternal(const uint8_t* encoded, 77 int DecodeRedundantInternal(const uint8_t* encoded,
75 size_t encoded_len, 78 size_t encoded_len,
76 int sample_rate_hz, 79 int sample_rate_hz,
77 int16_t* decoded, 80 int16_t* decoded,
78 SpeechType* speech_type) /* override */ { 81 SpeechType* speech_type) /* override */ {
79 return DecodeInternal(encoded, encoded_len, sample_rate_hz, decoded, 82 return DecodeInternal(encoded, encoded_len, sample_rate_hz, decoded,
80 speech_type); 83 speech_type);
81 } 84 }
82 85
83 private: 86 private:
87 const int sample_rate_hz_;
84 const size_t num_channels_; 88 const size_t num_channels_;
85 bool fec_enabled_; 89 bool fec_enabled_;
86 }; 90 };
87 91
88 class NetEqNetworkStatsTest : public NetEqExternalDecoderTest { 92 class NetEqNetworkStatsTest : public NetEqExternalDecoderTest {
89 public: 93 public:
90 static const int kPayloadSizeByte = 30; 94 static const int kPayloadSizeByte = 30;
91 static const int kFrameSizeMs = 20; 95 static const int kFrameSizeMs = 20;
92 96
93 enum logic { 97 enum logic {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 const size_t frame_size_samples_; 275 const size_t frame_size_samples_;
272 std::unique_ptr<test::RtpGenerator> rtp_generator_; 276 std::unique_ptr<test::RtpGenerator> rtp_generator_;
273 WebRtcRTPHeader rtp_header_; 277 WebRtcRTPHeader rtp_header_;
274 uint32_t last_lost_time_; 278 uint32_t last_lost_time_;
275 uint32_t packet_loss_interval_; 279 uint32_t packet_loss_interval_;
276 uint8_t payload_[kPayloadSizeByte]; 280 uint8_t payload_[kPayloadSizeByte];
277 AudioFrame output_frame_; 281 AudioFrame output_frame_;
278 }; 282 };
279 283
280 TEST(NetEqNetworkStatsTest, DecodeFec) { 284 TEST(NetEqNetworkStatsTest, DecodeFec) {
281 MockAudioDecoder decoder(1); 285 MockAudioDecoder decoder(48000, 1);
282 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, 48000, &decoder); 286 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, 48000, &decoder);
283 test.DecodeFecTest(); 287 test.DecodeFecTest();
284 EXPECT_CALL(decoder, Die()).Times(1); 288 EXPECT_CALL(decoder, Die()).Times(1);
285 } 289 }
286 290
287 TEST(NetEqNetworkStatsTest, StereoDecodeFec) { 291 TEST(NetEqNetworkStatsTest, StereoDecodeFec) {
288 MockAudioDecoder decoder(2); 292 MockAudioDecoder decoder(48000, 2);
289 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, 48000, &decoder); 293 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, 48000, &decoder);
290 test.DecodeFecTest(); 294 test.DecodeFecTest();
291 EXPECT_CALL(decoder, Die()).Times(1); 295 EXPECT_CALL(decoder, Die()).Times(1);
292 } 296 }
293 297
294 TEST(NetEqNetworkStatsTest, NoiseExpansionTest) { 298 TEST(NetEqNetworkStatsTest, NoiseExpansionTest) {
295 MockAudioDecoder decoder(1); 299 MockAudioDecoder decoder(48000, 1);
296 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, 48000, &decoder); 300 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, 48000, &decoder);
297 test.NoiseExpansionTest(); 301 test.NoiseExpansionTest();
298 EXPECT_CALL(decoder, Die()).Times(1); 302 EXPECT_CALL(decoder, Die()).Times(1);
299 } 303 }
300 304
301 } // namespace test 305 } // namespace test
302 } // namespace webrtc 306 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698