minyue@webrtc.org | 74aaf29 | 2014-07-16 21:28:26 +0000 | [diff] [blame] | 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 | #ifndef WEBRTC_VOICE_ENGINE_NETWORK_PREDICTOR_H_ |
| 12 | #define WEBRTC_VOICE_ENGINE_NETWORK_PREDICTOR_H_ |
| 13 | |
kwiberg | b7f89d6 | 2016-02-17 10:04:18 -0800 | [diff] [blame] | 14 | #include <memory> |
| 15 | |
minyue@webrtc.org | 74aaf29 | 2014-07-16 21:28:26 +0000 | [diff] [blame] | 16 | #include "webrtc/base/exp_filter.h" |
Henrik Kjellander | 98f5351 | 2015-10-28 18:17:40 +0100 | [diff] [blame] | 17 | #include "webrtc/system_wrappers/include/clock.h" |
minyue@webrtc.org | 74aaf29 | 2014-07-16 21:28:26 +0000 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | namespace voe { |
| 22 | |
| 23 | // NetworkPredictor is to predict network conditions e.g., packet loss rate, for |
| 24 | // sender and/or receiver to cope with changes in the network condition. |
| 25 | class NetworkPredictor { |
| 26 | public: |
| 27 | explicit NetworkPredictor(Clock* clock); |
| 28 | ~NetworkPredictor() {} |
| 29 | |
| 30 | // Gets the predicted packet loss rate. |
| 31 | uint8_t GetLossRate(); |
| 32 | |
| 33 | // Updates the packet loss rate predictor, on receiving a new observation of |
| 34 | // packet loss rate from past. Input packet loss rate should be in the |
| 35 | // interval [0, 255]. |
| 36 | void UpdatePacketLossRate(uint8_t loss_rate); |
| 37 | |
| 38 | private: |
| 39 | Clock* clock_; |
| 40 | int64_t last_loss_rate_update_time_ms_; |
| 41 | |
| 42 | // An exponential filter is used to predict packet loss rate. |
kwiberg | b7f89d6 | 2016-02-17 10:04:18 -0800 | [diff] [blame] | 43 | std::unique_ptr<rtc::ExpFilter> loss_rate_filter_; |
minyue@webrtc.org | 74aaf29 | 2014-07-16 21:28:26 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | } // namespace voe |
| 47 | } // namespace webrtc |
| 48 | #endif // WEBRTC_VOICE_ENGINE_NETWORK_PREDICTOR_H_ |