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

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

Issue 165180: Merge 22087 - Missing buffered attribute for <video>/<audio>... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: 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 | Annotate | Revision Log
« 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')
Property Changes:
Modified: svn:mergeinfo
Merged /trunk/src/media/base/pipeline_impl.cc:r22087
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 = static_cast<double>(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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 845
831 // Reset the pipeline, which will decrement a reference to this object. 846 // Reset the pipeline, which will decrement a reference to this object.
832 // We will get destroyed as soon as the remaining tasks finish executing. 847 // We will get destroyed as soon as the remaining tasks finish executing.
833 // To be safe, we'll set our pipeline reference to NULL. 848 // To be safe, we'll set our pipeline reference to NULL.
834 filters_.clear(); 849 filters_.clear();
835 filter_types_.clear(); 850 filter_types_.clear();
836 STLDeleteElements(&filter_threads_); 851 STLDeleteElements(&filter_threads_);
837 } 852 }
838 853
839 } // namespace media 854 } // 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