diff options
author | hclam@google.com <hclam@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-30 20:10:32 +0000 |
---|---|---|
committer | hclam@google.com <hclam@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-30 20:10:32 +0000 |
commit | 1ce1f40ba144705c5a52bccf6c7cf82c2bf405d9 (patch) | |
tree | 2c20c121e89f9802a67b59125cef3f477a1c5bcd /media/base/pipeline_impl_unittest.cc | |
parent | c16ca81ff44eba2d8d5b66b14aa35f1629202c58 (diff) | |
download | chromium_src-1ce1f40ba144705c5a52bccf6c7cf82c2bf405d9.zip chromium_src-1ce1f40ba144705c5a52bccf6c7cf82c2bf405d9.tar.gz chromium_src-1ce1f40ba144705c5a52bccf6c7cf82c2bf405d9.tar.bz2 |
Missing buffered attribute for <video>/<audio>
BUG=16056
TEST=LayoutTests/media/video-buffered.html
The current implementation of the buffered attribute for <video> and <audio>
is broken. There are several problems around this attribute:
1. We don't have any caching on disk, so we only keep a recent range of bytes
close to current playback position.
2. WebKit reports buffered as one range (0, max_time_buffered). But we only
cache a short partial range which doesn't start with 0. The correct
implementation is a list of ranges buffered. But this has to go into WebKit
first.
3. We don't have an accurate mapping between byte offset < - > timestamp.
So the current implementation is to lie about what we have buffered. We always
say we have buffered everything before the current download position. And we
only report one range. The calculation of time is also based on scaling the
duration with current buffered bytes.
Review URL: http://codereview.chromium.org/160300
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22087 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/pipeline_impl_unittest.cc')
-rw-r--r-- | media/base/pipeline_impl_unittest.cc | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc index 068b095..6400049 100644 --- a/media/base/pipeline_impl_unittest.cc +++ b/media/base/pipeline_impl_unittest.cc @@ -20,6 +20,16 @@ using ::testing::NotNull; using ::testing::Return; using ::testing::StrictMock; +namespace { + +// Total bytes of the data source. +const int kTotalBytes = 1024; + +// Buffered bytes of the data source. +const int kBufferedBytes = 1024; + +} // namespace + namespace media { // Used for setting expectations on pipeline callbacks. Using a StrictMock @@ -70,7 +80,9 @@ class PipelineImplTest : public ::testing::Test { // Sets up expectations to allow the data source to initialize. void InitializeDataSource() { EXPECT_CALL(*mocks_->data_source(), Initialize("", NotNull())) - .WillOnce(Invoke(&RunFilterCallback)); + .WillOnce(DoAll(SetTotalBytes(mocks_->data_source(), kTotalBytes), + SetBufferedBytes(mocks_->data_source(), kBufferedBytes), + Invoke(&RunFilterCallback))); EXPECT_CALL(*mocks_->data_source(), SetPlaybackRate(0.0f)); EXPECT_CALL(*mocks_->data_source(), Seek(base::TimeDelta(), NotNull())) .WillOnce(Invoke(&RunFilterCallback)); @@ -404,4 +416,27 @@ TEST_F(PipelineImplTest, SetVolume) { pipeline_->SetVolume(expected); } +TEST_F(PipelineImplTest, Properties) { + scoped_refptr<StrictMock<MockDemuxerStream> > stream = + new StrictMock<MockDemuxerStream>("video/x-foo"); + MockDemuxerStreamVector streams; + streams.push_back(stream); + + InitializeDataSource(); + base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100); + InitializeDemuxer(&streams, kDuration); + InitializeVideoDecoder(stream); + InitializeVideoRenderer(); + + InitializePipeline(); + EXPECT_TRUE(pipeline_->IsInitialized()); + EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); + EXPECT_EQ(kDuration.ToInternalValue(), + pipeline_->GetDuration().ToInternalValue()); + EXPECT_EQ(kTotalBytes, pipeline_->GetTotalBytes()); + EXPECT_EQ(kBufferedBytes, pipeline_->GetBufferedBytes()); + EXPECT_EQ(kDuration.ToInternalValue(), + pipeline_->GetBufferedTime().ToInternalValue()); +} + } // namespace media |