Ying Wang | 0810a7c | 2019-04-10 13:48:24 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019 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 API_NETWORK_STATE_PREDICTOR_H_ |
| 12 | #define API_NETWORK_STATE_PREDICTOR_H_ |
| 13 | |
| 14 | #include <memory> |
| 15 | #include <vector> |
| 16 | |
| 17 | namespace webrtc { |
| 18 | |
| 19 | enum class BandwidthUsage { |
| 20 | kBwNormal = 0, |
| 21 | kBwUnderusing = 1, |
| 22 | kBwOverusing = 2, |
| 23 | kLast |
| 24 | }; |
| 25 | |
| 26 | // TODO(yinwa): work in progress. API in class NetworkStatePredictor should not |
| 27 | // be used by other users until this comment is removed. |
| 28 | |
| 29 | // NetworkStatePredictor predict network state based on current network metrics. |
| 30 | // Usage: |
| 31 | // Setup by calling Initialize. |
| 32 | // For each update, call Update. Update returns network state |
| 33 | // prediction. |
| 34 | class NetworkStatePredictor { |
| 35 | public: |
| 36 | virtual ~NetworkStatePredictor() {} |
| 37 | |
| 38 | // Returns current network state prediction. |
| 39 | // Inputs: send_time_ms - packet send time. |
| 40 | // arrival_time_ms - packet arrival time. |
| 41 | // network_state - computed network state. |
| 42 | virtual BandwidthUsage Update(int64_t send_time_ms, |
| 43 | int64_t arrival_time_ms, |
| 44 | BandwidthUsage network_state) = 0; |
| 45 | }; |
| 46 | |
| 47 | class NetworkStatePredictorFactoryInterface { |
| 48 | public: |
| 49 | virtual std::unique_ptr<NetworkStatePredictor> |
| 50 | CreateNetworkStatePredictor() = 0; |
| 51 | virtual ~NetworkStatePredictorFactoryInterface() = default; |
| 52 | }; |
| 53 | |
| 54 | } // namespace webrtc |
| 55 | |
| 56 | #endif // API_NETWORK_STATE_PREDICTOR_H_ |