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

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

Issue 1413053002: Change to use local Random object instead of global rand() in the RtcEventLog unit test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 5 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) 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
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 BWE_TEST_LOGGING_ENABLE(false); 316 BWE_TEST_LOGGING_ENABLE(false);
317 BWE_TEST_LOGGING_LOG1("Loss", "%f%%", loss_percent); 317 BWE_TEST_LOGGING_LOG1("Loss", "%f%%", loss_percent);
318 assert(loss_percent >= 0.0f); 318 assert(loss_percent >= 0.0f);
319 assert(loss_percent <= 100.0f); 319 assert(loss_percent <= 100.0f);
320 loss_fraction_ = loss_percent * 0.01f; 320 loss_fraction_ = loss_percent * 0.01f;
321 } 321 }
322 322
323 void LossFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) { 323 void LossFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) {
324 assert(in_out); 324 assert(in_out);
325 for (PacketsIt it = in_out->begin(); it != in_out->end(); ) { 325 for (PacketsIt it = in_out->begin(); it != in_out->end(); ) {
326 if (random_.Rand() < loss_fraction_) { 326 if (random_.Rand<float>() < loss_fraction_) {
327 delete *it; 327 delete *it;
328 it = in_out->erase(it); 328 it = in_out->erase(it);
329 } else { 329 } else {
330 ++it; 330 ++it;
331 } 331 }
332 } 332 }
333 } 333 }
334 334
335 const int64_t kDefaultOneWayDelayUs = 0; 335 const int64_t kDefaultOneWayDelayUs = 0;
336 336
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 assert(reorder_percent <= 100.0f); 452 assert(reorder_percent <= 100.0f);
453 reorder_fraction_ = reorder_percent * 0.01f; 453 reorder_fraction_ = reorder_percent * 0.01f;
454 } 454 }
455 455
456 void ReorderFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) { 456 void ReorderFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) {
457 assert(in_out); 457 assert(in_out);
458 if (in_out->size() >= 2) { 458 if (in_out->size() >= 2) {
459 PacketsIt last_it = in_out->begin(); 459 PacketsIt last_it = in_out->begin();
460 PacketsIt it = last_it; 460 PacketsIt it = last_it;
461 while (++it != in_out->end()) { 461 while (++it != in_out->end()) {
462 if (random_.Rand() < reorder_fraction_) { 462 if (random_.Rand<float>() < reorder_fraction_) {
463 int64_t t1 = (*last_it)->send_time_us(); 463 int64_t t1 = (*last_it)->send_time_us();
464 int64_t t2 = (*it)->send_time_us(); 464 int64_t t2 = (*it)->send_time_us();
465 std::swap(*last_it, *it); 465 std::swap(*last_it, *it);
466 (*last_it)->set_send_time_us(t1); 466 (*last_it)->set_send_time_us(t1);
467 (*it)->set_send_time_us(t2); 467 (*it)->set_send_time_us(t2);
468 } 468 }
469 last_it = it; 469 last_it = it;
470 } 470 }
471 } 471 }
472 } 472 }
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 uint32_t PeriodicKeyFrameSource::NextPacketSize(uint32_t frame_size, 808 uint32_t PeriodicKeyFrameSource::NextPacketSize(uint32_t frame_size,
809 uint32_t remaining_payload) { 809 uint32_t remaining_payload) {
810 uint32_t fragments = 810 uint32_t fragments =
811 (frame_size + (kMaxPayloadSizeBytes - 1)) / kMaxPayloadSizeBytes; 811 (frame_size + (kMaxPayloadSizeBytes - 1)) / kMaxPayloadSizeBytes;
812 uint32_t avg_size = (frame_size + fragments - 1) / fragments; 812 uint32_t avg_size = (frame_size + fragments - 1) / fragments;
813 return std::min(avg_size, remaining_payload); 813 return std::min(avg_size, remaining_payload);
814 } 814 }
815 } // namespace bwe 815 } // namespace bwe
816 } // namespace testing 816 } // namespace testing
817 } // namespace webrtc 817 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698