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 } | |
211 for (size_t i = 0; i < buffered_byte_ranges_.size(); ++i) { | 207 for (size_t i = 0; i < buffered_byte_ranges_.size(); ++i) { |
212 TimeDelta start = TimeForByteOffset_Locked(buffered_byte_ranges_.start(i)); | 208 TimeDelta start = TimeForByteOffset_Locked(buffered_byte_ranges_.start(i)); |
213 TimeDelta end = TimeForByteOffset_Locked(buffered_byte_ranges_.end(i)); | 209 TimeDelta end = TimeForByteOffset_Locked(buffered_byte_ranges_.end(i)); |
214 // Cap approximated buffered time at the length of the video. | 210 // Cap approximated buffered time at the length of the video. |
215 end = std::min(end, clock_->Duration()); | 211 end = std::min(end, clock_->Duration()); |
216 time_ranges.Add(start, end); | 212 time_ranges.Add(start, end); |
217 } | 213 } |
218 | 214 |
219 return time_ranges; | 215 return time_ranges; |
220 } | 216 } |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 return time_offset; | 450 return time_offset; |
455 } | 451 } |
456 | 452 |
457 void Pipeline::AddBufferedByteRange(int64 start, int64 end) { | 453 void Pipeline::AddBufferedByteRange(int64 start, int64 end) { |
458 DCHECK(IsRunning()); | 454 DCHECK(IsRunning()); |
459 base::AutoLock auto_lock(lock_); | 455 base::AutoLock auto_lock(lock_); |
460 buffered_byte_ranges_.Add(start, end); | 456 buffered_byte_ranges_.Add(start, end); |
461 did_loading_progress_ = true; | 457 did_loading_progress_ = true; |
462 } | 458 } |
463 | 459 |
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 | |
472 void Pipeline::SetNaturalVideoSize(const gfx::Size& size) { | 460 void Pipeline::SetNaturalVideoSize(const gfx::Size& size) { |
473 DCHECK(IsRunning()); | 461 DCHECK(IsRunning()); |
474 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent( | 462 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent( |
475 size.width(), size.height())); | 463 size.width(), size.height())); |
476 | 464 |
477 base::AutoLock auto_lock(lock_); | 465 base::AutoLock auto_lock(lock_); |
478 natural_size_ = size; | 466 natural_size_ = size; |
479 } | 467 } |
480 | 468 |
481 void Pipeline::NotifyEnded() { | 469 void Pipeline::NotifyEnded() { |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { | 1276 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { |
1289 lock_.AssertAcquired(); | 1277 lock_.AssertAcquired(); |
1290 if (!waiting_for_clock_update_) | 1278 if (!waiting_for_clock_update_) |
1291 return; | 1279 return; |
1292 | 1280 |
1293 waiting_for_clock_update_ = false; | 1281 waiting_for_clock_update_ = false; |
1294 clock_->Play(); | 1282 clock_->Play(); |
1295 } | 1283 } |
1296 | 1284 |
1297 } // namespace media | 1285 } // namespace media |
OLD | NEW |