| 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 double max_frame_rate); | 30 double max_frame_rate); |
| 31 | 31 |
| 32 virtual ~AdaptiveCongestionControl() override; | 32 ~AdaptiveCongestionControl() override; |
| 33 | 33 |
| 34 virtual void UpdateRtt(base::TimeDelta rtt) override; | 34 void UpdateRtt(base::TimeDelta rtt) override; |
| 35 | 35 |
| 36 virtual void UpdateTargetPlayoutDelay(base::TimeDelta delay) override; | 36 void UpdateTargetPlayoutDelay(base::TimeDelta delay) override; |
| 37 | 37 |
| 38 // Called when an encoded frame is sent to the transport. | 38 // Called when an encoded frame is sent to the transport. |
| 39 virtual void SendFrameToTransport(uint32 frame_id, | 39 void SendFrameToTransport(uint32 frame_id, |
| 40 size_t frame_size, | 40 size_t frame_size, |
| 41 base::TimeTicks when) override; | 41 base::TimeTicks when) override; |
| 42 | 42 |
| 43 // Called when we receive an ACK for a frame. | 43 // Called when we receive an ACK for a frame. |
| 44 virtual void AckFrame(uint32 frame_id, base::TimeTicks when) override; | 44 void AckFrame(uint32 frame_id, base::TimeTicks when) override; |
| 45 | 45 |
| 46 // Returns the bitrate we should use for the next frame. | 46 // Returns the bitrate we should use for the next frame. |
| 47 virtual uint32 GetBitrate(base::TimeTicks playout_time, | 47 uint32 GetBitrate(base::TimeTicks playout_time, |
| 48 base::TimeDelta playout_delay) override; | 48 base::TimeDelta playout_delay) override; |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 struct FrameStats { | 51 struct FrameStats { |
| 52 FrameStats(); | 52 FrameStats(); |
| 53 // Time this frame was sent to the transport. | 53 // Time this frame was sent to the transport. |
| 54 base::TimeTicks sent_time; | 54 base::TimeTicks sent_time; |
| 55 // Time this frame was acked. | 55 // Time this frame was acked. |
| 56 base::TimeTicks ack_time; | 56 base::TimeTicks ack_time; |
| 57 // Size of encoded frame in bits. | 57 // Size of encoded frame in bits. |
| 58 size_t frame_size; | 58 size_t frame_size; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 89 size_t history_size_; | 89 size_t history_size_; |
| 90 size_t acked_bits_in_history_; | 90 size_t acked_bits_in_history_; |
| 91 base::TimeDelta dead_time_in_history_; | 91 base::TimeDelta dead_time_in_history_; |
| 92 | 92 |
| 93 DISALLOW_COPY_AND_ASSIGN(AdaptiveCongestionControl); | 93 DISALLOW_COPY_AND_ASSIGN(AdaptiveCongestionControl); |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 class FixedCongestionControl : public CongestionControl { | 96 class FixedCongestionControl : public CongestionControl { |
| 97 public: | 97 public: |
| 98 FixedCongestionControl(uint32 bitrate) : bitrate_(bitrate) {} | 98 FixedCongestionControl(uint32 bitrate) : bitrate_(bitrate) {} |
| 99 virtual ~FixedCongestionControl() override {} | 99 ~FixedCongestionControl() override {} |
| 100 | 100 |
| 101 virtual void UpdateRtt(base::TimeDelta rtt) override { | 101 void UpdateRtt(base::TimeDelta rtt) override {} |
| 102 } | |
| 103 | 102 |
| 104 virtual void UpdateTargetPlayoutDelay(base::TimeDelta delay) override { | 103 void UpdateTargetPlayoutDelay(base::TimeDelta delay) override {} |
| 105 } | |
| 106 | 104 |
| 107 // Called when an encoded frame is sent to the transport. | 105 // Called when an encoded frame is sent to the transport. |
| 108 virtual void SendFrameToTransport(uint32 frame_id, | 106 void SendFrameToTransport(uint32 frame_id, |
| 109 size_t frame_size, | 107 size_t frame_size, |
| 110 base::TimeTicks when) override { | 108 base::TimeTicks when) override {} |
| 111 } | |
| 112 | 109 |
| 113 // Called when we receive an ACK for a frame. | 110 // Called when we receive an ACK for a frame. |
| 114 virtual void AckFrame(uint32 frame_id, base::TimeTicks when) override { | 111 void AckFrame(uint32 frame_id, base::TimeTicks when) override {} |
| 115 } | |
| 116 | 112 |
| 117 // Returns the bitrate we should use for the next frame. | 113 // Returns the bitrate we should use for the next frame. |
| 118 virtual uint32 GetBitrate(base::TimeTicks playout_time, | 114 uint32 GetBitrate(base::TimeTicks playout_time, |
| 119 base::TimeDelta playout_delay) override { | 115 base::TimeDelta playout_delay) override { |
| 120 return bitrate_; | 116 return bitrate_; |
| 121 } | 117 } |
| 122 | 118 |
| 123 private: | 119 private: |
| 124 uint32 bitrate_; | 120 uint32 bitrate_; |
| 125 DISALLOW_COPY_AND_ASSIGN(FixedCongestionControl); | 121 DISALLOW_COPY_AND_ASSIGN(FixedCongestionControl); |
| 126 }; | 122 }; |
| 127 | 123 |
| 128 | 124 |
| 129 CongestionControl* NewAdaptiveCongestionControl( | 125 CongestionControl* NewAdaptiveCongestionControl( |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 VLOG(3) << " FBR:" << (bits_per_second / 1E6) | 330 VLOG(3) << " FBR:" << (bits_per_second / 1E6) |
| 335 << " EBF:" << empty_buffer_fraction | 331 << " EBF:" << empty_buffer_fraction |
| 336 << " SBR:" << (safe_bitrate / 1E6); | 332 << " SBR:" << (safe_bitrate / 1E6); |
| 337 bits_per_second = std::max(bits_per_second, min_bitrate_configured_); | 333 bits_per_second = std::max(bits_per_second, min_bitrate_configured_); |
| 338 bits_per_second = std::min(bits_per_second, max_bitrate_configured_); | 334 bits_per_second = std::min(bits_per_second, max_bitrate_configured_); |
| 339 return bits_per_second; | 335 return bits_per_second; |
| 340 } | 336 } |
| 341 | 337 |
| 342 } // namespace cast | 338 } // namespace cast |
| 343 } // namespace media | 339 } // namespace media |
| OLD | NEW |