summaryrefslogtreecommitdiffstats
path: root/webkit/glue/media
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-11-18 18:32:45 +0000
committerBen Murdoch <benm@google.com>2010-11-18 18:38:07 +0000
commit513209b27ff55e2841eac0e4120199c23acce758 (patch)
treeaeba30bb08c5f47c57003544e378a377c297eee6 /webkit/glue/media
parent164f7496de0fbee436b385a79ead9e3cb81a50c1 (diff)
downloadexternal_chromium-513209b27ff55e2841eac0e4120199c23acce758.zip
external_chromium-513209b27ff55e2841eac0e4120199c23acce758.tar.gz
external_chromium-513209b27ff55e2841eac0e4120199c23acce758.tar.bz2
Merge Chromium at r65505: Initial merge by git.
Change-Id: I31d8f1d8cd33caaf7f47ffa7350aef42d5fbdb45
Diffstat (limited to 'webkit/glue/media')
-rw-r--r--webkit/glue/media/buffered_data_source.cc62
-rw-r--r--webkit/glue/media/buffered_data_source.h44
-rw-r--r--webkit/glue/media/buffered_data_source_unittest.cc80
-rw-r--r--webkit/glue/media/simple_data_source.cc42
-rw-r--r--webkit/glue/media/simple_data_source.h36
-rw-r--r--webkit/glue/media/simple_data_source_unittest.cc27
-rw-r--r--webkit/glue/media/video_renderer_impl.cc29
-rw-r--r--webkit/glue/media/video_renderer_impl.h38
-rw-r--r--webkit/glue/media/web_data_source.cc17
-rw-r--r--webkit/glue/media/web_data_source.h36
-rw-r--r--webkit/glue/media/web_video_renderer.h4
11 files changed, 212 insertions, 203 deletions
diff --git a/webkit/glue/media/buffered_data_source.cc b/webkit/glue/media/buffered_data_source.cc
index 3456e3a..29c86ac 100644
--- a/webkit/glue/media/buffered_data_source.cc
+++ b/webkit/glue/media/buffered_data_source.cc
@@ -15,6 +15,7 @@
#include "net/http/http_response_headers.h"
#include "webkit/glue/media/buffered_data_source.h"
#include "webkit/glue/webkit_glue.h"
+#include "webkit/glue/webmediaplayer_impl.h"
namespace {
@@ -126,7 +127,7 @@ void BufferedResourceLoader::Start(net::CompletionCallback* start_callback,
bridge_.reset(
bridge_factory_->CreateBridge(
url_,
- IsMediaCacheEnabled() ? net::LOAD_NORMAL : net::LOAD_BYPASS_CACHE,
+ net::LOAD_NORMAL,
first_byte_position_,
last_byte_position_));
@@ -521,31 +522,14 @@ void BufferedResourceLoader::NotifyNetworkEvent() {
}
/////////////////////////////////////////////////////////////////////////////
-// BufferedDataSource, static methods
-bool BufferedDataSource::IsMediaFormatSupported(
- const media::MediaFormat& media_format) {
- std::string mime_type;
- std::string url;
- if (media_format.GetAsString(media::MediaFormat::kMimeType, &mime_type) &&
- media_format.GetAsString(media::MediaFormat::kURL, &url)) {
- GURL gurl(url);
-
- // This data source doesn't support data:// protocol, so reject it
- // explicitly.
- if (IsProtocolSupportedForMedia(gurl) && !IsDataProtocol(gurl))
- return true;
- }
- return false;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// BufferedDataSource, protected
+// BufferedDataSource
BufferedDataSource::BufferedDataSource(
MessageLoop* render_loop,
webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory)
: total_bytes_(kPositionNotSpecified),
loaded_(false),
streaming_(false),
+ single_origin_(true),
bridge_factory_(bridge_factory),
loader_(NULL),
network_activity_(false),
@@ -614,6 +598,13 @@ void BufferedDataSource::Initialize(const std::string& url,
NewRunnableMethod(this, &BufferedDataSource::InitializeTask));
}
+bool BufferedDataSource::IsUrlSupported(const std::string& url) {
+ GURL gurl(url);
+
+ // This data source doesn't support data:// protocol so reject it.
+ return IsProtocolSupportedForMedia(gurl) && !IsDataProtocol(gurl);
+}
+
void BufferedDataSource::Stop(media::FilterCallback* callback) {
{
AutoLock auto_lock(lock_);
@@ -623,6 +614,7 @@ void BufferedDataSource::Stop(media::FilterCallback* callback) {
callback->Run();
delete callback;
}
+
render_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this, &BufferedDataSource::CleanupTask));
}
@@ -655,6 +647,25 @@ bool BufferedDataSource::IsStreaming() {
return streaming_;
}
+bool BufferedDataSource::HasSingleOrigin() {
+ DCHECK(MessageLoop::current() == render_loop_);
+ return single_origin_;
+}
+
+void BufferedDataSource::Abort() {
+ DCHECK(MessageLoop::current() == render_loop_);
+
+ // If we are told to abort, immediately return from any pending read
+ // with an error.
+ if (read_callback_.get()) {
+ {
+ AutoLock auto_lock(lock_);
+ DoneRead_Locked(net::ERR_FAILED);
+ }
+ CleanupTask();
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////
// BufferedDataSource, render thread tasks
void BufferedDataSource::InitializeTask() {
@@ -720,7 +731,10 @@ void BufferedDataSource::ReadTask(
void BufferedDataSource::CleanupTask() {
DCHECK(MessageLoop::current() == render_loop_);
- DCHECK(!stopped_on_render_loop_);
+
+ // If we have already stopped, do nothing.
+ if (stopped_on_render_loop_)
+ return;
// Stop the watch dog.
watch_dog_timer_.Stop();
@@ -865,6 +879,9 @@ void BufferedDataSource::HttpInitialStartCallback(int error) {
DCHECK(MessageLoop::current() == render_loop_);
DCHECK(loader_.get());
+ // Check if the request ended up at a different origin via redirect.
+ single_origin_ = url_.GetOrigin() == loader_->url().GetOrigin();
+
int64 instance_size = loader_->instance_size();
bool partial_response = loader_->partial_response();
bool success = error == net::OK;
@@ -929,6 +946,9 @@ void BufferedDataSource::NonHttpInitialStartCallback(int error) {
DCHECK(MessageLoop::current() == render_loop_);
DCHECK(loader_.get());
+ // Check if the request ended up at a different origin via redirect.
+ single_origin_ = url_.GetOrigin() == loader_->url().GetOrigin();
+
int64 instance_size = loader_->instance_size();
bool success = error == net::OK && instance_size != kPositionNotSpecified;
diff --git a/webkit/glue/media/buffered_data_source.h b/webkit/glue/media/buffered_data_source.h
index e7b2e47..2af9e84 100644
--- a/webkit/glue/media/buffered_data_source.h
+++ b/webkit/glue/media/buffered_data_source.h
@@ -13,7 +13,6 @@
#include "base/timer.h"
#include "base/condition_variable.h"
#include "googleurl/src/gurl.h"
-#include "media/base/factory.h"
#include "media/base/filters.h"
#include "media/base/media_format.h"
#include "media/base/pipeline.h"
@@ -21,6 +20,8 @@
#include "net/base/completion_callback.h"
#include "net/base/file_stream.h"
#include "webkit/glue/media/media_resource_loader_bridge_factory.h"
+#include "webkit/glue/media/web_data_source.h"
+#include "webkit/glue/webmediaplayer_impl.h"
namespace webkit_glue {
/////////////////////////////////////////////////////////////////////////////
@@ -105,6 +106,9 @@ class BufferedResourceLoader :
// Returns true if network is currently active.
virtual bool network_activity() { return !completed_ && !deferred_; }
+ // Returns resulting URL.
+ virtual const GURL& url() { return url_; }
+
/////////////////////////////////////////////////////////////////////////////
// webkit_glue::ResourceLoaderBridge::Peer implementations.
virtual void OnUploadProgress(uint64 position, uint64 size) {}
@@ -122,7 +126,6 @@ class BufferedResourceLoader :
const URLRequestStatus& status,
const std::string& security_info,
const base::Time& completion_time);
- GURL GetURLForDebugging() const { return url_; }
protected:
friend class base::RefCountedThreadSafe<BufferedResourceLoader>;
@@ -212,27 +215,18 @@ class BufferedResourceLoader :
DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader);
};
-class BufferedDataSource : public media::DataSource {
+class BufferedDataSource : public WebDataSource {
public:
- // Methods called from pipeline thread
- // Static methods for creating this class.
- static media::FilterFactory* CreateFactory(
- MessageLoop* message_loop,
- webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory) {
- return new media::FilterFactoryImpl2<
- BufferedDataSource,
- MessageLoop*,
- webkit_glue::MediaResourceLoaderBridgeFactory*>(
- message_loop, bridge_factory);
- }
+ BufferedDataSource(
+ MessageLoop* render_loop,
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory);
- // media::FilterFactoryImpl2 implementation.
- static bool IsMediaFormatSupported(
- const media::MediaFormat& media_format);
+ virtual ~BufferedDataSource();
// media::MediaFilter implementation.
virtual void Initialize(const std::string& url,
media::FilterCallback* callback);
+ virtual bool IsUrlSupported(const std::string& url);
virtual void Stop(media::FilterCallback* callback);
virtual void SetPlaybackRate(float playback_rate);
@@ -248,11 +242,11 @@ class BufferedDataSource : public media::DataSource {
return media_format_;
}
+ // webkit_glue::WebDataSource implementation.
+ virtual bool HasSingleOrigin();
+ virtual void Abort();
+
protected:
- BufferedDataSource(
- MessageLoop* render_loop,
- webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory);
- virtual ~BufferedDataSource();
// A factory method to create a BufferedResourceLoader based on the read
// parameters. We can override this file to object a mock
@@ -266,11 +260,6 @@ class BufferedDataSource : public media::DataSource {
virtual base::TimeDelta GetTimeoutMilliseconds();
private:
- friend class media::FilterFactoryImpl2<
- BufferedDataSource,
- MessageLoop*,
- webkit_glue::MediaResourceLoaderBridgeFactory*>;
-
// Posted to perform initialization on render thread and start resource
// loading.
void InitializeTask();
@@ -349,6 +338,9 @@ class BufferedDataSource : public media::DataSource {
// i.e. range request is not supported.
bool streaming_;
+ // True if the media resource has a single origin.
+ bool single_origin_;
+
// A factory object to produce ResourceLoaderBridge.
scoped_ptr<webkit_glue::MediaResourceLoaderBridgeFactory> bridge_factory_;
diff --git a/webkit/glue/media/buffered_data_source_unittest.cc b/webkit/glue/media/buffered_data_source_unittest.cc
index f032595..81103b2 100644
--- a/webkit/glue/media/buffered_data_source_unittest.cc
+++ b/webkit/glue/media/buffered_data_source_unittest.cc
@@ -27,6 +27,7 @@ using ::testing::Invoke;
using ::testing::InvokeWithoutArgs;
using ::testing::NotNull;
using ::testing::Return;
+using ::testing::ReturnRef;
using ::testing::SetArgumentPointee;
using ::testing::StrictMock;
using ::testing::NiceMock;
@@ -79,7 +80,6 @@ class BufferedResourceLoaderTest : public testing::Test {
loader_ = new BufferedResourceLoader(&bridge_factory_, gurl_,
first_position_, last_position_);
- EXPECT_EQ(gurl_.spec(), loader_->GetURLForDebugging().spec());
}
void SetLoaderBuffer(size_t forward_capacity, size_t backward_capacity) {
@@ -526,6 +526,7 @@ class MockBufferedResourceLoader : public BufferedResourceLoader {
MOCK_METHOD0(instance_size, int64());
MOCK_METHOD0(partial_response, bool());
MOCK_METHOD0(network_activity, bool());
+ MOCK_METHOD0(url, const GURL&());
MOCK_METHOD0(GetBufferedFirstBytePosition, int64());
MOCK_METHOD0(GetBufferedLastBytePosition, int64());
@@ -539,15 +540,9 @@ class MockBufferedResourceLoader : public BufferedResourceLoader {
// CreateResourceLoader() method.
class MockBufferedDataSource : public BufferedDataSource {
public:
- // Static methods for creating this class.
- static media::FilterFactory* CreateFactory(
- MessageLoop* message_loop,
- MediaResourceLoaderBridgeFactory* bridge_factory) {
- return new media::FilterFactoryImpl2<
- MockBufferedDataSource,
- MessageLoop*,
- MediaResourceLoaderBridgeFactory*>(message_loop,
- bridge_factory);
+ MockBufferedDataSource(
+ MessageLoop* message_loop, MediaResourceLoaderBridgeFactory* factory)
+ : BufferedDataSource(message_loop, factory) {
}
virtual base::TimeDelta GetTimeoutMilliseconds() {
@@ -558,18 +553,7 @@ class MockBufferedDataSource : public BufferedDataSource {
MOCK_METHOD2(CreateResourceLoader, BufferedResourceLoader*(
int64 first_position, int64 last_position));
- protected:
- MockBufferedDataSource(
- MessageLoop* message_loop, MediaResourceLoaderBridgeFactory* factory)
- : BufferedDataSource(message_loop, factory) {
- }
-
private:
- friend class media::FilterFactoryImpl2<
- MockBufferedDataSource,
- MessageLoop*,
- MediaResourceLoaderBridgeFactory*>;
-
DISALLOW_COPY_AND_ASSIGN(MockBufferedDataSource);
};
@@ -579,8 +563,6 @@ class BufferedDataSourceTest : public testing::Test {
message_loop_ = MessageLoop::current();
bridge_factory_.reset(
new StrictMock<MockMediaResourceLoaderBridgeFactory>());
- factory_ = MockBufferedDataSource::CreateFactory(message_loop_,
- bridge_factory_.get());
// Prepare test data.
for (size_t i = 0; i < sizeof(data_); ++i) {
@@ -619,14 +601,15 @@ class BufferedDataSourceTest : public testing::Test {
url_format.SetAsString(media::MediaFormat::kMimeType,
media::mime_type::kURL);
url_format.SetAsString(media::MediaFormat::kURL, url);
- data_source_ = factory_->Create<MockBufferedDataSource>(url_format);
+ data_source_ = new MockBufferedDataSource(MessageLoop::current(),
+ bridge_factory_.get());
CHECK(data_source_);
// There is no need to provide a message loop to data source.
data_source_->set_host(&host_);
- scoped_refptr<NiceMock<MockBufferedResourceLoader> > first_loader =
- new NiceMock<MockBufferedResourceLoader>();
+ scoped_refptr<NiceMock<MockBufferedResourceLoader> > first_loader(
+ new NiceMock<MockBufferedResourceLoader>());
// Creates the mock loader to be injected.
loader_ = first_loader;
@@ -641,6 +624,8 @@ class BufferedDataSourceTest : public testing::Test {
// to be created.
if (partial_response && (error == net::ERR_INVALID_RESPONSE)) {
// Verify that the initial loader is stopped.
+ EXPECT_CALL(*loader_, url())
+ .WillRepeatedly(ReturnRef(gurl_));
EXPECT_CALL(*loader_, Stop());
// Replace loader_ with a new instance.
@@ -655,11 +640,18 @@ class BufferedDataSourceTest : public testing::Test {
}
}
+ // Attach a static function that deletes the memory referred by the
+ // "callback" parameter.
+ ON_CALL(*loader_, Read(_, _, _ , _))
+ .WillByDefault(DeleteArg<3>());
+
StrictMock<media::MockFilterCallback> callback;
- EXPECT_CALL(*loader_, instance_size())
- .WillRepeatedly(Return(instance_size));
- EXPECT_CALL(*loader_, partial_response())
- .WillRepeatedly(Return(partial_response));
+ ON_CALL(*loader_, instance_size())
+ .WillByDefault(Return(instance_size));
+ ON_CALL(*loader_, partial_response())
+ .WillByDefault(Return(partial_response));
+ ON_CALL(*loader_, url())
+ .WillByDefault(ReturnRef(gurl_));
if (initialized_ok) {
// Expected loaded or not.
EXPECT_CALL(host_, SetLoaded(loaded));
@@ -757,6 +749,27 @@ class BufferedDataSourceTest : public testing::Test {
memcmp(buffer_, data_ + static_cast<int>(position), read_size));
}
+ void ReadDataSourceHang(int64 position, int size) {
+ EXPECT_TRUE(loader_);
+
+ // Expect a call to read, but the call never returns.
+ EXPECT_CALL(*loader_, Read(position, size, NotNull(), NotNull()));
+ data_source_->Read(
+ position, size, buffer_,
+ NewCallback(this, &BufferedDataSourceTest::ReadCallback));
+ message_loop_->RunAllPending();
+
+ // Now expect the read to return after aborting the data source.
+ EXPECT_CALL(*this, ReadCallback(_));
+ EXPECT_CALL(*loader_, Stop());
+ data_source_->Abort();
+ message_loop_->RunAllPending();
+
+ // The loader has now been stopped. Set this to null so that when the
+ // DataSource is stopped, it does not expect a call to stop the loader.
+ loader_ = NULL;
+ }
+
void ReadDataSourceMiss(int64 position, int size) {
EXPECT_TRUE(loader_);
@@ -880,7 +893,6 @@ class BufferedDataSourceTest : public testing::Test {
bridge_factory_;
scoped_refptr<NiceMock<MockBufferedResourceLoader> > loader_;
scoped_refptr<MockBufferedDataSource> data_source_;
- scoped_refptr<media::FilterFactory> factory_;
StrictMock<media::MockFilterHost> host_;
GURL gurl_;
@@ -946,6 +958,12 @@ TEST_F(BufferedDataSourceTest, ReadCacheMiss) {
StopDataSource();
}
+TEST_F(BufferedDataSourceTest, ReadHang) {
+ InitializeDataSource(kHttpUrl, net::OK, true, 25, LOADING);
+ ReadDataSourceHang(10, 10);
+ StopDataSource();
+}
+
TEST_F(BufferedDataSourceTest, ReadFailed) {
InitializeDataSource(kHttpUrl, net::OK, true, 1024, LOADING);
ReadDataSourceHit(10, 10, 10);
diff --git a/webkit/glue/media/simple_data_source.cc b/webkit/glue/media/simple_data_source.cc
index 0b09edf..291928e 100644
--- a/webkit/glue/media/simple_data_source.cc
+++ b/webkit/glue/media/simple_data_source.cc
@@ -28,25 +28,13 @@ bool IsDataProtocol(const GURL& url) {
namespace webkit_glue {
-bool SimpleDataSource::IsMediaFormatSupported(
- const media::MediaFormat& media_format) {
- std::string mime_type;
- std::string url;
- if (media_format.GetAsString(media::MediaFormat::kMimeType, &mime_type) &&
- media_format.GetAsString(media::MediaFormat::kURL, &url)) {
- GURL gurl(url);
- if (IsProtocolSupportedForMedia(gurl))
- return true;
- }
- return false;
-}
-
SimpleDataSource::SimpleDataSource(
MessageLoop* render_loop,
webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory)
: render_loop_(render_loop),
bridge_factory_(bridge_factory),
size_(-1),
+ single_origin_(true),
state_(UNINITIALIZED) {
DCHECK(render_loop);
}
@@ -125,7 +113,9 @@ bool SimpleDataSource::OnReceivedRedirect(
const webkit_glue::ResourceResponseInfo& info,
bool* has_new_first_party_for_cookies,
GURL* new_first_party_for_cookies) {
- SetURL(new_url);
+ DCHECK(MessageLoop::current() == render_loop_);
+ single_origin_ = url_.GetOrigin() == new_url.GetOrigin();
+
// TODO(wtc): should we return a new first party for cookies URL?
*has_new_first_party_for_cookies = false;
return true;
@@ -134,22 +124,24 @@ bool SimpleDataSource::OnReceivedRedirect(
void SimpleDataSource::OnReceivedResponse(
const webkit_glue::ResourceResponseInfo& info,
bool content_filtered) {
+ DCHECK(MessageLoop::current() == render_loop_);
size_ = info.content_length;
}
void SimpleDataSource::OnReceivedData(const char* data, int len) {
+ DCHECK(MessageLoop::current() == render_loop_);
data_.append(data, len);
}
void SimpleDataSource::OnCompletedRequest(const URLRequestStatus& status,
const std::string& security_info,
const base::Time& completion_time) {
+ DCHECK(MessageLoop::current() == render_loop_);
AutoLock auto_lock(lock_);
// It's possible this gets called after Stop(), in which case |host_| is no
// longer valid.
- if (state_ == STOPPED) {
+ if (state_ == STOPPED)
return;
- }
// Otherwise we should be initializing and have created a bridge.
DCHECK_EQ(state_, INITIALIZING);
@@ -158,16 +150,21 @@ void SimpleDataSource::OnCompletedRequest(const URLRequestStatus& status,
// If we don't get a content length or the request has failed, report it
// as a network error.
- DCHECK(size_ == -1 || static_cast<size_t>(size_) == data_.length());
- if (size_ == -1) {
+ if (size_ == -1)
size_ = data_.length();
- }
+ DCHECK(static_cast<size_t>(size_) == data_.length());
DoneInitialization_Locked(status.is_success());
}
-GURL SimpleDataSource::GetURLForDebugging() const {
- return url_;
+bool SimpleDataSource::HasSingleOrigin() {
+ DCHECK(MessageLoop::current() == render_loop_);
+ return single_origin_;
+}
+
+void SimpleDataSource::Abort() {
+ DCHECK(MessageLoop::current() == render_loop_);
+ NOTIMPLEMENTED();
}
void SimpleDataSource::SetURL(const GURL& url) {
@@ -179,8 +176,8 @@ void SimpleDataSource::SetURL(const GURL& url) {
}
void SimpleDataSource::StartTask() {
- AutoLock auto_lock(lock_);
DCHECK(MessageLoop::current() == render_loop_);
+ AutoLock auto_lock(lock_);
// We may have stopped.
if (state_ == STOPPED)
@@ -205,6 +202,7 @@ void SimpleDataSource::StartTask() {
}
void SimpleDataSource::CancelTask() {
+ DCHECK(MessageLoop::current() == render_loop_);
AutoLock auto_lock(lock_);
DCHECK_EQ(state_, STOPPED);
diff --git a/webkit/glue/media/simple_data_source.h b/webkit/glue/media/simple_data_source.h
index d649c0d..ff1e247 100644
--- a/webkit/glue/media/simple_data_source.h
+++ b/webkit/glue/media/simple_data_source.h
@@ -12,31 +12,22 @@
#include "base/message_loop.h"
#include "base/scoped_ptr.h"
-#include "media/base/factory.h"
#include "media/base/filters.h"
#include "webkit/glue/media/media_resource_loader_bridge_factory.h"
+#include "webkit/glue/media/web_data_source.h"
class MessageLoop;
class WebMediaPlayerDelegateImpl;
namespace webkit_glue {
-class SimpleDataSource : public media::DataSource,
+class SimpleDataSource : public WebDataSource,
public webkit_glue::ResourceLoaderBridge::Peer {
public:
- static media::FilterFactory* CreateFactory(
- MessageLoop* message_loop,
- webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory) {
- return new media::FilterFactoryImpl2<
- SimpleDataSource,
- MessageLoop*,
- webkit_glue::MediaResourceLoaderBridgeFactory*>(message_loop,
- bridge_factory);
- }
-
- // media::FilterFactoryImpl2 implementation.
- static bool IsMediaFormatSupported(
- const media::MediaFormat& media_format);
+ SimpleDataSource(
+ MessageLoop* render_loop,
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory);
+ virtual ~SimpleDataSource();
// MediaFilter implementation.
virtual void Stop(media::FilterCallback* callback);
@@ -65,18 +56,12 @@ class SimpleDataSource : public media::DataSource,
virtual void OnCompletedRequest(const URLRequestStatus& status,
const std::string& security_info,
const base::Time& completion_time);
- virtual GURL GetURLForDebugging() const;
- private:
- friend class media::FilterFactoryImpl2<
- SimpleDataSource,
- MessageLoop*,
- webkit_glue::MediaResourceLoaderBridgeFactory*>;
- SimpleDataSource(
- MessageLoop* render_loop,
- webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory);
- virtual ~SimpleDataSource();
+ // webkit_glue::WebDataSource implementation.
+ virtual bool HasSingleOrigin();
+ virtual void Abort();
+ private:
// Updates |url_| and |media_format_| with the given URL.
void SetURL(const GURL& url);
@@ -102,6 +87,7 @@ class SimpleDataSource : public media::DataSource,
GURL url_;
std::string data_;
int64 size_;
+ bool single_origin_;
// Simple state tracking variable.
enum State {
diff --git a/webkit/glue/media/simple_data_source_unittest.cc b/webkit/glue/media/simple_data_source_unittest.cc
index 50c8910..537798f 100644
--- a/webkit/glue/media/simple_data_source_unittest.cc
+++ b/webkit/glue/media/simple_data_source_unittest.cc
@@ -42,8 +42,6 @@ class SimpleDataSourceTest : public testing::Test {
bridge_factory_.reset(
new NiceMock<MockMediaResourceLoaderBridgeFactory>());
bridge_.reset(new NiceMock<MockResourceLoaderBridge>());
- factory_ = SimpleDataSource::CreateFactory(MessageLoop::current(),
- bridge_factory_.get());
for (int i = 0; i < kDataSize; ++i) {
data_[i] = i;
@@ -58,11 +56,8 @@ class SimpleDataSourceTest : public testing::Test {
}
void InitializeDataSource(const char* url) {
- media::MediaFormat url_format;
- url_format.SetAsString(media::MediaFormat::kMimeType,
- media::mime_type::kURL);
- url_format.SetAsString(media::MediaFormat::kURL, url);
- data_source_ = factory_->Create<SimpleDataSource>(url_format);
+ data_source_ = new SimpleDataSource(MessageLoop::current(),
+ bridge_factory_.get());
CHECK(data_source_);
// There is no need to provide a message loop to data source.
@@ -167,7 +162,6 @@ class SimpleDataSourceTest : public testing::Test {
scoped_ptr<MessageLoop> message_loop_;
scoped_ptr<NiceMock<MockMediaResourceLoaderBridgeFactory> > bridge_factory_;
scoped_ptr<NiceMock<MockResourceLoaderBridge> > bridge_;
- scoped_refptr<media::FilterFactory> factory_;
scoped_refptr<SimpleDataSource> data_source_;
StrictMock<media::MockFilterHost> host_;
StrictMock<media::MockFilterCallback> callback_;
@@ -195,11 +189,9 @@ TEST_F(SimpleDataSourceTest, InitializeFile) {
}
TEST_F(SimpleDataSourceTest, InitializeData) {
- media::MediaFormat url_format;
- url_format.SetAsString(media::MediaFormat::kMimeType,
- media::mime_type::kURL);
- url_format.SetAsString(media::MediaFormat::kURL, kDataUrl);
- data_source_ = factory_->Create<SimpleDataSource>(url_format);
+ data_source_ = new SimpleDataSource(MessageLoop::current(),
+ bridge_factory_.get());
+ EXPECT_TRUE(data_source_->IsUrlSupported(kDataUrl));
CHECK(data_source_);
// There is no need to provide a message loop to data source.
@@ -217,15 +209,6 @@ TEST_F(SimpleDataSourceTest, InitializeData) {
DestroyDataSource();
}
-TEST_F(SimpleDataSourceTest, InitializeInvalid) {
- media::MediaFormat url_format;
- url_format.SetAsString(media::MediaFormat::kMimeType,
- media::mime_type::kURL);
- url_format.SetAsString(media::MediaFormat::kURL, kInvalidUrl);
- data_source_ = factory_->Create<SimpleDataSource>(url_format);
- EXPECT_FALSE(data_source_);
-}
-
TEST_F(SimpleDataSourceTest, RequestFailed) {
InitializeDataSource(kHttpUrl);
RequestFailed();
diff --git a/webkit/glue/media/video_renderer_impl.cc b/webkit/glue/media/video_renderer_impl.cc
index 16c9ef6..3bbd626 100644
--- a/webkit/glue/media/video_renderer_impl.cc
+++ b/webkit/glue/media/video_renderer_impl.cc
@@ -10,33 +10,13 @@
namespace webkit_glue {
-VideoRendererImpl::VideoRendererImpl(WebMediaPlayerImpl::Proxy* proxy,
- bool pts_logging)
- : proxy_(proxy),
- last_converted_frame_(NULL),
+VideoRendererImpl::VideoRendererImpl(bool pts_logging)
+ : last_converted_frame_(NULL),
pts_logging_(pts_logging) {
- // TODO(hclam): decide whether to do the following line in this thread or
- // in the render thread.
- proxy_->SetVideoRenderer(this);
}
VideoRendererImpl::~VideoRendererImpl() {}
-// static
-media::FilterFactory* VideoRendererImpl::CreateFactory(
- WebMediaPlayerImpl::Proxy* proxy,
- bool pts_logging) {
- return new media::FilterFactoryImpl2<VideoRendererImpl,
- WebMediaPlayerImpl::Proxy*,
- bool>(proxy, pts_logging);
-}
-
-// static
-bool VideoRendererImpl::IsMediaFormatSupported(
- const media::MediaFormat& media_format) {
- return ParseMediaFormat(media_format, NULL, NULL, NULL, NULL);
-}
-
bool VideoRendererImpl::OnInitialize(media::VideoDecoder* decoder) {
video_size_.SetSize(width(), height());
bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width(), height());
@@ -60,6 +40,11 @@ void VideoRendererImpl::OnFrameAvailable() {
proxy_->Repaint();
}
+void VideoRendererImpl::SetWebMediaPlayerImplProxy(
+ WebMediaPlayerImpl::Proxy* proxy) {
+ proxy_ = proxy;
+}
+
void VideoRendererImpl::SetRect(const gfx::Rect& rect) {
}
diff --git a/webkit/glue/media/video_renderer_impl.h b/webkit/glue/media/video_renderer_impl.h
index 38e8851..34c67d3 100644
--- a/webkit/glue/media/video_renderer_impl.h
+++ b/webkit/glue/media/video_renderer_impl.h
@@ -24,39 +24,16 @@ namespace webkit_glue {
class VideoRendererImpl : public WebVideoRenderer {
public:
+ explicit VideoRendererImpl(bool pts_logging);
+ virtual ~VideoRendererImpl();
+
// WebVideoRenderer implementation.
+ virtual void SetWebMediaPlayerImplProxy(WebMediaPlayerImpl::Proxy* proxy);
virtual void SetRect(const gfx::Rect& rect);
virtual void Paint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect);
virtual void GetCurrentFrame(scoped_refptr<media::VideoFrame>* frame_out);
virtual void PutCurrentFrame(scoped_refptr<media::VideoFrame> frame);
- // Static method for creating factory for this object.
- static media::FilterFactory* CreateFactory(WebMediaPlayerImpl::Proxy* proxy,
- bool pts_logging);
-
- // FilterFactoryImpl2 implementation.
- static bool IsMediaFormatSupported(const media::MediaFormat& media_format);
-
- // TODO(scherkus): remove this mega-hack, see http://crbug.com/28207
- class FactoryFactory : public webkit_glue::WebVideoRendererFactoryFactory {
- public:
- FactoryFactory(bool pts_logging)
- : webkit_glue::WebVideoRendererFactoryFactory(),
- pts_logging_(pts_logging) {
- }
-
- virtual media::FilterFactory* CreateFactory(
- webkit_glue::WebMediaPlayerImpl::Proxy* proxy) {
- return VideoRendererImpl::CreateFactory(proxy, pts_logging_);
- }
-
- private:
- // Whether we're logging video presentation timestamps (PTS).
- bool pts_logging_;
-
- DISALLOW_COPY_AND_ASSIGN(FactoryFactory);
- };
-
protected:
// Method called by VideoRendererBase during initialization.
virtual bool OnInitialize(media::VideoDecoder* decoder);
@@ -68,13 +45,6 @@ class VideoRendererImpl : public WebVideoRenderer {
virtual void OnFrameAvailable();
private:
- // Only the filter factories can create instances.
- friend class media::FilterFactoryImpl2<VideoRendererImpl,
- WebMediaPlayerImpl::Proxy*,
- bool>;
- VideoRendererImpl(WebMediaPlayerImpl::Proxy* proxy, bool pts_logging);
- virtual ~VideoRendererImpl();
-
// Determine the conditions to perform fast paint. Returns true if we can do
// fast paint otherwise false.
bool CanFastPaint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect);
diff --git a/webkit/glue/media/web_data_source.cc b/webkit/glue/media/web_data_source.cc
new file mode 100644
index 0000000..a46d594
--- /dev/null
+++ b/webkit/glue/media/web_data_source.cc
@@ -0,0 +1,17 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/base/filters.h"
+#include "webkit/glue/media/web_data_source.h"
+
+namespace webkit_glue {
+
+WebDataSource::WebDataSource()
+ : media::DataSource() {
+}
+
+WebDataSource::~WebDataSource() {
+}
+
+} // namespace webkit_glue
diff --git a/webkit/glue/media/web_data_source.h b/webkit/glue/media/web_data_source.h
new file mode 100644
index 0000000..956ac9e
--- /dev/null
+++ b/webkit/glue/media/web_data_source.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_GLUE_MEDIA_WEB_DATA_SOURCE_H_
+#define WEBKIT_GLUE_MEDIA_WEB_DATA_SOURCE_H_
+
+#include "media/base/filters.h"
+
+namespace webkit_glue {
+
+// An interface that allows WebMediaPlayerImpl::Proxy to communicate with the
+// DataSource in the pipeline.
+class WebDataSource : public media::DataSource {
+ public:
+ WebDataSource();
+ virtual ~WebDataSource();
+
+ // Returns true if the media resource has a single origin, false otherwise.
+ //
+ // Method called on the render thread.
+ virtual bool HasSingleOrigin() = 0;
+
+ // This method is used to unblock any read calls that would cause the
+ // media pipeline to stall.
+ //
+ // Method called on the render thread.
+ virtual void Abort() = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WebDataSource);
+};
+
+} // namespace webkit_glue
+
+#endif // WEBKIT_GLUE_MEDIA_WEB_DATA_SOURCE_H_
diff --git a/webkit/glue/media/web_video_renderer.h b/webkit/glue/media/web_video_renderer.h
index d8b47ad..efd3109 100644
--- a/webkit/glue/media/web_video_renderer.h
+++ b/webkit/glue/media/web_video_renderer.h
@@ -7,6 +7,7 @@
#include "media/base/video_frame.h"
#include "media/filters/video_renderer_base.h"
+#include "webkit/glue/webmediaplayer_impl.h"
namespace webkit_glue {
@@ -16,6 +17,9 @@ class WebVideoRenderer : public media::VideoRendererBase {
WebVideoRenderer() : media::VideoRendererBase() {}
virtual ~WebVideoRenderer() {}
+ // Saves the reference to WebMediaPlayerImpl::Proxy.
+ virtual void SetWebMediaPlayerImplProxy(WebMediaPlayerImpl::Proxy* proxy) = 0;
+
// This method is called with the same rect as the Paint() method and could
// be used by future implementations to implement an improved color space +
// scale code on a separate thread. Since we always do the stretch on the