summaryrefslogtreecommitdiffstats
path: root/media/base
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 21:49:49 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 21:49:49 +0000
commit38259a7a83545e07681d921564468844c7b03337 (patch)
treeceddb850f76be8ee565d9cc2d3d34d7ae445a1d7 /media/base
parent6b33da129646087bbc173a72c84e0690e91740de (diff)
downloadchromium_src-38259a7a83545e07681d921564468844c7b03337.zip
chromium_src-38259a7a83545e07681d921564468844c7b03337.tar.gz
chromium_src-38259a7a83545e07681d921564468844c7b03337.tar.bz2
BufferedDataSource to support server without range request support
This patch will enable BufferedDataSource to support servers with no range request support. It will start a probe request of 1 byte size besides the regular request. If the server does not support range request, we will turn on the is_streamed flag of FFmpeg and will not do any seeking. BUG=17628 TEST=test_shell_tests --gtest_filter=BufferedDataSource.* Review URL: http://codereview.chromium.org/160076 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21999 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r--media/base/filter_host.h3
-rw-r--r--media/base/filters.h5
-rw-r--r--media/base/mock_filter_host.h1
-rw-r--r--media/base/mock_filters.h2
-rw-r--r--media/base/pipeline.h4
-rw-r--r--media/base/pipeline_impl.cc12
-rw-r--r--media/base/pipeline_impl.h6
7 files changed, 30 insertions, 3 deletions
diff --git a/media/base/filter_host.h b/media/base/filter_host.h
index 5e70797..65aeebb 100644
--- a/media/base/filter_host.h
+++ b/media/base/filter_host.h
@@ -53,6 +53,9 @@ class FilterHost {
// Sets the size of the video output in pixel units.
virtual void SetVideoSize(size_t width, size_t height) = 0;
+ // Sets the flag to indicate that we are doing streaming.
+ virtual void SetStreaming(bool streaming) = 0;
+
protected:
virtual ~FilterHost() {}
};
diff --git a/media/base/filters.h b/media/base/filters.h
index 8fdfe011..3faede5 100644
--- a/media/base/filters.h
+++ b/media/base/filters.h
@@ -174,8 +174,9 @@ class DataSource : public MediaFilter {
// retrieved.
virtual bool GetSize(int64* size_out) = 0;
- // Returns true if this data source supports random seeking.
- virtual bool IsSeekable() = 0;
+ // Returns true if we are performing streaming. In this case seeking is
+ // not possible.
+ virtual bool IsStreaming() = 0;
};
diff --git a/media/base/mock_filter_host.h b/media/base/mock_filter_host.h
index 8bab1b5..a7150c2 100644
--- a/media/base/mock_filter_host.h
+++ b/media/base/mock_filter_host.h
@@ -36,6 +36,7 @@ class MockFilterHost : public FilterHost {
MOCK_METHOD1(SetTotalBytes, void(int64 total_bytes));
MOCK_METHOD1(SetBufferedBytes, void(int64 buffered_bytes));
MOCK_METHOD2(SetVideoSize, void(size_t width, size_t height));
+ MOCK_METHOD1(SetStreaming, void(bool streamed));
private:
DISALLOW_COPY_AND_ASSIGN(MockFilterHost);
diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h
index 7954aa9..d3546c4 100644
--- a/media/base/mock_filters.h
+++ b/media/base/mock_filters.h
@@ -102,7 +102,7 @@ class MockDataSource : public DataSource {
MOCK_METHOD4(Read, void(int64 position, size_t size, uint8* data,
DataSource::ReadCallback* callback));
MOCK_METHOD1(GetSize, bool(int64* size_out));
- MOCK_METHOD0(IsSeekable, bool());
+ MOCK_METHOD0(IsStreaming, bool());
protected:
virtual ~MockDataSource() {}
diff --git a/media/base/pipeline.h b/media/base/pipeline.h
index c0286e5..b54d442 100644
--- a/media/base/pipeline.h
+++ b/media/base/pipeline.h
@@ -147,6 +147,10 @@ class Pipeline : public base::RefCountedThreadSafe<Pipeline> {
// or the video has not been rendered yet, the width and height will be 0.
virtual void GetVideoSize(size_t* width_out, size_t* height_out) const = 0;
+ // If this method returns true, that means the data source is a streaming
+ // data source. Seeking may not be possible.
+ virtual bool IsStreaming() const = 0;
+
// Gets the current error status for the pipeline. If the pipeline is
// operating correctly, this will return OK.
virtual PipelineError GetError() const = 0;
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc
index a09c2c7..10ab9a3 100644
--- a/media/base/pipeline_impl.cc
+++ b/media/base/pipeline_impl.cc
@@ -237,6 +237,11 @@ void PipelineImpl::GetVideoSize(size_t* width_out, size_t* height_out) const {
*height_out = video_height_;
}
+bool PipelineImpl::IsStreaming() const {
+ AutoLock auto_lock(lock_);
+ return streaming_;
+}
+
PipelineError PipelineImpl::GetError() const {
AutoLock auto_lock(lock_);
return error_;
@@ -249,6 +254,7 @@ void PipelineImpl::ResetState() {
duration_ = kZero;
buffered_time_ = kZero;
buffered_bytes_ = 0;
+ streaming_ = false;
total_bytes_ = 0;
video_width_ = 0;
video_height_ = 0;
@@ -343,6 +349,12 @@ void PipelineImpl::SetVideoSize(size_t width, size_t height) {
video_height_ = height;
}
+void PipelineImpl::SetStreaming(bool streaming) {
+ DCHECK(IsRunning());
+ AutoLock auto_lock(lock_);
+ streaming_ = streaming;
+}
+
void PipelineImpl::InsertRenderedMimeType(const std::string& major_mime_type) {
DCHECK(IsRunning());
AutoLock auto_lock(lock_);
diff --git a/media/base/pipeline_impl.h b/media/base/pipeline_impl.h
index 02c8bce..e83822d 100644
--- a/media/base/pipeline_impl.h
+++ b/media/base/pipeline_impl.h
@@ -81,6 +81,7 @@ class PipelineImpl : public Pipeline, public FilterHost {
virtual int64 GetBufferedBytes() const;
virtual int64 GetTotalBytes() const;
virtual void GetVideoSize(size_t* width_out, size_t* height_out) const;
+ virtual bool IsStreaming() const;
virtual PipelineError GetError() const;
private:
@@ -129,6 +130,7 @@ class PipelineImpl : public Pipeline, public FilterHost {
virtual void SetTotalBytes(int64 total_bytes);
virtual void SetBufferedBytes(int64 buffered_bytes);
virtual void SetVideoSize(size_t width, size_t height);
+ virtual void SetStreaming(bool streamed);
// Method called during initialization to insert a mime type into the
// |rendered_mime_types_| set.
@@ -267,6 +269,10 @@ class PipelineImpl : public Pipeline, public FilterHost {
size_t video_width_;
size_t video_height_;
+ // Sets by the filters to indicate whether the data source is a streaming
+ // source.
+ bool streaming_;
+
// Current volume level (from 0.0f to 1.0f). This value is set immediately
// via SetVolume() and a task is dispatched on the message loop to notify the
// filters.