You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.7 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. #include "test/mock_audio_encoder.h"
  11. namespace webrtc {
  12. MockAudioEncoder::MockAudioEncoder() = default;
  13. MockAudioEncoder::~MockAudioEncoder() = default;
  14. MockAudioEncoder::FakeEncoding::FakeEncoding(
  15. const AudioEncoder::EncodedInfo& info)
  16. : info_(info) {}
  17. MockAudioEncoder::FakeEncoding::FakeEncoding(size_t encoded_bytes) {
  18. info_.encoded_bytes = encoded_bytes;
  19. }
  20. AudioEncoder::EncodedInfo MockAudioEncoder::FakeEncoding::operator()(
  21. uint32_t timestamp,
  22. rtc::ArrayView<const int16_t> audio,
  23. rtc::Buffer* encoded) {
  24. encoded->SetSize(encoded->size() + info_.encoded_bytes);
  25. return info_;
  26. }
  27. MockAudioEncoder::CopyEncoding::~CopyEncoding() = default;
  28. MockAudioEncoder::CopyEncoding::CopyEncoding(
  29. AudioEncoder::EncodedInfo info,
  30. rtc::ArrayView<const uint8_t> payload)
  31. : info_(info), payload_(payload) {}
  32. MockAudioEncoder::CopyEncoding::CopyEncoding(
  33. rtc::ArrayView<const uint8_t> payload)
  34. : payload_(payload) {
  35. info_.encoded_bytes = payload_.size();
  36. }
  37. AudioEncoder::EncodedInfo MockAudioEncoder::CopyEncoding::operator()(
  38. uint32_t timestamp,
  39. rtc::ArrayView<const int16_t> audio,
  40. rtc::Buffer* encoded) {
  41. RTC_CHECK(encoded);
  42. RTC_CHECK_LE(info_.encoded_bytes, payload_.size());
  43. encoded->AppendData(payload_.data(), info_.encoded_bytes);
  44. return info_;
  45. }
  46. } // namespace webrtc