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.

116 lines
3.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright (c) 2014 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 "api/audio_codecs/audio_encoder.h"
  11. #include "rtc_base/checks.h"
  12. #include "rtc_base/trace_event.h"
  13. namespace webrtc {
  14. ANAStats::ANAStats() = default;
  15. ANAStats::~ANAStats() = default;
  16. ANAStats::ANAStats(const ANAStats&) = default;
  17. AudioEncoder::EncodedInfo::EncodedInfo() = default;
  18. AudioEncoder::EncodedInfo::EncodedInfo(const EncodedInfo&) = default;
  19. AudioEncoder::EncodedInfo::EncodedInfo(EncodedInfo&&) = default;
  20. AudioEncoder::EncodedInfo::~EncodedInfo() = default;
  21. AudioEncoder::EncodedInfo& AudioEncoder::EncodedInfo::operator=(
  22. const EncodedInfo&) = default;
  23. AudioEncoder::EncodedInfo& AudioEncoder::EncodedInfo::operator=(EncodedInfo&&) =
  24. default;
  25. int AudioEncoder::RtpTimestampRateHz() const {
  26. return SampleRateHz();
  27. }
  28. AudioEncoder::EncodedInfo AudioEncoder::Encode(
  29. uint32_t rtp_timestamp,
  30. rtc::ArrayView<const int16_t> audio,
  31. rtc::Buffer* encoded) {
  32. TRACE_EVENT0("webrtc", "AudioEncoder::Encode");
  33. RTC_CHECK_EQ(audio.size(),
  34. static_cast<size_t>(NumChannels() * SampleRateHz() / 100));
  35. const size_t old_size = encoded->size();
  36. EncodedInfo info = EncodeImpl(rtp_timestamp, audio, encoded);
  37. RTC_CHECK_EQ(encoded->size() - old_size, info.encoded_bytes);
  38. return info;
  39. }
  40. bool AudioEncoder::SetFec(bool enable) {
  41. return !enable;
  42. }
  43. bool AudioEncoder::SetDtx(bool enable) {
  44. return !enable;
  45. }
  46. bool AudioEncoder::GetDtx() const {
  47. return false;
  48. }
  49. bool AudioEncoder::SetApplication(Application application) {
  50. return false;
  51. }
  52. void AudioEncoder::SetMaxPlaybackRate(int frequency_hz) {}
  53. void AudioEncoder::SetTargetBitrate(int target_bps) {}
  54. rtc::ArrayView<std::unique_ptr<AudioEncoder>>
  55. AudioEncoder::ReclaimContainedEncoders() {
  56. return nullptr;
  57. }
  58. bool AudioEncoder::EnableAudioNetworkAdaptor(const std::string& config_string,
  59. RtcEventLog* event_log) {
  60. return false;
  61. }
  62. void AudioEncoder::DisableAudioNetworkAdaptor() {}
  63. void AudioEncoder::OnReceivedUplinkPacketLossFraction(
  64. float uplink_packet_loss_fraction) {}
  65. void AudioEncoder::OnReceivedUplinkRecoverablePacketLossFraction(
  66. float uplink_recoverable_packet_loss_fraction) {}
  67. void AudioEncoder::OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) {
  68. OnReceivedUplinkBandwidth(target_audio_bitrate_bps, absl::nullopt);
  69. }
  70. void AudioEncoder::OnReceivedUplinkBandwidth(
  71. int target_audio_bitrate_bps,
  72. absl::optional<int64_t> bwe_period_ms) {}
  73. void AudioEncoder::OnReceivedUplinkAllocation(BitrateAllocationUpdate update) {
  74. OnReceivedUplinkBandwidth(update.target_bitrate.bps(),
  75. update.bwe_period.ms());
  76. }
  77. void AudioEncoder::OnReceivedRtt(int rtt_ms) {}
  78. void AudioEncoder::OnReceivedOverhead(size_t overhead_bytes_per_packet) {}
  79. void AudioEncoder::SetReceiverFrameLengthRange(int min_frame_length_ms,
  80. int max_frame_length_ms) {}
  81. ANAStats AudioEncoder::GetANAStats() const {
  82. return ANAStats();
  83. }
  84. absl::optional<std::pair<TimeDelta, TimeDelta>>
  85. AudioEncoder::GetFrameLengthRange() const {
  86. return absl::nullopt;
  87. }
  88. } // namespace webrtc