| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // The purpose of this file is determine what bitrate to use for mirroring. | 5 // The purpose of this file is determine what bitrate to use for mirroring. |
| 6 // Ideally this should be as much as possible, without causing any frames to | 6 // Ideally this should be as much as possible, without causing any frames to |
| 7 // arrive late. | 7 // arrive late. |
| 8 | 8 |
| 9 // The current algorithm is to measure how much bandwidth we've been using | 9 // The current algorithm is to measure how much bandwidth we've been using |
| 10 // recently. We also keep track of how much data has been queued up for sending | 10 // recently. We also keep track of how much data has been queued up for sending |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 namespace media { | 22 namespace media { |
| 23 namespace cast { | 23 namespace cast { |
| 24 | 24 |
| 25 class AdaptiveCongestionControl : public CongestionControl { | 25 class AdaptiveCongestionControl : public CongestionControl { |
| 26 public: | 26 public: |
| 27 AdaptiveCongestionControl(base::TickClock* clock, | 27 AdaptiveCongestionControl(base::TickClock* clock, |
| 28 uint32 max_bitrate_configured, | 28 uint32 max_bitrate_configured, |
| 29 uint32 min_bitrate_configured, | 29 uint32 min_bitrate_configured, |
| 30 size_t max_unacked_frames); | 30 size_t max_unacked_frames); |
| 31 | 31 |
| 32 virtual ~AdaptiveCongestionControl() OVERRIDE; | 32 virtual ~AdaptiveCongestionControl() override; |
| 33 | 33 |
| 34 virtual void UpdateRtt(base::TimeDelta rtt) OVERRIDE; | 34 virtual void UpdateRtt(base::TimeDelta rtt) override; |
| 35 | 35 |
| 36 // Called when an encoded frame is sent to the transport. | 36 // Called when an encoded frame is sent to the transport. |
| 37 virtual void SendFrameToTransport(uint32 frame_id, | 37 virtual void SendFrameToTransport(uint32 frame_id, |
| 38 size_t frame_size, | 38 size_t frame_size, |
| 39 base::TimeTicks when) OVERRIDE; | 39 base::TimeTicks when) override; |
| 40 | 40 |
| 41 // Called when we receive an ACK for a frame. | 41 // Called when we receive an ACK for a frame. |
| 42 virtual void AckFrame(uint32 frame_id, base::TimeTicks when) OVERRIDE; | 42 virtual void AckFrame(uint32 frame_id, base::TimeTicks when) override; |
| 43 | 43 |
| 44 // Returns the bitrate we should use for the next frame. | 44 // Returns the bitrate we should use for the next frame. |
| 45 virtual uint32 GetBitrate(base::TimeTicks playout_time, | 45 virtual uint32 GetBitrate(base::TimeTicks playout_time, |
| 46 base::TimeDelta playout_delay) OVERRIDE; | 46 base::TimeDelta playout_delay) override; |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 struct FrameStats { | 49 struct FrameStats { |
| 50 FrameStats(); | 50 FrameStats(); |
| 51 // Time this frame was sent to the transport. | 51 // Time this frame was sent to the transport. |
| 52 base::TimeTicks sent_time; | 52 base::TimeTicks sent_time; |
| 53 // Time this frame was acked. | 53 // Time this frame was acked. |
| 54 base::TimeTicks ack_time; | 54 base::TimeTicks ack_time; |
| 55 // Size of encoded frame in bits. | 55 // Size of encoded frame in bits. |
| 56 size_t frame_size; | 56 size_t frame_size; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 84 size_t history_size_; | 84 size_t history_size_; |
| 85 size_t acked_bits_in_history_; | 85 size_t acked_bits_in_history_; |
| 86 base::TimeDelta dead_time_in_history_; | 86 base::TimeDelta dead_time_in_history_; |
| 87 | 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(AdaptiveCongestionControl); | 88 DISALLOW_COPY_AND_ASSIGN(AdaptiveCongestionControl); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 class FixedCongestionControl : public CongestionControl { | 91 class FixedCongestionControl : public CongestionControl { |
| 92 public: | 92 public: |
| 93 FixedCongestionControl(uint32 bitrate) : bitrate_(bitrate) {} | 93 FixedCongestionControl(uint32 bitrate) : bitrate_(bitrate) {} |
| 94 virtual ~FixedCongestionControl() OVERRIDE {} | 94 virtual ~FixedCongestionControl() override {} |
| 95 | 95 |
| 96 virtual void UpdateRtt(base::TimeDelta rtt) OVERRIDE { | 96 virtual void UpdateRtt(base::TimeDelta rtt) override { |
| 97 } | 97 } |
| 98 | 98 |
| 99 // Called when an encoded frame is sent to the transport. | 99 // Called when an encoded frame is sent to the transport. |
| 100 virtual void SendFrameToTransport(uint32 frame_id, | 100 virtual void SendFrameToTransport(uint32 frame_id, |
| 101 size_t frame_size, | 101 size_t frame_size, |
| 102 base::TimeTicks when) OVERRIDE { | 102 base::TimeTicks when) override { |
| 103 } | 103 } |
| 104 | 104 |
| 105 // Called when we receive an ACK for a frame. | 105 // Called when we receive an ACK for a frame. |
| 106 virtual void AckFrame(uint32 frame_id, base::TimeTicks when) OVERRIDE { | 106 virtual void AckFrame(uint32 frame_id, base::TimeTicks when) override { |
| 107 } | 107 } |
| 108 | 108 |
| 109 // Returns the bitrate we should use for the next frame. | 109 // Returns the bitrate we should use for the next frame. |
| 110 virtual uint32 GetBitrate(base::TimeTicks playout_time, | 110 virtual uint32 GetBitrate(base::TimeTicks playout_time, |
| 111 base::TimeDelta playout_delay) OVERRIDE { | 111 base::TimeDelta playout_delay) override { |
| 112 return bitrate_; | 112 return bitrate_; |
| 113 } | 113 } |
| 114 | 114 |
| 115 private: | 115 private: |
| 116 uint32 bitrate_; | 116 uint32 bitrate_; |
| 117 DISALLOW_COPY_AND_ASSIGN(FixedCongestionControl); | 117 DISALLOW_COPY_AND_ASSIGN(FixedCongestionControl); |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 | 120 |
| 121 CongestionControl* NewAdaptiveCongestionControl( | 121 CongestionControl* NewAdaptiveCongestionControl( |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 VLOG(3) << " FBR:" << (bits_per_second / 1E6) | 310 VLOG(3) << " FBR:" << (bits_per_second / 1E6) |
| 311 << " EBF:" << empty_buffer_fraction | 311 << " EBF:" << empty_buffer_fraction |
| 312 << " SBR:" << (safe_bitrate / 1E6); | 312 << " SBR:" << (safe_bitrate / 1E6); |
| 313 bits_per_second = std::max(bits_per_second, min_bitrate_configured_); | 313 bits_per_second = std::max(bits_per_second, min_bitrate_configured_); |
| 314 bits_per_second = std::min(bits_per_second, max_bitrate_configured_); | 314 bits_per_second = std::min(bits_per_second, max_bitrate_configured_); |
| 315 return bits_per_second; | 315 return bits_per_second; |
| 316 } | 316 } |
| 317 | 317 |
| 318 } // namespace cast | 318 } // namespace cast |
| 319 } // namespace media | 319 } // namespace media |
| OLD | NEW |