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

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

Issue 1319683002: AudioDecoder: Replace Init() with Reset() (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@buffer
Patch Set: review fixes Created 5 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) 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
(...skipping 10 matching lines...) Expand all
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. This is a copy from
27 // audio_decoder_impl.{cc, h}. 27 // audio_decoder_impl.{cc, h}.
28 class ExternalPcm16B : public AudioDecoder { 28 class ExternalPcm16B : public AudioDecoder {
29 public: 29 public:
30 ExternalPcm16B() {} 30 ExternalPcm16B() {}
31 virtual int Init() { return 0; } 31 void Reset() override {}
32 32
33 protected: 33 protected:
34 int DecodeInternal(const uint8_t* encoded, 34 int DecodeInternal(const uint8_t* encoded,
35 size_t encoded_len, 35 size_t encoded_len,
36 int sample_rate_hz, 36 int sample_rate_hz,
37 int16_t* decoded, 37 int16_t* decoded,
38 SpeechType* speech_type) override { 38 SpeechType* speech_type) override {
39 size_t ret = WebRtcPcm16b_Decode(encoded, encoded_len, decoded); 39 size_t ret = WebRtcPcm16b_Decode(encoded, encoded_len, decoded);
40 *speech_type = ConvertSpeechType(1); 40 *speech_type = ConvertSpeechType(1);
41 return static_cast<int>(ret); 41 return static_cast<int>(ret);
42 } 42 }
43 size_t Channels() const override { return 1; } 43 size_t Channels() const override { return 1; }
44 44
45 private: 45 private:
46 DISALLOW_COPY_AND_ASSIGN(ExternalPcm16B); 46 DISALLOW_COPY_AND_ASSIGN(ExternalPcm16B);
47 }; 47 };
48 48
49 // Create a mock of ExternalPcm16B which delegates all calls to the real object. 49 // Create a mock of ExternalPcm16B which delegates all calls to the real object.
50 // The reason is that we can then track that the correct calls are being made. 50 // The reason is that we can then track that the correct calls are being made.
51 class MockExternalPcm16B : public ExternalPcm16B { 51 class MockExternalPcm16B : public ExternalPcm16B {
52 public: 52 public:
53 MockExternalPcm16B() { 53 MockExternalPcm16B() {
54 // By default, all calls are delegated to the real object. 54 // By default, all calls are delegated to the real object.
55 ON_CALL(*this, Decode(_, _, _, _, _, _)) 55 ON_CALL(*this, Decode(_, _, _, _, _, _))
56 .WillByDefault(Invoke(&real_, &ExternalPcm16B::Decode)); 56 .WillByDefault(Invoke(&real_, &ExternalPcm16B::Decode));
57 ON_CALL(*this, HasDecodePlc()) 57 ON_CALL(*this, HasDecodePlc())
58 .WillByDefault(Invoke(&real_, &ExternalPcm16B::HasDecodePlc)); 58 .WillByDefault(Invoke(&real_, &ExternalPcm16B::HasDecodePlc));
59 ON_CALL(*this, DecodePlc(_, _)) 59 ON_CALL(*this, DecodePlc(_, _))
60 .WillByDefault(Invoke(&real_, &ExternalPcm16B::DecodePlc)); 60 .WillByDefault(Invoke(&real_, &ExternalPcm16B::DecodePlc));
61 ON_CALL(*this, Init()) 61 ON_CALL(*this, Reset())
62 .WillByDefault(Invoke(&real_, &ExternalPcm16B::Init)); 62 .WillByDefault(Invoke(&real_, &ExternalPcm16B::Reset));
63 ON_CALL(*this, IncomingPacket(_, _, _, _, _)) 63 ON_CALL(*this, IncomingPacket(_, _, _, _, _))
64 .WillByDefault(Invoke(&real_, &ExternalPcm16B::IncomingPacket)); 64 .WillByDefault(Invoke(&real_, &ExternalPcm16B::IncomingPacket));
65 ON_CALL(*this, ErrorCode()) 65 ON_CALL(*this, ErrorCode())
66 .WillByDefault(Invoke(&real_, &ExternalPcm16B::ErrorCode)); 66 .WillByDefault(Invoke(&real_, &ExternalPcm16B::ErrorCode));
67 } 67 }
68 virtual ~MockExternalPcm16B() { Die(); } 68 virtual ~MockExternalPcm16B() { Die(); }
69 69
70 MOCK_METHOD0(Die, void()); 70 MOCK_METHOD0(Die, void());
71 MOCK_METHOD6(Decode, 71 MOCK_METHOD6(Decode,
72 int(const uint8_t* encoded, 72 int(const uint8_t* encoded,
73 size_t encoded_len, 73 size_t encoded_len,
74 int sample_rate_hz, 74 int sample_rate_hz,
75 size_t max_decoded_bytes, 75 size_t max_decoded_bytes,
76 int16_t* decoded, 76 int16_t* decoded,
77 SpeechType* speech_type)); 77 SpeechType* speech_type));
78 MOCK_CONST_METHOD0(HasDecodePlc, 78 MOCK_CONST_METHOD0(HasDecodePlc,
79 bool()); 79 bool());
80 MOCK_METHOD2(DecodePlc, 80 MOCK_METHOD2(DecodePlc,
81 size_t(size_t num_frames, int16_t* decoded)); 81 size_t(size_t num_frames, int16_t* decoded));
82 MOCK_METHOD0(Init, 82 MOCK_METHOD0(Reset, void());
83 int());
84 MOCK_METHOD5(IncomingPacket, 83 MOCK_METHOD5(IncomingPacket,
85 int(const uint8_t* payload, size_t payload_len, 84 int(const uint8_t* payload, size_t payload_len,
86 uint16_t rtp_sequence_number, uint32_t rtp_timestamp, 85 uint16_t rtp_sequence_number, uint32_t rtp_timestamp,
87 uint32_t arrival_timestamp)); 86 uint32_t arrival_timestamp));
88 MOCK_METHOD0(ErrorCode, 87 MOCK_METHOD0(ErrorCode,
89 int()); 88 int());
90 89
91 private: 90 private:
92 ExternalPcm16B real_; 91 ExternalPcm16B real_;
93 }; 92 };
94 93
95 } // namespace webrtc 94 } // namespace webrtc
96 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_EXTERNAL_DECODER_PCM16B_H _ 95 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_EXTERNAL_DECODER_PCM16B_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698