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

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

Issue 2342443005: Moved Opus-specific payload splitting into AudioDecoderOpus. (Closed)
Patch Set: Created 4 years, 3 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
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 21 matching lines...) Expand all
32 32
33 MockAudioDecoder(int sample_rate_hz, size_t num_channels) 33 MockAudioDecoder(int sample_rate_hz, size_t num_channels)
34 : sample_rate_hz_(sample_rate_hz), 34 : sample_rate_hz_(sample_rate_hz),
35 num_channels_(num_channels), 35 num_channels_(num_channels),
36 fec_enabled_(false) {} 36 fec_enabled_(false) {}
37 ~MockAudioDecoder() /* override */ { Die(); } 37 ~MockAudioDecoder() /* override */ { Die(); }
38 MOCK_METHOD0(Die, void()); 38 MOCK_METHOD0(Die, void());
39 39
40 MOCK_METHOD0(Reset, void()); 40 MOCK_METHOD0(Reset, void());
41 41
42 int PacketDuration(const uint8_t* encoded, 42 class MockFrame : public AudioDecoder::EncodedAudioFrame {
43 size_t encoded_len) const /* override */ { 43 public:
44 return kPacketDuration; 44 MockFrame(size_t num_channels) : num_channels_(num_channels) {}
45
46 size_t Duration() const /* override */ { return kPacketDuration; }
kwiberg-webrtc 2016/09/19 11:07:49 Do you need to comment out the overrides when you'
ossu 2016/09/19 11:41:01 No, I don't think I should have to. Wonder why the
kwiberg-webrtc 2016/09/19 11:55:16 Because MOCK_METHOD0 et al. expand to method decla
ossu 2016/09/19 14:07:34 Oh, right, now I see. I forgot why I left them in.
47
48 rtc::Optional<DecodeResult> Decode(rtc::ArrayView<int16_t> decoded) const
49 /* override */ {
50 memset(decoded.data(), 0,
hlundin-webrtc 2016/09/15 09:33:30 ASSERT_GE(decoded.size(), sizeof(int16_t) * kPacke
ossu 2016/09/15 12:22:53 Acknowledged.
51 sizeof(int16_t) * kPacketDuration * num_channels_);
52 return rtc::Optional<DecodeResult>(
53 {kPacketDuration * num_channels_, kSpeech});
54 }
55
56 private:
57 size_t num_channels_;
hlundin-webrtc 2016/09/15 09:33:30 const
ossu 2016/09/15 12:22:53 Acknowledged.
58 };
59
60 std::vector<ParseResult> ParsePayload(rtc::Buffer* payload,
61 uint32_t timestamp) /* override */ {
62 std::vector<ParseResult> results;
63 if (fec_enabled_) {
64 std::unique_ptr<MockFrame> fec_frame(new MockFrame(num_channels_));
65 results.emplace_back(timestamp - kPacketDuration, 1,
66 std::move(fec_frame));
67 }
68
69 std::unique_ptr<MockFrame> frame(new MockFrame(num_channels_));
70 results.emplace_back(timestamp, 0, std::move(frame));
71 return results;
45 } 72 }
46 73
47 int PacketDurationRedundant(const uint8_t* encoded, 74 int PacketDuration(const uint8_t* encoded, size_t encoded_len) const
48 size_t encoded_len) const /* override */ { 75 /* override */ {
76 // Since going through ParsePayload, PacketDuration should never get called.
77 RTC_DCHECK(false);
49 return kPacketDuration; 78 return kPacketDuration;
50 } 79 }
51 80
52 bool PacketHasFec( 81 bool PacketHasFec(
53 const uint8_t* encoded, size_t encoded_len) const /* override */ { 82 const uint8_t* encoded, size_t encoded_len) const /* override */ {
83 // Since going through ParsePayload, PacketHasFec should never get called.
84 RTC_DCHECK(false);
hlundin-webrtc 2016/09/15 09:33:30 FAIL();
ossu 2016/09/15 12:22:53 Acknowledged.
54 return fec_enabled_; 85 return fec_enabled_;
55 } 86 }
56 87
57 int SampleRateHz() const /* override */ { return sample_rate_hz_; } 88 int SampleRateHz() const /* override */ { return sample_rate_hz_; }
58 89
59 size_t Channels() const /* override */ { return num_channels_; } 90 size_t Channels() const /* override */ { return num_channels_; }
60 91
61 void set_fec_enabled(bool enable_fec) { fec_enabled_ = enable_fec; } 92 void set_fec_enabled(bool enable_fec) { fec_enabled_ = enable_fec; }
62 93
63 bool fec_enabled() const { return fec_enabled_; } 94 bool fec_enabled() const { return fec_enabled_; }
64 95
65 protected: 96 protected:
66 // Override the following methods such that no actual payload is needed. 97 // Override the following methods such that no actual payload is needed.
67 int DecodeInternal(const uint8_t* encoded, 98 int DecodeInternal(const uint8_t* encoded,
68 size_t encoded_len, 99 size_t encoded_len,
69 int /*sample_rate_hz*/, 100 int /*sample_rate_hz*/,
70 int16_t* decoded, 101 int16_t* decoded,
71 SpeechType* speech_type) /* override */ { 102 SpeechType* speech_type) /* override */ {
72 *speech_type = kSpeech; 103 // Since going through ParsePayload, DecodeInternal should never get called.
73 memset(decoded, 0, sizeof(int16_t) * kPacketDuration * Channels()); 104 RTC_DCHECK(false);
hlundin-webrtc 2016/09/15 09:33:30 FAIL();
ossu 2016/09/15 12:22:53 Acknowledged.
74 return kPacketDuration * Channels();
75 }
76
77 int DecodeRedundantInternal(const uint8_t* encoded,
78 size_t encoded_len,
79 int sample_rate_hz,
80 int16_t* decoded,
81 SpeechType* speech_type) /* override */ {
82 return DecodeInternal(encoded, encoded_len, sample_rate_hz, decoded,
83 speech_type);
84 } 105 }
85 106
86 private: 107 private:
87 const int sample_rate_hz_; 108 const int sample_rate_hz_;
88 const size_t num_channels_; 109 const size_t num_channels_;
89 bool fec_enabled_; 110 bool fec_enabled_;
90 }; 111 };
91 112
92 class NetEqNetworkStatsTest : public NetEqExternalDecoderTest { 113 class NetEqNetworkStatsTest : public NetEqExternalDecoderTest {
93 public: 114 public:
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 318
298 TEST(NetEqNetworkStatsTest, NoiseExpansionTest) { 319 TEST(NetEqNetworkStatsTest, NoiseExpansionTest) {
299 MockAudioDecoder decoder(48000, 1); 320 MockAudioDecoder decoder(48000, 1);
300 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, 48000, &decoder); 321 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, 48000, &decoder);
301 test.NoiseExpansionTest(); 322 test.NoiseExpansionTest();
302 EXPECT_CALL(decoder, Die()).Times(1); 323 EXPECT_CALL(decoder, Die()).Times(1);
303 } 324 }
304 325
305 } // namespace test 326 } // namespace test
306 } // namespace webrtc 327 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698