1 /* 2 * Copyright (c) 2015 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_REMOTE_BITRATE_ESTIMATOR_REMOTE_BITRATE_ESTIMATOR_SINGLE_STREAM_H_ 12 #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_REMOTE_BITRATE_ESTIMATOR_SINGLE_STREAM_H_ 13 14 #include <map> 15 #include <vector> 16 17 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" 18 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" 19 #include "webrtc/modules/remote_bitrate_estimator/rate_statistics.h" 20 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 21 22 namespace webrtc { 23 24 class RemoteBitrateEstimatorSingleStream : public RemoteBitrateEstimator { 25 public: 26 RemoteBitrateEstimatorSingleStream(RemoteBitrateObserver* observer, 27 Clock* clock); 28 virtual ~RemoteBitrateEstimatorSingleStream(); 29 30 void IncomingPacket(int64_t arrival_time_ms, 31 size_t payload_size, 32 const RTPHeader& header, 33 bool was_paced) override; 34 int32_t Process() override; 35 int64_t TimeUntilNextProcess() override; 36 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; 37 void RemoveStream(unsigned int ssrc) override; 38 bool LatestEstimate(std::vector<unsigned int>* ssrcs, 39 unsigned int* bitrate_bps) const override; 40 bool GetStats(ReceiveBandwidthEstimatorStats* output) const override; 41 void SetMinBitrate(int min_bitrate_bps) override; 42 43 private: 44 struct Detector; 45 46 typedef std::map<unsigned int, Detector*> SsrcOveruseEstimatorMap; 47 48 // Triggers a new estimate calculation. 49 void UpdateEstimate(int64_t time_now) 50 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_.get()); 51 52 void GetSsrcs(std::vector<unsigned int>* ssrcs) const 53 SHARED_LOCKS_REQUIRED(crit_sect_.get()); 54 55 Clock* clock_; 56 SsrcOveruseEstimatorMap overuse_detectors_ GUARDED_BY(crit_sect_.get()); 57 RateStatistics incoming_bitrate_ GUARDED_BY(crit_sect_.get()); 58 rtc::scoped_ptr<AimdRateControl> remote_rate_ GUARDED_BY(crit_sect_.get()); 59 RemoteBitrateObserver* observer_ GUARDED_BY(crit_sect_.get()); 60 rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; 61 int64_t last_process_time_; 62 int64_t process_interval_ms_ GUARDED_BY(crit_sect_.get()); 63 64 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RemoteBitrateEstimatorSingleStream); 65 }; 66 67 } // namespace webrtc 68 69 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_REMOTE_BITRATE_ESTIMATOR_SINGLE_STREAM_H_ 70