OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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/test/bwe_test_framework.h" | 11 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h" |
12 | 12 |
13 #include <stdio.h> | 13 #include <stdio.h> |
14 | 14 |
15 #include <sstream> | 15 #include <sstream> |
16 | 16 |
17 #include "webrtc/base/common.h" | |
18 #include "webrtc/base/constructormagic.h" | 17 #include "webrtc/base/constructormagic.h" |
19 | 18 |
20 namespace webrtc { | 19 namespace webrtc { |
21 namespace testing { | 20 namespace testing { |
22 namespace bwe { | 21 namespace bwe { |
23 | 22 |
24 class DelayCapHelper { | 23 class DelayCapHelper { |
25 public: | 24 public: |
26 // Max delay = 0 stands for +infinite. | 25 // Max delay = 0 stands for +infinite. |
27 DelayCapHelper() : max_delay_us_(0), delay_stats_() {} | 26 DelayCapHelper() : max_delay_us_(0), delay_stats_() {} |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 } | 215 } |
217 | 216 |
218 RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener, | 217 RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener, |
219 int flow_id, | 218 int flow_id, |
220 const char* name, | 219 const char* name, |
221 const std::string& algorithm_name) | 220 const std::string& algorithm_name) |
222 : PacketProcessor(listener, flow_id, kRegular), | 221 : PacketProcessor(listener, flow_id, kRegular), |
223 packets_per_second_stats_(), | 222 packets_per_second_stats_(), |
224 kbps_stats_(), | 223 kbps_stats_(), |
225 start_plotting_time_ms_(0), | 224 start_plotting_time_ms_(0), |
225 #if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE | |
226 flow_id_(flow_id), | 226 flow_id_(flow_id), |
227 #endif | |
227 name_(name), | 228 name_(name), |
228 algorithm_name_(algorithm_name) { | 229 algorithm_name_(algorithm_name) {} |
229 // Only used when compiling with BWE test logging enabled. | |
230 RTC_UNUSED(flow_id_); | |
231 } | |
232 | 230 |
233 RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener, | 231 RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener, |
234 const FlowIds& flow_ids, | 232 const FlowIds& flow_ids, |
235 const char* name, | 233 const char* name, |
236 const std::string& algorithm_name) | 234 const std::string& algorithm_name) |
237 : PacketProcessor(listener, flow_ids, kRegular), | 235 : PacketProcessor(listener, flow_ids, kRegular), |
238 packets_per_second_stats_(), | 236 packets_per_second_stats_(), |
239 kbps_stats_(), | 237 kbps_stats_(), |
240 start_plotting_time_ms_(0), | 238 start_plotting_time_ms_(0), |
241 flow_id_(0), | |
242 name_(name), | 239 name_(name), |
243 algorithm_name_(algorithm_name) { | 240 algorithm_name_(algorithm_name) { |
244 // TODO(terelius): Appending the flow IDs to the algorithm name is a hack to | 241 // TODO(terelius): Appending the flow IDs to the algorithm name is a hack to |
245 // keep the current plot functionality without having to print the full | 242 // keep the current plot functionality without having to print the full |
246 // context for each PLOT line. It is unclear whether multiple flow IDs are | 243 // context for each PLOT line. It is unclear whether multiple flow IDs are |
247 // needed at all in the long term. | 244 // needed at all in the long term. |
248 std::stringstream ss; | 245 std::stringstream ss; |
249 ss << algorithm_name_; | 246 ss << algorithm_name_; |
250 for (int flow_id : flow_ids) { | 247 for (int flow_id : flow_ids) { |
251 ss << ',' << flow_id; | 248 ss << ',' << flow_id; |
(...skipping 19 matching lines...) Expand all Loading... | |
271 BWE_TEST_LOGGING_CONTEXT("RateCounterFilter"); | 268 BWE_TEST_LOGGING_CONTEXT("RateCounterFilter"); |
272 packets_per_second_stats_.Log("pps"); | 269 packets_per_second_stats_.Log("pps"); |
273 kbps_stats_.Log("kbps"); | 270 kbps_stats_.Log("kbps"); |
274 } | 271 } |
275 | 272 |
276 Stats<double> RateCounterFilter::GetBitrateStats() const { | 273 Stats<double> RateCounterFilter::GetBitrateStats() const { |
277 return kbps_stats_; | 274 return kbps_stats_; |
278 } | 275 } |
279 | 276 |
280 void RateCounterFilter::Plot(int64_t timestamp_ms) { | 277 void RateCounterFilter::Plot(int64_t timestamp_ms) { |
278 #if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE | |
stefan-webrtc
2017/02/17 10:27:32
I really would prefer a better option to this... M
nisse-webrtc
2017/02/20 08:11:22
I added a TODO, with your name on it.
| |
281 uint32_t plot_kbps = 0; | 279 uint32_t plot_kbps = 0; |
282 if (timestamp_ms >= start_plotting_time_ms_) { | 280 if (timestamp_ms >= start_plotting_time_ms_) { |
283 plot_kbps = rate_counter_.bits_per_second() / 1000.0; | 281 plot_kbps = rate_counter_.bits_per_second() / 1000.0; |
284 } | 282 } |
285 BWE_TEST_LOGGING_CONTEXT(name_.c_str()); | 283 BWE_TEST_LOGGING_CONTEXT(name_.c_str()); |
286 if (algorithm_name_.empty()) { | 284 if (algorithm_name_.empty()) { |
287 BWE_TEST_LOGGING_PLOT_WITH_SSRC(0, "Throughput_kbps#1", timestamp_ms, | 285 BWE_TEST_LOGGING_PLOT_WITH_SSRC(0, "Throughput_kbps#1", timestamp_ms, |
288 plot_kbps, flow_id_); | 286 plot_kbps, flow_id_); |
289 } else { | 287 } else { |
290 BWE_TEST_LOGGING_PLOT_WITH_NAME_AND_SSRC(0, "Throughput_kbps#1", | 288 BWE_TEST_LOGGING_PLOT_WITH_NAME_AND_SSRC(0, "Throughput_kbps#1", |
291 timestamp_ms, plot_kbps, flow_id_, | 289 timestamp_ms, plot_kbps, flow_id_, |
292 algorithm_name_); | 290 algorithm_name_); |
293 } | 291 } |
294 | 292 #endif |
295 RTC_UNUSED(plot_kbps); | |
296 } | 293 } |
297 | 294 |
298 void RateCounterFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) { | 295 void RateCounterFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) { |
299 assert(in_out); | 296 assert(in_out); |
300 for (const Packet* packet : *in_out) { | 297 for (const Packet* packet : *in_out) { |
301 rate_counter_.UpdateRates(packet->send_time_us(), | 298 rate_counter_.UpdateRates(packet->send_time_us(), |
302 static_cast<int>(packet->payload_size())); | 299 static_cast<int>(packet->payload_size())); |
303 } | 300 } |
304 packets_per_second_stats_.Push(rate_counter_.packets_per_second()); | 301 packets_per_second_stats_.Push(rate_counter_.packets_per_second()); |
305 kbps_stats_.Push(rate_counter_.bits_per_second() / 1000.0); | 302 kbps_stats_.Push(rate_counter_.bits_per_second() / 1000.0); |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
813 uint32_t PeriodicKeyFrameSource::NextPacketSize(uint32_t frame_size, | 810 uint32_t PeriodicKeyFrameSource::NextPacketSize(uint32_t frame_size, |
814 uint32_t remaining_payload) { | 811 uint32_t remaining_payload) { |
815 uint32_t fragments = | 812 uint32_t fragments = |
816 (frame_size + (kMaxPayloadSizeBytes - 1)) / kMaxPayloadSizeBytes; | 813 (frame_size + (kMaxPayloadSizeBytes - 1)) / kMaxPayloadSizeBytes; |
817 uint32_t avg_size = (frame_size + fragments - 1) / fragments; | 814 uint32_t avg_size = (frame_size + fragments - 1) / fragments; |
818 return std::min(avg_size, remaining_payload); | 815 return std::min(avg_size, remaining_payload); |
819 } | 816 } |
820 } // namespace bwe | 817 } // namespace bwe |
821 } // namespace testing | 818 } // namespace testing |
822 } // namespace webrtc | 819 } // namespace webrtc |
OLD | NEW |