OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" | 11 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" |
12 | 12 |
13 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
14 #include "webrtc/base/trace_event.h" | 14 #include "webrtc/base/trace_event.h" |
15 #include "webrtc/system_wrappers/include/field_trial.h" | |
15 | 16 |
16 namespace webrtc { | 17 namespace webrtc { |
17 | 18 |
18 AudioEncoder::EncodedInfo::EncodedInfo() = default; | 19 AudioEncoder::EncodedInfo::EncodedInfo() = default; |
19 AudioEncoder::EncodedInfo::EncodedInfo(const EncodedInfo&) = default; | 20 AudioEncoder::EncodedInfo::EncodedInfo(const EncodedInfo&) = default; |
20 AudioEncoder::EncodedInfo::EncodedInfo(EncodedInfo&&) = default; | 21 AudioEncoder::EncodedInfo::EncodedInfo(EncodedInfo&&) = default; |
21 AudioEncoder::EncodedInfo::~EncodedInfo() = default; | 22 AudioEncoder::EncodedInfo::~EncodedInfo() = default; |
22 AudioEncoder::EncodedInfo& AudioEncoder::EncodedInfo::operator=( | 23 AudioEncoder::EncodedInfo& AudioEncoder::EncodedInfo::operator=( |
23 const EncodedInfo&) = default; | 24 const EncodedInfo&) = default; |
24 AudioEncoder::EncodedInfo& AudioEncoder::EncodedInfo::operator=(EncodedInfo&&) = | 25 AudioEncoder::EncodedInfo& AudioEncoder::EncodedInfo::operator=(EncodedInfo&&) = |
25 default; | 26 default; |
26 | 27 |
28 AudioEncoder::AudioEncoder() = default; | |
29 AudioEncoder::~AudioEncoder() = default; | |
30 | |
27 int AudioEncoder::RtpTimestampRateHz() const { | 31 int AudioEncoder::RtpTimestampRateHz() const { |
28 return SampleRateHz(); | 32 return SampleRateHz(); |
29 } | 33 } |
30 | 34 |
31 AudioEncoder::EncodedInfo AudioEncoder::Encode( | 35 AudioEncoder::EncodedInfo AudioEncoder::Encode( |
32 uint32_t rtp_timestamp, | 36 uint32_t rtp_timestamp, |
33 rtc::ArrayView<const int16_t> audio, | 37 rtc::ArrayView<const int16_t> audio, |
34 rtc::Buffer* encoded) { | 38 rtc::Buffer* encoded) { |
35 TRACE_EVENT0("webrtc", "AudioEncoder::Encode"); | 39 TRACE_EVENT0("webrtc", "AudioEncoder::Encode"); |
36 RTC_CHECK_EQ(audio.size(), | 40 RTC_CHECK_EQ(audio.size(), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 void AudioEncoder::DisableAudioNetworkAdaptor() {} | 79 void AudioEncoder::DisableAudioNetworkAdaptor() {} |
76 | 80 |
77 void AudioEncoder::OnReceivedUplinkBandwidth(int uplink_bandwidth_bps) {} | 81 void AudioEncoder::OnReceivedUplinkBandwidth(int uplink_bandwidth_bps) {} |
78 | 82 |
79 void AudioEncoder::OnReceivedUplinkPacketLossFraction( | 83 void AudioEncoder::OnReceivedUplinkPacketLossFraction( |
80 float uplink_packet_loss_fraction) { | 84 float uplink_packet_loss_fraction) { |
81 SetProjectedPacketLossRate(uplink_packet_loss_fraction); | 85 SetProjectedPacketLossRate(uplink_packet_loss_fraction); |
82 } | 86 } |
83 | 87 |
84 void AudioEncoder::OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) { | 88 void AudioEncoder::OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) { |
85 SetTargetBitrate(target_audio_bitrate_bps); | 89 if (webrtc::field_trial::FindFullName("WebRTC-SendSideBwe-WithOverhead") == |
90 "Enabled") { | |
91 if (!overhead_bytes_per_packet_) { | |
92 // Ignore the target bitrate is overhead is unknown. | |
93 return; | |
94 } | |
95 int overhead_rate = | |
96 8 * 1000 * *overhead_bytes_per_packet_ / Num10MsFramesInNextPacket(); | |
michaelt
2016/11/24 13:55:18
I think this calculation is wrong by a a factor of
| |
97 SetTargetBitrate(std::max(0, target_audio_bitrate_bps - overhead_rate)); | |
98 } else { | |
99 SetTargetBitrate(target_audio_bitrate_bps); | |
100 } | |
86 } | 101 } |
87 | 102 |
88 void AudioEncoder::OnReceivedRtt(int rtt_ms) {} | 103 void AudioEncoder::OnReceivedRtt(int rtt_ms) {} |
89 | 104 |
105 void AudioEncoder::OnReceivedOverhead(size_t overhead_bytes_per_packet) { | |
106 overhead_bytes_per_packet_ = rtc::Optional<size_t>(overhead_bytes_per_packet); | |
107 } | |
108 | |
90 void AudioEncoder::SetReceiverFrameLengthRange(int min_frame_length_ms, | 109 void AudioEncoder::SetReceiverFrameLengthRange(int min_frame_length_ms, |
91 int max_frame_length_ms) {} | 110 int max_frame_length_ms) {} |
92 | 111 |
93 } // namespace webrtc | 112 } // namespace webrtc |
OLD | NEW |