| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "media/blink/multibuffer_data_source.h" | 5 #include "media/blink/multibuffer_data_source.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 playback_rate = std::max(playback_rate, 1.0); | 563 playback_rate = std::max(playback_rate, 1.0); |
| 564 playback_rate = std::min(playback_rate, kMaxPlaybackRate); | 564 playback_rate = std::min(playback_rate, kMaxPlaybackRate); |
| 565 | 565 |
| 566 int64_t bytes_per_second = (bitrate / 8.0) * playback_rate; | 566 int64_t bytes_per_second = (bitrate / 8.0) * playback_rate; |
| 567 | 567 |
| 568 int64_t preload = clamp(kTargetSecondsBufferedAhead * bytes_per_second, | 568 int64_t preload = clamp(kTargetSecondsBufferedAhead * bytes_per_second, |
| 569 kMinBufferPreload, kMaxBufferPreload); | 569 kMinBufferPreload, kMaxBufferPreload); |
| 570 int64_t back_buffer = clamp(kTargetSecondsBufferedBehind * bytes_per_second, | 570 int64_t back_buffer = clamp(kTargetSecondsBufferedBehind * bytes_per_second, |
| 571 kMinBufferPreload, kMaxBufferPreload); | 571 kMinBufferPreload, kMaxBufferPreload); |
| 572 int64_t pin_forwards = kMaxBufferSize - back_buffer; | 572 int64_t pin_forwards = kMaxBufferSize - back_buffer; |
| 573 DCHECK_LE(preload_ + kPreloadHighExtra, pin_forwards); | 573 DCHECK_LE(preload + kPreloadHighExtra, pin_forwards); |
| 574 reader_->SetMaxBuffer(back_buffer, pin_forwards); | 574 reader_->SetMaxBuffer(back_buffer, preload + kPreloadHighExtra); |
| 575 | 575 |
| 576 if (preload_ == METADATA) { | 576 if (preload_ == METADATA) { |
| 577 reader_->SetPreload(0, 0); | 577 reader_->SetPreload(0, 0); |
| 578 } else { | 578 } else { |
| 579 reader_->SetPreload(preload + kPreloadHighExtra, preload); | 579 reader_->SetPreload(preload + kPreloadHighExtra, preload); |
| 580 } | 580 } |
| 581 } | 581 } |
| 582 | 582 |
| 583 } // namespace media | 583 } // namespace media |
| OLD | NEW |