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