OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2017 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_INCLUDE_RECEIVE_SIDE_CONGESTION_CON
TROLLER_H_ |
| 12 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_RECEIVE_SIDE_CONGESTION_CON
TROLLER_H_ |
| 13 |
| 14 #include <memory> |
| 15 #include <vector> |
| 16 |
| 17 #include "webrtc/base/constructormagic.h" |
| 18 #include "webrtc/base/criticalsection.h" |
| 19 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" |
| 20 |
| 21 namespace webrtc { |
| 22 class RemoteBitrateEstimator; |
| 23 class RemoteBitrateObserver; |
| 24 |
| 25 // This class represents the congestion control state for receive |
| 26 // streams. For send side bandwidth estimation, this is simply |
| 27 // relaying for each received RTP packet back to the sender. While for |
| 28 // receive side bandwidth estimation, we do the estimation locally and |
| 29 // send our results back to the sender. |
| 30 class ReceiveSideCongestionController : public CallStatsObserver, |
| 31 public Module { |
| 32 public: |
| 33 ReceiveSideCongestionController( |
| 34 const Clock* clock, |
| 35 RemoteBitrateObserver* remote_bitrate_observer, |
| 36 PacketRouter* packet_router); |
| 37 |
| 38 virtual ~ReceiveSideCongestionController() {} |
| 39 |
| 40 virtual void OnReceivedPacket(int64_t arrival_time_ms, |
| 41 size_t payload_size, |
| 42 const RTPHeader& header); |
| 43 |
| 44 // TODO(nisse): Delete these methods, design a more specific interface. |
| 45 virtual RemoteBitrateEstimator* GetRemoteBitrateEstimator(bool send_side_bwe); |
| 46 virtual const RemoteBitrateEstimator* GetRemoteBitrateEstimator( |
| 47 bool send_side_bwe) const; |
| 48 |
| 49 // TODO(nisse): Called by CongestionController, but not otherwise wired up. |
| 50 // Implements CallStatsObserver. |
| 51 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; |
| 52 |
| 53 // This is send bitrate, used to control the rate of feedback messages. |
| 54 void OnBitrateChanged(int bitrate_bps); |
| 55 |
| 56 // Implements Module. |
| 57 int64_t TimeUntilNextProcess() override; |
| 58 void Process() override; |
| 59 |
| 60 private: |
| 61 class WrappingBitrateEstimator : public RemoteBitrateEstimator { |
| 62 public: |
| 63 WrappingBitrateEstimator(RemoteBitrateObserver* observer, |
| 64 const Clock* clock); |
| 65 |
| 66 virtual ~WrappingBitrateEstimator() {} |
| 67 |
| 68 void IncomingPacket(int64_t arrival_time_ms, |
| 69 size_t payload_size, |
| 70 const RTPHeader& header) override; |
| 71 |
| 72 void Process() override; |
| 73 |
| 74 int64_t TimeUntilNextProcess() override; |
| 75 |
| 76 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; |
| 77 |
| 78 void RemoveStream(unsigned int ssrc) override; |
| 79 |
| 80 bool LatestEstimate(std::vector<unsigned int>* ssrcs, |
| 81 unsigned int* bitrate_bps) const override; |
| 82 |
| 83 void SetMinBitrate(int min_bitrate_bps) override; |
| 84 |
| 85 private: |
| 86 void PickEstimatorFromHeader(const RTPHeader& header) |
| 87 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
| 88 void PickEstimator() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
| 89 RemoteBitrateObserver* observer_; |
| 90 const Clock* const clock_; |
| 91 rtc::CriticalSection crit_sect_; |
| 92 std::unique_ptr<RemoteBitrateEstimator> rbe_; |
| 93 bool using_absolute_send_time_; |
| 94 uint32_t packets_since_absolute_send_time_; |
| 95 int min_bitrate_bps_; |
| 96 |
| 97 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WrappingBitrateEstimator); |
| 98 }; |
| 99 |
| 100 WrappingBitrateEstimator remote_bitrate_estimator_; |
| 101 RemoteEstimatorProxy remote_estimator_proxy_; |
| 102 }; |
| 103 |
| 104 } // namespace webrtc |
| 105 |
| 106 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_RECEIVE_SIDE_CONGESTION_
CONTROLLER_H_ |
OLD | NEW |