Chromium Code Reviews| Index: media/cast/congestion_control/congestion_control.h |
| diff --git a/media/cast/congestion_control/congestion_control.h b/media/cast/congestion_control/congestion_control.h |
| index 236300a36bd9c91db166c034f02017a15e705949..7f8f0c0429937108ca85aa85649bb5c5b57508be 100644 |
| --- a/media/cast/congestion_control/congestion_control.h |
| +++ b/media/cast/congestion_control/congestion_control.h |
| @@ -5,6 +5,8 @@ |
| #ifndef MEDIA_CAST_CONGESTION_CONTROL_CONGESTION_CONTROL_H_ |
| #define MEDIA_CAST_CONGESTION_CONTROL_CONGESTION_CONTROL_H_ |
| +#include <deque> |
| + |
| #include "base/basictypes.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/time/tick_clock.h" |
| @@ -16,28 +18,61 @@ namespace cast { |
| class CongestionControl { |
| public: |
| CongestionControl(base::TickClock* clock, |
| - float congestion_control_back_off, |
| uint32 max_bitrate_configured, |
| uint32 min_bitrate_configured, |
| - uint32 start_bitrate); |
| + size_t max_unacked_frames); |
| 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); |
| + void UpdateRTT(base::TimeDelta rtt); |
|
Alpha Left Google
2014/06/10 22:20:39
nit: This should be Rtt to be consistent with the
hubbe
2014/06/11 00:04:15
Done.
Alpha Left Google
2014/06/11 01:16:28
I mean UpdateRtt instead of UpdateRTT. The variabl
|
| + void SendFrameToTransport(uint32 frame_id, |
|
Alpha Left Google
2014/06/10 22:20:39
Please document this method. When should this be c
hubbe
2014/06/11 00:04:15
Done.
|
| + size_t frame_size, |
| + base::TimeTicks when); |
| + void AckFrame(uint32 frame_id, base::TimeTicks when); |
|
Alpha Left Google
2014/06/10 22:20:39
Please document. A one line is sufficient.
hubbe
2014/06/11 00:04:15
Done.
|
| - // Returns true if the bitrate have changed. |
| - bool OnNack(base::TimeDelta rtt_ms, uint32* new_bitrate); |
| + // Returns the bitrate we should use for the next frame. |
| + uint32 GetBitrate(base::TimeTicks playout_time, |
| + base::TimeDelta playout_delay); |
| private: |
| + struct FrameStats { |
| + FrameStats(); |
| + // Time this frame was sent to the transport. |
| + base::TimeTicks sent_time; |
| + // Time this frame was acked. |
| + base::TimeTicks ack_time; |
| + // Size of encoded frame in bits. |
| + size_t frame_size; |
| + }; |
| + |
| + // Calculate how much "dead air" there is between two frames. |
|
Alpha Left Google
2014/06/10 22:20:39
Please be more descriptive of what "dead air" mean
hubbe
2014/06/11 00:04:15
Done.
|
| + static base::TimeDelta DeadTime(const FrameStats& a, const FrameStats& b); |
| + // Get the FrameStats for a given |frame_id|. |
| + // Note: Older FrameStats will be removed automatically. |
| + FrameStats* GetFrameStats(uint32 frame_id); |
| + // Calculata safe bitrate. This is based on how much we've been |
| + // sending in the past. |
| + double CalculateSafeBitrate(); |
| + |
| + // For a given frame, calculate when it might be acked. |
| + // (Or return the time it was acked, if it was.) |
| + base::TimeTicks EstimatedAckTime(uint32 frame_id, double bitrate); |
| + // Calculate when we start sending the data for a given frame. |
| + // This is done by calculating when we were done sending the previous |
| + // frame, but obvoiusly can't be less than |sent_time| (if known). |
| + base::TimeTicks EstimatedSendingTime(uint32 frame_id, double bitrate); |
| + |
| base::TickClock* const clock_; // Not owned by this class. |
| - 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_; |
| + std::deque<FrameStats> frame_stats_; |
| + uint32 last_frame_stats_; |
| + uint32 last_acked_frame_; |
| + uint32 last_encoded_frame_; |
| + base::TimeDelta rtt_; |
| + size_t history_size_; |
| + size_t acked_bits_in_history_; |
| + base::TimeDelta dead_time_in_history_; |
| DISALLOW_COPY_AND_ASSIGN(CongestionControl); |
| }; |