blob: f1b9b280dccc5457c47259dbafc597793b7eb5ac [file] [log] [blame]
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_CAST_CONGESTION_CONTROL_CONGESTION_CONTROL_H_
#define MEDIA_CAST_CONGESTION_CONTROL_CONGESTION_CONTROL_H_
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/default_tick_clock.h"
#include "base/time/tick_clock.h"
#include "base/time/time.h"
namespace media {
namespace cast {
class CongestionControl {
public:
CongestionControl(float congestion_control_back_off,
uint32 max_bitrate_configured,
uint32 min_bitrate_configured,
uint32 start_bitrate);
virtual ~CongestionControl() {}
// Don't call OnAck if the same message contain a NACK.
// Returns true if the bitrate have changed.
bool OnAck(base::TimeDelta rtt_ms, uint32* new_bitrate);
// Returns true if the bitrate have changed.
bool OnNack(base::TimeDelta rtt_ms, uint32* new_bitrate);
void set_clock(base::TickClock* clock) {
clock_ = clock;
}
private:
const float congestion_control_back_off_;
const uint32 max_bitrate_configured_;
const uint32 min_bitrate_configured_;
uint32 bitrate_;
base::TimeTicks time_last_increase_;
base::TimeTicks time_last_decrease_;
scoped_ptr<base::TickClock> default_tick_clock_;
base::TickClock* clock_;
DISALLOW_COPY_AND_ASSIGN(CongestionControl);
};
} // namespace cast
} // namespace media
#endif // MEDIA_CAST_CONGESTION_CONTROL_CONGESTION_CONTROL_H_