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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } | 195 } |
196 | 196 |
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) | |
206 return time_ranges; | |
207 for (size_t i = 0; i < buffered_time_ranges_.size(); ++i) { | 205 for (size_t i = 0; i < buffered_time_ranges_.size(); ++i) { |
208 time_ranges.Add(buffered_time_ranges_.start(i), | 206 time_ranges.Add(buffered_time_ranges_.start(i), |
209 buffered_time_ranges_.end(i)); | 207 buffered_time_ranges_.end(i)); |
210 } | 208 } |
| 209 if (clock_->Duration() == TimeDelta() || total_bytes_ == 0) |
| 210 return time_ranges; |
211 for (size_t i = 0; i < buffered_byte_ranges_.size(); ++i) { | 211 for (size_t i = 0; i < buffered_byte_ranges_.size(); ++i) { |
212 TimeDelta start = TimeForByteOffset_Locked(buffered_byte_ranges_.start(i)); | 212 TimeDelta start = TimeForByteOffset_Locked(buffered_byte_ranges_.start(i)); |
213 TimeDelta end = TimeForByteOffset_Locked(buffered_byte_ranges_.end(i)); | 213 TimeDelta end = TimeForByteOffset_Locked(buffered_byte_ranges_.end(i)); |
214 // Cap approximated buffered time at the length of the video. | 214 // Cap approximated buffered time at the length of the video. |
215 end = std::min(end, clock_->Duration()); | 215 end = std::min(end, clock_->Duration()); |
216 time_ranges.Add(start, end); | 216 time_ranges.Add(start, end); |
217 } | 217 } |
218 | 218 |
219 return time_ranges; | 219 return time_ranges; |
220 } | 220 } |
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { | 1275 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { |
1276 lock_.AssertAcquired(); | 1276 lock_.AssertAcquired(); |
1277 if (!waiting_for_clock_update_) | 1277 if (!waiting_for_clock_update_) |
1278 return; | 1278 return; |
1279 | 1279 |
1280 waiting_for_clock_update_ = false; | 1280 waiting_for_clock_update_ = false; |
1281 clock_->Play(); | 1281 clock_->Play(); |
1282 } | 1282 } |
1283 | 1283 |
1284 } // namespace media | 1284 } // namespace media |
OLD | NEW |