Line data Source code
1 : /*
2 : * Copyright (c) 2012 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 : * Usage: this class will register multiple RtcpBitrateObserver's one at each
11 : * RTCP module. It will aggregate the results and run one bandwidth estimation
12 : * and push the result to the encoder via VideoEncoderCallback.
13 : */
14 :
15 : #ifndef WEBRTC_MODULES_BITRATE_CONTROLLER_BITRATE_CONTROLLER_IMPL_H_
16 : #define WEBRTC_MODULES_BITRATE_CONTROLLER_BITRATE_CONTROLLER_IMPL_H_
17 :
18 : #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
19 :
20 : #include <list>
21 : #include <utility>
22 : #include <vector>
23 :
24 : #include "webrtc/base/constructormagic.h"
25 : #include "webrtc/base/criticalsection.h"
26 : #include "webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h"
27 :
28 : namespace webrtc {
29 :
30 : class BitrateControllerImpl : public BitrateController {
31 : public:
32 : // TODO(perkj): BitrateObserver has been deprecated and is not used in WebRTC.
33 : // |observer| is left for project that is not yet updated.
34 : BitrateControllerImpl(Clock* clock,
35 : BitrateObserver* observer,
36 : RtcEventLog* event_log);
37 0 : virtual ~BitrateControllerImpl() {}
38 :
39 : bool AvailableBandwidth(uint32_t* bandwidth) const override;
40 :
41 : RtcpBandwidthObserver* CreateRtcpBandwidthObserver() override;
42 :
43 : // Deprecated
44 : void SetStartBitrate(int start_bitrate_bps) override;
45 : // Deprecated
46 : void SetMinMaxBitrate(int min_bitrate_bps, int max_bitrate_bps) override;
47 :
48 : void SetBitrates(int start_bitrate_bps,
49 : int min_bitrate_bps,
50 : int max_bitrate_bps) override;
51 :
52 : void ResetBitrates(int bitrate_bps,
53 : int min_bitrate_bps,
54 : int max_bitrate_bps) override;
55 :
56 :
57 : void SetReservedBitrate(uint32_t reserved_bitrate_bps) override;
58 :
59 : // Returns true if the parameters have changed since the last call.
60 : bool GetNetworkParameters(uint32_t* bitrate,
61 : uint8_t* fraction_loss,
62 : int64_t* rtt) override;
63 :
64 : void OnDelayBasedBweResult(const DelayBasedBwe::Result& result) override;
65 :
66 : int64_t TimeUntilNextProcess() override;
67 : void Process() override;
68 :
69 : private:
70 : class RtcpBandwidthObserverImpl;
71 :
72 : // Called by BitrateObserver's direct from the RTCP module.
73 : void OnReceiverEstimatedBitrate(uint32_t bitrate);
74 :
75 : void OnReceivedRtcpReceiverReport(uint8_t fraction_loss,
76 : int64_t rtt,
77 : int number_of_packets,
78 : int64_t now_ms);
79 :
80 : // Deprecated
81 : void MaybeTriggerOnNetworkChanged();
82 :
83 : void OnNetworkChanged(uint32_t bitrate,
84 : uint8_t fraction_loss, // 0 - 255.
85 : int64_t rtt) EXCLUSIVE_LOCKS_REQUIRED(critsect_);
86 :
87 : // Used by process thread.
88 : Clock* const clock_;
89 : BitrateObserver* const observer_;
90 : int64_t last_bitrate_update_ms_;
91 : RtcEventLog* const event_log_;
92 :
93 : rtc::CriticalSection critsect_;
94 : SendSideBandwidthEstimation bandwidth_estimation_ GUARDED_BY(critsect_);
95 : uint32_t reserved_bitrate_bps_ GUARDED_BY(critsect_);
96 :
97 : uint32_t last_bitrate_bps_ GUARDED_BY(critsect_);
98 : uint8_t last_fraction_loss_ GUARDED_BY(critsect_);
99 : int64_t last_rtt_ms_ GUARDED_BY(critsect_);
100 : uint32_t last_reserved_bitrate_bps_ GUARDED_BY(critsect_);
101 :
102 : RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(BitrateControllerImpl);
103 : };
104 : } // namespace webrtc
105 : #endif // WEBRTC_MODULES_BITRATE_CONTROLLER_BITRATE_CONTROLLER_IMPL_H_
|