network_state_predictor.h 1.7 KB

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