Switch webrtc users from deprecated ctors.

Stop using of deprecated ctors of FakeNetworkPipe in most part of
webrtc codebase, except DirectTransport, where further refactoring will
be continued in future CLs.

Bug: webrtc:9630
Change-Id: I823404469e461601ddbc026eaeac668eeda8045f
Reviewed-on: https://webrtc-review.googlesource.com/94763
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24327}
This commit is contained in:
Artem Titov 2018-08-17 13:00:54 +02:00 committed by Commit Bot
parent 506c569443
commit 3229d65fd0
5 changed files with 50 additions and 31 deletions

View File

@ -190,9 +190,11 @@ rtc_static_library("call") {
":rtp_interfaces",
":rtp_receiver",
":rtp_sender",
":simulated_network",
":video_stream_api",
"..:webrtc_common",
"../api:callfactory_api",
"../api:simulated_network_api",
"../api:transport_api",
"../api/transport:network_control",
"../audio",

View File

@ -17,8 +17,8 @@
namespace webrtc {
DegradedCall::DegradedCall(
std::unique_ptr<Call> call,
absl::optional<FakeNetworkPipe::Config> send_config,
absl::optional<FakeNetworkPipe::Config> receive_config)
absl::optional<DefaultNetworkSimulationConfig> send_config,
absl::optional<DefaultNetworkSimulationConfig> receive_config)
: clock_(Clock::GetRealTimeClock()),
call_(std::move(call)),
send_config_(send_config),
@ -27,8 +27,10 @@ DegradedCall::DegradedCall(
num_send_streams_(0),
receive_config_(receive_config) {
if (receive_config_) {
auto network = absl::make_unique<SimulatedNetwork>(*receive_config_);
receive_simulated_network_ = network.get();
receive_pipe_ =
absl::make_unique<webrtc::FakeNetworkPipe>(clock_, *receive_config_);
absl::make_unique<webrtc::FakeNetworkPipe>(clock_, std::move(network));
receive_pipe_->SetReceiver(call_->Receiver());
}
if (send_process_thread_) {
@ -68,7 +70,9 @@ VideoSendStream* DegradedCall::CreateVideoSendStream(
VideoSendStream::Config config,
VideoEncoderConfig encoder_config) {
if (send_config_ && !send_pipe_) {
send_pipe_ = absl::make_unique<FakeNetworkPipe>(clock_, *send_config_,
auto network = absl::make_unique<SimulatedNetwork>(*send_config_);
send_simulated_network_ = network.get();
send_pipe_ = absl::make_unique<FakeNetworkPipe>(clock_, std::move(network),
config.send_transport);
config.send_transport = this;
send_process_thread_->RegisterModule(send_pipe_.get(), RTC_FROM_HERE);
@ -83,7 +87,9 @@ VideoSendStream* DegradedCall::CreateVideoSendStream(
VideoEncoderConfig encoder_config,
std::unique_ptr<FecController> fec_controller) {
if (send_config_ && !send_pipe_) {
send_pipe_ = absl::make_unique<FakeNetworkPipe>(clock_, *send_config_,
auto network = absl::make_unique<SimulatedNetwork>(*send_config_);
send_simulated_network_ = network.get();
send_pipe_ = absl::make_unique<FakeNetworkPipe>(clock_, std::move(network),
config.send_transport);
config.send_transport = this;
send_process_thread_->RegisterModule(send_pipe_.get(), RTC_FROM_HERE);

View File

@ -15,8 +15,10 @@
#include "absl/types/optional.h"
#include "api/call/transport.h"
#include "api/test/simulated_network.h"
#include "call/call.h"
#include "call/fake_network_pipe.h"
#include "call/simulated_network.h"
#include "modules/utility/include/process_thread.h"
#include "system_wrappers/include/clock.h"
@ -24,9 +26,10 @@ namespace webrtc {
class DegradedCall : public Call, private Transport, private PacketReceiver {
public:
explicit DegradedCall(std::unique_ptr<Call> call,
absl::optional<FakeNetworkPipe::Config> send_config,
absl::optional<FakeNetworkPipe::Config> receive_config);
explicit DegradedCall(
std::unique_ptr<Call> call,
absl::optional<DefaultNetworkSimulationConfig> send_config,
absl::optional<DefaultNetworkSimulationConfig> receive_config);
~DegradedCall() override;
// Implements Call.
@ -90,12 +93,14 @@ class DegradedCall : public Call, private Transport, private PacketReceiver {
Clock* const clock_;
const std::unique_ptr<Call> call_;
const absl::optional<FakeNetworkPipe::Config> send_config_;
const absl::optional<DefaultNetworkSimulationConfig> send_config_;
const std::unique_ptr<ProcessThread> send_process_thread_;
SimulatedNetwork* send_simulated_network_;
std::unique_ptr<FakeNetworkPipe> send_pipe_;
size_t num_send_streams_;
const absl::optional<FakeNetworkPipe::Config> receive_config_;
const absl::optional<DefaultNetworkSimulationConfig> receive_config_;
SimulatedNetwork* receive_simulated_network_;
std::unique_ptr<FakeNetworkPipe> receive_pipe_;
};

View File

@ -28,7 +28,7 @@ namespace webrtc {
// capacity introduced delay.
class SimulatedNetwork : public NetworkSimulationInterface {
public:
using Config = NetworkSimulationInterface::SimulatedNetworkConfig;
using Config = DefaultNetworkSimulationConfig;
explicit SimulatedNetwork(Config config, uint64_t random_seed = 1);
~SimulatedNetwork() override;

View File

@ -73,12 +73,13 @@ class FakeNetworkPipeTest : public ::testing::Test {
// Test the capacity link and verify we get as many packets as we expect.
TEST_F(FakeNetworkPipeTest, CapacityTest) {
FakeNetworkPipe::Config config;
DefaultNetworkSimulationConfig config;
config.queue_length_packets = 20;
config.link_capacity_kbps = 80;
MockReceiver receiver;
std::unique_ptr<FakeNetworkPipe> pipe(
new FakeNetworkPipe(&fake_clock_, config, &receiver));
auto simulated_network = absl::make_unique<SimulatedNetwork>(config);
std::unique_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(
&fake_clock_, std::move(simulated_network), &receiver));
// Add 10 packets of 1000 bytes, = 80 kb, and verify it takes one second to
// get through the pipe.
@ -112,13 +113,14 @@ TEST_F(FakeNetworkPipeTest, CapacityTest) {
// Test the extra network delay.
TEST_F(FakeNetworkPipeTest, ExtraDelayTest) {
FakeNetworkPipe::Config config;
DefaultNetworkSimulationConfig config;
config.queue_length_packets = 20;
config.queue_delay_ms = 100;
config.link_capacity_kbps = 80;
MockReceiver receiver;
std::unique_ptr<FakeNetworkPipe> pipe(
new FakeNetworkPipe(&fake_clock_, config, &receiver));
auto simulated_network = absl::make_unique<SimulatedNetwork>(config);
std::unique_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(
&fake_clock_, std::move(simulated_network), &receiver));
const int kNumPackets = 2;
const int kPacketSize = 1000;
@ -147,12 +149,13 @@ TEST_F(FakeNetworkPipeTest, ExtraDelayTest) {
// Test the number of buffers and packets are dropped when sending too many
// packets too quickly.
TEST_F(FakeNetworkPipeTest, QueueLengthTest) {
FakeNetworkPipe::Config config;
DefaultNetworkSimulationConfig config;
config.queue_length_packets = 2;
config.link_capacity_kbps = 80;
MockReceiver receiver;
std::unique_ptr<FakeNetworkPipe> pipe(
new FakeNetworkPipe(&fake_clock_, config, &receiver));
auto simulated_network = absl::make_unique<SimulatedNetwork>(config);
std::unique_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(
&fake_clock_, std::move(simulated_network), &receiver));
const int kPacketSize = 1000;
const int kPacketTimeMs =
@ -170,13 +173,14 @@ TEST_F(FakeNetworkPipeTest, QueueLengthTest) {
// Test we get statistics as expected.
TEST_F(FakeNetworkPipeTest, StatisticsTest) {
FakeNetworkPipe::Config config;
DefaultNetworkSimulationConfig config;
config.queue_length_packets = 2;
config.queue_delay_ms = 20;
config.link_capacity_kbps = 80;
MockReceiver receiver;
std::unique_ptr<FakeNetworkPipe> pipe(
new FakeNetworkPipe(&fake_clock_, config, &receiver));
auto simulated_network = absl::make_unique<SimulatedNetwork>(config);
std::unique_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(
&fake_clock_, std::move(simulated_network), &receiver));
const int kPacketSize = 1000;
const int kPacketTimeMs =
@ -201,7 +205,7 @@ TEST_F(FakeNetworkPipeTest, StatisticsTest) {
// Change the link capacity half-way through the test and verify that the
// delivery times change accordingly.
TEST_F(FakeNetworkPipeTest, ChangingCapacityWithEmptyPipeTest) {
FakeNetworkPipe::Config config;
DefaultNetworkSimulationConfig config;
config.queue_length_packets = 20;
config.link_capacity_kbps = 80;
MockReceiver receiver;
@ -262,7 +266,7 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithEmptyPipeTest) {
// Change the link capacity half-way through the test and verify that the
// delivery times change accordingly.
TEST_F(FakeNetworkPipeTest, ChangingCapacityWithPacketsInPipeTest) {
FakeNetworkPipe::Config config;
DefaultNetworkSimulationConfig config;
config.queue_length_packets = 20;
config.link_capacity_kbps = 80;
MockReceiver receiver;
@ -317,7 +321,7 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithPacketsInPipeTest) {
// At first disallow reordering and then allow reordering.
TEST_F(FakeNetworkPipeTest, DisallowReorderingThenAllowReordering) {
FakeNetworkPipe::Config config;
DefaultNetworkSimulationConfig config;
config.queue_length_packets = 1000;
config.link_capacity_kbps = 800;
config.queue_delay_ms = 100;
@ -370,13 +374,14 @@ TEST_F(FakeNetworkPipeTest, BurstLoss) {
const int kNumPackets = 10000;
const int kPacketSize = 10;
FakeNetworkPipe::Config config;
DefaultNetworkSimulationConfig config;
config.queue_length_packets = kNumPackets;
config.loss_percent = kLossPercent;
config.avg_burst_loss_length = kAvgBurstLength;
ReorderTestReceiver receiver;
auto simulated_network = absl::make_unique<SimulatedNetwork>(config);
std::unique_ptr<FakeNetworkPipe> pipe(
new FakeNetworkPipe(&fake_clock_, config, &receiver));
new FakeNetworkPipe(&fake_clock_, std::move(config), &receiver));
SendPackets(pipe.get(), kNumPackets, kPacketSize);
fake_clock_.AdvanceTimeMilliseconds(1000);
@ -404,11 +409,12 @@ TEST_F(FakeNetworkPipeTest, BurstLoss) {
}
TEST_F(FakeNetworkPipeTest, SetReceiver) {
FakeNetworkPipe::Config config;
DefaultNetworkSimulationConfig config;
config.link_capacity_kbps = 800;
MockReceiver receiver;
std::unique_ptr<FakeNetworkPipe> pipe(
new FakeNetworkPipe(&fake_clock_, config, &receiver));
auto simulated_network = absl::make_unique<SimulatedNetwork>(config);
std::unique_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(
&fake_clock_, std::move(simulated_network), &receiver));
const int kPacketSize = 1000;
const int kPacketTimeMs =