diff options
author | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-30 08:09:15 +0000 |
---|---|---|
committer | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-30 08:09:15 +0000 |
commit | 7ed21bea852d071a525ef35540eb26c22381f0d5 (patch) | |
tree | cc1bce24976a57eebfef2933fa16d7466c345664 /media | |
parent | 42816d78df4d63c4eb01768b89051e2b77717823 (diff) | |
download | chromium_src-7ed21bea852d071a525ef35540eb26c22381f0d5.zip chromium_src-7ed21bea852d071a525ef35540eb26c22381f0d5.tar.gz chromium_src-7ed21bea852d071a525ef35540eb26c22381f0d5.tar.bz2 |
Delete Pipeline::GetBufferedBytes() in preparation for didLoadingProgress() switchover.
BUG=http://webk.it/86113
Review URL: https://chromiumcodereview.appspot.com/10458005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139495 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/base/pipeline.cc | 17 | ||||
-rw-r--r-- | media/base/pipeline.h | 17 | ||||
-rw-r--r-- | media/base/pipeline_unittest.cc | 9 |
3 files changed, 25 insertions, 18 deletions
diff --git a/media/base/pipeline.cc b/media/base/pipeline.cc index 4b4fec0..0b3063c 100644 --- a/media/base/pipeline.cc +++ b/media/base/pipeline.cc @@ -221,14 +221,6 @@ TimeDelta Pipeline::GetMediaDuration() const { return clock_->Duration(); } -int64 Pipeline::GetBufferedBytes() const { - base::AutoLock auto_lock(lock_); - int64 ret = 0; - for (size_t i = 0; i < buffered_byte_ranges_.size(); ++i) - ret += buffered_byte_ranges_.end(i) - buffered_byte_ranges_.start(i); - return ret; -} - int64 Pipeline::GetTotalBytes() const { base::AutoLock auto_lock(lock_); return total_bytes_; @@ -240,6 +232,13 @@ void Pipeline::GetNaturalVideoSize(gfx::Size* out_size) const { *out_size = natural_size_; } +bool Pipeline::DidLoadingProgress() const { + base::AutoLock auto_lock(lock_); + bool ret = did_loading_progress_; + did_loading_progress_ = false; + return ret; +} + PipelineStatistics Pipeline::GetStatistics() const { base::AutoLock auto_lock(lock_); return statistics_; @@ -259,6 +258,7 @@ void Pipeline::ResetState() { error_caused_teardown_ = false; playback_rate_change_pending_ = false; buffered_byte_ranges_.clear(); + did_loading_progress_ = false; total_bytes_ = 0; natural_size_.SetSize(0, 0); volume_ = 1.0f; @@ -455,6 +455,7 @@ void Pipeline::AddBufferedByteRange(int64 start, int64 end) { DCHECK(IsRunning()); base::AutoLock auto_lock(lock_); buffered_byte_ranges_.Add(start, end); + did_loading_progress_ = true; } void Pipeline::SetNaturalVideoSize(const gfx::Size& size) { diff --git a/media/base/pipeline.h b/media/base/pipeline.h index 45f59b8..c5436621 100644 --- a/media/base/pipeline.h +++ b/media/base/pipeline.h @@ -217,13 +217,6 @@ class MEDIA_EXPORT Pipeline // been determined yet, then returns 0. base::TimeDelta GetMediaDuration() const; - // Get the total number of bytes that are buffered on the client and ready to - // be played. - // TODO(fischman): this interface is only needed so WMPI can provide - // bytesLoaded() which is only present so that HTMLMediaElement can decide - // whether progress has been made. Bogus! http://webk.it/86113 - int64 GetBufferedBytes() const; - // Get the total size of the media file. If the size has not yet been // determined or can not be determined, this value is 0. int64 GetTotalBytes() const; @@ -233,6 +226,10 @@ class MEDIA_EXPORT Pipeline // be 0. void GetNaturalVideoSize(gfx::Size* out_size) const; + // Return true if loading progress has been made since the last time this + // method was called. + bool DidLoadingProgress() const; + // Gets the current pipeline statistics. PipelineStatistics GetStatistics() const; @@ -478,9 +475,13 @@ class MEDIA_EXPORT Pipeline // Whether or not a playback rate change should be done once seeking is done. bool playback_rate_change_pending_; - // Amount of available buffered data. + // Amount of available buffered data. Set by filters. Ranges<int64> buffered_byte_ranges_; + // True when AddBufferedByteRange() has been called more recently than + // DidLoadingProgress(). + mutable bool did_loading_progress_; + // Total size of the media. Set by filters. int64 total_bytes_; diff --git a/media/base/pipeline_unittest.cc b/media/base/pipeline_unittest.cc index 6679421..54e4cd7 100644 --- a/media/base/pipeline_unittest.cc +++ b/media/base/pipeline_unittest.cc @@ -283,7 +283,6 @@ TEST_F(PipelineTest, NotStarted) { EXPECT_EQ(0u, pipeline_->GetBufferedTimeRanges().size()); EXPECT_TRUE(kZero == pipeline_->GetMediaDuration()); - EXPECT_EQ(0, pipeline_->GetBufferedBytes()); EXPECT_EQ(0, pipeline_->GetTotalBytes()); // Should always get set to zero. @@ -459,7 +458,7 @@ TEST_F(PipelineTest, Properties) { EXPECT_EQ(kDuration.ToInternalValue(), pipeline_->GetMediaDuration().ToInternalValue()); EXPECT_EQ(kTotalBytes, pipeline_->GetTotalBytes()); - EXPECT_EQ(0, pipeline_->GetBufferedBytes()); + EXPECT_FALSE(pipeline_->DidLoadingProgress()); } TEST_F(PipelineTest, GetBufferedTimeRanges) { @@ -477,7 +476,10 @@ TEST_F(PipelineTest, GetBufferedTimeRanges) { EXPECT_EQ(0u, pipeline_->GetBufferedTimeRanges().size()); + EXPECT_FALSE(pipeline_->DidLoadingProgress()); pipeline_->AddBufferedByteRange(0, kTotalBytes / 8); + EXPECT_TRUE(pipeline_->DidLoadingProgress()); + EXPECT_FALSE(pipeline_->DidLoadingProgress()); EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); EXPECT_EQ(base::TimeDelta(), pipeline_->GetBufferedTimeRanges().start(0)); EXPECT_EQ(kDuration / 8, pipeline_->GetBufferedTimeRanges().end(0)); @@ -486,8 +488,11 @@ TEST_F(PipelineTest, GetBufferedTimeRanges) { ExpectSeek(kSeekTime); DoSeek(kSeekTime); + EXPECT_FALSE(pipeline_->DidLoadingProgress()); pipeline_->AddBufferedByteRange(kTotalBytes / 2, kTotalBytes / 2 + kTotalBytes / 8); + EXPECT_TRUE(pipeline_->DidLoadingProgress()); + EXPECT_FALSE(pipeline_->DidLoadingProgress()); EXPECT_EQ(2u, pipeline_->GetBufferedTimeRanges().size()); EXPECT_EQ(base::TimeDelta(), pipeline_->GetBufferedTimeRanges().start(0)); EXPECT_EQ(kDuration / 8, pipeline_->GetBufferedTimeRanges().end(0)); |