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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc

Issue 1481003002: Revert of Make overuse estimator one dimensional. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
(...skipping 10 matching lines...) Expand all
21 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 21 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
22 #include "webrtc/system_wrappers/include/logging.h" 22 #include "webrtc/system_wrappers/include/logging.h"
23 #include "webrtc/typedefs.h" 23 #include "webrtc/typedefs.h"
24 24
25 namespace webrtc { 25 namespace webrtc {
26 26
27 enum { kTimestampGroupLengthMs = 5 }; 27 enum { kTimestampGroupLengthMs = 5 };
28 static const double kTimestampToMs = 1.0 / 90.0; 28 static const double kTimestampToMs = 1.0 / 90.0;
29 29
30 struct RemoteBitrateEstimatorSingleStream::Detector { 30 struct RemoteBitrateEstimatorSingleStream::Detector {
31 explicit Detector(int64_t last_packet_time_ms, bool enable_burst_grouping) 31 explicit Detector(int64_t last_packet_time_ms,
32 : last_packet_time_ms(last_packet_time_ms), 32 const OverUseDetectorOptions& options,
33 inter_arrival(90 * kTimestampGroupLengthMs, 33 bool enable_burst_grouping)
34 kTimestampToMs, 34 : last_packet_time_ms(last_packet_time_ms),
35 enable_burst_grouping), 35 inter_arrival(90 * kTimestampGroupLengthMs, kTimestampToMs,
36 estimator(), 36 enable_burst_grouping),
37 detector() {} 37 estimator(options),
38 detector(options) {}
38 int64_t last_packet_time_ms; 39 int64_t last_packet_time_ms;
39 InterArrival inter_arrival; 40 InterArrival inter_arrival;
40 OveruseEstimator estimator; 41 OveruseEstimator estimator;
41 OveruseDetector detector; 42 OveruseDetector detector;
42 }; 43 };
43 44
44 RemoteBitrateEstimatorSingleStream::RemoteBitrateEstimatorSingleStream( 45 RemoteBitrateEstimatorSingleStream::RemoteBitrateEstimatorSingleStream(
45 RemoteBitrateObserver* observer, 46 RemoteBitrateObserver* observer,
46 Clock* clock) 47 Clock* clock)
47 : clock_(clock), 48 : clock_(clock),
(...skipping 26 matching lines...) Expand all
74 CriticalSectionScoped cs(crit_sect_.get()); 75 CriticalSectionScoped cs(crit_sect_.get());
75 SsrcOveruseEstimatorMap::iterator it = overuse_detectors_.find(ssrc); 76 SsrcOveruseEstimatorMap::iterator it = overuse_detectors_.find(ssrc);
76 if (it == overuse_detectors_.end()) { 77 if (it == overuse_detectors_.end()) {
77 // This is a new SSRC. Adding to map. 78 // This is a new SSRC. Adding to map.
78 // TODO(holmer): If the channel changes SSRC the old SSRC will still be 79 // TODO(holmer): If the channel changes SSRC the old SSRC will still be
79 // around in this map until the channel is deleted. This is OK since the 80 // around in this map until the channel is deleted. This is OK since the
80 // callback will no longer be called for the old SSRC. This will be 81 // callback will no longer be called for the old SSRC. This will be
81 // automatically cleaned up when we have one RemoteBitrateEstimator per REMB 82 // automatically cleaned up when we have one RemoteBitrateEstimator per REMB
82 // group. 83 // group.
83 std::pair<SsrcOveruseEstimatorMap::iterator, bool> insert_result = 84 std::pair<SsrcOveruseEstimatorMap::iterator, bool> insert_result =
84 overuse_detectors_.insert( 85 overuse_detectors_.insert(std::make_pair(
85 std::make_pair(ssrc, new Detector(now_ms, true))); 86 ssrc, new Detector(now_ms, OverUseDetectorOptions(), true)));
86 it = insert_result.first; 87 it = insert_result.first;
87 } 88 }
88 Detector* estimator = it->second; 89 Detector* estimator = it->second;
89 estimator->last_packet_time_ms = now_ms; 90 estimator->last_packet_time_ms = now_ms;
90 incoming_bitrate_.Update(payload_size, now_ms); 91 incoming_bitrate_.Update(payload_size, now_ms);
91 const BandwidthUsage prior_state = estimator->detector.State(); 92 const BandwidthUsage prior_state = estimator->detector.State();
92 uint32_t timestamp_delta = 0; 93 uint32_t timestamp_delta = 0;
93 int64_t time_delta = 0; 94 int64_t time_delta = 0;
95 int size_delta = 0;
94 if (estimator->inter_arrival.ComputeDeltas(rtp_timestamp, arrival_time_ms, 96 if (estimator->inter_arrival.ComputeDeltas(rtp_timestamp, arrival_time_ms,
95 &timestamp_delta, &time_delta)) { 97 payload_size, &timestamp_delta,
98 &time_delta, &size_delta)) {
96 double timestamp_delta_ms = timestamp_delta * kTimestampToMs; 99 double timestamp_delta_ms = timestamp_delta * kTimestampToMs;
97 estimator->estimator.Update(time_delta, timestamp_delta_ms, 100 estimator->estimator.Update(time_delta, timestamp_delta_ms, size_delta,
98 estimator->detector.State()); 101 estimator->detector.State());
99 estimator->detector.Detect(estimator->estimator.offset(), 102 estimator->detector.Detect(estimator->estimator.offset(),
100 timestamp_delta_ms, 103 timestamp_delta_ms,
101 estimator->estimator.num_of_deltas(), now_ms); 104 estimator->estimator.num_of_deltas(), now_ms);
102 } 105 }
103 if (estimator->detector.State() == kBwOverusing) { 106 if (estimator->detector.State() == kBwOverusing) {
104 uint32_t incoming_bitrate_bps = incoming_bitrate_.Rate(now_ms); 107 uint32_t incoming_bitrate_bps = incoming_bitrate_.Rate(now_ms);
105 if (prior_state != kBwOverusing || 108 if (prior_state != kBwOverusing ||
106 remote_rate_->TimeToReduceFurther(now_ms, incoming_bitrate_bps)) { 109 remote_rate_->TimeToReduceFurther(now_ms, incoming_bitrate_bps)) {
107 // The first overuse should immediately trigger a new estimate. 110 // The first overuse should immediately trigger a new estimate.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 (*ssrcs)[i] = it->first; 228 (*ssrcs)[i] = it->first;
226 } 229 }
227 } 230 }
228 231
229 void RemoteBitrateEstimatorSingleStream::SetMinBitrate(int min_bitrate_bps) { 232 void RemoteBitrateEstimatorSingleStream::SetMinBitrate(int min_bitrate_bps) {
230 CriticalSectionScoped cs(crit_sect_.get()); 233 CriticalSectionScoped cs(crit_sect_.get());
231 remote_rate_->SetMinBitrate(min_bitrate_bps); 234 remote_rate_->SetMinBitrate(min_bitrate_bps);
232 } 235 }
233 236
234 } // namespace webrtc 237 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698