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 encoders via BitrateObserver(s).
13 : */
14 :
15 : #ifndef WEBRTC_MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_
16 : #define WEBRTC_MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_
17 :
18 : #include <map>
19 :
20 : #include "webrtc/modules/congestion_controller/delay_based_bwe.h"
21 : #include "webrtc/modules/include/module.h"
22 : #include "webrtc/modules/pacing/paced_sender.h"
23 : #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
24 :
25 : namespace webrtc {
26 :
27 : class CriticalSectionWrapper;
28 : class RtcEventLog;
29 : struct PacketInfo;
30 :
31 : // Deprecated
32 : // TODO(perkj): Remove BitrateObserver when no implementations use it.
33 : class BitrateObserver {
34 : // Observer class for bitrate changes announced due to change in bandwidth
35 : // estimate or due to bitrate allocation changes. Fraction loss and rtt is
36 : // also part of this callback to allow the obsevrer to optimize its settings
37 : // for different types of network environments. The bitrate does not include
38 : // packet headers and is measured in bits per second.
39 : public:
40 : virtual void OnNetworkChanged(uint32_t bitrate_bps,
41 : uint8_t fraction_loss, // 0 - 255.
42 : int64_t rtt_ms) = 0;
43 :
44 : virtual ~BitrateObserver() {}
45 : };
46 :
47 0 : class BitrateController : public Module {
48 : // This class collects feedback from all streams sent to a peer (via
49 : // RTCPBandwidthObservers). It does one aggregated send side bandwidth
50 : // estimation and divide the available bitrate between all its registered
51 : // BitrateObservers.
52 : public:
53 : static const int kDefaultStartBitratebps = 300000;
54 :
55 : // Deprecated:
56 : // TODO(perkj): BitrateObserver has been deprecated and is not used in WebRTC.
57 : // Remove this method once other other projects does not use it.
58 : static BitrateController* CreateBitrateController(Clock* clock,
59 : BitrateObserver* observer,
60 : RtcEventLog* event_log);
61 :
62 : static BitrateController* CreateBitrateController(Clock* clock,
63 : RtcEventLog* event_log);
64 :
65 0 : virtual ~BitrateController() {}
66 :
67 : virtual RtcpBandwidthObserver* CreateRtcpBandwidthObserver() = 0;
68 :
69 : // Deprecated
70 : virtual void SetStartBitrate(int start_bitrate_bps) = 0;
71 : // Deprecated
72 : virtual void SetMinMaxBitrate(int min_bitrate_bps, int max_bitrate_bps) = 0;
73 : virtual void SetBitrates(int start_bitrate_bps,
74 : int min_bitrate_bps,
75 : int max_bitrate_bps) = 0;
76 :
77 : virtual void ResetBitrates(int bitrate_bps,
78 : int min_bitrate_bps,
79 : int max_bitrate_bps) = 0;
80 :
81 : virtual void OnDelayBasedBweResult(const DelayBasedBwe::Result& result) = 0;
82 :
83 : // Gets the available payload bandwidth in bits per second. Note that
84 : // this bandwidth excludes packet headers.
85 : virtual bool AvailableBandwidth(uint32_t* bandwidth) const = 0;
86 :
87 : virtual void SetReservedBitrate(uint32_t reserved_bitrate_bps) = 0;
88 :
89 : virtual bool GetNetworkParameters(uint32_t* bitrate,
90 : uint8_t* fraction_loss,
91 : int64_t* rtt) = 0;
92 : };
93 : } // namespace webrtc
94 : #endif // WEBRTC_MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_
|