ossu | 10a029e | 2016-03-01 08:41:31 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 11 | #include "test/mock_audio_encoder.h" |
ossu | 10a029e | 2016-03-01 08:41:31 | [diff] [blame] | 12 | |
| 13 | namespace webrtc { |
| 14 | |
ossu | eb1fde4 | 2017-05-02 13:46:30 | [diff] [blame] | 15 | MockAudioEncoder::MockAudioEncoder() = default; |
Sebastian Jansson | 5d436ac | 2018-02-21 17:23:43 | [diff] [blame] | 16 | MockAudioEncoder::~MockAudioEncoder() = default; |
ossu | eb1fde4 | 2017-05-02 13:46:30 | [diff] [blame] | 17 | |
ossu | 10a029e | 2016-03-01 08:41:31 | [diff] [blame] | 18 | MockAudioEncoder::FakeEncoding::FakeEncoding( |
| 19 | const AudioEncoder::EncodedInfo& info) |
ossu | eb1fde4 | 2017-05-02 13:46:30 | [diff] [blame] | 20 | : info_(info) {} |
ossu | 10a029e | 2016-03-01 08:41:31 | [diff] [blame] | 21 | |
| 22 | MockAudioEncoder::FakeEncoding::FakeEncoding(size_t encoded_bytes) { |
| 23 | info_.encoded_bytes = encoded_bytes; |
| 24 | } |
| 25 | |
| 26 | AudioEncoder::EncodedInfo MockAudioEncoder::FakeEncoding::operator()( |
| 27 | uint32_t timestamp, |
| 28 | rtc::ArrayView<const int16_t> audio, |
| 29 | rtc::Buffer* encoded) { |
| 30 | encoded->SetSize(encoded->size() + info_.encoded_bytes); |
| 31 | return info_; |
| 32 | } |
| 33 | |
ossu | eb1fde4 | 2017-05-02 13:46:30 | [diff] [blame] | 34 | MockAudioEncoder::CopyEncoding::~CopyEncoding() = default; |
| 35 | |
ossu | 10a029e | 2016-03-01 08:41:31 | [diff] [blame] | 36 | MockAudioEncoder::CopyEncoding::CopyEncoding( |
| 37 | AudioEncoder::EncodedInfo info, |
| 38 | rtc::ArrayView<const uint8_t> payload) |
ossu | eb1fde4 | 2017-05-02 13:46:30 | [diff] [blame] | 39 | : info_(info), payload_(payload) {} |
ossu | 10a029e | 2016-03-01 08:41:31 | [diff] [blame] | 40 | |
| 41 | MockAudioEncoder::CopyEncoding::CopyEncoding( |
| 42 | rtc::ArrayView<const uint8_t> payload) |
| 43 | : payload_(payload) { |
| 44 | info_.encoded_bytes = payload_.size(); |
| 45 | } |
| 46 | |
| 47 | AudioEncoder::EncodedInfo MockAudioEncoder::CopyEncoding::operator()( |
| 48 | uint32_t timestamp, |
| 49 | rtc::ArrayView<const int16_t> audio, |
| 50 | rtc::Buffer* encoded) { |
| 51 | RTC_CHECK(encoded); |
| 52 | RTC_CHECK_LE(info_.encoded_bytes, payload_.size()); |
| 53 | encoded->AppendData(payload_.data(), info_.encoded_bytes); |
| 54 | return info_; |
| 55 | } |
| 56 | |
ossu | 10a029e | 2016-03-01 08:41:31 | [diff] [blame] | 57 | } // namespace webrtc |