• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 MODULES_CONGESTION_CONTROLLER_GOOG_CC_ACKNOWLEDGED_BITRATE_ESTIMATOR_INTERFACE_H_
12 #define MODULES_CONGESTION_CONTROLLER_GOOG_CC_ACKNOWLEDGED_BITRATE_ESTIMATOR_INTERFACE_H_
13 
14 #include <memory>
15 #include <vector>
16 
17 #include "absl/types/optional.h"
18 #include "api/transport/network_types.h"
19 #include "api/transport/webrtc_key_value_config.h"
20 #include "api/units/data_rate.h"
21 #include "rtc_base/experiments/struct_parameters_parser.h"
22 
23 namespace webrtc {
24 
25 struct RobustThroughputEstimatorSettings {
26   static constexpr char kKey[] = "WebRTC-Bwe-RobustThroughputEstimatorSettings";
27   static constexpr size_t kMaxPackets = 500;
28 
29   RobustThroughputEstimatorSettings() = delete;
30   explicit RobustThroughputEstimatorSettings(
31       const WebRtcKeyValueConfig* key_value_config);
32 
33   bool enabled = false;  // Set to true to use RobustThroughputEstimator.
34 
35   // The estimator handles delay spikes by removing the largest receive time
36   // gap, but this introduces some bias that may lead to overestimation when
37   // there isn't any delay spike. If |reduce_bias| is true, we instead replace
38   // the largest receive time gap by the second largest. This reduces the bias
39   // at the cost of not completely removing the genuine delay spikes.
40   bool reduce_bias = true;
41 
42   // If |assume_shared_link| is false, we ignore the size of the first packet
43   // when computing the receive rate. Otherwise, we remove half of the first
44   // and last packet's sizes.
45   bool assume_shared_link = false;
46 
47   // The estimator window keeps at least |min_packets| packets and up to
48   // kMaxPackets received during the last |window_duration|.
49   unsigned min_packets = 20;
50   TimeDelta window_duration = TimeDelta::Millis(500);
51 
52   // The estimator window requires at least |initial_packets| packets received
53   // over at least |initial_duration|.
54   unsigned initial_packets = 20;
55 
56   // If audio packets are included in allocation, but not in bandwidth
57   // estimation and the sent audio packets get double counted,
58   // then it might be useful to reduce the weight to 0.5.
59   double unacked_weight = 1.0;
60 
61   std::unique_ptr<StructParametersParser> Parser();
62 };
63 
64 class AcknowledgedBitrateEstimatorInterface {
65  public:
66   static std::unique_ptr<AcknowledgedBitrateEstimatorInterface> Create(
67       const WebRtcKeyValueConfig* key_value_config);
68   virtual ~AcknowledgedBitrateEstimatorInterface();
69 
70   virtual void IncomingPacketFeedbackVector(
71       const std::vector<PacketResult>& packet_feedback_vector) = 0;
72   virtual absl::optional<DataRate> bitrate() const = 0;
73   virtual absl::optional<DataRate> PeekRate() const = 0;
74   virtual void SetAlr(bool in_alr) = 0;
75   virtual void SetAlrEndedTime(Timestamp alr_ended_time) = 0;
76 };
77 
78 }  // namespace webrtc
79 
80 #endif  // MODULES_CONGESTION_CONTROLLER_GOOG_CC_ACKNOWLEDGED_BITRATE_ESTIMATOR_INTERFACE_H_
81