mediasoup 3.11.21 → 3.11.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/node/lib/Worker.js +1 -1
  2. package/node/lib/index.d.ts +1 -1
  3. package/node/lib/index.js +1 -1
  4. package/package.json +1 -1
  5. package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.cc +20 -1
  6. package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.h +3 -0
  7. package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/delay_based_bwe.cc +2 -2
  8. package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +1 -1
  9. package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/trendline_estimator.cc +113 -106
  10. package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/trendline_estimator.h +47 -26
  11. package/worker/deps/libwebrtc/libwebrtc/rtc_base/experiments/alr_experiment.cc +8 -5
  12. package/worker/deps/libwebrtc/libwebrtc/rtc_base/experiments/alr_experiment.h +1 -0
  13. package/worker/include/RTC/RtcLogger.hpp +58 -0
  14. package/worker/include/RTC/RtpPacket.hpp +4 -0
  15. package/worker/include/RTC/RtpStreamRecv.hpp +3 -1
  16. package/worker/include/RTC/SeqManager.hpp +0 -1
  17. package/worker/meson.build +7 -0
  18. package/worker/meson_options.txt +1 -0
  19. package/worker/src/RTC/PipeConsumer.cpp +15 -0
  20. package/worker/src/RTC/Producer.cpp +14 -1
  21. package/worker/src/RTC/Router.cpp +2 -0
  22. package/worker/src/RTC/RtcLogger.cpp +101 -0
  23. package/worker/src/RTC/RtpPacket.cpp +9 -0
  24. package/worker/src/RTC/RtpStreamRecv.cpp +14 -11
  25. package/worker/src/RTC/SeqManager.cpp +48 -65
  26. package/worker/src/RTC/SimpleConsumer.cpp +17 -0
  27. package/worker/src/RTC/SimulcastConsumer.cpp +34 -0
  28. package/worker/src/RTC/SvcConsumer.cpp +19 -0
  29. package/worker/src/RTC/Transport.cpp +7 -0
  30. package/worker/test/src/RTC/TestRtpStreamRecv.cpp +4 -3
  31. package/worker/test/src/RTC/TestSeqManager.cpp +80 -83
@@ -90,7 +90,7 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter {
90
90
  // options
91
91
  {
92
92
  env: {
93
- MEDIASOUP_VERSION: '3.11.21',
93
+ MEDIASOUP_VERSION: '3.11.22',
94
94
  // Let the worker process inherit all environment variables, useful
95
95
  // if a custom and not in the path GCC is used so the user can set
96
96
  // LD_LIBRARY_PATH environment variable for runtime.
@@ -10,7 +10,7 @@ export { types };
10
10
  /**
11
11
  * Expose mediasoup version.
12
12
  */
13
- export declare const version = "3.11.21";
13
+ export declare const version = "3.11.22";
14
14
  /**
15
15
  * Expose parseScalabilityMode() function.
16
16
  */
package/node/lib/index.js CHANGED
@@ -11,7 +11,7 @@ exports.types = types;
11
11
  /**
12
12
  * Expose mediasoup version.
13
13
  */
14
- exports.version = '3.11.21';
14
+ exports.version = '3.11.22';
15
15
  /**
16
16
  * Expose parseScalabilityMode() function.
17
17
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasoup",
3
- "version": "3.11.21",
3
+ "version": "3.11.22",
4
4
  "description": "Cutting Edge WebRTC Video Conferencing",
5
5
  "contributors": [
6
6
  "Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
@@ -62,6 +62,11 @@ AlrDetector::AlrDetector(
62
62
  experiment_settings
63
63
  ? experiment_settings->alr_stop_budget_level_percent / 100.0
64
64
  : kDefaultStopBudgetLevelRatio),
65
+ alr_timeout_(
66
+ "alr_timeout",
67
+ experiment_settings
68
+ ? experiment_settings->alr_timeout
69
+ : kDefaultAlrTimeout),
65
70
  alr_budget_(0, true) {
66
71
  ParseFieldTrial({&bandwidth_usage_ratio_, &start_budget_level_ratio_,
67
72
  &stop_budget_level_ratio_},
@@ -73,7 +78,7 @@ AlrDetector::~AlrDetector() {}
73
78
  void AlrDetector::OnBytesSent(size_t bytes_sent, int64_t send_time_ms) {
74
79
  if (!last_send_time_ms_.has_value()) {
75
80
  last_send_time_ms_ = send_time_ms;
76
- // Since the duration for sending the bytes is unknwon, return without
81
+ // Since the duration for sending the bytes is unknown, return without
77
82
  // updating alr state.
78
83
  return;
79
84
  }
@@ -109,4 +114,18 @@ absl::optional<int64_t> AlrDetector::GetApplicationLimitedRegionStartTime()
109
114
  return alr_started_time_ms_;
110
115
  }
111
116
 
117
+ absl::optional<int64_t> AlrDetector::GetApplicationLimitedRegionStartTime(
118
+ int64_t at_time_ms) {
119
+ if (!alr_started_time_ms_ && *last_send_time_ms_) {
120
+ int64_t delta_time_ms = at_time_ms - *last_send_time_ms_;
121
+ // If ALR is stopped and we haven't sent any packets for a while, force start.
122
+ if (delta_time_ms > alr_timeout_) {
123
+ MS_WARN_TAG(bwe, "large delta_time_ms: %ld, forcing alr state change",
124
+ delta_time_ms);
125
+ alr_started_time_ms_.emplace(at_time_ms);
126
+ }
127
+ }
128
+ return alr_started_time_ms_;
129
+ }
130
+
112
131
  } // namespace webrtc
@@ -43,6 +43,7 @@ class AlrDetector {
43
43
  // Returns time in milliseconds when the current application-limited region
44
44
  // started or empty result if the sender is currently not application-limited.
45
45
  absl::optional<int64_t> GetApplicationLimitedRegionStartTime() const;
46
+ absl::optional<int64_t> GetApplicationLimitedRegionStartTime(int64_t at_time_ms);
46
47
 
47
48
  void UpdateBudgetWithElapsedTime(int64_t delta_time_ms);
48
49
  void UpdateBudgetWithBytesSent(size_t bytes_sent);
@@ -56,6 +57,7 @@ class AlrDetector {
56
57
  static constexpr double kDefaultBandwidthUsageRatio = 0.65;
57
58
  static constexpr double kDefaultStartBudgetLevelRatio = 0.80;
58
59
  static constexpr double kDefaultStopBudgetLevelRatio = 0.50;
60
+ static constexpr int kDefaultAlrTimeout = 3000;
59
61
 
60
62
  AlrDetector(const WebRtcKeyValueConfig* key_value_config,
61
63
  absl::optional<AlrExperimentSettings> experiment_settings);
@@ -64,6 +66,7 @@ class AlrDetector {
64
66
  FieldTrialParameter<double> bandwidth_usage_ratio_;
65
67
  FieldTrialParameter<double> start_budget_level_ratio_;
66
68
  FieldTrialParameter<double> stop_budget_level_ratio_;
69
+ FieldTrialParameter<int> alr_timeout_;
67
70
 
68
71
  absl::optional<int64_t> last_send_time_ms_;
69
72
 
@@ -61,7 +61,7 @@ DelayBasedBwe::DelayBasedBwe(const WebRtcKeyValueConfig* key_value_config,
61
61
  network_state_predictor_(network_state_predictor),
62
62
  inter_arrival_(),
63
63
  delay_detector_(
64
- new TrendlineEstimator(key_value_config_, network_state_predictor_)),
64
+ new TrendlineEstimator(network_state_predictor_)),
65
65
  last_seen_packet_(Timestamp::MinusInfinity()),
66
66
  uma_recorded_(false),
67
67
  rate_control_(key_value_config, /*send_side=*/true),
@@ -127,7 +127,7 @@ void DelayBasedBwe::IncomingPacketFeedback(const PacketResult& packet_feedback,
127
127
  new InterArrival((kTimestampGroupLengthMs << kInterArrivalShift) / 1000,
128
128
  kTimestampToMs, true));
129
129
  delay_detector_.reset(
130
- new TrendlineEstimator(key_value_config_, network_state_predictor_));
130
+ new TrendlineEstimator(network_state_predictor_));
131
131
  }
132
132
  last_seen_packet_ = at_time;
133
133
 
@@ -195,7 +195,7 @@ NetworkControlUpdate GoogCcNetworkController::OnProcessInterval(
195
195
  }
196
196
  bandwidth_estimation_->UpdateEstimate(msg.at_time);
197
197
  absl::optional<int64_t> start_time_ms =
198
- alr_detector_->GetApplicationLimitedRegionStartTime();
198
+ alr_detector_->GetApplicationLimitedRegionStartTime(msg.at_time.ms());
199
199
  probe_controller_->SetAlrStartTimeMs(start_time_ms);
200
200
 
201
201
  auto probes = probe_controller_->Process(msg.at_time.ms());
@@ -13,96 +13,92 @@
13
13
 
14
14
  #include "modules/congestion_controller/goog_cc/trendline_estimator.h"
15
15
 
16
- #include "modules/remote_bitrate_estimator/include/bwe_defines.h"
17
- #include "rtc_base/numerics/safe_minmax.h"
18
-
19
- #include "Logger.hpp"
20
-
21
- #include <absl/types/optional.h>
22
16
  #include <math.h>
17
+
23
18
  #include <algorithm>
24
19
  #include <string>
25
20
 
21
+ #include "absl/strings/match.h"
22
+ #include "absl/types/optional.h"
23
+ #include "api/network_state_predictor.h"
24
+ #include "rtc_base/numerics/safe_minmax.h"
25
+ #include "api/transport/webrtc_key_value_config.h"
26
+
27
+ #include "Logger.hpp"
28
+
26
29
  namespace webrtc {
27
30
 
28
31
  namespace {
29
32
 
30
33
  // Parameters for linear least squares fit of regression line to noisy data.
31
- constexpr size_t kDefaultTrendlineWindowSize = 20;
32
- constexpr double kDefaultTrendlineSmoothingCoeff = 0.6;
34
+ constexpr double kDefaultTrendlineSmoothingCoeff = 0.9;
33
35
  constexpr double kDefaultTrendlineThresholdGain = 4.0;
34
- const char kBweWindowSizeInPacketsExperiment[] =
35
- "WebRTC-BweWindowSizeInPackets";
36
-
37
- size_t ReadTrendlineFilterWindowSize(
38
- const WebRtcKeyValueConfig* key_value_config) {
39
- std::string experiment_string =
40
- key_value_config->Lookup(kBweWindowSizeInPacketsExperiment);
41
- size_t window_size;
42
- int parsed_values =
43
- sscanf(experiment_string.c_str(), "Enabled-%zu", &window_size);
44
- if (parsed_values == 1) {
45
- if (window_size > 1)
46
- return window_size;
47
- MS_WARN_DEV("window size must be greater than 1");
48
- }
49
- MS_WARN_DEV(
50
- "failed to parse parameters for BweWindowSizeInPackets"
51
- " experiment from field trial string, using default");
52
- return kDefaultTrendlineWindowSize;
53
- }
54
36
 
55
37
  absl::optional<double> LinearFitSlope(
56
- const std::deque<std::pair<double, double>>& points) {
57
- //RTC_DCHECK(points.size() >= 2);
38
+ const std::deque<TrendlineEstimator::PacketTiming>& packets) {
39
+ // RTC_DCHECK(packets.size() >= 2);
58
40
  // Compute the "center of mass".
59
41
  double sum_x = 0;
60
42
  double sum_y = 0;
61
- for (const auto& point : points) {
62
- sum_x += point.first;
63
- sum_y += point.second;
43
+ for (const auto& packet : packets) {
44
+ sum_x += packet.arrival_time_ms;
45
+ sum_y += packet.smoothed_delay_ms;
64
46
  }
65
- double x_avg = sum_x / points.size();
66
- double y_avg = sum_y / points.size();
47
+ double x_avg = sum_x / packets.size();
48
+ double y_avg = sum_y / packets.size();
67
49
  // Compute the slope k = \sum (x_i-x_avg)(y_i-y_avg) / \sum (x_i-x_avg)^2
68
50
  double numerator = 0;
69
51
  double denominator = 0;
70
- for (const auto& point : points) {
71
- numerator += (point.first - x_avg) * (point.second - y_avg);
72
- denominator += (point.first - x_avg) * (point.first - x_avg);
52
+ for (const auto& packet : packets) {
53
+ double x = packet.arrival_time_ms;
54
+ double y = packet.smoothed_delay_ms;
55
+ numerator += (x - x_avg) * (y - y_avg);
56
+ denominator += (x - x_avg) * (x - x_avg);
73
57
  }
74
58
  if (denominator == 0)
75
59
  return absl::nullopt;
76
60
  return numerator / denominator;
77
61
  }
78
62
 
63
+ absl::optional<double> ComputeSlopeCap(
64
+ const std::deque<TrendlineEstimator::PacketTiming>& packets,
65
+ const TrendlineEstimatorSettings& settings) {
66
+ // RTC_DCHECK(1 <= settings.beginning_packets &&
67
+ // settings.beginning_packets < packets.size());
68
+ // RTC_DCHECK(1 <= settings.end_packets &&
69
+ // settings.end_packets < packets.size());
70
+ // RTC_DCHECK(settings.beginning_packets + settings.end_packets <=
71
+ // packets.size());
72
+ TrendlineEstimator::PacketTiming early = packets[0];
73
+ for (size_t i = 1; i < settings.beginning_packets; ++i) {
74
+ if (packets[i].raw_delay_ms < early.raw_delay_ms)
75
+ early = packets[i];
76
+ }
77
+ size_t late_start = packets.size() - settings.end_packets;
78
+ TrendlineEstimator::PacketTiming late = packets[late_start];
79
+ for (size_t i = late_start + 1; i < packets.size(); ++i) {
80
+ if (packets[i].raw_delay_ms < late.raw_delay_ms)
81
+ late = packets[i];
82
+ }
83
+ if (late.arrival_time_ms - early.arrival_time_ms < 1) {
84
+ return absl::nullopt;
85
+ }
86
+ return (late.raw_delay_ms - early.raw_delay_ms) /
87
+ (late.arrival_time_ms - early.arrival_time_ms) +
88
+ settings.cap_uncertainty;
89
+ }
90
+
79
91
  constexpr double kMaxAdaptOffsetMs = 15.0;
80
- constexpr double kOverUsingTimeThreshold = 30;
92
+ constexpr double kOverUsingTimeThreshold = 10;
81
93
  constexpr int kMinNumDeltas = 60;
82
94
  constexpr int kDeltaCounterMax = 1000;
83
95
 
84
96
  } // namespace
85
97
 
86
98
  TrendlineEstimator::TrendlineEstimator(
87
- const WebRtcKeyValueConfig* key_value_config,
88
99
  NetworkStatePredictor* network_state_predictor)
89
- : TrendlineEstimator(
90
- key_value_config->Lookup(kBweWindowSizeInPacketsExperiment)
91
- .find("Enabled") == 0
92
- ? ReadTrendlineFilterWindowSize(key_value_config)
93
- : kDefaultTrendlineWindowSize,
94
- kDefaultTrendlineSmoothingCoeff,
95
- kDefaultTrendlineThresholdGain,
96
- network_state_predictor) {}
97
-
98
- TrendlineEstimator::TrendlineEstimator(
99
- size_t window_size,
100
- double smoothing_coef,
101
- double threshold_gain,
102
- NetworkStatePredictor* network_state_predictor)
103
- : window_size_(window_size),
104
- smoothing_coef_(smoothing_coef),
105
- threshold_gain_(threshold_gain),
100
+ : smoothing_coef_(kDefaultTrendlineSmoothingCoeff),
101
+ threshold_gain_(kDefaultTrendlineThresholdGain),
106
102
  num_of_deltas_(0),
107
103
  first_arrival_time_ms_(-1),
108
104
  accumulated_delay_(0),
@@ -120,63 +116,75 @@ TrendlineEstimator::TrendlineEstimator(
120
116
  hypothesis_(BandwidthUsage::kBwNormal),
121
117
  hypothesis_predicted_(BandwidthUsage::kBwNormal),
122
118
  network_state_predictor_(network_state_predictor) {
123
- MS_DEBUG_DEV(
124
- "using Trendline filter for delay change estimation with window size: %zu",
125
- window_size_);
126
119
  }
127
120
 
128
121
  TrendlineEstimator::~TrendlineEstimator() {}
129
122
 
123
+ void TrendlineEstimator::UpdateTrendline(double recv_delta_ms,
124
+ double send_delta_ms,
125
+ int64_t send_time_ms,
126
+ int64_t arrival_time_ms) {
127
+ const double delta_ms = recv_delta_ms - send_delta_ms;
128
+ ++num_of_deltas_;
129
+ num_of_deltas_ = std::min(num_of_deltas_, kDeltaCounterMax);
130
+ if (first_arrival_time_ms_ == -1)
131
+ first_arrival_time_ms_ = arrival_time_ms;
132
+
133
+ // Exponential backoff filter.
134
+ accumulated_delay_ += delta_ms;
135
+ // BWE_TEST_LOGGING_PLOT(1, "accumulated_delay_ms", arrival_time_ms,
136
+ // accumulated_delay_);
137
+ smoothed_delay_ = smoothing_coef_ * smoothed_delay_ +
138
+ (1 - smoothing_coef_) * accumulated_delay_;
139
+ // BWE_TEST_LOGGING_PLOT(1, "smoothed_delay_ms", arrival_time_ms,
140
+ // smoothed_delay_);
141
+
142
+ // Maintain packet window
143
+ delay_hist_.emplace_back(
144
+ static_cast<double>(arrival_time_ms - first_arrival_time_ms_),
145
+ smoothed_delay_, accumulated_delay_);
146
+ if (settings_.enable_sort) {
147
+ for (size_t i = delay_hist_.size() - 1;
148
+ i > 0 &&
149
+ delay_hist_[i].arrival_time_ms < delay_hist_[i - 1].arrival_time_ms;
150
+ --i) {
151
+ std::swap(delay_hist_[i], delay_hist_[i - 1]);
152
+ }
153
+ }
154
+ if (delay_hist_.size() > settings_.window_size)
155
+ delay_hist_.pop_front();
156
+
157
+ // Simple linear regression.
158
+ double trend = prev_trend_;
159
+ if (delay_hist_.size() == settings_.window_size) {
160
+ // Update trend_ if it is possible to fit a line to the data. The delay
161
+ // trend can be seen as an estimate of (send_rate - capacity)/capacity.
162
+ // 0 < trend < 1 -> the delay increases, queues are filling up
163
+ // trend == 0 -> the delay does not change
164
+ // trend < 0 -> the delay decreases, queues are being emptied
165
+ trend = LinearFitSlope(delay_hist_).value_or(trend);
166
+ if (settings_.enable_cap) {
167
+ absl::optional<double> cap = ComputeSlopeCap(delay_hist_, settings_);
168
+ // We only use the cap to filter out overuse detections, not
169
+ // to detect additional underuses.
170
+ if (trend >= 0 && cap.has_value() && trend > cap.value()) {
171
+ trend = cap.value();
172
+ }
173
+ }
174
+ }
175
+ // BWE_TEST_LOGGING_PLOT(1, "trendline_slope", arrival_time_ms, trend);
176
+
177
+ Detect(trend, send_delta_ms, arrival_time_ms);
178
+ }
179
+
130
180
  void TrendlineEstimator::Update(double recv_delta_ms,
131
181
  double send_delta_ms,
132
182
  int64_t send_time_ms,
133
183
  int64_t arrival_time_ms,
134
184
  bool calculated_deltas) {
135
185
  if (calculated_deltas) {
136
- const double delta_ms = recv_delta_ms - send_delta_ms;
137
- ++num_of_deltas_;
138
- num_of_deltas_ = std::min(num_of_deltas_, kDeltaCounterMax);
139
- if (first_arrival_time_ms_ == -1)
140
- first_arrival_time_ms_ = arrival_time_ms;
141
-
142
- // Exponential backoff filter.
143
- accumulated_delay_ += delta_ms;
144
- // BWE_TEST_LOGGING_PLOT(1, "accumulated_delay_ms", arrival_time_ms,
145
- // accumulated_delay_);
146
- // smoothed_delay_ = smoothing_coef_ * smoothed_delay_ +
147
- // (1 - smoothing_coef_) * accumulated_delay_;
148
- // MS_NOTE: Apply WEMA to the current delta_ms. Don't consider the
149
- // accumulated delay. Tests show it behaves more robustly upon delta peaks.
150
- smoothed_delay_ = smoothing_coef_ * delta_ms +
151
- (1 - smoothing_coef_) * smoothed_delay_;
152
- // BWE_TEST_LOGGING_PLOT(1, "smoothed_delay_ms", arrival_time_ms,
153
- // smoothed_delay_);
154
-
155
- // Simple linear regression.
156
- delay_hist_.push_back(std::make_pair(
157
- static_cast<double>(arrival_time_ms - first_arrival_time_ms_),
158
- smoothed_delay_));
159
- if (delay_hist_.size() > window_size_)
160
- delay_hist_.pop_front();
161
- double trend = prev_trend_;
162
- if (delay_hist_.size() == window_size_) {
163
- // Update trend_ if it is possible to fit a line to the data. The delay
164
- // trend can be seen as an estimate of (send_rate - capacity)/capacity.
165
- // 0 < trend < 1 -> the delay increases, queues are filling up
166
- // trend == 0 -> the delay does not change
167
- // trend < 0 -> the delay decreases, queues are being emptied
168
- trend = LinearFitSlope(delay_hist_).value_or(trend);
169
- }
170
-
171
- // BWE_TEST_LOGGING_PLOT(1, "trendline_slope", arrival_time_ms, trend);
172
-
173
- MS_DEBUG_DEV("trend:%f, send_delta_ms:%f, recv_delta_ms:%f, delta_ms:%f arrival_time_ms:%" PRIi64 ", accumulated_delay_:%f, smoothed_delay_:%f", trend, send_delta_ms, recv_delta_ms, delta_ms, arrival_time_ms, accumulated_delay_, smoothed_delay_);
174
- Detect(trend, send_delta_ms, arrival_time_ms);
175
- }
176
- else {
177
- MS_DEBUG_DEV("no calculated deltas");
186
+ UpdateTrendline(recv_delta_ms, send_delta_ms, send_time_ms, arrival_time_ms);
178
187
  }
179
-
180
188
  if (network_state_predictor_) {
181
189
  hypothesis_predicted_ = network_state_predictor_->Update(
182
190
  send_time_ms, arrival_time_ms, hypothesis_);
@@ -212,6 +220,7 @@ void TrendlineEstimator::Detect(double trend, double ts_delta, int64_t now_ms) {
212
220
  if (trend >= prev_trend_) {
213
221
  time_over_using_ = 0;
214
222
  overuse_counter_ = 0;
223
+ hypothesis_ = BandwidthUsage::kBwOverusing;
215
224
  MS_DEBUG_DEV("hypothesis_: BandwidthUsage::kBwOverusing");
216
225
 
217
226
  #if MS_LOG_DEV_LEVEL == 3
@@ -219,8 +228,6 @@ void TrendlineEstimator::Detect(double trend, double ts_delta, int64_t now_ms) {
219
228
  MS_DEBUG_DEV("arrival_time_ms - first_arrival_time_ms_:%f, smoothed_delay_:%f", kv.first, kv.second);
220
229
  }
221
230
  #endif
222
-
223
- hypothesis_ = BandwidthUsage::kBwOverusing;
224
231
  }
225
232
  }
226
233
  } else if (modified_trend < -threshold_) {
@@ -231,8 +238,8 @@ void TrendlineEstimator::Detect(double trend, double ts_delta, int64_t now_ms) {
231
238
  } else {
232
239
  time_over_using_ = -1;
233
240
  overuse_counter_ = 0;
234
- MS_DEBUG_DEV("---- BandwidthUsage::kBwNormal ---");
235
241
  hypothesis_ = BandwidthUsage::kBwNormal;
242
+ MS_DEBUG_DEV("---- BandwidthUsage::kBwNormal ---");
236
243
  }
237
244
  prev_trend_ = trend;
238
245
  UpdateThreshold(modified_trend, now_ms);
@@ -10,37 +10,48 @@
10
10
  #ifndef MODULES_CONGESTION_CONTROLLER_GOOG_CC_TRENDLINE_ESTIMATOR_H_
11
11
  #define MODULES_CONGESTION_CONTROLLER_GOOG_CC_TRENDLINE_ESTIMATOR_H_
12
12
 
13
+ #include <stddef.h>
14
+ #include <stdint.h>
15
+
16
+ #include <deque>
17
+ #include <memory>
18
+ #include <utility>
19
+
13
20
  #include "api/network_state_predictor.h"
14
21
  #include "api/transport/webrtc_key_value_config.h"
15
22
  #include "modules/congestion_controller/goog_cc/delay_increase_detector_interface.h"
16
23
  #include "modules/remote_bitrate_estimator/include/bwe_defines.h"
17
24
  #include "rtc_base/constructor_magic.h"
18
25
 
19
- #include <stddef.h>
20
- #include <stdint.h>
21
- #include <deque>
22
- #include <utility>
23
-
24
26
  namespace webrtc {
25
27
 
28
+ struct TrendlineEstimatorSettings {
29
+ static constexpr unsigned kDefaultTrendlineWindowSize = 20;
30
+
31
+ // Sort the packets in the window. Should be redundant,
32
+ // but then almost no cost.
33
+ bool enable_sort = false;
34
+
35
+ // Cap the trendline slope based on the minimum delay seen
36
+ // in the beginning_packets and end_packets respectively.
37
+ bool enable_cap = false;
38
+ unsigned beginning_packets = 7;
39
+ unsigned end_packets = 7;
40
+ double cap_uncertainty = 0.0;
41
+
42
+ // Size (in packets) of the window.
43
+ unsigned window_size = kDefaultTrendlineWindowSize;
44
+ };
45
+
26
46
  class TrendlineEstimator : public DelayIncreaseDetectorInterface {
27
47
  public:
28
- TrendlineEstimator(const WebRtcKeyValueConfig* key_value_config,
29
- NetworkStatePredictor* network_state_predictor);
30
- // |window_size| is the number of points required to compute a trend line.
31
- // |smoothing_coef| controls how much we smooth out the delay before fitting
32
- // the trend line. |threshold_gain| is used to scale the trendline slope for
33
- // comparison to the old threshold. Once the old estimator has been removed
34
- // (or the thresholds been merged into the estimators), we can just set the
35
- // threshold instead of setting a gain.|network_state_predictor| is used to
36
- // bettter predict network state.
37
- TrendlineEstimator(size_t window_size,
38
- double smoothing_coef,
39
- double threshold_gain,
40
- NetworkStatePredictor* network_state_predictor);
48
+ TrendlineEstimator(NetworkStatePredictor* network_state_predictor);
41
49
 
42
50
  ~TrendlineEstimator() override;
43
51
 
52
+ TrendlineEstimator(const TrendlineEstimator&) = delete;
53
+ TrendlineEstimator& operator=(const TrendlineEstimator&) = delete;
54
+
44
55
  // Update the estimator with a new sample. The deltas should represent deltas
45
56
  // between timestamp groups as defined by the InterArrival class.
46
57
  void Update(double recv_delta_ms,
@@ -49,21 +60,33 @@ class TrendlineEstimator : public DelayIncreaseDetectorInterface {
49
60
  int64_t arrival_time_ms,
50
61
  bool calculated_deltas) override;
51
62
 
63
+ void UpdateTrendline(double recv_delta_ms,
64
+ double send_delta_ms,
65
+ int64_t send_time_ms,
66
+ int64_t arrival_time_ms);
67
+
52
68
  BandwidthUsage State() const override;
53
69
 
54
- protected:
55
- // Used in unit tests.
56
- double modified_trend() const { return prev_trend_ * threshold_gain_; }
70
+ struct PacketTiming {
71
+ PacketTiming(double arrival_time_ms,
72
+ double smoothed_delay_ms,
73
+ double raw_delay_ms)
74
+ : arrival_time_ms(arrival_time_ms),
75
+ smoothed_delay_ms(smoothed_delay_ms),
76
+ raw_delay_ms(raw_delay_ms) {}
77
+ double arrival_time_ms;
78
+ double smoothed_delay_ms;
79
+ double raw_delay_ms;
80
+ };
57
81
 
58
82
  private:
59
83
  friend class GoogCcStatePrinter;
60
-
61
84
  void Detect(double trend, double ts_delta, int64_t now_ms);
62
85
 
63
86
  void UpdateThreshold(double modified_offset, int64_t now_ms);
64
87
 
65
88
  // Parameters.
66
- const size_t window_size_;
89
+ TrendlineEstimatorSettings settings_;
67
90
  const double smoothing_coef_;
68
91
  const double threshold_gain_;
69
92
  // Used by the existing threshold.
@@ -74,7 +97,7 @@ class TrendlineEstimator : public DelayIncreaseDetectorInterface {
74
97
  double accumulated_delay_;
75
98
  double smoothed_delay_;
76
99
  // Linear least squares regression.
77
- std::deque<std::pair<double, double>> delay_hist_;
100
+ std::deque<PacketTiming> delay_hist_;
78
101
 
79
102
  const double k_up_;
80
103
  const double k_down_;
@@ -88,8 +111,6 @@ class TrendlineEstimator : public DelayIncreaseDetectorInterface {
88
111
  BandwidthUsage hypothesis_;
89
112
  BandwidthUsage hypothesis_predicted_;
90
113
  NetworkStatePredictor* network_state_predictor_;
91
-
92
- RTC_DISALLOW_COPY_AND_ASSIGN(TrendlineEstimator);
93
114
  };
94
115
  } // namespace webrtc
95
116
 
@@ -26,7 +26,7 @@ const char AlrExperimentSettings::kScreenshareProbingBweExperimentName[] =
26
26
  "WebRTC-ProbingScreenshareBwe";
27
27
  const char AlrExperimentSettings::kStrictPacingAndProbingExperimentName[] =
28
28
  "WebRTC-StrictPacingAndProbing";
29
- const char kDefaultProbingScreenshareBweSettings[] = "1.0,2875,80,40,-60,3";
29
+ const char kDefaultProbingScreenshareBweSettings[] = "1.0,2875,80,40,-60,3,3000";
30
30
 
31
31
  bool AlrExperimentSettings::MaxOneFieldTrialEnabled() {
32
32
  return AlrExperimentSettings::MaxOneFieldTrialEnabled(
@@ -71,12 +71,13 @@ AlrExperimentSettings::CreateFromFieldTrial(
71
71
  }
72
72
 
73
73
  AlrExperimentSettings settings;
74
- if (sscanf(group_name.c_str(), "%f,%" PRId64 ",%d,%d,%d,%d",
74
+ if (sscanf(group_name.c_str(), "%f,%" PRId64 ",%d,%d,%d,%d,%d",
75
75
  &settings.pacing_factor, &settings.max_paced_queue_time,
76
76
  &settings.alr_bandwidth_usage_percent,
77
77
  &settings.alr_start_budget_level_percent,
78
78
  &settings.alr_stop_budget_level_percent,
79
- &settings.group_id) == 6) {
79
+ &settings.group_id,
80
+ &settings.alr_timeout) == 7) {
80
81
  ret.emplace(settings);
81
82
  MS_DEBUG_TAG(bwe, "Using ALR experiment settings: "
82
83
  "pacing factor: %f"
@@ -84,13 +85,15 @@ AlrExperimentSettings::CreateFromFieldTrial(
84
85
  ", ALR bandwidth usage percent: %d"
85
86
  ", ALR start budget level percent: %d"
86
87
  ", ALR end budget level percent: %d"
87
- ", ALR experiment group ID: %d",
88
+ ", ALR experiment group ID: %d"
89
+ ", ALR timeout: %d",
88
90
  settings.pacing_factor,
89
91
  settings.max_paced_queue_time,
90
92
  settings.alr_bandwidth_usage_percent,
91
93
  settings.alr_start_budget_level_percent,
92
94
  settings.alr_stop_budget_level_percent,
93
- settings.group_id);
95
+ settings.group_id,
96
+ settings.alr_timeout);
94
97
  } else {
95
98
  MS_DEBUG_TAG(bwe, "Failed to parse ALR experiment: %s", experiment_name);
96
99
  }
@@ -24,6 +24,7 @@ struct AlrExperimentSettings {
24
24
  int alr_bandwidth_usage_percent;
25
25
  int alr_start_budget_level_percent;
26
26
  int alr_stop_budget_level_percent;
27
+ int alr_timeout;
27
28
  // Will be sent to the receive side for stats slicing.
28
29
  // Can be 0..6, because it's sent as a 3 bits value and there's also
29
30
  // reserved value to indicate absence of experiment.
@@ -0,0 +1,58 @@
1
+ #ifndef MS_RTC_RTC_LOGGER_HPP
2
+ #define MS_RTC_RTC_LOGGER_HPP
3
+
4
+ #include "common.hpp"
5
+ #include <absl/container/flat_hash_map.h>
6
+
7
+ namespace RTC
8
+ {
9
+ namespace RtcLogger
10
+ {
11
+ class RtpPacket
12
+ {
13
+ public:
14
+ enum class DropReason : uint8_t
15
+ {
16
+ NONE = 0,
17
+ PRODUCER_NOT_FOUND,
18
+ RECV_RTP_STREAM_NOT_FOUND,
19
+ RECV_RTP_STREAM_DISCARDED,
20
+ CONSUMER_INACTIVE,
21
+ INVALID_TARGET_LAYER,
22
+ UNSUPPORTED_PAYLOAD_TYPE,
23
+ NOT_A_KEYFRAME,
24
+ SPATIAL_LAYER_MISMATCH,
25
+ TOO_HIGH_TIMESTAMP_EXTRA_NEEDED,
26
+ PACKET_PREVIOUS_TO_SPATIAL_LAYER_SWITCH,
27
+ DROPPED_BY_CODEC,
28
+ SEND_RTP_STREAM_DISCARDED,
29
+ };
30
+
31
+ static absl::flat_hash_map<DropReason, std::string> dropReason2String;
32
+
33
+ RtpPacket() = default;
34
+ ~RtpPacket() = default;
35
+ void Sent();
36
+ void Dropped(DropReason dropReason);
37
+
38
+ private:
39
+ void Log() const;
40
+ void Clear();
41
+
42
+ public:
43
+ uint64_t timestamp;
44
+ std::string recvTransportId{};
45
+ std::string sendTransportId{};
46
+ std::string routerId{};
47
+ std::string producerId{};
48
+ std::string consumerId{};
49
+ uint32_t recvRtpTimestamp;
50
+ uint32_t sendRtpTimestamp;
51
+ uint16_t recvSeqNumber;
52
+ uint16_t sendSeqNumber;
53
+ bool dropped;
54
+ DropReason dropReason{ DropReason::NONE };
55
+ };
56
+ }; // namespace RtcLogger
57
+ } // namespace RTC
58
+ #endif