• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2018 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_RTP_CONTROL_HANDLER_H_
12 #define MODULES_CONGESTION_CONTROLLER_RTP_CONTROL_HANDLER_H_
13 
14 #include <stdint.h>
15 
16 #include "absl/types/optional.h"
17 #include "api/transport/network_types.h"
18 #include "api/units/data_size.h"
19 #include "api/units/time_delta.h"
20 #include "modules/pacing/paced_sender.h"
21 #include "rtc_base/constructor_magic.h"
22 #include "rtc_base/synchronization/sequence_checker.h"
23 
24 namespace webrtc {
25 // This is used to observe the network controller state and route calls to
26 // the proper handler. It also keeps cached values for safe asynchronous use.
27 // This makes sure that things running on the worker queue can't access state
28 // in RtpTransportControllerSend, which would risk causing data race on
29 // destruction unless members are properly ordered.
30 class CongestionControlHandler {
31  public:
32   CongestionControlHandler();
33   ~CongestionControlHandler();
34 
35   void SetTargetRate(TargetTransferRate new_target_rate);
36   void SetNetworkAvailability(bool network_available);
37   void SetPacerQueue(TimeDelta expected_queue_time);
38   absl::optional<TargetTransferRate> GetUpdate();
39 
40  private:
41   absl::optional<TargetTransferRate> last_incoming_;
42   absl::optional<TargetTransferRate> last_reported_;
43   bool network_available_ = true;
44   bool encoder_paused_in_last_report_ = false;
45 
46   const bool disable_pacer_emergency_stop_;
47   int64_t pacer_expected_queue_ms_ = 0;
48 
49   SequenceChecker sequenced_checker_;
50   RTC_DISALLOW_COPY_AND_ASSIGN(CongestionControlHandler);
51 };
52 }  // namespace webrtc
53 #endif  // MODULES_CONGESTION_CONTROLLER_RTP_CONTROL_HANDLER_H_
54