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

Side by Side Diff: webrtc/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h

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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_EXTERNAL_DECODER_PCM16B_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_EXTERNAL_DECODER_PCM16B_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_EXTERNAL_DECODER_PCM16B_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_EXTERNAL_DECODER_PCM16B_H_
13 13
14 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" 14 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h"
15 15
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "webrtc/base/constructormagic.h" 17 #include "webrtc/base/constructormagic.h"
18 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" 18 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h"
19 #include "webrtc/typedefs.h" 19 #include "webrtc/typedefs.h"
20 20
21 namespace webrtc { 21 namespace webrtc {
22 22
23 using ::testing::_; 23 using ::testing::_;
24 using ::testing::Invoke; 24 using ::testing::Invoke;
25 25
26 // Implement an external version of the PCM16b decoder. This is a copy from 26 // Implement an external version of the PCM16b decoder.
27 // audio_decoder_impl.{cc, h}.
28 class ExternalPcm16B : public AudioDecoder { 27 class ExternalPcm16B : public AudioDecoder {
29 public: 28 public:
30 ExternalPcm16B() {} 29 explicit ExternalPcm16B(int sample_rate_hz)
30 : sample_rate_hz_(sample_rate_hz) {}
31 void Reset() override {} 31 void Reset() override {}
32 32
33 int DecodeInternal(const uint8_t* encoded, 33 int DecodeInternal(const uint8_t* encoded,
34 size_t encoded_len, 34 size_t encoded_len,
35 int sample_rate_hz, 35 int sample_rate_hz,
36 int16_t* decoded, 36 int16_t* decoded,
37 SpeechType* speech_type) override { 37 SpeechType* speech_type) override {
38 EXPECT_EQ(sample_rate_hz_, sample_rate_hz);
38 size_t ret = WebRtcPcm16b_Decode(encoded, encoded_len, decoded); 39 size_t ret = WebRtcPcm16b_Decode(encoded, encoded_len, decoded);
39 *speech_type = ConvertSpeechType(1); 40 *speech_type = ConvertSpeechType(1);
40 return static_cast<int>(ret); 41 return static_cast<int>(ret);
41 } 42 }
43 int SampleRateHz() const override { return sample_rate_hz_; }
42 size_t Channels() const override { return 1; } 44 size_t Channels() const override { return 1; }
43 45
44 private: 46 private:
47 const int sample_rate_hz_;
45 RTC_DISALLOW_COPY_AND_ASSIGN(ExternalPcm16B); 48 RTC_DISALLOW_COPY_AND_ASSIGN(ExternalPcm16B);
46 }; 49 };
47 50
48 // Create a mock of ExternalPcm16B which delegates all calls to the real object. 51 // Create a mock of ExternalPcm16B which delegates all calls to the real object.
49 // The reason is that we can then track that the correct calls are being made. 52 // The reason is that we can then track that the correct calls are being made.
50 class MockExternalPcm16B : public ExternalPcm16B { 53 class MockExternalPcm16B : public AudioDecoder {
51 public: 54 public:
52 MockExternalPcm16B() { 55 explicit MockExternalPcm16B(int sample_rate_hz) : real_(sample_rate_hz) {
53 // By default, all calls are delegated to the real object. 56 // By default, all calls are delegated to the real object.
54 ON_CALL(*this, DecodeInternal(_, _, _, _, _)) 57 ON_CALL(*this, DecodeInternal(_, _, _, _, _))
55 .WillByDefault(Invoke(&real_, &ExternalPcm16B::DecodeInternal)); 58 .WillByDefault(Invoke(&real_, &ExternalPcm16B::DecodeInternal));
56 ON_CALL(*this, HasDecodePlc()) 59 ON_CALL(*this, HasDecodePlc())
57 .WillByDefault(Invoke(&real_, &ExternalPcm16B::HasDecodePlc)); 60 .WillByDefault(Invoke(&real_, &ExternalPcm16B::HasDecodePlc));
58 ON_CALL(*this, DecodePlc(_, _)) 61 ON_CALL(*this, DecodePlc(_, _))
59 .WillByDefault(Invoke(&real_, &ExternalPcm16B::DecodePlc)); 62 .WillByDefault(Invoke(&real_, &ExternalPcm16B::DecodePlc));
60 ON_CALL(*this, Reset()) 63 ON_CALL(*this, Reset())
61 .WillByDefault(Invoke(&real_, &ExternalPcm16B::Reset)); 64 .WillByDefault(Invoke(&real_, &ExternalPcm16B::Reset));
62 ON_CALL(*this, IncomingPacket(_, _, _, _, _)) 65 ON_CALL(*this, IncomingPacket(_, _, _, _, _))
(...skipping 15 matching lines...) Expand all
78 MOCK_METHOD2(DecodePlc, 81 MOCK_METHOD2(DecodePlc,
79 size_t(size_t num_frames, int16_t* decoded)); 82 size_t(size_t num_frames, int16_t* decoded));
80 MOCK_METHOD0(Reset, void()); 83 MOCK_METHOD0(Reset, void());
81 MOCK_METHOD5(IncomingPacket, 84 MOCK_METHOD5(IncomingPacket,
82 int(const uint8_t* payload, size_t payload_len, 85 int(const uint8_t* payload, size_t payload_len,
83 uint16_t rtp_sequence_number, uint32_t rtp_timestamp, 86 uint16_t rtp_sequence_number, uint32_t rtp_timestamp,
84 uint32_t arrival_timestamp)); 87 uint32_t arrival_timestamp));
85 MOCK_METHOD0(ErrorCode, 88 MOCK_METHOD0(ErrorCode,
86 int()); 89 int());
87 90
91 int SampleRateHz() const /* override */ { return real_.SampleRateHz(); }
92 size_t Channels() const /* override */ { return real_.Channels(); }
93
88 private: 94 private:
89 ExternalPcm16B real_; 95 ExternalPcm16B real_;
90 }; 96 };
91 97
92 } // namespace webrtc 98 } // namespace webrtc
93 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_EXTERNAL_DECODER_PCM16B_H _ 99 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_EXTERNAL_DECODER_PCM16B_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698