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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc

Issue 2684613002: Delete webrtc/base/common.h (Closed)
Patch Set: Added TODO comment. Created 3 years, 10 months 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) 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
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
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 // TODO(stefan): Reorganize logging configuration to reduce amount
279 // of preprocessor conditionals in the code.
280 #if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE
281 uint32_t plot_kbps = 0; 281 uint32_t plot_kbps = 0;
282 if (timestamp_ms >= start_plotting_time_ms_) { 282 if (timestamp_ms >= start_plotting_time_ms_) {
283 plot_kbps = rate_counter_.bits_per_second() / 1000.0; 283 plot_kbps = rate_counter_.bits_per_second() / 1000.0;
284 } 284 }
285 BWE_TEST_LOGGING_CONTEXT(name_.c_str()); 285 BWE_TEST_LOGGING_CONTEXT(name_.c_str());
286 if (algorithm_name_.empty()) { 286 if (algorithm_name_.empty()) {
287 BWE_TEST_LOGGING_PLOT_WITH_SSRC(0, "Throughput_kbps#1", timestamp_ms, 287 BWE_TEST_LOGGING_PLOT_WITH_SSRC(0, "Throughput_kbps#1", timestamp_ms,
288 plot_kbps, flow_id_); 288 plot_kbps, flow_id_);
289 } else { 289 } else {
290 BWE_TEST_LOGGING_PLOT_WITH_NAME_AND_SSRC(0, "Throughput_kbps#1", 290 BWE_TEST_LOGGING_PLOT_WITH_NAME_AND_SSRC(0, "Throughput_kbps#1",
291 timestamp_ms, plot_kbps, flow_id_, 291 timestamp_ms, plot_kbps, flow_id_,
292 algorithm_name_); 292 algorithm_name_);
293 } 293 }
294 294 #endif
295 RTC_UNUSED(plot_kbps);
296 } 295 }
297 296
298 void RateCounterFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) { 297 void RateCounterFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) {
299 assert(in_out); 298 assert(in_out);
300 for (const Packet* packet : *in_out) { 299 for (const Packet* packet : *in_out) {
301 rate_counter_.UpdateRates(packet->send_time_us(), 300 rate_counter_.UpdateRates(packet->send_time_us(),
302 static_cast<int>(packet->payload_size())); 301 static_cast<int>(packet->payload_size()));
303 } 302 }
304 packets_per_second_stats_.Push(rate_counter_.packets_per_second()); 303 packets_per_second_stats_.Push(rate_counter_.packets_per_second());
305 kbps_stats_.Push(rate_counter_.bits_per_second() / 1000.0); 304 kbps_stats_.Push(rate_counter_.bits_per_second() / 1000.0);
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 uint32_t PeriodicKeyFrameSource::NextPacketSize(uint32_t frame_size, 812 uint32_t PeriodicKeyFrameSource::NextPacketSize(uint32_t frame_size,
814 uint32_t remaining_payload) { 813 uint32_t remaining_payload) {
815 uint32_t fragments = 814 uint32_t fragments =
816 (frame_size + (kMaxPayloadSizeBytes - 1)) / kMaxPayloadSizeBytes; 815 (frame_size + (kMaxPayloadSizeBytes - 1)) / kMaxPayloadSizeBytes;
817 uint32_t avg_size = (frame_size + fragments - 1) / fragments; 816 uint32_t avg_size = (frame_size + fragments - 1) / fragments;
818 return std::min(avg_size, remaining_payload); 817 return std::min(avg_size, remaining_payload);
819 } 818 }
820 } // namespace bwe 819 } // namespace bwe
821 } // namespace testing 820 } // namespace testing
822 } // namespace webrtc 821 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698