summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 01:26:40 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 01:26:40 +0000
commitcef6492128ea70329523cbcf5d4c204660090857 (patch)
tree7386081bed04bb489d9e19fa64f8090ff4bfb6a4 /webkit
parentb02c01713a168403f65d5193ad6934d761c7fbaa (diff)
downloadchromium_src-cef6492128ea70329523cbcf5d4c204660090857.zip
chromium_src-cef6492128ea70329523cbcf5d4c204660090857.tar.gz
chromium_src-cef6492128ea70329523cbcf5d4c204660090857.tar.bz2
Adding callback support to media filter Initialize() and Seek().
Also includes unit tests for AudioRendererBase and VideoRendererBase. I had to rollback my first attempt at this change. Original review: http://codereview.chromium.org/155469 BUG=16014,16031 TEST=media_unittests, layout tests Review URL: http://codereview.chromium.org/155608 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20836 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/media/simple_data_source.cc27
-rw-r--r--webkit/glue/media/simple_data_source.h6
2 files changed, 21 insertions, 12 deletions
diff --git a/webkit/glue/media/simple_data_source.cc b/webkit/glue/media/simple_data_source.cc
index 2f49e67..afa27ff 100644
--- a/webkit/glue/media/simple_data_source.cc
+++ b/webkit/glue/media/simple_data_source.cc
@@ -55,22 +55,26 @@ void SimpleDataSource::Stop() {
NewRunnableMethod(this, &SimpleDataSource::CancelTask));
}
-bool SimpleDataSource::Initialize(const std::string& url) {
+void SimpleDataSource::Initialize(const std::string& url,
+ media::FilterCallback* callback) {
AutoLock auto_lock(lock_);
DCHECK_EQ(state_, UNINITIALIZED);
+ DCHECK(callback);
state_ = INITIALIZING;
+ initialize_callback_.reset(callback);
// Validate the URL.
SetURL(GURL(url));
if (!url_.is_valid() || !IsSchemeSupported(url_)) {
host()->Error(media::PIPELINE_ERROR_NETWORK);
- return false;
+ initialize_callback_->Run();
+ initialize_callback_.reset();
+ return;
}
// Post a task to the render thread to start loading the resource.
render_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this, &SimpleDataSource::StartTask));
- return true;
}
const media::MediaFormat& SimpleDataSource::media_format() {
@@ -144,16 +148,17 @@ void SimpleDataSource::OnCompletedRequest(const URLRequestStatus& status,
if (size_ == -1) {
size_ = data_.length();
}
- if (!status.is_success()) {
- host()->Error(media::PIPELINE_ERROR_NETWORK);
- return;
- }
// We're initialized!
- state_ = INITIALIZED;
- host()->SetTotalBytes(size_);
- host()->SetBufferedBytes(size_);
- host()->InitializationComplete();
+ if (status.is_success()) {
+ state_ = INITIALIZED;
+ host()->SetTotalBytes(size_);
+ host()->SetBufferedBytes(size_);
+ } else {
+ host()->Error(media::PIPELINE_ERROR_NETWORK);
+ }
+ initialize_callback_->Run();
+ initialize_callback_.reset();
}
std::string SimpleDataSource::GetURLForDebugging() {
diff --git a/webkit/glue/media/simple_data_source.h b/webkit/glue/media/simple_data_source.h
index 7918034..8a63df4 100644
--- a/webkit/glue/media/simple_data_source.h
+++ b/webkit/glue/media/simple_data_source.h
@@ -38,7 +38,8 @@ class SimpleDataSource : public media::DataSource,
virtual void Stop();
// DataSource implementation.
- virtual bool Initialize(const std::string& url);
+ virtual void Initialize(const std::string& url,
+ media::FilterCallback* callback);
virtual const media::MediaFormat& media_format();
virtual size_t Read(uint8* data, size_t size);
virtual bool GetPosition(int64* position_out);
@@ -104,6 +105,9 @@ class SimpleDataSource : public media::DataSource,
// Used for accessing |state_|.
Lock lock_;
+ // Filter callbacks.
+ scoped_ptr<media::FilterCallback> initialize_callback_;
+
DISALLOW_COPY_AND_ASSIGN(SimpleDataSource);
};