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

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: Priority levels are ints, kHighestPriority is gone. Also small cleanups. 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; }
47
48 rtc::Optional<DecodeResult> Decode(
49 rtc::ArrayView<int16_t> decoded) const override {
50 const size_t output_size =
51 sizeof(int16_t) * kPacketDuration * num_channels_;
52 if (decoded.size() >= output_size) {
53 memset(decoded.data(), 0,
54 sizeof(int16_t) * kPacketDuration * num_channels_);
55 return rtc::Optional<DecodeResult>(
56 {kPacketDuration * num_channels_, kSpeech});
57 } else {
58 EXPECT_GE(decoded.size(), output_size);
kwiberg-webrtc 2016/09/20 09:14:45 Isn't it always the case that !(decoded.size() >=
ossu 2016/09/20 13:51:56 Yup! Putting an ASSERT in here won't work, since w
kwiberg-webrtc 2016/09/20 14:56:22 Does something like this work? ADD_FAILURE() <<
ossu 2016/09/20 15:45:21 1) Yes, but it's more to write. 2) Isn't that more
kwiberg-webrtc 2016/09/20 16:19:15 1) It's more code, but you don't need that multili
59 return rtc::Optional<DecodeResult>();
60 }
61 }
62
63 private:
64 const size_t num_channels_;
65 };
66
67 std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload,
68 uint32_t timestamp) /* override */ {
69 std::vector<ParseResult> results;
70 if (fec_enabled_) {
71 std::unique_ptr<MockFrame> fec_frame(new MockFrame(num_channels_));
72 results.emplace_back(timestamp - kPacketDuration, 1,
73 std::move(fec_frame));
74 }
75
76 std::unique_ptr<MockFrame> frame(new MockFrame(num_channels_));
77 results.emplace_back(timestamp, 0, std::move(frame));
78 return results;
45 } 79 }
46 80
47 int PacketDurationRedundant(const uint8_t* encoded, 81 int PacketDuration(const uint8_t* encoded, size_t encoded_len) const
48 size_t encoded_len) const /* override */ { 82 /* override */ {
83 ADD_FAILURE() << "Since going through ParsePayload, PacketDuration should "
84 "never get called.";
49 return kPacketDuration; 85 return kPacketDuration;
50 } 86 }
51 87
52 bool PacketHasFec( 88 bool PacketHasFec(
53 const uint8_t* encoded, size_t encoded_len) const /* override */ { 89 const uint8_t* encoded, size_t encoded_len) const /* override */ {
90 ADD_FAILURE() << "Since going through ParsePayload, PacketHasFec should "
91 "never get called.";
54 return fec_enabled_; 92 return fec_enabled_;
55 } 93 }
56 94
57 int SampleRateHz() const /* override */ { return sample_rate_hz_; } 95 int SampleRateHz() const /* override */ { return sample_rate_hz_; }
58 96
59 size_t Channels() const /* override */ { return num_channels_; } 97 size_t Channels() const /* override */ { return num_channels_; }
60 98
61 void set_fec_enabled(bool enable_fec) { fec_enabled_ = enable_fec; } 99 void set_fec_enabled(bool enable_fec) { fec_enabled_ = enable_fec; }
62 100
63 bool fec_enabled() const { return fec_enabled_; } 101 bool fec_enabled() const { return fec_enabled_; }
64 102
65 protected: 103 protected:
66 // Override the following methods such that no actual payload is needed.
67 int DecodeInternal(const uint8_t* encoded, 104 int DecodeInternal(const uint8_t* encoded,
68 size_t encoded_len, 105 size_t encoded_len,
69 int /*sample_rate_hz*/, 106 int sample_rate_hz,
70 int16_t* decoded, 107 int16_t* decoded,
71 SpeechType* speech_type) /* override */ { 108 SpeechType* speech_type) /* override */ {
72 *speech_type = kSpeech; 109 ADD_FAILURE() << "Since going through ParsePayload, DecodeInternal should "
73 memset(decoded, 0, sizeof(int16_t) * kPacketDuration * Channels()); 110 "never get called.";
74 return kPacketDuration * Channels(); 111 return -1;
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 } 112 }
85 113
86 private: 114 private:
87 const int sample_rate_hz_; 115 const int sample_rate_hz_;
88 const size_t num_channels_; 116 const size_t num_channels_;
89 bool fec_enabled_; 117 bool fec_enabled_;
90 }; 118 };
91 119
92 class NetEqNetworkStatsTest : public NetEqExternalDecoderTest { 120 class NetEqNetworkStatsTest : public NetEqExternalDecoderTest {
93 public: 121 public:
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 325
298 TEST(NetEqNetworkStatsTest, NoiseExpansionTest) { 326 TEST(NetEqNetworkStatsTest, NoiseExpansionTest) {
299 MockAudioDecoder decoder(48000, 1); 327 MockAudioDecoder decoder(48000, 1);
300 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, 48000, &decoder); 328 NetEqNetworkStatsTest test(NetEqDecoder::kDecoderOpus, 48000, &decoder);
301 test.NoiseExpansionTest(); 329 test.NoiseExpansionTest();
302 EXPECT_CALL(decoder, Die()).Times(1); 330 EXPECT_CALL(decoder, Die()).Times(1);
303 } 331 }
304 332
305 } // namespace test 333 } // namespace test
306 } // namespace webrtc 334 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698