pwestin@webrtc.org | 1cd1162 | 2012-04-19 12:13:52 +0000 | [diff] [blame^] | 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 "modules/rtp_rtcp/interface/rtp_rtcp_defines.h" |
| 19 | |
| 20 | namespace webrtc { |
| 21 | |
| 22 | class BitrateObserver { |
| 23 | /* |
| 24 | * Observer class for the encoders, each encoder should implement this class |
| 25 | * to get the target bitrate. It also get the fraction loss and rtt to |
| 26 | * optimize its settings for this type of network. |
| 27 | */ |
| 28 | public: |
| 29 | virtual void OnNetworkChanged(const uint32_t targer_bitrate, |
| 30 | const uint8_t fraction_loss, // 0 - 255. |
| 31 | const uint32_t rtt) = 0; |
| 32 | |
| 33 | protected: |
| 34 | virtual ~BitrateObserver() {} |
| 35 | }; |
| 36 | |
| 37 | // TODO(pwestin) move code from vie_remb in here |
| 38 | |
| 39 | class BitrateController { |
| 40 | /* |
| 41 | * This class collects feedback from all streams sent to a peer (via |
| 42 | * RTCPBandwidthObservers). It does one aggregated send side bandwidth |
| 43 | * estimation and divide the available bitrate between all its registered |
| 44 | * BitrateObservers. |
| 45 | */ |
| 46 | public: |
| 47 | static BitrateController* CreateBitrateController(); |
| 48 | virtual ~BitrateController() {} |
| 49 | |
| 50 | virtual RtcpBandwidthObserver* CreateRtcpBandwidthObserver() = 0; |
| 51 | |
| 52 | /* |
| 53 | * Set the start and max send bitrate used by the bandwidth management. |
| 54 | * |
| 55 | * observer, updates bitrates if already in use. |
| 56 | * min_bitrate_kbit = 0 equals no min bitrate. |
| 57 | * max_bitrate_kit = 0 equals no max bitrate. |
| 58 | */ |
| 59 | virtual void SetBitrateObserver(BitrateObserver* observer, |
| 60 | const uint32_t start_bitrate, |
| 61 | const uint32_t min_bitrate, |
| 62 | const uint32_t max_bitrate) = 0; |
| 63 | |
| 64 | virtual void RemoveBitrateObserver(BitrateObserver* observer) = 0; |
| 65 | }; |
| 66 | } // namespace webrtc |
| 67 | #endif // WEBRTC_MODULES_BITRATE_CONTROLLER_INCLUDE_BITRATE_CONTROLLER_H_ |