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