webrtc/api/test/simulated_network.h
Ilya Nikolaevskiy b661c658da Revert "Remove rtc::Optional alias and api:optional target"
This reverts commit 6f5b0f920a.

Reason for revert: Breaks internal project.

Original change's description:
> Remove rtc::Optional alias and api:optional target
> 
> Update left-overs where old target still was used.
> 
> Bug: webrtc:9078
> Change-Id: I2162c928091fc4ff1dea33a3f03adbe47207d206
> Reviewed-on: https://webrtc-review.googlesource.com/84740
> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#23913}

TBR=danilchap@webrtc.org,kwiberg@webrtc.org

Change-Id: I95f5ec33520b823c3d0c9cb83d945d6a15355367
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9078
Reviewed-on: https://webrtc-review.googlesource.com/88140
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23921}
2018-07-11 07:41:41 +00:00

77 lines
2.5 KiB
C++

/*
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef API_TEST_SIMULATED_NETWORK_H_
#define API_TEST_SIMULATED_NETWORK_H_
#include <stddef.h>
#include <stdint.h>
#include <deque>
#include <queue>
#include <vector>
#include "api/optional.h"
#include "rtc_base/criticalsection.h"
#include "rtc_base/random.h"
#include "rtc_base/thread_annotations.h"
namespace webrtc {
struct PacketInFlightInfo {
PacketInFlightInfo(size_t size, int64_t send_time_us, uint64_t packet_id)
: size(size), send_time_us(send_time_us), packet_id(packet_id) {}
size_t size;
int64_t send_time_us;
// Unique identifier for the packet in relation to other packets in flight.
uint64_t packet_id;
};
struct PacketDeliveryInfo {
static constexpr int kNotReceived = -1;
PacketDeliveryInfo(PacketInFlightInfo source, int64_t receive_time_us)
: receive_time_us(receive_time_us), packet_id(source.packet_id) {}
int64_t receive_time_us;
uint64_t packet_id;
};
class NetworkSimulationInterface {
public:
// TODO(phoglund): this one shouldn't really be here; make fake network pipes
// injectable instead in the video quality test fixture.
struct SimulatedNetworkConfig {
SimulatedNetworkConfig() {}
// Queue length in number of packets.
size_t queue_length_packets = 0;
// Delay in addition to capacity induced delay.
int queue_delay_ms = 0;
// Standard deviation of the extra delay.
int delay_standard_deviation_ms = 0;
// Link capacity in kbps.
int link_capacity_kbps = 0;
// Random packet loss.
int loss_percent = 0;
// If packets are allowed to be reordered.
bool allow_reordering = false;
// The average length of a burst of lost packets.
int avg_burst_loss_length = -1;
};
virtual bool EnqueuePacket(PacketInFlightInfo packet_info) = 0;
// Retrieves all packets that should be delivered by the given receive time.
virtual std::vector<PacketDeliveryInfo> DequeueDeliverablePackets(
int64_t receive_time_us) = 0;
virtual absl::optional<int64_t> NextDeliveryTimeUs() const = 0;
virtual ~NetworkSimulationInterface() = default;
};
} // namespace webrtc
#endif // API_TEST_SIMULATED_NETWORK_H_