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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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), |
226 flow_id_(flow_id), | 225 flow_id_(flow_id), |
227 name_(name), | 226 name_(name), |
228 algorithm_name_(algorithm_name) { | 227 algorithm_name_(algorithm_name) {} |
229 // Only used when compiling with BWE test logging enabled. | |
230 RTC_UNUSED(flow_id_); | |
231 } | |
232 | 228 |
233 RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener, | 229 RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener, |
234 const FlowIds& flow_ids, | 230 const FlowIds& flow_ids, |
235 const char* name, | 231 const char* name, |
236 const std::string& algorithm_name) | 232 const std::string& algorithm_name) |
237 : PacketProcessor(listener, flow_ids, kRegular), | 233 : PacketProcessor(listener, flow_ids, kRegular), |
238 packets_per_second_stats_(), | 234 packets_per_second_stats_(), |
239 kbps_stats_(), | 235 kbps_stats_(), |
240 start_plotting_time_ms_(0), | 236 start_plotting_time_ms_(0), |
241 flow_id_(0), | 237 flow_id_(0), |
(...skipping 29 matching lines...) Expand all Loading... |
271 BWE_TEST_LOGGING_CONTEXT("RateCounterFilter"); | 267 BWE_TEST_LOGGING_CONTEXT("RateCounterFilter"); |
272 packets_per_second_stats_.Log("pps"); | 268 packets_per_second_stats_.Log("pps"); |
273 kbps_stats_.Log("kbps"); | 269 kbps_stats_.Log("kbps"); |
274 } | 270 } |
275 | 271 |
276 Stats<double> RateCounterFilter::GetBitrateStats() const { | 272 Stats<double> RateCounterFilter::GetBitrateStats() const { |
277 return kbps_stats_; | 273 return kbps_stats_; |
278 } | 274 } |
279 | 275 |
280 void RateCounterFilter::Plot(int64_t timestamp_ms) { | 276 void RateCounterFilter::Plot(int64_t timestamp_ms) { |
| 277 #if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE |
281 uint32_t plot_kbps = 0; | 278 uint32_t plot_kbps = 0; |
282 if (timestamp_ms >= start_plotting_time_ms_) { | 279 if (timestamp_ms >= start_plotting_time_ms_) { |
283 plot_kbps = rate_counter_.bits_per_second() / 1000.0; | 280 plot_kbps = rate_counter_.bits_per_second() / 1000.0; |
284 } | 281 } |
285 BWE_TEST_LOGGING_CONTEXT(name_.c_str()); | 282 BWE_TEST_LOGGING_CONTEXT(name_.c_str()); |
286 if (algorithm_name_.empty()) { | 283 if (algorithm_name_.empty()) { |
287 BWE_TEST_LOGGING_PLOT_WITH_SSRC(0, "Throughput_kbps#1", timestamp_ms, | 284 BWE_TEST_LOGGING_PLOT_WITH_SSRC(0, "Throughput_kbps#1", timestamp_ms, |
288 plot_kbps, flow_id_); | 285 plot_kbps, flow_id_); |
289 } else { | 286 } else { |
290 BWE_TEST_LOGGING_PLOT_WITH_NAME_AND_SSRC(0, "Throughput_kbps#1", | 287 BWE_TEST_LOGGING_PLOT_WITH_NAME_AND_SSRC(0, "Throughput_kbps#1", |
291 timestamp_ms, plot_kbps, flow_id_, | 288 timestamp_ms, plot_kbps, flow_id_, |
292 algorithm_name_); | 289 algorithm_name_); |
293 } | 290 } |
294 | 291 #endif |
295 RTC_UNUSED(plot_kbps); | |
296 } | 292 } |
297 | 293 |
298 void RateCounterFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) { | 294 void RateCounterFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) { |
299 assert(in_out); | 295 assert(in_out); |
300 for (const Packet* packet : *in_out) { | 296 for (const Packet* packet : *in_out) { |
301 rate_counter_.UpdateRates(packet->send_time_us(), | 297 rate_counter_.UpdateRates(packet->send_time_us(), |
302 static_cast<int>(packet->payload_size())); | 298 static_cast<int>(packet->payload_size())); |
303 } | 299 } |
304 packets_per_second_stats_.Push(rate_counter_.packets_per_second()); | 300 packets_per_second_stats_.Push(rate_counter_.packets_per_second()); |
305 kbps_stats_.Push(rate_counter_.bits_per_second() / 1000.0); | 301 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, | 809 uint32_t PeriodicKeyFrameSource::NextPacketSize(uint32_t frame_size, |
814 uint32_t remaining_payload) { | 810 uint32_t remaining_payload) { |
815 uint32_t fragments = | 811 uint32_t fragments = |
816 (frame_size + (kMaxPayloadSizeBytes - 1)) / kMaxPayloadSizeBytes; | 812 (frame_size + (kMaxPayloadSizeBytes - 1)) / kMaxPayloadSizeBytes; |
817 uint32_t avg_size = (frame_size + fragments - 1) / fragments; | 813 uint32_t avg_size = (frame_size + fragments - 1) / fragments; |
818 return std::min(avg_size, remaining_payload); | 814 return std::min(avg_size, remaining_payload); |
819 } | 815 } |
820 } // namespace bwe | 816 } // namespace bwe |
821 } // namespace testing | 817 } // namespace testing |
822 } // namespace webrtc | 818 } // namespace webrtc |
OLD | NEW |