summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-30 20:25:05 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-30 20:25:05 +0000
commitd0e865a89b8d5a8ef5d93ea0bf2d9644c94c0b5c (patch)
tree106dae251c952fb0ae4a9df750ac950536d3b9d8
parent567f23965887abeee2901ba3f6014ee53d0ae6eb (diff)
downloadchromium_src-d0e865a89b8d5a8ef5d93ea0bf2d9644c94c0b5c.zip
chromium_src-d0e865a89b8d5a8ef5d93ea0bf2d9644c94c0b5c.tar.gz
chromium_src-d0e865a89b8d5a8ef5d93ea0bf2d9644c94c0b5c.tar.bz2
Enable streaming in ffmpeg based on data sourcemedia::DataSource interface has IsSeekable() method to decideon runtime whether the data source is seekable or not. Thisinformation is provided to FFmpeg to decide whether to dostreaming or not. In the case of streaming, FFmpeg does notsupport seeking.
Review URL: http://codereview.chromium.org/57015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12802 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/renderer/media/data_source_impl.cc6
-rw-r--r--chrome/renderer/media/data_source_impl.h7
-rw-r--r--media/base/filters.h3
-rw-r--r--media/base/mock_media_filters.h4
-rw-r--r--media/filters/ffmpeg_glue.cc22
-rw-r--r--media/filters/file_data_source.cc5
-rw-r--r--media/filters/file_data_source.h1
7 files changed, 37 insertions, 11 deletions
diff --git a/chrome/renderer/media/data_source_impl.cc b/chrome/renderer/media/data_source_impl.cc
index ba78743..65a725f 100644
--- a/chrome/renderer/media/data_source_impl.cc
+++ b/chrome/renderer/media/data_source_impl.cc
@@ -139,6 +139,12 @@ bool DataSourceImpl::GetSize(int64* size_out) {
return false;
}
+bool DataSourceImpl::IsSeekable() {
+ // If URI is file then it is seekable.
+ // TODO(hclam): make other protocols seekable.
+ return uri_.find("file:///") == 0;
+}
+
void DataSourceImpl::OnCreateFileStream(base::PlatformFile file) {
stream_.reset(
new net::FileStream(
diff --git a/chrome/renderer/media/data_source_impl.h b/chrome/renderer/media/data_source_impl.h
index d5326cb..c56be77 100644
--- a/chrome/renderer/media/data_source_impl.h
+++ b/chrome/renderer/media/data_source_impl.h
@@ -56,8 +56,10 @@
// | Called to obtain current position in the file.
// |-- SetPosition()
// | Performs a seek operation.
-// \-- GetSize()
-// Retrieve the size of the resource.
+// |-- GetSize()
+// | Retrieve the size of the resource.
+// \-- IsSeekable()
+// Returns true if URL is file:/// or else false.
//
// IO thread
// +-- OnCreateFileStream()
@@ -138,6 +140,7 @@ class DataSourceImpl : public media::DataSource,
virtual bool GetPosition(int64* position_out);
virtual bool SetPosition(int64 position);
virtual bool GetSize(int64* size_out);
+ virtual bool IsSeekable();
const media::MediaFormat& media_format();
diff --git a/media/base/filters.h b/media/base/filters.h
index 6d2b17e..3ade294 100644
--- a/media/base/filters.h
+++ b/media/base/filters.h
@@ -124,6 +124,9 @@ class DataSource : public MediaFilter {
// Returns true and the file size, false if the file size could not be
// retrieved.
virtual bool GetSize(int64* size_out) = 0;
+
+ // Returns true if this data source supports random seeking.
+ virtual bool IsSeekable() = 0;
};
diff --git a/media/base/mock_media_filters.h b/media/base/mock_media_filters.h
index fef7938..d043999 100644
--- a/media/base/mock_media_filters.h
+++ b/media/base/mock_media_filters.h
@@ -158,6 +158,10 @@ class MockDataSource : public DataSource {
return false;
}
+ virtual bool IsSeekable() {
+ return true;
+ }
+
// Simple position getter for unit testing.
int64 position() const { return position_; }
diff --git a/media/filters/ffmpeg_glue.cc b/media/filters/ffmpeg_glue.cc
index 231baae..b1149c3 100644
--- a/media/filters/ffmpeg_glue.cc
+++ b/media/filters/ffmpeg_glue.cc
@@ -19,8 +19,7 @@ int OpenContext(URLContext* h, const char* filename, int flags) {
data_source->AddRef();
h->priv_data = data_source;
h->flags = URL_RDONLY;
- // TODO(scherkus): data source should be able to tell us if we're streaming.
- h->is_streamed = false;
+ h->is_streamed = !data_source->IsSeekable();
return 0;
}
@@ -113,6 +112,11 @@ FFmpegGlue::FFmpegGlue() {
}
FFmpegGlue::~FFmpegGlue() {
+ DataSourceMap::iterator iter = data_sources_.begin();
+ while (iter != data_sources_.end()) {
+ DataSource* data_source = iter->second;
+ iter = data_sources_.erase(iter);
+ }
}
std::string FFmpegGlue::AddDataSource(DataSource* data_source) {
@@ -126,13 +130,13 @@ std::string FFmpegGlue::AddDataSource(DataSource* data_source) {
void FFmpegGlue::RemoveDataSource(DataSource* data_source) {
AutoLock auto_lock(lock_);
- for (DataSourceMap::iterator cur, iter = data_sources_.begin();
- iter != data_sources_.end();) {
- cur = iter;
- iter++;
-
- if (cur->second == data_source)
- data_sources_.erase(cur);
+ DataSourceMap::iterator iter = data_sources_.begin();
+ while (iter != data_sources_.end()) {
+ if (iter->second == data_source) {
+ iter = data_sources_.erase(iter);
+ } else {
+ ++iter;
+ }
}
}
diff --git a/media/filters/file_data_source.cc b/media/filters/file_data_source.cc
index c622c04..bdab8fb 100644
--- a/media/filters/file_data_source.cc
+++ b/media/filters/file_data_source.cc
@@ -111,4 +111,9 @@ bool FileDataSource::GetSize(int64* size_out) {
return (NULL != file_);
}
+bool FileDataSource::IsSeekable() {
+ // A file data source is always seekable.
+ return true;
+}
+
} // namespace media
diff --git a/media/filters/file_data_source.h b/media/filters/file_data_source.h
index c7bfdfd..e93c662 100644
--- a/media/filters/file_data_source.h
+++ b/media/filters/file_data_source.h
@@ -34,6 +34,7 @@ class FileDataSource : public DataSource {
virtual bool GetPosition(int64* position_out);
virtual bool SetPosition(int64 position);
virtual bool GetSize(int64* size_out);
+ virtual bool IsSeekable();
private:
friend class FilterFactoryImpl0<FileDataSource>;