Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: webrtc/modules/congestion_controller/delay_based_bwe.h

Issue 2377303002: Revert of Fix race / crash in OnNetworkRouteChanged(). (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ 11 #ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_
12 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ 12 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_
13 13
14 #include <list> 14 #include <list>
15 #include <map> 15 #include <map>
16 #include <memory> 16 #include <memory>
17 #include <vector> 17 #include <vector>
18 18
19 #include "webrtc/base/checks.h" 19 #include "webrtc/base/checks.h"
20 #include "webrtc/base/constructormagic.h" 20 #include "webrtc/base/constructormagic.h"
21 #include "webrtc/base/criticalsection.h"
21 #include "webrtc/base/rate_statistics.h" 22 #include "webrtc/base/rate_statistics.h"
22 #include "webrtc/base/thread_checker.h" 23 #include "webrtc/base/thread_checker.h"
23 #include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h" 24 #include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h"
24 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" 25 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h"
25 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h" 26 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h"
26 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h" 27 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h"
27 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" 28 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h"
28 #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h" 29 #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h"
30 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
29 31
30 namespace webrtc { 32 namespace webrtc {
31 33
32 class DelayBasedBwe { 34 class DelayBasedBwe : public RemoteBitrateEstimator {
33 public: 35 public:
34 static const int64_t kStreamTimeOutMs = 2000; 36 DelayBasedBwe(RemoteBitrateObserver* observer, Clock* clock);
35
36 struct Result {
37 Result() : updated(false), probe(false), target_bitrate_bps(0) {}
38 Result(bool probe, uint32_t target_bitrate_bps)
39 : updated(true), probe(probe), target_bitrate_bps(target_bitrate_bps) {}
40 bool updated;
41 bool probe;
42 uint32_t target_bitrate_bps;
43 };
44
45 explicit DelayBasedBwe(Clock* clock);
46 virtual ~DelayBasedBwe() {} 37 virtual ~DelayBasedBwe() {}
47 38
48 Result IncomingPacketFeedbackVector( 39 void IncomingPacketFeedbackVector(
49 const std::vector<PacketInfo>& packet_feedback_vector); 40 const std::vector<PacketInfo>& packet_feedback_vector) override;
50 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms); 41 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
51 bool LatestEstimate(std::vector<uint32_t>* ssrcs, 42 bool LatestEstimate(std::vector<uint32_t>* ssrcs,
52 uint32_t* bitrate_bps) const; 43 uint32_t* bitrate_bps) const override;
53 void SetMinBitrate(int min_bitrate_bps); 44 void SetMinBitrate(int min_bitrate_bps) override;
45
46 // Required by RemoteBitrateEstimator but does nothing.
47 void Process() override;
48 // Required by RemoteBitrateEstimator but does nothing.
49 int64_t TimeUntilNextProcess() override;
50 // Required by RemoteBitrateEstimator but does nothing.
51 void RemoveStream(uint32_t ssrc) override;
52 void IncomingPacket(int64_t arrival_time_ms,
53 size_t payload_size,
54 const RTPHeader& header) override {
55 RTC_NOTREACHED();
56 }
54 57
55 private: 58 private:
56 Result IncomingPacketInfo(const PacketInfo& info); 59 void IncomingPacketInfo(const PacketInfo& info);
57 // Updates the current remote rate estimate and returns true if a valid 60 // Updates the current remote rate estimate and returns true if a valid
58 // estimate exists. 61 // estimate exists.
59 bool UpdateEstimate(int64_t packet_arrival_time_ms, 62 bool UpdateEstimate(int64_t packet_arrival_time_ms,
60 int64_t now_ms, 63 int64_t now_ms,
61 uint32_t* target_bitrate_bps); 64 uint32_t* target_bitrate_bps)
65 EXCLUSIVE_LOCKS_REQUIRED(crit_);
62 66
63 rtc::ThreadChecker network_thread_; 67 rtc::ThreadChecker network_thread_;
64 Clock* const clock_; 68 Clock* const clock_;
69 RemoteBitrateObserver* const observer_;
65 std::unique_ptr<InterArrival> inter_arrival_; 70 std::unique_ptr<InterArrival> inter_arrival_;
66 std::unique_ptr<OveruseEstimator> estimator_; 71 std::unique_ptr<OveruseEstimator> estimator_;
67 OveruseDetector detector_; 72 OveruseDetector detector_;
68 RateStatistics incoming_bitrate_; 73 RateStatistics incoming_bitrate_;
69 int64_t last_update_ms_; 74 int64_t last_update_ms_;
70 int64_t last_seen_packet_ms_; 75 int64_t last_seen_packet_ms_;
71 bool uma_recorded_; 76 bool uma_recorded_;
72 AimdRateControl remote_rate_; 77
73 ProbeBitrateEstimator probe_bitrate_estimator_; 78 rtc::CriticalSection crit_;
79 AimdRateControl remote_rate_ GUARDED_BY(&crit_);
80 ProbeBitrateEstimator probe_bitrate_estimator_ GUARDED_BY(&crit_);
74 81
75 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe); 82 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe);
76 }; 83 };
77 84
78 } // namespace webrtc 85 } // namespace webrtc
79 86
80 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ 87 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698