2018-03-14 15:16:50 +01:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "call/degraded_call.h"
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2019-09-17 17:06:18 +02:00
|
|
|
#include <memory>
|
2018-03-14 15:16:50 +01:00
|
|
|
#include <utility>
|
|
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "rtc_base/location.h"
|
2018-03-14 15:16:50 +01:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2019-02-08 16:08:10 +01:00
|
|
|
|
2019-08-06 15:54:23 +02:00
|
|
|
DegradedCall::FakeNetworkPipeOnTaskQueue::FakeNetworkPipeOnTaskQueue(
|
2022-02-23 11:34:46 +01:00
|
|
|
TaskQueueBase* task_queue,
|
|
|
|
|
const ScopedTaskSafety& task_safety,
|
2019-02-08 16:08:10 +01:00
|
|
|
Clock* clock,
|
2019-08-12 15:56:51 +02:00
|
|
|
std::unique_ptr<NetworkBehaviorInterface> network_behavior)
|
2019-08-06 15:54:23 +02:00
|
|
|
: clock_(clock),
|
2022-02-23 11:34:46 +01:00
|
|
|
task_queue_(task_queue),
|
|
|
|
|
task_safety_(task_safety),
|
2019-08-12 15:56:51 +02:00
|
|
|
pipe_(clock, std::move(network_behavior)) {}
|
2019-08-06 15:54:23 +02:00
|
|
|
|
|
|
|
|
void DegradedCall::FakeNetworkPipeOnTaskQueue::SendRtp(
|
|
|
|
|
const uint8_t* packet,
|
|
|
|
|
size_t length,
|
2019-08-12 15:56:51 +02:00
|
|
|
const PacketOptions& options,
|
|
|
|
|
Transport* transport) {
|
|
|
|
|
pipe_.SendRtp(packet, length, options, transport);
|
2019-08-06 15:54:23 +02:00
|
|
|
Process();
|
2019-02-08 16:08:10 +01:00
|
|
|
}
|
|
|
|
|
|
2019-08-06 15:54:23 +02:00
|
|
|
void DegradedCall::FakeNetworkPipeOnTaskQueue::SendRtcp(const uint8_t* packet,
|
2019-08-12 15:56:51 +02:00
|
|
|
size_t length,
|
|
|
|
|
Transport* transport) {
|
|
|
|
|
pipe_.SendRtcp(packet, length, transport);
|
2019-08-06 15:54:23 +02:00
|
|
|
Process();
|
2019-02-08 16:08:10 +01:00
|
|
|
}
|
|
|
|
|
|
2019-08-12 15:56:51 +02:00
|
|
|
void DegradedCall::FakeNetworkPipeOnTaskQueue::AddActiveTransport(
|
|
|
|
|
Transport* transport) {
|
|
|
|
|
pipe_.AddActiveTransport(transport);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DegradedCall::FakeNetworkPipeOnTaskQueue::RemoveActiveTransport(
|
|
|
|
|
Transport* transport) {
|
|
|
|
|
pipe_.RemoveActiveTransport(transport);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-06 15:54:23 +02:00
|
|
|
bool DegradedCall::FakeNetworkPipeOnTaskQueue::Process() {
|
|
|
|
|
pipe_.Process();
|
|
|
|
|
auto time_to_next = pipe_.TimeUntilNextProcess();
|
|
|
|
|
if (!time_to_next) {
|
|
|
|
|
// Packet was probably sent immediately.
|
|
|
|
|
return false;
|
2019-02-08 16:08:10 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-23 11:34:46 +01:00
|
|
|
task_queue_->PostTask(ToQueuedTask(task_safety_, [this, time_to_next] {
|
|
|
|
|
RTC_DCHECK_RUN_ON(task_queue_);
|
2019-08-06 15:54:23 +02:00
|
|
|
int64_t next_process_time = *time_to_next + clock_->TimeInMilliseconds();
|
|
|
|
|
if (!next_process_ms_ || next_process_time < *next_process_ms_) {
|
|
|
|
|
next_process_ms_ = next_process_time;
|
2022-02-23 11:34:46 +01:00
|
|
|
task_queue_->PostDelayedHighPrecisionTask(
|
|
|
|
|
ToQueuedTask(task_safety_,
|
|
|
|
|
[this] {
|
|
|
|
|
RTC_DCHECK_RUN_ON(task_queue_);
|
|
|
|
|
if (!Process()) {
|
|
|
|
|
next_process_ms_.reset();
|
|
|
|
|
}
|
|
|
|
|
}),
|
2019-08-06 15:54:23 +02:00
|
|
|
*time_to_next);
|
|
|
|
|
}
|
2022-02-23 11:34:46 +01:00
|
|
|
}));
|
2019-02-08 16:08:10 +01:00
|
|
|
|
2019-08-06 15:54:23 +02:00
|
|
|
return true;
|
2019-02-08 16:08:10 +01:00
|
|
|
}
|
|
|
|
|
|
2019-08-12 15:56:51 +02:00
|
|
|
DegradedCall::FakeNetworkPipeTransportAdapter::FakeNetworkPipeTransportAdapter(
|
|
|
|
|
FakeNetworkPipeOnTaskQueue* fake_network,
|
|
|
|
|
Call* call,
|
|
|
|
|
Clock* clock,
|
|
|
|
|
Transport* real_transport)
|
|
|
|
|
: network_pipe_(fake_network),
|
|
|
|
|
call_(call),
|
|
|
|
|
clock_(clock),
|
|
|
|
|
real_transport_(real_transport) {
|
|
|
|
|
network_pipe_->AddActiveTransport(real_transport);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DegradedCall::FakeNetworkPipeTransportAdapter::
|
|
|
|
|
~FakeNetworkPipeTransportAdapter() {
|
|
|
|
|
network_pipe_->RemoveActiveTransport(real_transport_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DegradedCall::FakeNetworkPipeTransportAdapter::SendRtp(
|
|
|
|
|
const uint8_t* packet,
|
|
|
|
|
size_t length,
|
|
|
|
|
const PacketOptions& options) {
|
|
|
|
|
// A call here comes from the RTP stack (probably pacer). We intercept it and
|
|
|
|
|
// put it in the fake network pipe instead, but report to Call that is has
|
|
|
|
|
// been sent, so that the bandwidth estimator sees the delay we add.
|
|
|
|
|
network_pipe_->SendRtp(packet, length, options, real_transport_);
|
|
|
|
|
if (options.packet_id != -1) {
|
|
|
|
|
rtc::SentPacket sent_packet;
|
|
|
|
|
sent_packet.packet_id = options.packet_id;
|
|
|
|
|
sent_packet.send_time_ms = clock_->TimeInMilliseconds();
|
|
|
|
|
sent_packet.info.included_in_feedback = options.included_in_feedback;
|
|
|
|
|
sent_packet.info.included_in_allocation = options.included_in_allocation;
|
|
|
|
|
sent_packet.info.packet_size_bytes = length;
|
|
|
|
|
sent_packet.info.packet_type = rtc::PacketType::kData;
|
|
|
|
|
call_->OnSentPacket(sent_packet);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DegradedCall::FakeNetworkPipeTransportAdapter::SendRtcp(
|
|
|
|
|
const uint8_t* packet,
|
|
|
|
|
size_t length) {
|
|
|
|
|
network_pipe_->SendRtcp(packet, length, real_transport_);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-14 15:16:50 +01:00
|
|
|
DegradedCall::DegradedCall(
|
|
|
|
|
std::unique_ptr<Call> call,
|
Add support for time-varying constraints in DegradedCall.
The fake network configs are now specified using just two field trials:
WebRTC-FakeNetworkSendConfig and WebRTC-FakeNetworkReceiveConfig.
Both of them have the following parameters from
BuiltInNetworkBehaviorConfig:
* queue_length_packets // Queue length in number of packets.
* queue_delay_ms // Delay in addition to capacity induced delay.
* delay_standard_deviation_ms // Standard deviation of the extra delay.
* link_capacity_kbps // Link capacity in kbps.
* loss_percent // Random packet loss.
* allow_reordering // If packets are allowed to be reordered.
* avg_burst_loss_length // The average length of a burst of lost packets.
* packet_overhead // Additional bytes to add to packet size.
* codel_active_queue_management // Enable CoDel active queue management.
Plus:
* duration // For how long to use this config before progressing.
Example:
WebRTC-FakeNetworkSendConfig/queue_delay_ms:66|1,loss_percent:1|0,link_capacity_kbps:200|10000,queue_length_packets:10|100,duration:15s|45s/
This creates two configs:
1. For 15s, apply 66ms delay, 1% loss, 200kbps bandwidth, 10 packet queue size
2. For 45s, apply 1ms delay, 0% loss, 10Mbps bandwidth, 100 packets queue size
(then repeat)
Bug: webrtc:13655
Change-Id: I0524f572de480731df4d414724203772182c628b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251043
Reviewed-by: Stefan Holmer <holmer@google.com>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35952}
2022-02-08 12:35:46 +01:00
|
|
|
const std::vector<TimeScopedNetworkConfig>& send_configs,
|
2022-02-23 11:34:46 +01:00
|
|
|
const std::vector<TimeScopedNetworkConfig>& receive_configs)
|
2018-03-14 15:16:50 +01:00
|
|
|
: clock_(Clock::GetRealTimeClock()),
|
|
|
|
|
call_(std::move(call)),
|
Add support for time-varying constraints in DegradedCall.
The fake network configs are now specified using just two field trials:
WebRTC-FakeNetworkSendConfig and WebRTC-FakeNetworkReceiveConfig.
Both of them have the following parameters from
BuiltInNetworkBehaviorConfig:
* queue_length_packets // Queue length in number of packets.
* queue_delay_ms // Delay in addition to capacity induced delay.
* delay_standard_deviation_ms // Standard deviation of the extra delay.
* link_capacity_kbps // Link capacity in kbps.
* loss_percent // Random packet loss.
* allow_reordering // If packets are allowed to be reordered.
* avg_burst_loss_length // The average length of a burst of lost packets.
* packet_overhead // Additional bytes to add to packet size.
* codel_active_queue_management // Enable CoDel active queue management.
Plus:
* duration // For how long to use this config before progressing.
Example:
WebRTC-FakeNetworkSendConfig/queue_delay_ms:66|1,loss_percent:1|0,link_capacity_kbps:200|10000,queue_length_packets:10|100,duration:15s|45s/
This creates two configs:
1. For 15s, apply 66ms delay, 1% loss, 200kbps bandwidth, 10 packet queue size
2. For 45s, apply 1ms delay, 0% loss, 10Mbps bandwidth, 100 packets queue size
(then repeat)
Bug: webrtc:13655
Change-Id: I0524f572de480731df4d414724203772182c628b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251043
Reviewed-by: Stefan Holmer <holmer@google.com>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35952}
2022-02-08 12:35:46 +01:00
|
|
|
send_config_index_(0),
|
|
|
|
|
send_configs_(send_configs),
|
2019-08-06 15:54:23 +02:00
|
|
|
send_simulated_network_(nullptr),
|
Add support for time-varying constraints in DegradedCall.
The fake network configs are now specified using just two field trials:
WebRTC-FakeNetworkSendConfig and WebRTC-FakeNetworkReceiveConfig.
Both of them have the following parameters from
BuiltInNetworkBehaviorConfig:
* queue_length_packets // Queue length in number of packets.
* queue_delay_ms // Delay in addition to capacity induced delay.
* delay_standard_deviation_ms // Standard deviation of the extra delay.
* link_capacity_kbps // Link capacity in kbps.
* loss_percent // Random packet loss.
* allow_reordering // If packets are allowed to be reordered.
* avg_burst_loss_length // The average length of a burst of lost packets.
* packet_overhead // Additional bytes to add to packet size.
* codel_active_queue_management // Enable CoDel active queue management.
Plus:
* duration // For how long to use this config before progressing.
Example:
WebRTC-FakeNetworkSendConfig/queue_delay_ms:66|1,loss_percent:1|0,link_capacity_kbps:200|10000,queue_length_packets:10|100,duration:15s|45s/
This creates two configs:
1. For 15s, apply 66ms delay, 1% loss, 200kbps bandwidth, 10 packet queue size
2. For 45s, apply 1ms delay, 0% loss, 10Mbps bandwidth, 100 packets queue size
(then repeat)
Bug: webrtc:13655
Change-Id: I0524f572de480731df4d414724203772182c628b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251043
Reviewed-by: Stefan Holmer <holmer@google.com>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35952}
2022-02-08 12:35:46 +01:00
|
|
|
receive_config_index_(0),
|
|
|
|
|
receive_configs_(receive_configs) {
|
|
|
|
|
if (!receive_configs_.empty()) {
|
|
|
|
|
auto network = std::make_unique<SimulatedNetwork>(receive_configs_[0]);
|
2018-08-17 13:00:54 +02:00
|
|
|
receive_simulated_network_ = network.get();
|
2018-03-14 15:16:50 +01:00
|
|
|
receive_pipe_ =
|
2019-09-17 17:06:18 +02:00
|
|
|
std::make_unique<webrtc::FakeNetworkPipe>(clock_, std::move(network));
|
2018-03-14 15:16:50 +01:00
|
|
|
receive_pipe_->SetReceiver(call_->Receiver());
|
Add support for time-varying constraints in DegradedCall.
The fake network configs are now specified using just two field trials:
WebRTC-FakeNetworkSendConfig and WebRTC-FakeNetworkReceiveConfig.
Both of them have the following parameters from
BuiltInNetworkBehaviorConfig:
* queue_length_packets // Queue length in number of packets.
* queue_delay_ms // Delay in addition to capacity induced delay.
* delay_standard_deviation_ms // Standard deviation of the extra delay.
* link_capacity_kbps // Link capacity in kbps.
* loss_percent // Random packet loss.
* allow_reordering // If packets are allowed to be reordered.
* avg_burst_loss_length // The average length of a burst of lost packets.
* packet_overhead // Additional bytes to add to packet size.
* codel_active_queue_management // Enable CoDel active queue management.
Plus:
* duration // For how long to use this config before progressing.
Example:
WebRTC-FakeNetworkSendConfig/queue_delay_ms:66|1,loss_percent:1|0,link_capacity_kbps:200|10000,queue_length_packets:10|100,duration:15s|45s/
This creates two configs:
1. For 15s, apply 66ms delay, 1% loss, 200kbps bandwidth, 10 packet queue size
2. For 45s, apply 1ms delay, 0% loss, 10Mbps bandwidth, 100 packets queue size
(then repeat)
Bug: webrtc:13655
Change-Id: I0524f572de480731df4d414724203772182c628b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251043
Reviewed-by: Stefan Holmer <holmer@google.com>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35952}
2022-02-08 12:35:46 +01:00
|
|
|
if (receive_configs_.size() > 1) {
|
|
|
|
|
call_->network_thread()->PostDelayedTask(
|
|
|
|
|
ToQueuedTask(task_safety_, [this] { UpdateReceiveNetworkConfig(); }),
|
|
|
|
|
receive_configs_[0].duration.ms());
|
|
|
|
|
}
|
2018-03-14 15:16:50 +01:00
|
|
|
}
|
Add support for time-varying constraints in DegradedCall.
The fake network configs are now specified using just two field trials:
WebRTC-FakeNetworkSendConfig and WebRTC-FakeNetworkReceiveConfig.
Both of them have the following parameters from
BuiltInNetworkBehaviorConfig:
* queue_length_packets // Queue length in number of packets.
* queue_delay_ms // Delay in addition to capacity induced delay.
* delay_standard_deviation_ms // Standard deviation of the extra delay.
* link_capacity_kbps // Link capacity in kbps.
* loss_percent // Random packet loss.
* allow_reordering // If packets are allowed to be reordered.
* avg_burst_loss_length // The average length of a burst of lost packets.
* packet_overhead // Additional bytes to add to packet size.
* codel_active_queue_management // Enable CoDel active queue management.
Plus:
* duration // For how long to use this config before progressing.
Example:
WebRTC-FakeNetworkSendConfig/queue_delay_ms:66|1,loss_percent:1|0,link_capacity_kbps:200|10000,queue_length_packets:10|100,duration:15s|45s/
This creates two configs:
1. For 15s, apply 66ms delay, 1% loss, 200kbps bandwidth, 10 packet queue size
2. For 45s, apply 1ms delay, 0% loss, 10Mbps bandwidth, 100 packets queue size
(then repeat)
Bug: webrtc:13655
Change-Id: I0524f572de480731df4d414724203772182c628b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251043
Reviewed-by: Stefan Holmer <holmer@google.com>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35952}
2022-02-08 12:35:46 +01:00
|
|
|
if (!send_configs_.empty()) {
|
|
|
|
|
auto network = std::make_unique<SimulatedNetwork>(send_configs_[0]);
|
2019-08-12 15:56:51 +02:00
|
|
|
send_simulated_network_ = network.get();
|
2019-09-17 17:06:18 +02:00
|
|
|
send_pipe_ = std::make_unique<FakeNetworkPipeOnTaskQueue>(
|
2022-02-23 11:34:46 +01:00
|
|
|
call_->network_thread(), task_safety_, clock_, std::move(network));
|
Add support for time-varying constraints in DegradedCall.
The fake network configs are now specified using just two field trials:
WebRTC-FakeNetworkSendConfig and WebRTC-FakeNetworkReceiveConfig.
Both of them have the following parameters from
BuiltInNetworkBehaviorConfig:
* queue_length_packets // Queue length in number of packets.
* queue_delay_ms // Delay in addition to capacity induced delay.
* delay_standard_deviation_ms // Standard deviation of the extra delay.
* link_capacity_kbps // Link capacity in kbps.
* loss_percent // Random packet loss.
* allow_reordering // If packets are allowed to be reordered.
* avg_burst_loss_length // The average length of a burst of lost packets.
* packet_overhead // Additional bytes to add to packet size.
* codel_active_queue_management // Enable CoDel active queue management.
Plus:
* duration // For how long to use this config before progressing.
Example:
WebRTC-FakeNetworkSendConfig/queue_delay_ms:66|1,loss_percent:1|0,link_capacity_kbps:200|10000,queue_length_packets:10|100,duration:15s|45s/
This creates two configs:
1. For 15s, apply 66ms delay, 1% loss, 200kbps bandwidth, 10 packet queue size
2. For 45s, apply 1ms delay, 0% loss, 10Mbps bandwidth, 100 packets queue size
(then repeat)
Bug: webrtc:13655
Change-Id: I0524f572de480731df4d414724203772182c628b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251043
Reviewed-by: Stefan Holmer <holmer@google.com>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35952}
2022-02-08 12:35:46 +01:00
|
|
|
if (send_configs_.size() > 1) {
|
|
|
|
|
call_->network_thread()->PostDelayedTask(
|
|
|
|
|
ToQueuedTask(task_safety_, [this] { UpdateSendNetworkConfig(); }),
|
|
|
|
|
send_configs_[0].duration.ms());
|
|
|
|
|
}
|
2019-08-12 15:56:51 +02:00
|
|
|
}
|
2018-03-14 15:16:50 +01:00
|
|
|
}
|
|
|
|
|
|
2019-08-06 15:54:23 +02:00
|
|
|
DegradedCall::~DegradedCall() = default;
|
2018-03-14 15:16:50 +01:00
|
|
|
|
|
|
|
|
AudioSendStream* DegradedCall::CreateAudioSendStream(
|
|
|
|
|
const AudioSendStream::Config& config) {
|
Add support for time-varying constraints in DegradedCall.
The fake network configs are now specified using just two field trials:
WebRTC-FakeNetworkSendConfig and WebRTC-FakeNetworkReceiveConfig.
Both of them have the following parameters from
BuiltInNetworkBehaviorConfig:
* queue_length_packets // Queue length in number of packets.
* queue_delay_ms // Delay in addition to capacity induced delay.
* delay_standard_deviation_ms // Standard deviation of the extra delay.
* link_capacity_kbps // Link capacity in kbps.
* loss_percent // Random packet loss.
* allow_reordering // If packets are allowed to be reordered.
* avg_burst_loss_length // The average length of a burst of lost packets.
* packet_overhead // Additional bytes to add to packet size.
* codel_active_queue_management // Enable CoDel active queue management.
Plus:
* duration // For how long to use this config before progressing.
Example:
WebRTC-FakeNetworkSendConfig/queue_delay_ms:66|1,loss_percent:1|0,link_capacity_kbps:200|10000,queue_length_packets:10|100,duration:15s|45s/
This creates two configs:
1. For 15s, apply 66ms delay, 1% loss, 200kbps bandwidth, 10 packet queue size
2. For 45s, apply 1ms delay, 0% loss, 10Mbps bandwidth, 100 packets queue size
(then repeat)
Bug: webrtc:13655
Change-Id: I0524f572de480731df4d414724203772182c628b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251043
Reviewed-by: Stefan Holmer <holmer@google.com>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35952}
2022-02-08 12:35:46 +01:00
|
|
|
if (!send_configs_.empty()) {
|
2019-09-17 17:06:18 +02:00
|
|
|
auto transport_adapter = std::make_unique<FakeNetworkPipeTransportAdapter>(
|
2019-08-12 15:56:51 +02:00
|
|
|
send_pipe_.get(), call_.get(), clock_, config.send_transport);
|
|
|
|
|
AudioSendStream::Config degrade_config = config;
|
|
|
|
|
degrade_config.send_transport = transport_adapter.get();
|
|
|
|
|
AudioSendStream* send_stream = call_->CreateAudioSendStream(degrade_config);
|
|
|
|
|
if (send_stream) {
|
|
|
|
|
audio_send_transport_adapters_[send_stream] =
|
|
|
|
|
std::move(transport_adapter);
|
|
|
|
|
}
|
|
|
|
|
return send_stream;
|
|
|
|
|
}
|
2018-03-14 15:16:50 +01:00
|
|
|
return call_->CreateAudioSendStream(config);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DegradedCall::DestroyAudioSendStream(AudioSendStream* send_stream) {
|
|
|
|
|
call_->DestroyAudioSendStream(send_stream);
|
2019-08-12 15:56:51 +02:00
|
|
|
audio_send_transport_adapters_.erase(send_stream);
|
2018-03-14 15:16:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AudioReceiveStream* DegradedCall::CreateAudioReceiveStream(
|
|
|
|
|
const AudioReceiveStream::Config& config) {
|
|
|
|
|
return call_->CreateAudioReceiveStream(config);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DegradedCall::DestroyAudioReceiveStream(
|
|
|
|
|
AudioReceiveStream* receive_stream) {
|
|
|
|
|
call_->DestroyAudioReceiveStream(receive_stream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VideoSendStream* DegradedCall::CreateVideoSendStream(
|
|
|
|
|
VideoSendStream::Config config,
|
|
|
|
|
VideoEncoderConfig encoder_config) {
|
2019-08-12 15:56:51 +02:00
|
|
|
std::unique_ptr<FakeNetworkPipeTransportAdapter> transport_adapter;
|
Add support for time-varying constraints in DegradedCall.
The fake network configs are now specified using just two field trials:
WebRTC-FakeNetworkSendConfig and WebRTC-FakeNetworkReceiveConfig.
Both of them have the following parameters from
BuiltInNetworkBehaviorConfig:
* queue_length_packets // Queue length in number of packets.
* queue_delay_ms // Delay in addition to capacity induced delay.
* delay_standard_deviation_ms // Standard deviation of the extra delay.
* link_capacity_kbps // Link capacity in kbps.
* loss_percent // Random packet loss.
* allow_reordering // If packets are allowed to be reordered.
* avg_burst_loss_length // The average length of a burst of lost packets.
* packet_overhead // Additional bytes to add to packet size.
* codel_active_queue_management // Enable CoDel active queue management.
Plus:
* duration // For how long to use this config before progressing.
Example:
WebRTC-FakeNetworkSendConfig/queue_delay_ms:66|1,loss_percent:1|0,link_capacity_kbps:200|10000,queue_length_packets:10|100,duration:15s|45s/
This creates two configs:
1. For 15s, apply 66ms delay, 1% loss, 200kbps bandwidth, 10 packet queue size
2. For 45s, apply 1ms delay, 0% loss, 10Mbps bandwidth, 100 packets queue size
(then repeat)
Bug: webrtc:13655
Change-Id: I0524f572de480731df4d414724203772182c628b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251043
Reviewed-by: Stefan Holmer <holmer@google.com>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35952}
2022-02-08 12:35:46 +01:00
|
|
|
if (!send_configs_.empty()) {
|
2019-09-17 17:06:18 +02:00
|
|
|
transport_adapter = std::make_unique<FakeNetworkPipeTransportAdapter>(
|
2019-08-12 15:56:51 +02:00
|
|
|
send_pipe_.get(), call_.get(), clock_, config.send_transport);
|
|
|
|
|
config.send_transport = transport_adapter.get();
|
2018-03-14 15:16:50 +01:00
|
|
|
}
|
2019-08-12 15:56:51 +02:00
|
|
|
VideoSendStream* send_stream = call_->CreateVideoSendStream(
|
|
|
|
|
std::move(config), std::move(encoder_config));
|
|
|
|
|
if (send_stream && transport_adapter) {
|
|
|
|
|
video_send_transport_adapters_[send_stream] = std::move(transport_adapter);
|
|
|
|
|
}
|
|
|
|
|
return send_stream;
|
2018-03-14 15:16:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VideoSendStream* DegradedCall::CreateVideoSendStream(
|
|
|
|
|
VideoSendStream::Config config,
|
|
|
|
|
VideoEncoderConfig encoder_config,
|
|
|
|
|
std::unique_ptr<FecController> fec_controller) {
|
2019-08-12 15:56:51 +02:00
|
|
|
std::unique_ptr<FakeNetworkPipeTransportAdapter> transport_adapter;
|
Add support for time-varying constraints in DegradedCall.
The fake network configs are now specified using just two field trials:
WebRTC-FakeNetworkSendConfig and WebRTC-FakeNetworkReceiveConfig.
Both of them have the following parameters from
BuiltInNetworkBehaviorConfig:
* queue_length_packets // Queue length in number of packets.
* queue_delay_ms // Delay in addition to capacity induced delay.
* delay_standard_deviation_ms // Standard deviation of the extra delay.
* link_capacity_kbps // Link capacity in kbps.
* loss_percent // Random packet loss.
* allow_reordering // If packets are allowed to be reordered.
* avg_burst_loss_length // The average length of a burst of lost packets.
* packet_overhead // Additional bytes to add to packet size.
* codel_active_queue_management // Enable CoDel active queue management.
Plus:
* duration // For how long to use this config before progressing.
Example:
WebRTC-FakeNetworkSendConfig/queue_delay_ms:66|1,loss_percent:1|0,link_capacity_kbps:200|10000,queue_length_packets:10|100,duration:15s|45s/
This creates two configs:
1. For 15s, apply 66ms delay, 1% loss, 200kbps bandwidth, 10 packet queue size
2. For 45s, apply 1ms delay, 0% loss, 10Mbps bandwidth, 100 packets queue size
(then repeat)
Bug: webrtc:13655
Change-Id: I0524f572de480731df4d414724203772182c628b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251043
Reviewed-by: Stefan Holmer <holmer@google.com>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35952}
2022-02-08 12:35:46 +01:00
|
|
|
if (!send_configs_.empty()) {
|
2019-09-17 17:06:18 +02:00
|
|
|
transport_adapter = std::make_unique<FakeNetworkPipeTransportAdapter>(
|
2019-08-12 15:56:51 +02:00
|
|
|
send_pipe_.get(), call_.get(), clock_, config.send_transport);
|
|
|
|
|
config.send_transport = transport_adapter.get();
|
2018-03-14 15:16:50 +01:00
|
|
|
}
|
2019-08-12 15:56:51 +02:00
|
|
|
VideoSendStream* send_stream = call_->CreateVideoSendStream(
|
2018-03-14 15:16:50 +01:00
|
|
|
std::move(config), std::move(encoder_config), std::move(fec_controller));
|
2019-08-12 15:56:51 +02:00
|
|
|
if (send_stream && transport_adapter) {
|
|
|
|
|
video_send_transport_adapters_[send_stream] = std::move(transport_adapter);
|
|
|
|
|
}
|
|
|
|
|
return send_stream;
|
2018-03-14 15:16:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DegradedCall::DestroyVideoSendStream(VideoSendStream* send_stream) {
|
2018-03-16 10:47:16 +01:00
|
|
|
call_->DestroyVideoSendStream(send_stream);
|
2019-08-12 15:56:51 +02:00
|
|
|
video_send_transport_adapters_.erase(send_stream);
|
2018-03-14 15:16:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VideoReceiveStream* DegradedCall::CreateVideoReceiveStream(
|
|
|
|
|
VideoReceiveStream::Config configuration) {
|
|
|
|
|
return call_->CreateVideoReceiveStream(std::move(configuration));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DegradedCall::DestroyVideoReceiveStream(
|
|
|
|
|
VideoReceiveStream* receive_stream) {
|
|
|
|
|
call_->DestroyVideoReceiveStream(receive_stream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FlexfecReceiveStream* DegradedCall::CreateFlexfecReceiveStream(
|
|
|
|
|
const FlexfecReceiveStream::Config& config) {
|
|
|
|
|
return call_->CreateFlexfecReceiveStream(config);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DegradedCall::DestroyFlexfecReceiveStream(
|
|
|
|
|
FlexfecReceiveStream* receive_stream) {
|
|
|
|
|
call_->DestroyFlexfecReceiveStream(receive_stream);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-11 12:07:14 +02:00
|
|
|
void DegradedCall::AddAdaptationResource(
|
|
|
|
|
rtc::scoped_refptr<Resource> resource) {
|
|
|
|
|
call_->AddAdaptationResource(std::move(resource));
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-14 15:16:50 +01:00
|
|
|
PacketReceiver* DegradedCall::Receiver() {
|
Add support for time-varying constraints in DegradedCall.
The fake network configs are now specified using just two field trials:
WebRTC-FakeNetworkSendConfig and WebRTC-FakeNetworkReceiveConfig.
Both of them have the following parameters from
BuiltInNetworkBehaviorConfig:
* queue_length_packets // Queue length in number of packets.
* queue_delay_ms // Delay in addition to capacity induced delay.
* delay_standard_deviation_ms // Standard deviation of the extra delay.
* link_capacity_kbps // Link capacity in kbps.
* loss_percent // Random packet loss.
* allow_reordering // If packets are allowed to be reordered.
* avg_burst_loss_length // The average length of a burst of lost packets.
* packet_overhead // Additional bytes to add to packet size.
* codel_active_queue_management // Enable CoDel active queue management.
Plus:
* duration // For how long to use this config before progressing.
Example:
WebRTC-FakeNetworkSendConfig/queue_delay_ms:66|1,loss_percent:1|0,link_capacity_kbps:200|10000,queue_length_packets:10|100,duration:15s|45s/
This creates two configs:
1. For 15s, apply 66ms delay, 1% loss, 200kbps bandwidth, 10 packet queue size
2. For 45s, apply 1ms delay, 0% loss, 10Mbps bandwidth, 100 packets queue size
(then repeat)
Bug: webrtc:13655
Change-Id: I0524f572de480731df4d414724203772182c628b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251043
Reviewed-by: Stefan Holmer <holmer@google.com>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35952}
2022-02-08 12:35:46 +01:00
|
|
|
if (!receive_configs_.empty()) {
|
2018-03-14 15:16:50 +01:00
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
return call_->Receiver();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RtpTransportControllerSendInterface*
|
|
|
|
|
DegradedCall::GetTransportControllerSend() {
|
|
|
|
|
return call_->GetTransportControllerSend();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Call::Stats DegradedCall::GetStats() const {
|
|
|
|
|
return call_->GetStats();
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-29 11:04:48 +02:00
|
|
|
const FieldTrialsView& DegradedCall::trials() const {
|
2020-09-22 11:36:35 +02:00
|
|
|
return call_->trials();
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-19 09:21:06 +02:00
|
|
|
TaskQueueBase* DegradedCall::network_thread() const {
|
|
|
|
|
return call_->network_thread();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TaskQueueBase* DegradedCall::worker_thread() const {
|
|
|
|
|
return call_->worker_thread();
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-14 15:16:50 +01:00
|
|
|
void DegradedCall::SignalChannelNetworkState(MediaType media,
|
|
|
|
|
NetworkState state) {
|
|
|
|
|
call_->SignalChannelNetworkState(media, state);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-04 15:21:55 +02:00
|
|
|
void DegradedCall::OnAudioTransportOverheadChanged(
|
2018-03-14 15:16:50 +01:00
|
|
|
int transport_overhead_per_packet) {
|
2018-10-04 15:21:55 +02:00
|
|
|
call_->OnAudioTransportOverheadChanged(transport_overhead_per_packet);
|
2018-03-14 15:16:50 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-15 23:01:57 +02:00
|
|
|
void DegradedCall::OnLocalSsrcUpdated(AudioReceiveStream& stream,
|
|
|
|
|
uint32_t local_ssrc) {
|
|
|
|
|
call_->OnLocalSsrcUpdated(stream, local_ssrc);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-16 16:31:18 +02:00
|
|
|
void DegradedCall::OnUpdateSyncGroup(AudioReceiveStream& stream,
|
|
|
|
|
const std::string& sync_group) {
|
|
|
|
|
call_->OnUpdateSyncGroup(stream, sync_group);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-14 15:16:50 +01:00
|
|
|
void DegradedCall::OnSentPacket(const rtc::SentPacket& sent_packet) {
|
Add support for time-varying constraints in DegradedCall.
The fake network configs are now specified using just two field trials:
WebRTC-FakeNetworkSendConfig and WebRTC-FakeNetworkReceiveConfig.
Both of them have the following parameters from
BuiltInNetworkBehaviorConfig:
* queue_length_packets // Queue length in number of packets.
* queue_delay_ms // Delay in addition to capacity induced delay.
* delay_standard_deviation_ms // Standard deviation of the extra delay.
* link_capacity_kbps // Link capacity in kbps.
* loss_percent // Random packet loss.
* allow_reordering // If packets are allowed to be reordered.
* avg_burst_loss_length // The average length of a burst of lost packets.
* packet_overhead // Additional bytes to add to packet size.
* codel_active_queue_management // Enable CoDel active queue management.
Plus:
* duration // For how long to use this config before progressing.
Example:
WebRTC-FakeNetworkSendConfig/queue_delay_ms:66|1,loss_percent:1|0,link_capacity_kbps:200|10000,queue_length_packets:10|100,duration:15s|45s/
This creates two configs:
1. For 15s, apply 66ms delay, 1% loss, 200kbps bandwidth, 10 packet queue size
2. For 45s, apply 1ms delay, 0% loss, 10Mbps bandwidth, 100 packets queue size
(then repeat)
Bug: webrtc:13655
Change-Id: I0524f572de480731df4d414724203772182c628b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251043
Reviewed-by: Stefan Holmer <holmer@google.com>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35952}
2022-02-08 12:35:46 +01:00
|
|
|
if (!send_configs_.empty()) {
|
2018-03-14 15:16:50 +01:00
|
|
|
// If we have a degraded send-transport, we have already notified call
|
|
|
|
|
// about the supposed network send time. Discard the actual network send
|
|
|
|
|
// time in order to properly fool the BWE.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
call_->OnSentPacket(sent_packet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PacketReceiver::DeliveryStatus DegradedCall::DeliverPacket(
|
|
|
|
|
MediaType media_type,
|
|
|
|
|
rtc::CopyOnWriteBuffer packet,
|
2018-08-07 11:03:12 +02:00
|
|
|
int64_t packet_time_us) {
|
|
|
|
|
PacketReceiver::DeliveryStatus status = receive_pipe_->DeliverPacket(
|
|
|
|
|
media_type, std::move(packet), packet_time_us);
|
2018-03-14 15:16:50 +01:00
|
|
|
// This is not optimal, but there are many places where there are thread
|
|
|
|
|
// checks that fail if we're not using the worker thread call into this
|
|
|
|
|
// method. If we want to fix this we probably need a task queue to do handover
|
2019-08-12 15:56:51 +02:00
|
|
|
// of all overriden methods, which feels like overkill for the current use
|
2018-03-14 15:16:50 +01:00
|
|
|
// case.
|
|
|
|
|
// By just having this thread call out via the Process() method we work around
|
|
|
|
|
// that, with the tradeoff that a non-zero delay may become a little larger
|
|
|
|
|
// than anticipated at very low packet rates.
|
|
|
|
|
receive_pipe_->Process();
|
|
|
|
|
return status;
|
|
|
|
|
}
|
Add support for time-varying constraints in DegradedCall.
The fake network configs are now specified using just two field trials:
WebRTC-FakeNetworkSendConfig and WebRTC-FakeNetworkReceiveConfig.
Both of them have the following parameters from
BuiltInNetworkBehaviorConfig:
* queue_length_packets // Queue length in number of packets.
* queue_delay_ms // Delay in addition to capacity induced delay.
* delay_standard_deviation_ms // Standard deviation of the extra delay.
* link_capacity_kbps // Link capacity in kbps.
* loss_percent // Random packet loss.
* allow_reordering // If packets are allowed to be reordered.
* avg_burst_loss_length // The average length of a burst of lost packets.
* packet_overhead // Additional bytes to add to packet size.
* codel_active_queue_management // Enable CoDel active queue management.
Plus:
* duration // For how long to use this config before progressing.
Example:
WebRTC-FakeNetworkSendConfig/queue_delay_ms:66|1,loss_percent:1|0,link_capacity_kbps:200|10000,queue_length_packets:10|100,duration:15s|45s/
This creates two configs:
1. For 15s, apply 66ms delay, 1% loss, 200kbps bandwidth, 10 packet queue size
2. For 45s, apply 1ms delay, 0% loss, 10Mbps bandwidth, 100 packets queue size
(then repeat)
Bug: webrtc:13655
Change-Id: I0524f572de480731df4d414724203772182c628b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251043
Reviewed-by: Stefan Holmer <holmer@google.com>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35952}
2022-02-08 12:35:46 +01:00
|
|
|
|
|
|
|
|
void DegradedCall::UpdateSendNetworkConfig() {
|
|
|
|
|
send_config_index_ = (send_config_index_ + 1) % send_configs_.size();
|
|
|
|
|
send_simulated_network_->SetConfig(send_configs_[send_config_index_]);
|
|
|
|
|
call_->network_thread()->PostDelayedTask(
|
|
|
|
|
ToQueuedTask(task_safety_, [this] { UpdateSendNetworkConfig(); }),
|
|
|
|
|
send_configs_[send_config_index_].duration.ms());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DegradedCall::UpdateReceiveNetworkConfig() {
|
|
|
|
|
receive_config_index_ = (receive_config_index_ + 1) % receive_configs_.size();
|
|
|
|
|
receive_simulated_network_->SetConfig(
|
|
|
|
|
receive_configs_[receive_config_index_]);
|
|
|
|
|
call_->network_thread()->PostDelayedTask(
|
|
|
|
|
ToQueuedTask(task_safety_, [this] { UpdateReceiveNetworkConfig(); }),
|
|
|
|
|
receive_configs_[receive_config_index_].duration.ms());
|
|
|
|
|
}
|
2018-03-14 15:16:50 +01:00
|
|
|
} // namespace webrtc
|