Index: webrtc/voice_engine/channel.cc |
diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc |
index 582bde5f26216f645340ef2102d87e485ff2fafb..6543789e8b5917be13b11b97717c4eb2abe95283 100644 |
--- a/webrtc/voice_engine/channel.cc |
+++ b/webrtc/voice_engine/channel.cc |
@@ -1285,19 +1285,27 @@ int32_t Channel::SetSendCodec(const CodecInst& codec) { |
void Channel::SetBitRate(int bitrate_bps) { |
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
"Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps); |
- audio_coding_->SetBitRate(bitrate_bps); |
+ audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
+ if (!*encoder) { |
+ // There is no existing encoder. |
+ return; |
+ } |
+ (*encoder)->OnReceivedTargetAudioBitrate(bitrate_bps); |
+ }); |
kwiberg-webrtc
2016/10/06 09:46:13
You can probably just do
if (*encoder) {
(*
minyue-webrtc
2016/10/11 09:00:22
Done.
|
retransmission_rate_limiter_->SetMaxRate(bitrate_bps); |
} |
void Channel::OnIncomingFractionLoss(int fraction_lost) { |
network_predictor_->UpdatePacketLossRate(fraction_lost); |
uint8_t average_fraction_loss = network_predictor_->GetLossRate(); |
- |
- // Normalizes rate to 0 - 100. |
- if (audio_coding_->SetPacketLossRate(100 * average_fraction_loss / 255) != |
- 0) { |
- assert(false); // This should not happen. |
- } |
+ audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
+ if (!*encoder) { |
+ // There is no existing encoder. |
+ return; |
+ } |
+ (*encoder)->OnReceivedUplinkPacketLossFraction(average_fraction_loss / |
+ 255.0f); |
+ }); |
} |
int32_t Channel::SetVADStatus(bool enableVAD, |
@@ -1494,6 +1502,41 @@ int Channel::GetOpusDtx(bool* enabled) { |
return success; |
} |
+bool Channel::EnableAudioNetworkAdaptor(const std::string& config_string) { |
+ bool success = false; |
+ audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
+ if (!*encoder) { |
+ // There is no existing encoder. |
+ return; |
+ } |
+ success = (*encoder)->EnableAudioNetworkAdaptor(config_string, |
+ Clock::GetRealTimeClock()); |
+ }); |
+ return success; |
+} |
+ |
+void Channel::DisableAudioNetworkAdaptor() { |
+ audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
+ if (!*encoder) { |
+ // There is no existing encoder. |
+ return; |
+ } |
+ (*encoder)->DisableAudioNetworkAdaptor(); |
+ }); |
+} |
+ |
+void Channel::SetReceiverFrameLengthRange(int min_frame_length_ms, |
+ int max_frame_length_ms) { |
+ audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
+ if (!*encoder) { |
+ // There is no existing encoder. |
+ return; |
+ } |
+ (*encoder)->SetReceiverFrameLengthRange(min_frame_length_ms, |
+ max_frame_length_ms); |
+ }); |
+} |
+ |
int32_t Channel::RegisterExternalTransport(Transport* transport) { |
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
"Channel::RegisterExternalTransport()"); |
@@ -1654,6 +1697,15 @@ int32_t Channel::ReceivedRTCPPacket(const uint8_t* data, size_t length) { |
} |
retransmission_rate_limiter_->SetWindowSize(nack_window_ms); |
+ // Invoke audio encoders OnReceivedRtt(). |
+ audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
+ if (!*encoder) { |
+ // There is no existing encoder. |
+ return; |
+ } |
+ (*encoder)->OnReceivedRtt(rtt); |
+ }); |
+ |
uint32_t ntp_secs = 0; |
uint32_t ntp_frac = 0; |
uint32_t rtp_timestamp = 0; |