Files
platform-external-webrtc/webrtc/voice_engine/network_predictor.cc
mflodman@webrtc.org 0a7d4eed98 Remove usage of BitrateController in VoiceEngine.
Bitrate controller is used in VoiceEngine to smoothen the fraction loss
from RTCP report blocks. This CL removes the usage of the
BitrateController and calculates its own fraction loss average insted.
This introduces some duplicated code between BitrateController and
Channel, but removes processing overhead and the incorrect bandwidth
estimation numbers reported by the bitrate controller.

BUG=4310
TEST=voe_cmd_test with network simulator
R=minyue@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/39999004

Cr-Commit-Position: refs/heads/master@{#8386}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8386 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-17 12:57:44 +00:00

39 lines
1.2 KiB
C++

/*
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/voice_engine/network_predictor.h"
namespace webrtc {
namespace voe {
NetworkPredictor::NetworkPredictor(Clock* clock)
: clock_(clock),
last_loss_rate_update_time_ms_(clock_->TimeInMilliseconds()),
loss_rate_filter_(new rtc::ExpFilter(0.9999f)) {
}
uint8_t NetworkPredictor::GetLossRate() {
float value = loss_rate_filter_->filtered();
return (value == rtc::ExpFilter::kValueUndefined) ? 0 :
static_cast<uint8_t>(value + 0.5);
}
void NetworkPredictor::UpdatePacketLossRate(uint8_t loss_rate) {
int64_t now_ms = clock_->TimeInMilliseconds();
// Update the recursive average filter.
loss_rate_filter_->Apply(
static_cast<float>(now_ms - last_loss_rate_update_time_ms_),
static_cast<float>(loss_rate));
last_loss_rate_update_time_ms_ = now_ms;
}
} // namespace voe
} // namespace webrtc