#include "modules/pacing/pacing_controller.h"
#include <algorithm>
#include <memory>
#include <utility>
#include <vector>
#include "absl/cleanup/cleanup.h"
#include "absl/strings/match.h"
#include "api/units/data_size.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "modules/pacing/bitrate_prober.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "system_wrappers/include/clock.h"
namespace webrtc {
namespace {
constexpr TimeDelta kCongestedPacketInterval = …;
constexpr TimeDelta kMaxDebtInTime = …;
constexpr TimeDelta kMaxElapsedTime = …;
bool IsDisabled(const FieldTrialsView& field_trials, absl::string_view key) { … }
bool IsEnabled(const FieldTrialsView& field_trials, absl::string_view key) { … }
}
const TimeDelta PacingController::kPausedProcessInterval = …;
const TimeDelta PacingController::kMinSleepTime = …;
const TimeDelta PacingController::kTargetPaddingDuration = …;
const TimeDelta PacingController::kMaxPaddingReplayDuration = …;
const TimeDelta PacingController::kMaxEarlyProbeProcessing = …;
PacingController::PacingController(Clock* clock,
PacketSender* packet_sender,
const FieldTrialsView& field_trials,
Configuration configuration)
: … { … }
PacingController::~PacingController() = default;
void PacingController::CreateProbeClusters(
rtc::ArrayView<const ProbeClusterConfig> probe_cluster_configs) { … }
void PacingController::Pause() { … }
void PacingController::Resume() { … }
bool PacingController::IsPaused() const { … }
void PacingController::SetCongested(bool congested) { … }
void PacingController::SetCircuitBreakerThreshold(int num_iterations) { … }
void PacingController::RemovePacketsForSsrc(uint32_t ssrc) { … }
bool PacingController::IsProbing() const { … }
Timestamp PacingController::CurrentTime() const { … }
void PacingController::SetProbingEnabled(bool enabled) { … }
void PacingController::SetPacingRates(DataRate pacing_rate,
DataRate padding_rate) { … }
void PacingController::EnqueuePacket(std::unique_ptr<RtpPacketToSend> packet) { … }
void PacingController::SetAccountForAudioPackets(bool account_for_audio) { … }
void PacingController::SetIncludeOverhead() { … }
void PacingController::SetTransportOverhead(DataSize overhead_per_packet) { … }
void PacingController::SetSendBurstInterval(TimeDelta burst_interval) { … }
void PacingController::SetAllowProbeWithoutMediaPacket(bool allow) { … }
TimeDelta PacingController::ExpectedQueueTime() const { … }
size_t PacingController::QueueSizePackets() const { … }
const std::array<int, kNumMediaTypes>&
PacingController::SizeInPacketsPerRtpPacketMediaType() const { … }
DataSize PacingController::QueueSizeData() const { … }
DataSize PacingController::CurrentBufferLevel() const { … }
absl::optional<Timestamp> PacingController::FirstSentPacketTime() const { … }
Timestamp PacingController::OldestPacketEnqueueTime() const { … }
TimeDelta PacingController::UpdateTimeAndGetElapsed(Timestamp now) { … }
bool PacingController::ShouldSendKeepalive(Timestamp now) const { … }
Timestamp PacingController::NextSendTime() const { … }
void PacingController::ProcessPackets() { … }
DataSize PacingController::PaddingToAdd(DataSize recommended_probe_size,
DataSize data_sent) const { … }
std::unique_ptr<RtpPacketToSend> PacingController::GetPendingPacket(
const PacedPacketInfo& pacing_info,
Timestamp target_send_time,
Timestamp now) { … }
void PacingController::OnPacketSent(RtpPacketMediaType packet_type,
DataSize packet_size,
Timestamp send_time) { … }
void PacingController::UpdateBudgetWithElapsedTime(TimeDelta delta) { … }
void PacingController::UpdateBudgetWithSentData(DataSize size) { … }
void PacingController::UpdatePaddingBudgetWithSentData(DataSize size) { … }
void PacingController::SetQueueTimeLimit(TimeDelta limit) { … }
void PacingController::MaybeUpdateMediaRateDueToLongQueue(Timestamp now) { … }
Timestamp PacingController::NextUnpacedSendTime() const { … }
}