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/buffered_data_source.h" | 5 #include "media/blink/buffered_data_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 base::Bind(&BufferedDataSource::StopLoader, weak_factory_.GetWeakPtr())); | 224 base::Bind(&BufferedDataSource::StopLoader, weak_factory_.GetWeakPtr())); |
225 } | 225 } |
226 | 226 |
227 void BufferedDataSource::SetBitrate(int bitrate) { | 227 void BufferedDataSource::SetBitrate(int bitrate) { |
228 render_task_runner_->PostTask(FROM_HERE, | 228 render_task_runner_->PostTask(FROM_HERE, |
229 base::Bind(&BufferedDataSource::SetBitrateTask, | 229 base::Bind(&BufferedDataSource::SetBitrateTask, |
230 weak_factory_.GetWeakPtr(), | 230 weak_factory_.GetWeakPtr(), |
231 bitrate)); | 231 bitrate)); |
232 } | 232 } |
233 | 233 |
| 234 void BufferedDataSource::OnBufferingHaveEnough() { |
| 235 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 236 if (loader_ && preload_ == METADATA && !media_has_played_ && !IsStreaming()) |
| 237 loader_->CancelUponDeferral(); |
| 238 } |
| 239 |
234 void BufferedDataSource::Read( | 240 void BufferedDataSource::Read( |
235 int64 position, int size, uint8* data, | 241 int64 position, int size, uint8* data, |
236 const DataSource::ReadCB& read_cb) { | 242 const DataSource::ReadCB& read_cb) { |
237 DVLOG(1) << "Read: " << position << " offset, " << size << " bytes"; | 243 DVLOG(1) << "Read: " << position << " offset, " << size << " bytes"; |
238 DCHECK(!read_cb.is_null()); | 244 DCHECK(!read_cb.is_null()); |
239 | 245 |
240 { | 246 { |
241 base::AutoLock auto_lock(lock_); | 247 base::AutoLock auto_lock(lock_); |
242 DCHECK(!read_op_); | 248 DCHECK(!read_op_); |
243 | 249 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 } | 551 } |
546 | 552 |
547 // If media is currently playing or the page indicated preload=auto or the | 553 // If media is currently playing or the page indicated preload=auto or the |
548 // the server does not support the byte range request or we do not want to go | 554 // the server does not support the byte range request or we do not want to go |
549 // too far ahead of the read head, use threshold strategy to enable/disable | 555 // too far ahead of the read head, use threshold strategy to enable/disable |
550 // deferring when the buffer is full/depleted. | 556 // deferring when the buffer is full/depleted. |
551 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); | 557 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); |
552 } | 558 } |
553 | 559 |
554 } // namespace media | 560 } // namespace media |
OLD | NEW |