xref: /aosp_15_r20/external/webrtc/modules/congestion_controller/goog_cc/robust_throughput_estimator.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
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_ROBUST_THROUGHPUT_ESTIMATOR_H_
12 #define MODULES_CONGESTION_CONTROLLER_GOOG_CC_ROBUST_THROUGHPUT_ESTIMATOR_H_
13 
14 #include <deque>
15 #include <vector>
16 
17 #include "absl/types/optional.h"
18 #include "api/transport/network_types.h"
19 #include "api/units/data_rate.h"
20 #include "api/units/timestamp.h"
21 #include "modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator_interface.h"
22 
23 namespace webrtc {
24 
25 class RobustThroughputEstimator : public AcknowledgedBitrateEstimatorInterface {
26  public:
27   explicit RobustThroughputEstimator(
28       const RobustThroughputEstimatorSettings& settings);
29   ~RobustThroughputEstimator() override;
30 
31   void IncomingPacketFeedbackVector(
32       const std::vector<PacketResult>& packet_feedback_vector) override;
33 
34   absl::optional<DataRate> bitrate() const override;
35 
PeekRate()36   absl::optional<DataRate> PeekRate() const override { return bitrate(); }
SetAlr(bool)37   void SetAlr(bool /*in_alr*/) override {}
SetAlrEndedTime(Timestamp)38   void SetAlrEndedTime(Timestamp /*alr_ended_time*/) override {}
39 
40  private:
41   bool FirstPacketOutsideWindow();
42 
43   const RobustThroughputEstimatorSettings settings_;
44   std::deque<PacketResult> window_;
45   Timestamp latest_discarded_send_time_ = Timestamp::MinusInfinity();
46 };
47 
48 }  // namespace webrtc
49 
50 #endif  // MODULES_CONGESTION_CONTROLLER_GOOG_CC_ROBUST_THROUGHPUT_ESTIMATOR_H_
51