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

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

Issue 2366333003: 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/optional.h"
22 #include "webrtc/base/rate_statistics.h" 22 #include "webrtc/base/rate_statistics.h"
23 #include "webrtc/base/thread_checker.h" 23 #include "webrtc/base/thread_checker.h"
24 #include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h" 24 #include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h"
25 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" 25 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h"
26 #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"
27 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h" 27 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h"
28 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" 28 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h"
29 #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"
31 30
32 namespace webrtc { 31 namespace webrtc {
33 32
34 class DelayBasedBwe : public RemoteBitrateEstimator { 33 class DelayBasedBwe {
35 public: 34 public:
36 DelayBasedBwe(RemoteBitrateObserver* observer, Clock* clock); 35 static const int64_t kStreamTimeOutMs = 2000;
36
37 struct Result {
38 Result() : updated(false), probe(false), target_bitrate_bps(0) {}
39 Result(bool probe, uint32_t target_bitrate_bps)
40 : updated(true), probe(probe), target_bitrate_bps(target_bitrate_bps) {}
41 bool updated;
42 bool probe;
43 uint32_t target_bitrate_bps;
44 };
45
46 explicit DelayBasedBwe(Clock* clock);
37 virtual ~DelayBasedBwe() {} 47 virtual ~DelayBasedBwe() {}
38 48
39 void IncomingPacketFeedbackVector( 49 Result IncomingPacketFeedbackVector(
40 const std::vector<PacketInfo>& packet_feedback_vector) override; 50 const std::vector<PacketInfo>& packet_feedback_vector);
41 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; 51 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms);
42 bool LatestEstimate(std::vector<uint32_t>* ssrcs, 52 bool LatestEstimate(std::vector<uint32_t>* ssrcs,
43 uint32_t* bitrate_bps) const override; 53 uint32_t* bitrate_bps) const;
44 void SetMinBitrate(int min_bitrate_bps) override; 54 void SetMinBitrate(int min_bitrate_bps);
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 }
57 55
58 private: 56 private:
59 void IncomingPacketInfo(const PacketInfo& info); 57 Result IncomingPacketInfo(const PacketInfo& info);
60 // Updates the current remote rate estimate and returns true if a valid 58 // Updates the current remote rate estimate and returns true if a valid
61 // estimate exists. 59 // estimate exists.
62 bool UpdateEstimate(int64_t packet_arrival_time_ms, 60 bool UpdateEstimate(int64_t packet_arrival_time_ms,
63 int64_t now_ms, 61 int64_t now_ms,
64 uint32_t* target_bitrate_bps) 62 uint32_t* target_bitrate_bps);
65 EXCLUSIVE_LOCKS_REQUIRED(crit_);
66 63
67 rtc::ThreadChecker network_thread_; 64 rtc::ThreadChecker network_thread_;
68 Clock* const clock_; 65 Clock* const clock_;
69 RemoteBitrateObserver* const observer_;
70 std::unique_ptr<InterArrival> inter_arrival_; 66 std::unique_ptr<InterArrival> inter_arrival_;
71 std::unique_ptr<OveruseEstimator> estimator_; 67 std::unique_ptr<OveruseEstimator> estimator_;
72 OveruseDetector detector_; 68 OveruseDetector detector_;
73 RateStatistics incoming_bitrate_; 69 RateStatistics incoming_bitrate_;
74 int64_t last_update_ms_; 70 int64_t last_update_ms_;
75 int64_t last_seen_packet_ms_; 71 int64_t last_seen_packet_ms_;
76 bool uma_recorded_; 72 bool uma_recorded_;
77 73 AimdRateControl remote_rate_;
78 rtc::CriticalSection crit_; 74 ProbeBitrateEstimator probe_bitrate_estimator_;
79 AimdRateControl remote_rate_ GUARDED_BY(&crit_);
80 ProbeBitrateEstimator probe_bitrate_estimator_ GUARDED_BY(&crit_);
81 75
82 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe); 76 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe);
83 }; 77 };
84 78
85 } // namespace webrtc 79 } // namespace webrtc
86 80
87 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ 81 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698