tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

audio_encoder.cc (3804B)


      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 
     11 #include "api/audio_codecs/audio_encoder.h"
     12 
     13 #include <cstddef>
     14 #include <cstdint>
     15 #include <memory>
     16 #include <optional>
     17 
     18 #include "absl/strings/string_view.h"
     19 #include "api/array_view.h"
     20 #include "api/call/bitrate_allocation.h"
     21 #include "rtc_base/buffer.h"
     22 #include "rtc_base/checks.h"
     23 #include "rtc_base/trace_event.h"
     24 
     25 namespace webrtc {
     26 
     27 // TODO(peah): Rationale
     28 static_assert(AudioEncoder::kMaxNumberOfChannels <= 255, "");
     29 
     30 ANAStats::ANAStats() = default;
     31 ANAStats::~ANAStats() = default;
     32 ANAStats::ANAStats(const ANAStats&) = default;
     33 
     34 AudioEncoder::EncodedInfo::EncodedInfo() = default;
     35 AudioEncoder::EncodedInfo::EncodedInfo(const EncodedInfo&) = default;
     36 AudioEncoder::EncodedInfo::EncodedInfo(EncodedInfo&&) = default;
     37 AudioEncoder::EncodedInfo::~EncodedInfo() = default;
     38 AudioEncoder::EncodedInfo& AudioEncoder::EncodedInfo::operator=(
     39    const EncodedInfo&) = default;
     40 AudioEncoder::EncodedInfo& AudioEncoder::EncodedInfo::operator=(EncodedInfo&&) =
     41    default;
     42 
     43 int AudioEncoder::RtpTimestampRateHz() const {
     44  return SampleRateHz();
     45 }
     46 
     47 AudioEncoder::EncodedInfo AudioEncoder::Encode(uint32_t rtp_timestamp,
     48                                               ArrayView<const int16_t> audio,
     49                                               Buffer* encoded) {
     50  TRACE_EVENT0("webrtc", "AudioEncoder::Encode");
     51  RTC_CHECK_EQ(audio.size(),
     52               static_cast<size_t>(NumChannels() * SampleRateHz() / 100));
     53 
     54  const size_t old_size = encoded->size();
     55  EncodedInfo info = EncodeImpl(rtp_timestamp, audio, encoded);
     56  RTC_CHECK_EQ(encoded->size() - old_size, info.encoded_bytes);
     57  return info;
     58 }
     59 
     60 bool AudioEncoder::SetFec(bool enable) {
     61  return !enable;
     62 }
     63 
     64 bool AudioEncoder::SetDtx(bool enable) {
     65  return !enable;
     66 }
     67 
     68 bool AudioEncoder::GetDtx() const {
     69  return false;
     70 }
     71 
     72 bool AudioEncoder::SetApplication(Application /* application */) {
     73  return false;
     74 }
     75 
     76 void AudioEncoder::SetMaxPlaybackRate(int /* frequency_hz */) {}
     77 
     78 void AudioEncoder::SetTargetBitrate(int /* target_bps */) {}
     79 
     80 ArrayView<std::unique_ptr<AudioEncoder>>
     81 AudioEncoder::ReclaimContainedEncoders() {
     82  return nullptr;
     83 }
     84 
     85 bool AudioEncoder::EnableAudioNetworkAdaptor(absl::string_view /*config*/) {
     86  return false;
     87 }
     88 
     89 void AudioEncoder::DisableAudioNetworkAdaptor() {}
     90 
     91 void AudioEncoder::OnReceivedUplinkPacketLossFraction(
     92    float /* uplink_packet_loss_fraction */) {}
     93 
     94 void AudioEncoder::OnReceivedUplinkRecoverablePacketLossFraction(
     95    float /* uplink_recoverable_packet_loss_fraction */) {
     96  RTC_DCHECK_NOTREACHED();
     97 }
     98 
     99 void AudioEncoder::OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) {
    100  OnReceivedUplinkBandwidth(target_audio_bitrate_bps, std::nullopt);
    101 }
    102 
    103 void AudioEncoder::OnReceivedUplinkBandwidth(
    104    int /* target_audio_bitrate_bps */,
    105    std::optional<int64_t> /* bwe_period_ms */) {}
    106 
    107 void AudioEncoder::OnReceivedUplinkAllocation(BitrateAllocationUpdate update) {
    108  OnReceivedUplinkBandwidth(update.target_bitrate.bps(),
    109                            update.bwe_period.ms());
    110 }
    111 
    112 void AudioEncoder::OnReceivedRtt(int /* rtt_ms */) {}
    113 
    114 void AudioEncoder::OnReceivedOverhead(size_t /* overhead_bytes_per_packet */) {}
    115 
    116 void AudioEncoder::SetReceiverFrameLengthRange(int /* min_frame_length_ms */,
    117                                               int /* max_frame_length_ms */) {}
    118 
    119 ANAStats AudioEncoder::GetANAStats() const {
    120  return ANAStats();
    121 }
    122 
    123 }  // namespace webrtc