Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: media/base/pipeline_impl.cc

Issue 160300: Missing buffered attribute for <video>/<audio> (Closed)
Patch Set: done Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/mock_filters.h ('k') | media/base/pipeline_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008-2009 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 // TODO(scherkus): clean up PipelineImpl... too many crazy function names, 5 // TODO(scherkus): clean up PipelineImpl... too many crazy function names,
6 // potential deadlocks, etc... 6 // potential deadlocks, etc...
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/condition_variable.h" 9 #include "base/condition_variable.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 AutoLock auto_lock(lock_); 204 AutoLock auto_lock(lock_);
205 base::TimeDelta elapsed = clock_.Elapsed(); 205 base::TimeDelta elapsed = clock_.Elapsed();
206 if (elapsed > duration_) { 206 if (elapsed > duration_) {
207 return duration_; 207 return duration_;
208 } 208 }
209 return elapsed; 209 return elapsed;
210 } 210 }
211 211
212 base::TimeDelta PipelineImpl::GetBufferedTime() const { 212 base::TimeDelta PipelineImpl::GetBufferedTime() const {
213 AutoLock auto_lock(lock_); 213 AutoLock auto_lock(lock_);
214 return buffered_time_; 214
215 // If buffered time was set, we report that value directly.
216 if (buffered_time_.ToInternalValue() > 0)
217 return buffered_time_;
218
219 // If buffered time was not set, we use duration and buffered bytes to
220 // estimate the buffered time.
221 // TODO(hclam): The estimation is based on linear interpolation which is
222 // not accurate enough. We should find a better way to estimate the value.
223 if (total_bytes_ == 0)
224 return base::TimeDelta();
225
226 double ratio = buffered_bytes_;
227 ratio /= total_bytes_;
228 return base::TimeDelta::FromMilliseconds(
229 static_cast<int64>(duration_.InMilliseconds() * ratio));
215 } 230 }
216 231
217 base::TimeDelta PipelineImpl::GetDuration() const { 232 base::TimeDelta PipelineImpl::GetDuration() const {
218 AutoLock auto_lock(lock_); 233 AutoLock auto_lock(lock_);
219 return duration_; 234 return duration_;
220 } 235 }
221 236
222 int64 PipelineImpl::GetBufferedBytes() const { 237 int64 PipelineImpl::GetBufferedBytes() const {
223 AutoLock auto_lock(lock_); 238 AutoLock auto_lock(lock_);
224 return buffered_bytes_; 239 return buffered_bytes_;
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 823
809 // Reset the pipeline, which will decrement a reference to this object. 824 // Reset the pipeline, which will decrement a reference to this object.
810 // We will get destroyed as soon as the remaining tasks finish executing. 825 // We will get destroyed as soon as the remaining tasks finish executing.
811 // To be safe, we'll set our pipeline reference to NULL. 826 // To be safe, we'll set our pipeline reference to NULL.
812 filters_.clear(); 827 filters_.clear();
813 filter_types_.clear(); 828 filter_types_.clear();
814 STLDeleteElements(&filter_threads_); 829 STLDeleteElements(&filter_threads_);
815 } 830 }
816 831
817 } // namespace media 832 } // namespace media
OLDNEW
« no previous file with comments | « media/base/mock_filters.h ('k') | media/base/pipeline_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698