| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" | 11 #include "webrtc/test/mock_audio_encoder.h" |
| 12 | 12 |
| 13 namespace webrtc { | 13 namespace webrtc { |
| 14 | 14 |
| 15 MockAudioEncoder::MockAudioEncoder() = default; |
| 16 MockAudioEncoder::~MockAudioEncoder() { |
| 17 Die(); |
| 18 } |
| 19 |
| 15 MockAudioEncoder::FakeEncoding::FakeEncoding( | 20 MockAudioEncoder::FakeEncoding::FakeEncoding( |
| 16 const AudioEncoder::EncodedInfo& info) | 21 const AudioEncoder::EncodedInfo& info) |
| 17 : info_(info) { } | 22 : info_(info) {} |
| 18 | 23 |
| 19 MockAudioEncoder::FakeEncoding::FakeEncoding(size_t encoded_bytes) { | 24 MockAudioEncoder::FakeEncoding::FakeEncoding(size_t encoded_bytes) { |
| 20 info_.encoded_bytes = encoded_bytes; | 25 info_.encoded_bytes = encoded_bytes; |
| 21 } | 26 } |
| 22 | 27 |
| 23 AudioEncoder::EncodedInfo MockAudioEncoder::FakeEncoding::operator()( | 28 AudioEncoder::EncodedInfo MockAudioEncoder::FakeEncoding::operator()( |
| 24 uint32_t timestamp, | 29 uint32_t timestamp, |
| 25 rtc::ArrayView<const int16_t> audio, | 30 rtc::ArrayView<const int16_t> audio, |
| 26 rtc::Buffer* encoded) { | 31 rtc::Buffer* encoded) { |
| 27 encoded->SetSize(encoded->size() + info_.encoded_bytes); | 32 encoded->SetSize(encoded->size() + info_.encoded_bytes); |
| 28 return info_; | 33 return info_; |
| 29 } | 34 } |
| 30 | 35 |
| 36 MockAudioEncoder::CopyEncoding::~CopyEncoding() = default; |
| 37 |
| 31 MockAudioEncoder::CopyEncoding::CopyEncoding( | 38 MockAudioEncoder::CopyEncoding::CopyEncoding( |
| 32 AudioEncoder::EncodedInfo info, | 39 AudioEncoder::EncodedInfo info, |
| 33 rtc::ArrayView<const uint8_t> payload) | 40 rtc::ArrayView<const uint8_t> payload) |
| 34 : info_(info), payload_(payload) { } | 41 : info_(info), payload_(payload) {} |
| 35 | 42 |
| 36 MockAudioEncoder::CopyEncoding::CopyEncoding( | 43 MockAudioEncoder::CopyEncoding::CopyEncoding( |
| 37 rtc::ArrayView<const uint8_t> payload) | 44 rtc::ArrayView<const uint8_t> payload) |
| 38 : payload_(payload) { | 45 : payload_(payload) { |
| 39 info_.encoded_bytes = payload_.size(); | 46 info_.encoded_bytes = payload_.size(); |
| 40 } | 47 } |
| 41 | 48 |
| 42 AudioEncoder::EncodedInfo MockAudioEncoder::CopyEncoding::operator()( | 49 AudioEncoder::EncodedInfo MockAudioEncoder::CopyEncoding::operator()( |
| 43 uint32_t timestamp, | 50 uint32_t timestamp, |
| 44 rtc::ArrayView<const int16_t> audio, | 51 rtc::ArrayView<const int16_t> audio, |
| 45 rtc::Buffer* encoded) { | 52 rtc::Buffer* encoded) { |
| 46 RTC_CHECK(encoded); | 53 RTC_CHECK(encoded); |
| 47 RTC_CHECK_LE(info_.encoded_bytes, payload_.size()); | 54 RTC_CHECK_LE(info_.encoded_bytes, payload_.size()); |
| 48 encoded->AppendData(payload_.data(), info_.encoded_bytes); | 55 encoded->AppendData(payload_.data(), info_.encoded_bytes); |
| 49 return info_; | 56 return info_; |
| 50 } | 57 } |
| 51 | 58 |
| 52 } // namespace webrtc | 59 } // namespace webrtc |
| OLD | NEW |