tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

control_handler.h (1990B)


      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 <optional>
     17 
     18 #include "api/sequence_checker.h"
     19 #include "api/transport/network_types.h"
     20 #include "api/units/time_delta.h"
     21 #include "rtc_base/system/no_unique_address.h"
     22 
     23 namespace webrtc {
     24 // This is used to observe the network controller state and route calls to
     25 // the proper handler. It also keeps cached values for safe asynchronous use.
     26 // This makes sure that things running on the worker queue can't access state
     27 // in RtpTransportControllerSend, which would risk causing data race on
     28 // destruction unless members are properly ordered.
     29 class CongestionControlHandler {
     30 public:
     31  CongestionControlHandler() = default;
     32 
     33  CongestionControlHandler(const CongestionControlHandler&) = delete;
     34  CongestionControlHandler& operator=(const CongestionControlHandler&) = delete;
     35 
     36  ~CongestionControlHandler() = default;
     37 
     38  void SetTargetRate(TargetTransferRate new_target_rate);
     39  void SetNetworkAvailability(bool network_available);
     40  void SetPacerQueue(TimeDelta expected_queue_time);
     41  std::optional<TargetTransferRate> GetUpdate();
     42 
     43 private:
     44  std::optional<TargetTransferRate> last_incoming_;
     45  std::optional<TargetTransferRate> last_reported_;
     46  bool network_available_ = true;
     47  bool encoder_paused_in_last_report_ = false;
     48 
     49  int64_t pacer_expected_queue_ms_ = 0;
     50 
     51  RTC_NO_UNIQUE_ADDRESS SequenceChecker sequenced_checker_;
     52 };
     53 }  // namespace webrtc
     54 #endif  // MODULES_CONGESTION_CONTROLLER_RTP_CONTROL_HANDLER_H_