| Index: webrtc/test/fake_network_pipe.cc
|
| diff --git a/webrtc/test/fake_network_pipe.cc b/webrtc/test/fake_network_pipe.cc
|
| index 0b3aa6ac71c2b3695789fb19713d32a0c14ecbc0..d594ab8104e3b6d7b0499b85415732544ae3b40d 100644
|
| --- a/webrtc/test/fake_network_pipe.cc
|
| +++ b/webrtc/test/fake_network_pipe.cc
|
| @@ -33,31 +33,14 @@ FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
|
| : clock_(clock),
|
| packet_receiver_(NULL),
|
| random_(seed),
|
| - config_(config),
|
| + config_(),
|
| dropped_packets_(0),
|
| sent_packets_(0),
|
| total_packet_delay_(0),
|
| bursting_(false),
|
| next_process_time_(clock_->TimeInMilliseconds()),
|
| last_log_time_(clock_->TimeInMilliseconds()) {
|
| - double prob_loss = config.loss_percent / 100.0;
|
| - if (config_.avg_burst_loss_length == -1) {
|
| - // Uniform loss
|
| - prob_loss_bursting_ = prob_loss;
|
| - prob_start_bursting_ = prob_loss;
|
| - } else {
|
| - // Lose packets according to a gilbert-elliot model.
|
| - int avg_burst_loss_length = config.avg_burst_loss_length;
|
| - int min_avg_burst_loss_length = std::ceil(prob_loss / (1 - prob_loss));
|
| -
|
| - RTC_CHECK_GT(avg_burst_loss_length, min_avg_burst_loss_length)
|
| - << "For a total packet loss of " << config.loss_percent << "%% then"
|
| - << " avg_burst_loss_length must be " << min_avg_burst_loss_length + 1
|
| - << " or higher.";
|
| -
|
| - prob_loss_bursting_ = (1.0 - 1.0 / avg_burst_loss_length);
|
| - prob_start_bursting_ = prob_loss / (1 - prob_loss) / avg_burst_loss_length;
|
| - }
|
| + SetConfig(config);
|
| }
|
|
|
| FakeNetworkPipe::~FakeNetworkPipe() {
|
| @@ -78,6 +61,24 @@ void FakeNetworkPipe::SetReceiver(PacketReceiver* receiver) {
|
| void FakeNetworkPipe::SetConfig(const FakeNetworkPipe::Config& config) {
|
| rtc::CritScope crit(&lock_);
|
| config_ = config; // Shallow copy of the struct.
|
| + double prob_loss = config.loss_percent / 100.0;
|
| + if (config_.avg_burst_loss_length == -1) {
|
| + // Uniform loss
|
| + prob_loss_bursting_ = prob_loss;
|
| + prob_start_bursting_ = prob_loss;
|
| + } else {
|
| + // Lose packets according to a gilbert-elliot model.
|
| + int avg_burst_loss_length = config.avg_burst_loss_length;
|
| + int min_avg_burst_loss_length = std::ceil(prob_loss / (1 - prob_loss));
|
| +
|
| + RTC_CHECK_GT(avg_burst_loss_length, min_avg_burst_loss_length)
|
| + << "For a total packet loss of " << config.loss_percent << "%% then"
|
| + << " avg_burst_loss_length must be " << min_avg_burst_loss_length + 1
|
| + << " or higher.";
|
| +
|
| + prob_loss_bursting_ = (1.0 - 1.0 / avg_burst_loss_length);
|
| + prob_start_bursting_ = prob_loss / (1 - prob_loss) / avg_burst_loss_length;
|
| + }
|
| }
|
|
|
| void FakeNetworkPipe::SendPacket(const uint8_t* data, size_t data_length) {
|
|
|