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

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

Issue 2468413009: Revert of Change TWCC send interval to reduce overhead on low BW situations. (Closed)
Patch Set: Created 4 years, 1 month 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" 11 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h"
12 12
13 #include <limits> 13 #include <limits>
14 #include <algorithm>
15 14
16 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
17 #include "webrtc/base/logging.h" 16 #include "webrtc/base/logging.h"
18 #include "webrtc/system_wrappers/include/clock.h" 17 #include "webrtc/system_wrappers/include/clock.h"
19 #include "webrtc/modules/pacing/packet_router.h" 18 #include "webrtc/modules/pacing/packet_router.h"
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
22 21
23 namespace webrtc { 22 namespace webrtc {
24 23
25 // TODO(sprang): Tune these! 24 // TODO(sprang): Tune these!
25 const int RemoteEstimatorProxy::kDefaultProcessIntervalMs = 50;
26 const int RemoteEstimatorProxy::kBackWindowMs = 500; 26 const int RemoteEstimatorProxy::kBackWindowMs = 500;
27 const int RemoteEstimatorProxy::kMinSendIntervalMs = 50;
28 const int RemoteEstimatorProxy::kMaxSendIntervalMs = 250;
29 const int RemoteEstimatorProxy::kDefaultSendIntervalMs = 100;
30 27
31 // The maximum allowed value for a timestamp in milliseconds. This is lower 28 // The maximum allowed value for a timestamp in milliseconds. This is lower
32 // than the numerical limit since we often convert to microseconds. 29 // than the numerical limit since we often convert to microseconds.
33 static constexpr int64_t kMaxTimeMs = 30 static constexpr int64_t kMaxTimeMs =
34 std::numeric_limits<int64_t>::max() / 1000; 31 std::numeric_limits<int64_t>::max() / 1000;
35 32
36 RemoteEstimatorProxy::RemoteEstimatorProxy(Clock* clock, 33 RemoteEstimatorProxy::RemoteEstimatorProxy(Clock* clock,
37 PacketRouter* packet_router) 34 PacketRouter* packet_router)
38 : clock_(clock), 35 : clock_(clock),
39 packet_router_(packet_router), 36 packet_router_(packet_router),
40 last_process_time_ms_(-1), 37 last_process_time_ms_(-1),
41 media_ssrc_(0), 38 media_ssrc_(0),
42 feedback_sequence_(0), 39 feedback_sequence_(0),
43 window_start_seq_(-1), 40 window_start_seq_(-1) {}
44 send_interval_ms_(kDefaultSendIntervalMs) {}
45 41
46 RemoteEstimatorProxy::~RemoteEstimatorProxy() {} 42 RemoteEstimatorProxy::~RemoteEstimatorProxy() {}
47 43
48 void RemoteEstimatorProxy::IncomingPacketFeedbackVector( 44 void RemoteEstimatorProxy::IncomingPacketFeedbackVector(
49 const std::vector<PacketInfo>& packet_feedback_vector) { 45 const std::vector<PacketInfo>& packet_feedback_vector) {
50 rtc::CritScope cs(&lock_); 46 rtc::CritScope cs(&lock_);
51 for (PacketInfo info : packet_feedback_vector) 47 for (PacketInfo info : packet_feedback_vector)
52 OnPacketArrival(info.sequence_number, info.arrival_time_ms); 48 OnPacketArrival(info.sequence_number, info.arrival_time_ms);
53 } 49 }
54 50
(...skipping 10 matching lines...) Expand all
65 61
66 OnPacketArrival(header.extension.transportSequenceNumber, arrival_time_ms); 62 OnPacketArrival(header.extension.transportSequenceNumber, arrival_time_ms);
67 } 63 }
68 64
69 bool RemoteEstimatorProxy::LatestEstimate(std::vector<unsigned int>* ssrcs, 65 bool RemoteEstimatorProxy::LatestEstimate(std::vector<unsigned int>* ssrcs,
70 unsigned int* bitrate_bps) const { 66 unsigned int* bitrate_bps) const {
71 return false; 67 return false;
72 } 68 }
73 69
74 int64_t RemoteEstimatorProxy::TimeUntilNextProcess() { 70 int64_t RemoteEstimatorProxy::TimeUntilNextProcess() {
71 int64_t now = clock_->TimeInMilliseconds();
75 int64_t time_until_next = 0; 72 int64_t time_until_next = 0;
76 if (last_process_time_ms_ != -1) { 73 if (last_process_time_ms_ != -1 &&
77 rtc::CritScope cs(&lock_); 74 now - last_process_time_ms_ < kDefaultProcessIntervalMs) {
78 int64_t now = clock_->TimeInMilliseconds(); 75 time_until_next = (last_process_time_ms_ + kDefaultProcessIntervalMs - now);
79 if (now - last_process_time_ms_ < send_interval_ms_)
80 time_until_next = (last_process_time_ms_ + send_interval_ms_ - now);
81 } 76 }
82 return time_until_next; 77 return time_until_next;
83 } 78 }
84 79
85 void RemoteEstimatorProxy::Process() { 80 void RemoteEstimatorProxy::Process() {
86 last_process_time_ms_ = clock_->TimeInMilliseconds(); 81 last_process_time_ms_ = clock_->TimeInMilliseconds();
87 82
88 bool more_to_build = true; 83 bool more_to_build = true;
89 while (more_to_build) { 84 while (more_to_build) {
90 rtcp::TransportFeedback feedback_packet; 85 rtcp::TransportFeedback feedback_packet;
91 if (BuildFeedbackPacket(&feedback_packet)) { 86 if (BuildFeedbackPacket(&feedback_packet)) {
92 RTC_DCHECK(packet_router_ != nullptr); 87 RTC_DCHECK(packet_router_ != nullptr);
93 packet_router_->SendFeedback(&feedback_packet); 88 packet_router_->SendFeedback(&feedback_packet);
94 } else { 89 } else {
95 more_to_build = false; 90 more_to_build = false;
96 } 91 }
97 } 92 }
98 } 93 }
99 94
100 void RemoteEstimatorProxy::OnBitrateChanged(int bitrate_bps) {
101 // TwccReportSize = Ipv4(20B) + UDP(8B) + SRTP(10B) +
102 // AverageTwccReport(30B)
103 // TwccReport size at 50ms interval is 24 byte.
104 // TwccReport size at 250ms interval is 36 byte.
105 // AverageTwccReport = (TwccReport(50ms) + TwccReport(250ms)) / 2
106 constexpr int kTwccReportSize = 20 + 8 + 10 + 30;
107
108 // Let TWCC reports occupy 5% of total bandwidth.
109 rtc::CritScope cs(&lock_);
110 send_interval_ms_ = std::min(
111 std::max(static_cast<int>(
112 kTwccReportSize * 8.0 * 1000.0 / (0.05 * bitrate_bps) + 0.5),
113 kMinSendIntervalMs),
114 kMaxSendIntervalMs);
115 }
116
117 void RemoteEstimatorProxy::OnPacketArrival(uint16_t sequence_number, 95 void RemoteEstimatorProxy::OnPacketArrival(uint16_t sequence_number,
118 int64_t arrival_time) { 96 int64_t arrival_time) {
119 if (arrival_time < 0 || arrival_time > kMaxTimeMs) { 97 if (arrival_time < 0 || arrival_time > kMaxTimeMs) {
120 LOG(LS_WARNING) << "Arrival time out of bounds: " << arrival_time; 98 LOG(LS_WARNING) << "Arrival time out of bounds: " << arrival_time;
121 return; 99 return;
122 } 100 }
123 101
124 // TODO(holmer): We should handle a backwards wrap here if the first 102 // TODO(holmer): We should handle a backwards wrap here if the first
125 // sequence number was small and the new sequence number is large. The 103 // sequence number was small and the new sequence number is large. The
126 // SequenceNumberUnwrapper doesn't do this, so we should replace this with 104 // SequenceNumberUnwrapper doesn't do this, so we should replace this with
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // Note: Don't erase items from packet_arrival_times_ after sending, in case 174 // Note: Don't erase items from packet_arrival_times_ after sending, in case
197 // they need to be re-sent after a reordering. Removal will be handled 175 // they need to be re-sent after a reordering. Removal will be handled
198 // by OnPacketArrival once packets are too old. 176 // by OnPacketArrival once packets are too old.
199 window_start_seq_ = it->first + 1; 177 window_start_seq_ = it->first + 1;
200 } 178 }
201 179
202 return true; 180 return true;
203 } 181 }
204 182
205 } // namespace webrtc 183 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698