OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base/pipeline.h" | 5 #include "media/base/pipeline.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 TimeDelta Pipeline::GetCurrentTime_Locked() const { | 197 TimeDelta Pipeline::GetCurrentTime_Locked() const { |
198 lock_.AssertAcquired(); | 198 lock_.AssertAcquired(); |
199 return clock_->Elapsed(); | 199 return clock_->Elapsed(); |
200 } | 200 } |
201 | 201 |
202 Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() { | 202 Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() { |
203 base::AutoLock auto_lock(lock_); | 203 base::AutoLock auto_lock(lock_); |
204 Ranges<TimeDelta> time_ranges; | 204 Ranges<TimeDelta> time_ranges; |
205 if (clock_->Duration() == TimeDelta() || total_bytes_ == 0) | 205 if (clock_->Duration() == TimeDelta() || total_bytes_ == 0) |
206 return time_ranges; | 206 return time_ranges; |
| 207 for (size_t i = 0; i < buffered_time_ranges_.size(); ++i) { |
| 208 time_ranges.Add(buffered_time_ranges_.start(i), |
| 209 buffered_time_ranges_.end(i)); |
| 210 } |
207 for (size_t i = 0; i < buffered_byte_ranges_.size(); ++i) { | 211 for (size_t i = 0; i < buffered_byte_ranges_.size(); ++i) { |
208 TimeDelta start = TimeForByteOffset_Locked(buffered_byte_ranges_.start(i)); | 212 TimeDelta start = TimeForByteOffset_Locked(buffered_byte_ranges_.start(i)); |
209 TimeDelta end = TimeForByteOffset_Locked(buffered_byte_ranges_.end(i)); | 213 TimeDelta end = TimeForByteOffset_Locked(buffered_byte_ranges_.end(i)); |
210 // Cap approximated buffered time at the length of the video. | 214 // Cap approximated buffered time at the length of the video. |
211 end = std::min(end, clock_->Duration()); | 215 end = std::min(end, clock_->Duration()); |
212 time_ranges.Add(start, end); | 216 time_ranges.Add(start, end); |
213 } | 217 } |
214 | 218 |
215 return time_ranges; | 219 return time_ranges; |
216 } | 220 } |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 return time_offset; | 454 return time_offset; |
451 } | 455 } |
452 | 456 |
453 void Pipeline::AddBufferedByteRange(int64 start, int64 end) { | 457 void Pipeline::AddBufferedByteRange(int64 start, int64 end) { |
454 DCHECK(IsRunning()); | 458 DCHECK(IsRunning()); |
455 base::AutoLock auto_lock(lock_); | 459 base::AutoLock auto_lock(lock_); |
456 buffered_byte_ranges_.Add(start, end); | 460 buffered_byte_ranges_.Add(start, end); |
457 did_loading_progress_ = true; | 461 did_loading_progress_ = true; |
458 } | 462 } |
459 | 463 |
| 464 void Pipeline::AddBufferedTimeRange(base::TimeDelta start, |
| 465 base::TimeDelta end) { |
| 466 DCHECK(IsRunning()); |
| 467 base::AutoLock auto_lock(lock_); |
| 468 buffered_time_ranges_.Add(start, end); |
| 469 did_loading_progress_ = true; |
| 470 } |
| 471 |
460 void Pipeline::SetNaturalVideoSize(const gfx::Size& size) { | 472 void Pipeline::SetNaturalVideoSize(const gfx::Size& size) { |
461 DCHECK(IsRunning()); | 473 DCHECK(IsRunning()); |
462 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent( | 474 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent( |
463 size.width(), size.height())); | 475 size.width(), size.height())); |
464 | 476 |
465 base::AutoLock auto_lock(lock_); | 477 base::AutoLock auto_lock(lock_); |
466 natural_size_ = size; | 478 natural_size_ = size; |
467 } | 479 } |
468 | 480 |
469 void Pipeline::NotifyEnded() { | 481 void Pipeline::NotifyEnded() { |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1276 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { | 1288 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { |
1277 lock_.AssertAcquired(); | 1289 lock_.AssertAcquired(); |
1278 if (!waiting_for_clock_update_) | 1290 if (!waiting_for_clock_update_) |
1279 return; | 1291 return; |
1280 | 1292 |
1281 waiting_for_clock_update_ = false; | 1293 waiting_for_clock_update_ = false; |
1282 clock_->Play(); | 1294 clock_->Play(); |
1283 } | 1295 } |
1284 | 1296 |
1285 } // namespace media | 1297 } // namespace media |
OLD | NEW |