Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: webrtc/voice_engine/network_predictor.cc

Issue 2390883004: Hooking up audio network adaptor to VoE. (Closed)
Patch Set: adding a comment Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 "webrtc/voice_engine/network_predictor.h"
12
13 namespace webrtc {
14 namespace voe {
15
16 NetworkPredictor::NetworkPredictor(Clock* clock)
17 : clock_(clock),
18 last_loss_rate_update_time_ms_(clock_->TimeInMilliseconds()),
19 loss_rate_filter_(new rtc::ExpFilter(0.9999f)) {
20 }
21
22 uint8_t NetworkPredictor::GetLossRate() {
23 float value = loss_rate_filter_->filtered();
24 return (value == rtc::ExpFilter::kValueUndefined) ? 0 :
25 static_cast<uint8_t>(value + 0.5);
26 }
27
28 void NetworkPredictor::UpdatePacketLossRate(uint8_t loss_rate) {
29 int64_t now_ms = clock_->TimeInMilliseconds();
30 // Update the recursive average filter.
31 loss_rate_filter_->Apply(
32 static_cast<float>(now_ms - last_loss_rate_update_time_ms_),
33 static_cast<float>(loss_rate));
34 last_loss_rate_update_time_ms_ = now_ms;
35 }
36
37 } // namespace voe
38 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/network_predictor.h ('k') | webrtc/voice_engine/network_predictor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698