Switch webrtc from deprecated usages of NetworkSimulationInterface
Bug: webrtc:9630 Change-Id: I42222261676b0c260c1aab81523a23988d3cd1c1 Reviewed-on: https://webrtc-review.googlesource.com/c/103780 Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Commit-Queue: Artem Titov <titovartem@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25011}
This commit is contained in:
parent
ae4237e5db
commit
8ea1e9def1
@ -118,8 +118,8 @@ class VideoQualityTestFixtureInterface {
|
||||
// Simulations of sender and receiver networks. They must either both be
|
||||
// null (in which case `config` from Params is used), or both be non-null
|
||||
// (in which case `config` from Params must be nullopt).
|
||||
std::unique_ptr<NetworkSimulationInterface> sender_network;
|
||||
std::unique_ptr<NetworkSimulationInterface> receiver_network;
|
||||
std::unique_ptr<NetworkBehaviorInterface> sender_network;
|
||||
std::unique_ptr<NetworkBehaviorInterface> receiver_network;
|
||||
|
||||
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory;
|
||||
};
|
||||
|
||||
@ -68,22 +68,22 @@ NetworkPacket& NetworkPacket::operator=(NetworkPacket&& o) {
|
||||
|
||||
FakeNetworkPipe::FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation)
|
||||
: FakeNetworkPipe(clock, std::move(network_simulation), nullptr, 1) {}
|
||||
std::unique_ptr<NetworkBehaviorInterface> network_behavior)
|
||||
: FakeNetworkPipe(clock, std::move(network_behavior), nullptr, 1) {}
|
||||
|
||||
FakeNetworkPipe::FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||
std::unique_ptr<NetworkBehaviorInterface> network_behavior,
|
||||
PacketReceiver* receiver)
|
||||
: FakeNetworkPipe(clock, std::move(network_simulation), receiver, 1) {}
|
||||
: FakeNetworkPipe(clock, std::move(network_behavior), receiver, 1) {}
|
||||
|
||||
FakeNetworkPipe::FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||
std::unique_ptr<NetworkBehaviorInterface> network_behavior,
|
||||
PacketReceiver* receiver,
|
||||
uint64_t seed)
|
||||
: clock_(clock),
|
||||
network_simulation_(std::move(network_simulation)),
|
||||
network_behavior_(std::move(network_behavior)),
|
||||
receiver_(receiver),
|
||||
transport_(nullptr),
|
||||
clock_offset_ms_(0),
|
||||
@ -95,10 +95,10 @@ FakeNetworkPipe::FakeNetworkPipe(
|
||||
|
||||
FakeNetworkPipe::FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||
std::unique_ptr<NetworkBehaviorInterface> network_behavior,
|
||||
Transport* transport)
|
||||
: clock_(clock),
|
||||
network_simulation_(std::move(network_simulation)),
|
||||
network_behavior_(std::move(network_behavior)),
|
||||
receiver_(nullptr),
|
||||
transport_(transport),
|
||||
clock_offset_ms_(0),
|
||||
@ -162,7 +162,7 @@ bool FakeNetworkPipe::EnqueuePacket(rtc::CopyOnWriteBuffer packet,
|
||||
|
||||
packets_in_flight_.emplace_back(StoredPacket(std::move(net_packet)));
|
||||
int64_t packet_id = reinterpret_cast<uint64_t>(&packets_in_flight_.back());
|
||||
bool sent = network_simulation_->EnqueuePacket(
|
||||
bool sent = network_behavior_->EnqueuePacket(
|
||||
PacketInFlightInfo(packet_size, time_now_us, packet_id));
|
||||
|
||||
if (!sent) {
|
||||
@ -217,7 +217,7 @@ void FakeNetworkPipe::Process() {
|
||||
}
|
||||
|
||||
std::vector<PacketDeliveryInfo> delivery_infos =
|
||||
network_simulation_->DequeueDeliverablePackets(time_now_us);
|
||||
network_behavior_->DequeueDeliverablePackets(time_now_us);
|
||||
for (auto& delivery_info : delivery_infos) {
|
||||
// In the common case where no reordering happens, find will return early
|
||||
// as the first packet will be a match.
|
||||
@ -261,8 +261,7 @@ void FakeNetworkPipe::Process() {
|
||||
packets_to_deliver.pop();
|
||||
DeliverNetworkPacket(&packet);
|
||||
}
|
||||
absl::optional<int64_t> delivery_us =
|
||||
network_simulation_->NextDeliveryTimeUs();
|
||||
absl::optional<int64_t> delivery_us = network_behavior_->NextDeliveryTimeUs();
|
||||
next_process_time_us_ = delivery_us
|
||||
? *delivery_us
|
||||
: time_now_us + kDefaultProcessIntervalMs * 1000;
|
||||
|
||||
@ -90,26 +90,22 @@ class NetworkPacket {
|
||||
class FakeNetworkPipe : public webrtc::SimulatedPacketReceiverInterface,
|
||||
public Transport {
|
||||
public:
|
||||
// Will keep |network_simulation| alive while pipe is alive itself.
|
||||
// Will keep |network_behavior| alive while pipe is alive itself.
|
||||
// Use these constructors if you plan to insert packets using DeliverPacket().
|
||||
FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation);
|
||||
FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||
PacketReceiver* receiver);
|
||||
FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||
PacketReceiver* receiver,
|
||||
uint64_t seed);
|
||||
FakeNetworkPipe(Clock* clock,
|
||||
std::unique_ptr<NetworkBehaviorInterface> network_behavior);
|
||||
FakeNetworkPipe(Clock* clock,
|
||||
std::unique_ptr<NetworkBehaviorInterface> network_behavior,
|
||||
PacketReceiver* receiver);
|
||||
FakeNetworkPipe(Clock* clock,
|
||||
std::unique_ptr<NetworkBehaviorInterface> network_behavior,
|
||||
PacketReceiver* receiver,
|
||||
uint64_t seed);
|
||||
|
||||
// Use this constructor if you plan to insert packets using SendRt[c?]p().
|
||||
FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||
Transport* transport);
|
||||
FakeNetworkPipe(Clock* clock,
|
||||
std::unique_ptr<NetworkBehaviorInterface> network_behavior,
|
||||
Transport* transport);
|
||||
|
||||
~FakeNetworkPipe() override;
|
||||
|
||||
@ -193,7 +189,7 @@ class FakeNetworkPipe : public webrtc::SimulatedPacketReceiverInterface,
|
||||
Clock* const clock_;
|
||||
// |config_lock| guards the mostly constant things like the callbacks.
|
||||
rtc::CriticalSection config_lock_;
|
||||
const std::unique_ptr<NetworkSimulationInterface> network_simulation_;
|
||||
const std::unique_ptr<NetworkBehaviorInterface> network_behavior_;
|
||||
PacketReceiver* receiver_ RTC_GUARDED_BY(config_lock_);
|
||||
Transport* const transport_ RTC_GUARDED_BY(config_lock_);
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ namespace webrtc {
|
||||
// Class simulating a network link. This is a simple and naive solution just
|
||||
// faking capacity and adding an extra transport delay in addition to the
|
||||
// capacity introduced delay.
|
||||
class SimulatedNetwork : public NetworkSimulationInterface {
|
||||
class SimulatedNetwork : public NetworkBehaviorInterface {
|
||||
public:
|
||||
using Config = DefaultNetworkSimulationConfig;
|
||||
explicit SimulatedNetwork(Config config, uint64_t random_seed = 1);
|
||||
@ -36,7 +36,7 @@ class SimulatedNetwork : public NetworkSimulationInterface {
|
||||
void SetConfig(const Config& config);
|
||||
void PauseTransmissionUntil(int64_t until_us);
|
||||
|
||||
// NetworkSimulationInterface
|
||||
// NetworkBehaviorInterface
|
||||
bool EnqueuePacket(PacketInFlightInfo packet) override;
|
||||
std::vector<PacketDeliveryInfo> DequeueDeliverablePackets(
|
||||
int64_t receive_time_us) override;
|
||||
|
||||
@ -44,9 +44,9 @@ bool ActionReceiver::TryDeliverPacket(rtc::CopyOnWriteBuffer packet,
|
||||
NetworkNode::~NetworkNode() = default;
|
||||
|
||||
NetworkNode::NetworkNode(NetworkNodeConfig config,
|
||||
std::unique_ptr<NetworkSimulationInterface> simulation)
|
||||
std::unique_ptr<NetworkBehaviorInterface> behavior)
|
||||
: packet_overhead_(config.packet_overhead.bytes()),
|
||||
simulation_(std::move(simulation)) {}
|
||||
behavior_(std::move(behavior)) {}
|
||||
|
||||
void NetworkNode::SetRoute(uint64_t receiver, NetworkReceiverInterface* node) {
|
||||
rtc::CritScope crit(&crit_sect_);
|
||||
@ -66,7 +66,7 @@ bool NetworkNode::TryDeliverPacket(rtc::CopyOnWriteBuffer packet,
|
||||
if (routing_.find(receiver) == routing_.end())
|
||||
return false;
|
||||
uint64_t packet_id = next_packet_id_++;
|
||||
bool sent = simulation_->EnqueuePacket(PacketInFlightInfo(
|
||||
bool sent = behavior_->EnqueuePacket(PacketInFlightInfo(
|
||||
packet.size() + packet_overhead_, at_time.us(), packet_id));
|
||||
if (sent) {
|
||||
packets_.emplace_back(StoredPacket{packet, receiver, packet_id, false});
|
||||
@ -78,11 +78,11 @@ void NetworkNode::Process(Timestamp at_time) {
|
||||
std::vector<PacketDeliveryInfo> delivery_infos;
|
||||
{
|
||||
rtc::CritScope crit(&crit_sect_);
|
||||
absl::optional<int64_t> delivery_us = simulation_->NextDeliveryTimeUs();
|
||||
absl::optional<int64_t> delivery_us = behavior_->NextDeliveryTimeUs();
|
||||
if (delivery_us && *delivery_us > at_time.us())
|
||||
return;
|
||||
|
||||
delivery_infos = simulation_->DequeueDeliverablePackets(at_time.us());
|
||||
delivery_infos = behavior_->DequeueDeliverablePackets(at_time.us());
|
||||
}
|
||||
for (PacketDeliveryInfo& delivery_info : delivery_infos) {
|
||||
StoredPacket* packet = nullptr;
|
||||
@ -162,7 +162,7 @@ ColumnPrinter SimulationNode::ConfigPrinter() const {
|
||||
|
||||
SimulationNode::SimulationNode(
|
||||
NetworkNodeConfig config,
|
||||
std::unique_ptr<NetworkSimulationInterface> behavior,
|
||||
std::unique_ptr<NetworkBehaviorInterface> behavior,
|
||||
SimulatedNetwork* simulation)
|
||||
: NetworkNode(config, std::move(behavior)),
|
||||
simulated_network_(simulation),
|
||||
|
||||
@ -75,7 +75,7 @@ class NetworkNode : public NetworkReceiverInterface {
|
||||
friend class VideoStreamPair;
|
||||
|
||||
NetworkNode(NetworkNodeConfig config,
|
||||
std::unique_ptr<NetworkSimulationInterface> simulation);
|
||||
std::unique_ptr<NetworkBehaviorInterface> simulation);
|
||||
static void ClearRoute(int64_t receiver_id, std::vector<NetworkNode*> nodes);
|
||||
void Process(Timestamp at_time);
|
||||
|
||||
@ -90,7 +90,7 @@ class NetworkNode : public NetworkReceiverInterface {
|
||||
void ClearRoute(uint64_t receiver_id);
|
||||
rtc::CriticalSection crit_sect_;
|
||||
size_t packet_overhead_ RTC_GUARDED_BY(crit_sect_);
|
||||
const std::unique_ptr<NetworkSimulationInterface> simulation_
|
||||
const std::unique_ptr<NetworkBehaviorInterface> behavior_
|
||||
RTC_GUARDED_BY(crit_sect_);
|
||||
std::map<uint64_t, NetworkReceiverInterface*> routing_
|
||||
RTC_GUARDED_BY(crit_sect_);
|
||||
@ -110,7 +110,7 @@ class SimulationNode : public NetworkNode {
|
||||
friend class Scenario;
|
||||
|
||||
SimulationNode(NetworkNodeConfig config,
|
||||
std::unique_ptr<NetworkSimulationInterface> behavior,
|
||||
std::unique_ptr<NetworkBehaviorInterface> behavior,
|
||||
SimulatedNetwork* simulation);
|
||||
static std::unique_ptr<SimulationNode> Create(NetworkNodeConfig config);
|
||||
SimulatedNetwork* const simulated_network_;
|
||||
|
||||
@ -167,9 +167,9 @@ SimulationNode* Scenario::CreateSimulationNode(NetworkNodeConfig config) {
|
||||
|
||||
NetworkNode* Scenario::CreateNetworkNode(
|
||||
NetworkNodeConfig config,
|
||||
std::unique_ptr<NetworkSimulationInterface> simulation) {
|
||||
std::unique_ptr<NetworkBehaviorInterface> behavior) {
|
||||
RTC_DCHECK(config.mode == NetworkNodeConfig::TrafficMode::kCustom);
|
||||
network_nodes_.emplace_back(new NetworkNode(config, std::move(simulation)));
|
||||
network_nodes_.emplace_back(new NetworkNode(config, std::move(behavior)));
|
||||
NetworkNode* network_node = network_nodes_.back().get();
|
||||
Every(config.update_frequency,
|
||||
[this, network_node] { network_node->Process(Now()); });
|
||||
|
||||
@ -71,7 +71,7 @@ class Scenario {
|
||||
std::function<void(NetworkNodeConfig*)> config_modifier);
|
||||
NetworkNode* CreateNetworkNode(
|
||||
NetworkNodeConfig config,
|
||||
std::unique_ptr<NetworkSimulationInterface> simulation);
|
||||
std::unique_ptr<NetworkBehaviorInterface> behavior);
|
||||
|
||||
CallClient* CreateClient(std::string name, CallClientConfig config);
|
||||
CallClient* CreateClient(
|
||||
|
||||
@ -1006,16 +1006,16 @@ void VideoQualityTest::StopThumbnails() {
|
||||
|
||||
std::unique_ptr<test::LayerFilteringTransport>
|
||||
VideoQualityTest::CreateSendTransport() {
|
||||
std::unique_ptr<NetworkSimulationInterface> simulated_network = nullptr;
|
||||
std::unique_ptr<NetworkBehaviorInterface> network_behavior = nullptr;
|
||||
if (injection_components_->sender_network == nullptr) {
|
||||
simulated_network = absl::make_unique<SimulatedNetwork>(*params_.config);
|
||||
network_behavior = absl::make_unique<SimulatedNetwork>(*params_.config);
|
||||
} else {
|
||||
simulated_network = std::move(injection_components_->sender_network);
|
||||
network_behavior = std::move(injection_components_->sender_network);
|
||||
}
|
||||
return absl::make_unique<test::LayerFilteringTransport>(
|
||||
&task_queue_,
|
||||
absl::make_unique<FakeNetworkPipe>(Clock::GetRealTimeClock(),
|
||||
std::move(simulated_network)),
|
||||
std::move(network_behavior)),
|
||||
sender_call_.get(), kPayloadTypeVP8, kPayloadTypeVP9,
|
||||
params_.video[0].selected_tl, params_.ss[0].selected_sl,
|
||||
payload_type_map_, kVideoSendSsrcs[0],
|
||||
@ -1025,16 +1025,16 @@ VideoQualityTest::CreateSendTransport() {
|
||||
|
||||
std::unique_ptr<test::DirectTransport>
|
||||
VideoQualityTest::CreateReceiveTransport() {
|
||||
std::unique_ptr<NetworkSimulationInterface> simulated_network = nullptr;
|
||||
std::unique_ptr<NetworkBehaviorInterface> network_behavior = nullptr;
|
||||
if (injection_components_->receiver_network == nullptr) {
|
||||
simulated_network = absl::make_unique<SimulatedNetwork>(*params_.config);
|
||||
network_behavior = absl::make_unique<SimulatedNetwork>(*params_.config);
|
||||
} else {
|
||||
simulated_network = std::move(injection_components_->receiver_network);
|
||||
network_behavior = std::move(injection_components_->receiver_network);
|
||||
}
|
||||
return absl::make_unique<test::DirectTransport>(
|
||||
&task_queue_,
|
||||
absl::make_unique<FakeNetworkPipe>(Clock::GetRealTimeClock(),
|
||||
std::move(simulated_network)),
|
||||
std::move(network_behavior)),
|
||||
receiver_call_.get(), payload_type_map_);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user