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

Unified Diff: media/base/pipeline_impl.cc

Issue 160300: Missing buffered attribute for <video>/<audio> (Closed)
Patch Set: done Created 11 years, 5 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/pipeline_impl.cc
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc
index a09c2c7bd320abbd54392429115ac6196c79f75b..6424c1c7b19254b7e0e67a421be253ec08e9b7bf 100644
--- a/media/base/pipeline_impl.cc
+++ b/media/base/pipeline_impl.cc
@@ -211,7 +211,22 @@ base::TimeDelta PipelineImpl::GetCurrentTime() const {
base::TimeDelta PipelineImpl::GetBufferedTime() const {
AutoLock auto_lock(lock_);
- return buffered_time_;
+
+ // If buffered time was set, we report that value directly.
+ if (buffered_time_.ToInternalValue() > 0)
+ return buffered_time_;
+
+ // If buffered time was not set, we use duration and buffered bytes to
+ // estimate the buffered time.
+ // TODO(hclam): The estimation is based on linear interpolation which is
+ // not accurate enough. We should find a better way to estimate the value.
+ if (total_bytes_ == 0)
+ return base::TimeDelta();
+
+ double ratio = buffered_bytes_;
+ ratio /= total_bytes_;
+ return base::TimeDelta::FromMilliseconds(
+ static_cast<int64>(duration_.InMilliseconds() * ratio));
}
base::TimeDelta PipelineImpl::GetDuration() const {
« 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