Add FakeNetworkPipe ctor from NetworkSimulationInterface.
Add FakeNetworkPipe ctor from NetworkSimulationInterface to be able to inject different implementations of simulated networks. If user requires to do something with injected simulation he can keep raw reference, or introduce some proxy, that will hide shared ownership from FakeNetworkPipe. Also FakeNetworkPipe guarantee to keep simulation object alive while it is alive itself. Bug: webrtc:9630 Change-Id: Ie00ea1d47bf7658b0c6433cf2efbf364f885c8a0 Reviewed-on: https://webrtc-review.googlesource.com/94153 Reviewed-by: Sebastian Jansson <srte@webrtc.org> Commit-Queue: Artem Titov <titovartem@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24312}
This commit is contained in:
@ -43,6 +43,7 @@ NetworkPacket::NetworkPacket(rtc::CopyOnWriteBuffer packet,
|
||||
is_rtcp_(is_rtcp),
|
||||
media_type_(media_type),
|
||||
packet_time_us_(packet_time_us) {}
|
||||
|
||||
NetworkPacket::NetworkPacket(rtc::CopyOnWriteBuffer packet,
|
||||
int64_t send_time,
|
||||
int64_t arrival_time,
|
||||
@ -87,6 +88,20 @@ FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
|
||||
const FakeNetworkPipe::Config& config)
|
||||
: FakeNetworkPipe(clock, config, nullptr, 1) {}
|
||||
|
||||
FakeNetworkPipe::FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation)
|
||||
: clock_(clock),
|
||||
network_simulation_(std::move(network_simulation)),
|
||||
receiver_(nullptr),
|
||||
transport_(nullptr),
|
||||
clock_offset_ms_(0),
|
||||
dropped_packets_(0),
|
||||
sent_packets_(0),
|
||||
total_packet_delay_us_(0),
|
||||
next_process_time_us_(clock_->TimeInMicroseconds()),
|
||||
last_log_time_us_(clock_->TimeInMicroseconds()) {}
|
||||
|
||||
FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
|
||||
const FakeNetworkPipe::Config& config,
|
||||
PacketReceiver* receiver)
|
||||
|
@ -105,6 +105,10 @@ class FakeNetworkPipe : public Transport, public PacketReceiver, public Module {
|
||||
|
||||
// Use these constructors if you plan to insert packets using DeliverPacket().
|
||||
FakeNetworkPipe(Clock* clock, const FakeNetworkPipe::Config& config);
|
||||
// Will keep |network_simulation| alive while pipe is alive itself.
|
||||
FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation);
|
||||
FakeNetworkPipe(Clock* clock,
|
||||
const FakeNetworkPipe::Config& config,
|
||||
PacketReceiver* receiver);
|
||||
|
Reference in New Issue
Block a user