OLD | NEW |
(Empty) | |
| 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 |
| 11 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" |
| 12 |
| 13 namespace webrtc { |
| 14 |
| 15 MockAudioEncoder::FakeEncoding::FakeEncoding( |
| 16 const AudioEncoder::EncodedInfo& info) |
| 17 : info_(info) { } |
| 18 |
| 19 MockAudioEncoder::FakeEncoding::FakeEncoding(size_t encoded_bytes) { |
| 20 info_.encoded_bytes = encoded_bytes; |
| 21 } |
| 22 |
| 23 AudioEncoder::EncodedInfo MockAudioEncoder::FakeEncoding::operator()( |
| 24 uint32_t timestamp, |
| 25 rtc::ArrayView<const int16_t> audio, |
| 26 rtc::Buffer* encoded) { |
| 27 encoded->SetSize(encoded->size() + info_.encoded_bytes); |
| 28 return info_; |
| 29 } |
| 30 |
| 31 MockAudioEncoder::CopyEncoding::CopyEncoding( |
| 32 AudioEncoder::EncodedInfo info, |
| 33 rtc::ArrayView<const uint8_t> payload) |
| 34 : info_(info), payload_(payload) { } |
| 35 |
| 36 MockAudioEncoder::CopyEncoding::CopyEncoding( |
| 37 rtc::ArrayView<const uint8_t> payload) |
| 38 : payload_(payload) { |
| 39 info_.encoded_bytes = payload_.size(); |
| 40 } |
| 41 |
| 42 AudioEncoder::EncodedInfo MockAudioEncoder::CopyEncoding::operator()( |
| 43 uint32_t timestamp, |
| 44 rtc::ArrayView<const int16_t> audio, |
| 45 rtc::Buffer* encoded) { |
| 46 RTC_CHECK(encoded); |
| 47 RTC_CHECK_LE(info_.encoded_bytes, payload_.size()); |
| 48 encoded->AppendData(payload_.data(), info_.encoded_bytes); |
| 49 return info_; |
| 50 } |
| 51 |
| 52 MockAudioEncoderDeprecated::CopyEncoding::CopyEncoding( |
| 53 AudioEncoder::EncodedInfo info, |
| 54 rtc::ArrayView<const uint8_t> payload) |
| 55 : info_(info), payload_(payload) { } |
| 56 |
| 57 MockAudioEncoderDeprecated::CopyEncoding::CopyEncoding( |
| 58 rtc::ArrayView<const uint8_t> payload) |
| 59 : payload_(payload) { |
| 60 info_.encoded_bytes = payload_.size(); |
| 61 } |
| 62 |
| 63 AudioEncoder::EncodedInfo MockAudioEncoderDeprecated::CopyEncoding::operator()( |
| 64 uint32_t timestamp, |
| 65 rtc::ArrayView<const int16_t> audio, |
| 66 size_t max_bytes_encoded, |
| 67 uint8_t* encoded) { |
| 68 RTC_CHECK(encoded); |
| 69 RTC_CHECK_LE(info_.encoded_bytes, payload_.size()); |
| 70 std::memcpy(encoded, payload_.data(), info_.encoded_bytes); |
| 71 return info_; |
| 72 } |
| 73 |
| 74 } // namespace webrtc |
OLD | NEW |