chromium/media/cast/sender/congestion_control.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// The purpose of this file is determine what bitrate to use for mirroring.
// Ideally this should be as much as possible, without causing any frames to
// arrive late.

// The current algorithm is to measure how much bandwidth we've been using
// recently. We also keep track of how much data has been queued up for sending
// in a virtual "buffer" (this virtual buffer represents all the buffers between
// the sender and the receiver, including retransmissions and so forth.)
// If we estimate that our virtual buffer is mostly empty, we try to use
// more bandwidth than our recent usage, otherwise we use less.

#include "media/cast/sender/congestion_control.h"

#include <algorithm>
#include <deque>

#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/numerics/safe_conversions.h"
#include "base/trace_event/trace_event.h"
#include "media/cast/constants.h"

namespace media {
namespace cast {

class AdaptiveCongestionControl final : public CongestionControl {};

class FixedCongestionControl final : public CongestionControl {};

CongestionControl* NewAdaptiveCongestionControl(const base::TickClock* clock,
                                                int max_bitrate_configured,
                                                int min_bitrate_configured,
                                                double max_frame_rate) {}

CongestionControl* NewFixedCongestionControl(int bitrate) {}

// This means that we *try* to keep our buffer 90% empty.
// If it is less full, we increase the bandwidth, if it is more
// we decrease the bandwidth. Making this smaller makes the
// congestion control more aggressive.
static const double kTargetEmptyBufferFraction =;

// This is the size of our history in frames. Larger values makes the
// congestion control adapt slower.
static const size_t kHistorySize =;

AdaptiveCongestionControl::FrameStats::FrameStats() :{}

AdaptiveCongestionControl::AdaptiveCongestionControl(
    const base::TickClock* clock,
    int max_bitrate_configured,
    int min_bitrate_configured,
    double max_frame_rate)
    :{}

CongestionControl::~CongestionControl() = default;
AdaptiveCongestionControl::~AdaptiveCongestionControl() = default;

void AdaptiveCongestionControl::UpdateRtt(base::TimeDelta rtt) {}

void AdaptiveCongestionControl::UpdateTargetPlayoutDelay(
    base::TimeDelta delay) {}

// Calculate how much "dead air" there is between two frames.
base::TimeDelta AdaptiveCongestionControl::DeadTime(const FrameStats& a,
                                                    const FrameStats& b) {}

double AdaptiveCongestionControl::CalculateSafeBitrate() {}

AdaptiveCongestionControl::FrameStats* AdaptiveCongestionControl::GetFrameStats(
    FrameId frame_id) {}

void AdaptiveCongestionControl::PruneFrameStats() {}

void AdaptiveCongestionControl::AckFrame(FrameId frame_id,
                                         base::TimeTicks when) {}

void AdaptiveCongestionControl::AckLaterFrames(
    std::vector<FrameId> received_frames,
    base::TimeTicks when) {}

void AdaptiveCongestionControl::WillSendFrameToTransport(
    FrameId frame_id,
    size_t frame_size_in_bytes,
    base::TimeTicks when) {}

base::TimeTicks AdaptiveCongestionControl::EstimatedSendingTime(
    FrameId frame_id,
    double estimated_bitrate) {}

int AdaptiveCongestionControl::GetBitrate(base::TimeTicks playout_time,
                                          base::TimeDelta playout_delay) {}

}  // namespace cast
}  // namespace media