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): Call this whereever |
| 50 // CongestionController::OnNetworkRouteChanged is called. And rename it. |
| 51 // Resets the bitrate estimator. |
| 52 virtual void OnNetworkRouteChanged(int min_bitrate_bps); |
| 53 |
| 54 // TODO(nisse): Called by CongestionController, but not otherwise wired up. |
| 55 // Implements CallStatsObserver. |
| 56 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; |
| 57 |
| 58 // Implements Module. |
| 59 int64_t TimeUntilNextProcess() override; |
| 60 void Process() override; |
| 61 |
| 62 private: |
| 63 class WrappingBitrateEstimator : public RemoteBitrateEstimator { |
| 64 public: |
| 65 WrappingBitrateEstimator(RemoteBitrateObserver* observer, |
| 66 const Clock* clock); |
| 67 |
| 68 virtual ~WrappingBitrateEstimator() {} |
| 69 |
| 70 void IncomingPacket(int64_t arrival_time_ms, |
| 71 size_t payload_size, |
| 72 const RTPHeader& header) override; |
| 73 |
| 74 void Process() override; |
| 75 |
| 76 int64_t TimeUntilNextProcess() override; |
| 77 |
| 78 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; |
| 79 |
| 80 void RemoveStream(unsigned int ssrc) override; |
| 81 |
| 82 bool LatestEstimate(std::vector<unsigned int>* ssrcs, |
| 83 unsigned int* bitrate_bps) const override; |
| 84 |
| 85 void SetMinBitrate(int min_bitrate_bps) override; |
| 86 |
| 87 private: |
| 88 void PickEstimatorFromHeader(const RTPHeader& header) |
| 89 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
| 90 void PickEstimator() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
| 91 RemoteBitrateObserver* observer_; |
| 92 const Clock* const clock_; |
| 93 rtc::CriticalSection crit_sect_; |
| 94 std::unique_ptr<RemoteBitrateEstimator> rbe_; |
| 95 bool using_absolute_send_time_; |
| 96 uint32_t packets_since_absolute_send_time_; |
| 97 int min_bitrate_bps_; |
| 98 |
| 99 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WrappingBitrateEstimator); |
| 100 }; |
| 101 |
| 102 WrappingBitrateEstimator remote_bitrate_estimator_; |
| 103 RemoteEstimatorProxy remote_estimator_proxy_; |
| 104 }; |
| 105 |
| 106 } // namespace webrtc |
| 107 |
| 108 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_RECEIVE_SIDE_CONGESTION_
CONTROLLER_H_ |
OLD | NEW |