Line data Source code
1 : /*
2 : * Copyright (c) 2016 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 WEBRTC_MODULES_CONGESTION_CONTROLLER_PROBE_CONTROLLER_H_
12 : #define WEBRTC_MODULES_CONGESTION_CONTROLLER_PROBE_CONTROLLER_H_
13 :
14 : #include <initializer_list>
15 :
16 : #include "webrtc/base/criticalsection.h"
17 : #include "webrtc/common_types.h"
18 : #include "webrtc/modules/pacing/paced_sender.h"
19 :
20 : namespace webrtc {
21 :
22 : class Clock;
23 :
24 : // This class controls initiation of probing to estimate initial channel
25 : // capacity. There is also support for probing during a session when max
26 : // bitrate is adjusted by an application.
27 0 : class ProbeController {
28 : public:
29 : ProbeController(PacedSender* pacer, Clock* clock);
30 :
31 : void SetBitrates(int64_t min_bitrate_bps,
32 : int64_t start_bitrate_bps,
33 : int64_t max_bitrate_bps);
34 :
35 : void OnNetworkStateChanged(NetworkState state);
36 :
37 : void SetEstimatedBitrate(int64_t bitrate_bps);
38 :
39 : void EnablePeriodicAlrProbing(bool enable);
40 : void Process();
41 :
42 : private:
43 : enum class State {
44 : // Initial state where no probing has been triggered yet.
45 : kInit,
46 : // Waiting for probing results to continue further probing.
47 : kWaitingForProbingResult,
48 : // Probing is complete.
49 : kProbingComplete,
50 : };
51 :
52 : void InitiateExponentialProbing() EXCLUSIVE_LOCKS_REQUIRED(critsect_);
53 : void InitiateProbing(int64_t now_ms,
54 : std::initializer_list<int64_t> bitrates_to_probe,
55 : bool probe_further) EXCLUSIVE_LOCKS_REQUIRED(critsect_);
56 :
57 : rtc::CriticalSection critsect_;
58 : PacedSender* const pacer_;
59 : Clock* const clock_;
60 : NetworkState network_state_ GUARDED_BY(critsect_);
61 : State state_ GUARDED_BY(critsect_);
62 : int64_t min_bitrate_to_probe_further_bps_ GUARDED_BY(critsect_);
63 : int64_t time_last_probing_initiated_ms_ GUARDED_BY(critsect_);
64 : int64_t estimated_bitrate_bps_ GUARDED_BY(critsect_);
65 : int64_t start_bitrate_bps_ GUARDED_BY(critsect_);
66 : int64_t max_bitrate_bps_ GUARDED_BY(critsect_);
67 : int64_t last_alr_probing_time_ GUARDED_BY(critsect_);
68 : bool enable_periodic_alr_probing_ GUARDED_BY(critsect_);
69 :
70 : // For WebRTC.BWE.MidCallProbing.* metric.
71 : bool mid_call_probing_waiting_for_result_ GUARDED_BY(&critsect_);
72 : int64_t mid_call_probing_bitrate_bps_ GUARDED_BY(&critsect_);
73 : int64_t mid_call_probing_succcess_threshold_ GUARDED_BY(&critsect_);
74 :
75 : RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(ProbeController);
76 : };
77 :
78 : } // namespace webrtc
79 :
80 : #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_PROBE_CONTROLLER_H_
|