summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/render_process_host.cc1
-rw-r--r--chrome/renderer/render_view.cc5
-rw-r--r--chrome/renderer/render_view.h1
-rw-r--r--chrome/renderer/renderer.scons2
-rw-r--r--chrome/renderer/renderer.vcproj8
-rw-r--r--chrome/renderer/renderer_glue.cc6
-rw-r--r--chrome/renderer/webmediaplayer_delegate_impl.cc100
-rw-r--r--chrome/renderer/webmediaplayer_delegate_impl.h102
-rw-r--r--webkit/build/WebCore/SConscript1
-rw-r--r--webkit/build/glue/glue.vcproj20
-rw-r--r--webkit/build/port/port.vcproj4
-rw-r--r--webkit/glue/SConscript2
-rw-r--r--webkit/glue/media_player_private_impl.cc301
-rw-r--r--webkit/glue/webframe.h1
-rw-r--r--webkit/glue/webkit_glue.h4
-rw-r--r--webkit/glue/webmediaplayer.h63
-rw-r--r--webkit/glue/webmediaplayer_delegate.h80
-rw-r--r--webkit/glue/webmediaplayer_impl.cc61
-rw-r--r--webkit/glue/webmediaplayer_impl.h60
-rw-r--r--webkit/glue/webview_delegate.h14
-rw-r--r--webkit/port/platform/graphics/chromium/MediaPlayerPrivateChromium.h25
-rw-r--r--webkit/tools/test_shell/test_shell.cc5
-rw-r--r--webkit/tools/test_shell/test_shell_switches.cc3
-rw-r--r--webkit/tools/test_shell/test_shell_switches.h1
24 files changed, 854 insertions, 16 deletions
diff --git a/chrome/browser/render_process_host.cc b/chrome/browser/render_process_host.cc
index 2c659bc..dc3f84f 100644
--- a/chrome/browser/render_process_host.cc
+++ b/chrome/browser/render_process_host.cc
@@ -279,6 +279,7 @@ bool RenderProcessHost::Init() {
switches::kUseLowFragHeapCrt,
switches::kGearsInRenderer,
switches::kEnableGreasemonkey,
+ switches::kEnableVideo,
};
for (int i = 0; i < arraysize(switch_names); ++i) {
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 9a06b1c..2289d61 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -32,6 +32,7 @@
#include "chrome/renderer/localized_error.h"
#include "chrome/renderer/renderer_resources.h"
#include "chrome/renderer/visitedlink_slave.h"
+#include "chrome/renderer/webmediaplayer_delegate_impl.h"
#include "chrome/renderer/webplugin_delegate_proxy.h"
#include "chrome/views/message_box_view.h"
#include "net/base/escape.h"
@@ -1867,6 +1868,10 @@ WebPluginDelegate* RenderView::CreatePluginDelegate(
return proxy;
}
+webkit_glue::WebMediaPlayerDelegate* RenderView::CreateMediaPlayerDelegate() {
+ return new WebMediaPlayerDelegateImpl();
+}
+
void RenderView::OnMissingPluginStatus(WebPluginDelegate* delegate,
int status) {
if (first_default_plugin_ == NULL) {
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index e82ebac..cea0ce1 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -208,6 +208,7 @@ class RenderView : public RenderWidget, public WebViewDelegate,
const std::string& mime_type,
const std::string& clsid,
std::string* actual_mime_type);
+ virtual webkit_glue::WebMediaPlayerDelegate* CreateMediaPlayerDelegate();
virtual void OnMissingPluginStatus(WebPluginDelegate* delegate, int status);
virtual void OpenURL(WebView* webview, const GURL& url,
const GURL& referrer,
diff --git a/chrome/renderer/renderer.scons b/chrome/renderer/renderer.scons
index b65291a..50161ac 100644
--- a/chrome/renderer/renderer.scons
+++ b/chrome/renderer/renderer.scons
@@ -44,8 +44,8 @@ input_files = [
'renderer_glue.cc',
'renderer_main.cc',
'visitedlink_slave.cc',
+ 'webmediaplayer_delegate_impl.cc',
'webplugin_delegate_proxy.cc',
-
'automation/dom_automation_controller.cc',
'net/render_dns_master.cc',
diff --git a/chrome/renderer/renderer.vcproj b/chrome/renderer/renderer.vcproj
index 2fa8d0c..395809c 100644
--- a/chrome/renderer/renderer.vcproj
+++ b/chrome/renderer/renderer.vcproj
@@ -294,6 +294,14 @@
>
</File>
<File
+ RelativePath=".\webmediaplayer_delegate_impl.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\webmediaplayer_delegate_impl.h"
+ >
+ </File>
+ <File
RelativePath=".\webplugin_delegate_proxy.cc"
>
</File>
diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc
index bf325fb..44b2f01 100644
--- a/chrome/renderer/renderer_glue.cc
+++ b/chrome/renderer/renderer_glue.cc
@@ -8,8 +8,10 @@
#include <wininet.h>
#include "base/clipboard.h"
+#include "base/command_line.h"
#include "base/scoped_clipboard_writer.h"
#include "chrome/renderer/net/render_dns_master.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/resource_bundle.h"
#include "chrome/plugin/npobject_util.h"
#include "chrome/renderer/render_view.h"
@@ -133,6 +135,10 @@ ScopedClipboardWriterGlue::~ScopedClipboardWriterGlue() {
namespace webkit_glue {
+bool IsMediaPlayerAvailable() {
+ return CommandLine().HasSwitch(switches::kEnableVideo);
+}
+
void PrefetchDns(const std::string& hostname) {
if (!hostname.empty())
DnsPrefetchCString(hostname.c_str(), hostname.length());
diff --git a/chrome/renderer/webmediaplayer_delegate_impl.cc b/chrome/renderer/webmediaplayer_delegate_impl.cc
new file mode 100644
index 0000000..f4d3110
--- /dev/null
+++ b/chrome/renderer/webmediaplayer_delegate_impl.cc
@@ -0,0 +1,100 @@
+// Copyright (c) 2008 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 "chrome/renderer/webmediaplayer_delegate_impl.h"
+
+WebMediaPlayerDelegateImpl::WebMediaPlayerDelegateImpl()
+ : bytes_loaded_(0),
+ current_time_(0.0f),
+ data_rate_(0),
+ duration_(0.0f),
+ height_(0),
+ network_state_(webkit_glue::WebMediaPlayer::EMPTY),
+ paused_(true),
+ playback_rate_(0.0f),
+ ready_state_(webkit_glue::WebMediaPlayer::DATA_UNAVAILABLE),
+ seeking_(false),
+ total_bytes_(0),
+ video_(false),
+ visible_(false),
+ volume_(0.0f),
+ web_media_player_(NULL),
+ width_(0) {
+ // TODO(hclam): initialize the media player here
+}
+
+WebMediaPlayerDelegateImpl::~WebMediaPlayerDelegateImpl() {
+ // TODO(hclam): do the following things here:
+ // 1. Destroy the internal media player
+ // 2. Destroy the associated WebMediaPlayer
+}
+
+void WebMediaPlayerDelegateImpl::Initialize(
+ webkit_glue::WebMediaPlayer* media_player) {
+ web_media_player_ = media_player;
+}
+
+void WebMediaPlayerDelegateImpl::Load(const GURL& url) {
+ // TODO(hclam): delegate to google's media player
+}
+
+void WebMediaPlayerDelegateImpl::CancelLoad() {
+ // TODO(hclam): delegate to google's media player
+}
+
+void WebMediaPlayerDelegateImpl::Play() {
+ // TODO(hclam): delegate to google's media player
+}
+
+void WebMediaPlayerDelegateImpl::Pause() {
+ // TODO(hclam): delegate to google's media player
+}
+
+void WebMediaPlayerDelegateImpl::Stop() {
+ // TODO(hclam): delegate to google's media player
+}
+
+void WebMediaPlayerDelegateImpl::Seek(float time) {
+ // TODO(hclam): delegate to google's media player
+}
+
+void WebMediaPlayerDelegateImpl::SetEndTime(float time) {
+ // TODO(hclam): delegate to google's media player
+}
+
+void WebMediaPlayerDelegateImpl::SetPlaybackRate(float rate) {
+ // TODO(hclam): delegate to google's media player
+}
+
+void WebMediaPlayerDelegateImpl::SetVolume(float volume) {
+ // TODO(hclam): delegate to google's media player
+}
+
+void WebMediaPlayerDelegateImpl::SetVisible(bool visible) {
+ // TODO(hclam): delegate to google's media player
+}
+
+bool WebMediaPlayerDelegateImpl::IsTotalBytesKnown() {
+ // TODO(hclam): delegate to google's media player
+ return false;
+}
+
+float WebMediaPlayerDelegateImpl::GetMaxTimeBuffered() const {
+ // TODO(hclam): delegate to google's media player
+ return 0.0f;
+}
+
+float WebMediaPlayerDelegateImpl::GetMaxTimeSeekable() const {
+ // TODO(hclam): delegate to google's media player
+ return 0.0f;
+}
+
+void WebMediaPlayerDelegateImpl::SetRect(const gfx::Rect& rect) {
+ // TODO(hclam): Figure out what to do here..
+}
+
+void WebMediaPlayerDelegateImpl::Paint(skia::PlatformCanvas *canvas,
+ const gfx::Rect& rect) {
+ // TODO(hclam): grab a frame from the internal player and draw it.
+}
diff --git a/chrome/renderer/webmediaplayer_delegate_impl.h b/chrome/renderer/webmediaplayer_delegate_impl.h
new file mode 100644
index 0000000..4e6f53e
--- /dev/null
+++ b/chrome/renderer/webmediaplayer_delegate_impl.h
@@ -0,0 +1,102 @@
+// Copyright (c) 2008 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.
+//
+// Delegate calls from WebCore::MediaPlayerPrivate to google's video player.
+// It is a friend of VideoStackMediaPlayer, which is the actual media player
+// VideoStackMediaPlayer will use WebMediaPlayer to create a resource loader
+// and bridges the WebCore::ResourceHandle and media::DataSource, so that
+// VideoStackMediaPlayer would have no knowledge of WebCore::ResourceHandle.
+
+#ifndef CHROME_RENDERER_WEBMEDIAPLAYER_DELEGATE_IMPL_H_
+#define CHROME_RENDERER_WEBMEDIAPLAYER_DELEGATE_IMPL_H_
+
+#include "webkit/glue/webmediaplayer_delegate.h"
+
+namespace media {
+class VideoStackMediaPlayer;
+}
+
+class WebMediaPlayerDelegateImpl : public webkit_glue::WebMediaPlayerDelegate {
+ public:
+ WebMediaPlayerDelegateImpl();
+ virtual ~WebMediaPlayerDelegateImpl();
+
+ virtual void Initialize(webkit_glue::WebMediaPlayer* media_player);
+
+ virtual void Load(const GURL& url);
+ virtual void CancelLoad();
+
+ // Playback controls.
+ virtual void Play();
+ virtual void Pause();
+ virtual void Stop();
+ virtual void Seek(float time);
+ virtual void SetEndTime(float time);
+ virtual void SetPlaybackRate(float rate);
+ virtual void SetVolume(float volume);
+ virtual void SetVisible(bool visible);
+ virtual bool IsTotalBytesKnown();
+
+ // Methods for painting.
+ virtual void SetRect(const gfx::Rect& rect);
+
+ virtual void Paint(skia::PlatformCanvas *canvas, const gfx::Rect& rect);
+
+ // True if a video is loaded.
+ virtual bool IsVideo() const { return video_; }
+
+ // Dimension of the video.
+ virtual size_t GetWidth() const { return width_; }
+ virtual size_t GetHeight() const { return height_; }
+
+ // Getters fo playback state.
+ virtual bool IsPaused() const { return paused_; }
+ virtual bool IsSeeking() const { return seeking_; }
+ virtual float GetDuration() const { return duration_; }
+ virtual float GetCurrentTime() const { return current_time_; }
+ virtual float GetPlayBackRate() const { return playback_rate_; }
+ virtual float GetVolume() const { return volume_; }
+ virtual float GetMaxTimeBuffered() const;
+ virtual float GetMaxTimeSeekable() const;
+
+ // Get rate of loading the resource.
+ virtual int32 GetDataRate() const { return data_rate_; }
+
+ // Internal states of loading and network.
+ virtual webkit_glue::WebMediaPlayer::NetworkState GetNetworkState() const {
+ return network_state_;
+ }
+ virtual webkit_glue::WebMediaPlayer::ReadyState GetReadyState() const {
+ return ready_state_;
+ }
+
+ virtual int64 GetBytesLoaded() const { return bytes_loaded_; }
+ virtual int64 GetTotalBytes() const { return total_bytes_; }
+
+ // Inline getters.
+ webkit_glue::WebMediaPlayer* web_media_player() { return web_media_player_; }
+
+ private:
+ int64 bytes_loaded_;
+ float current_time_;
+ int32 data_rate_;
+ float duration_;
+ size_t height_;
+ webkit_glue::WebMediaPlayer::NetworkState network_state_;
+ bool paused_;
+ float playback_rate_;
+ webkit_glue::WebMediaPlayer::ReadyState ready_state_;
+ bool seeking_;
+ int64 total_bytes_;
+ bool video_;
+ media::VideoStackMediaPlayer* video_stack_media_player_;
+ bool visible_;
+ float volume_;
+ webkit_glue::WebMediaPlayer* web_media_player_;
+ size_t width_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerDelegateImpl);
+};
+
+#endif // ifndef CHROME_RENDERER_WEBMEDIAPLAYER_DELEGATE_IMPL_H_
diff --git a/webkit/build/WebCore/SConscript b/webkit/build/WebCore/SConscript
index 4f9a1ef3..fdab0a5 100644
--- a/webkit/build/WebCore/SConscript
+++ b/webkit/build/WebCore/SConscript
@@ -438,7 +438,6 @@ input_files = [
'$WEBCORE_DIR/platform/graphics/Image.cpp',
'$WEBCORE_DIR/platform/graphics/IntRect.cpp',
'$WEBCORE_DIR/platform/graphics/MediaPlayer.cpp',
- '$PORT_DIR/platform/graphics/chromium/MediaPlayerPrivateChromium.cpp',
'$WEBCORE_DIR/platform/graphics/Path.cpp',
'$WEBCORE_DIR/platform/graphics/PathTraversalState.cpp',
'$WEBCORE_DIR/platform/graphics/Pattern.cpp',
diff --git a/webkit/build/glue/glue.vcproj b/webkit/build/glue/glue.vcproj
index b391a24..26901a7 100644
--- a/webkit/build/glue/glue.vcproj
+++ b/webkit/build/glue/glue.vcproj
@@ -193,6 +193,14 @@
>
</File>
<File
+ RelativePath="..\..\glue\webmediaplayer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\glue\webmediaplayer_delegate.h"
+ >
+ </File>
+ <File
RelativePath="..\..\glue\webplugin.h"
>
</File>
@@ -441,6 +449,10 @@
>
</File>
<File
+ RelativePath="..\..\glue\media_player_private_impl.cc"
+ >
+ </File>
+ <File
RelativePath="..\..\glue\multipart_response_delegate.cc"
>
</File>
@@ -601,6 +613,14 @@
>
</File>
<File
+ RelativePath="..\..\glue\webmediaplayer_impl.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\glue\webmediaplayer_impl.h"
+ >
+ </File>
+ <File
RelativePath="..\..\glue\webplugin_impl.cc"
>
</File>
diff --git a/webkit/build/port/port.vcproj b/webkit/build/port/port.vcproj
index 14f8499..b388f20 100644
--- a/webkit/build/port/port.vcproj
+++ b/webkit/build/port/port.vcproj
@@ -1143,10 +1143,6 @@
>
</File>
<File
- RelativePath="..\..\port\platform\graphics\chromium\MediaPlayerPrivateChromium.cpp"
- >
- </File>
- <File
RelativePath="..\..\port\platform\graphics\chromium\MediaPlayerPrivateChromium.h"
>
</File>
diff --git a/webkit/glue/SConscript b/webkit/glue/SConscript
index e613d0b..68e16bd 100644
--- a/webkit/glue/SConscript
+++ b/webkit/glue/SConscript
@@ -50,6 +50,7 @@ input_files = [
'image_resource_fetcher.cc',
'inspector_client_impl.cc',
'localized_strings.cc',
+ 'media_player_private_impl.cc',
'multipart_response_delegate.cc',
'npruntime_util.cc',
'password_autocomplete_listener.cc',
@@ -72,6 +73,7 @@ input_files = [
'webframeloaderclient_impl.cc',
'webhistoryitem_impl.cc',
'webkit_glue.cc',
+ 'webmediaplayer_impl.cc',
'webplugin_impl.cc',
'webtextinput_impl.cc',
'weburlrequest_impl.cc',
diff --git a/webkit/glue/media_player_private_impl.cc b/webkit/glue/media_player_private_impl.cc
new file mode 100644
index 0000000..2112507
--- /dev/null
+++ b/webkit/glue/media_player_private_impl.cc
@@ -0,0 +1,301 @@
+// Copyright (c) 2006-2008 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 "config.h"
+
+#if ENABLE(VIDEO)
+
+#include "GraphicsContext.h"
+#include "IntRect.h"
+#include "MediaPlayerPrivateChromium.h"
+#include "PlatformContextSkia.h"
+#undef LOG
+
+#include "googleurl/src/gurl.h"
+#include "webkit/glue/glue_util.h"
+#include "webkit/glue/webframe.h"
+#include "webkit/glue/webkit_glue.h"
+#include "webkit/glue/webmediaplayer.h"
+#include "webkit/glue/webmediaplayer_impl.h"
+#include "webkit/glue/webmediaplayer_delegate.h"
+#include "webkit/glue/webview.h"
+#include "webkit/glue/webview_delegate.h"
+
+namespace WebCore {
+
+// We can't create the delegate here because m_player->frameView is null at
+// this moment. Although we can static_cast the MediaPlayerClient to
+// HTMLElement and get the frame from there, but creating the delegate from
+// load() seems to be a better idea.
+MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
+ : m_player(player),
+ m_delegate(NULL) {
+}
+
+MediaPlayerPrivate::~MediaPlayerPrivate() {
+ // Delete the delegate, it should delete the associated WebMediaPlayer.
+ delete m_delegate;
+}
+
+void MediaPlayerPrivate::load(const String& url) {
+ // Delete the delegate if it already exists. Because we may be in a different
+ // view since last load. WebMediaPlayer uses the view internally when
+ // using ResourceHandle, WebMediaPlayerDelegate contains the actual media
+ // player, in order to hook the actual media player with ResourceHandle in
+ // WebMediaPlayer given the new view, we destroy the old
+ // WebMediaPlayerDelegate and WebMediaPlayer and create a new set of both.
+ delete m_delegate;
+ m_delegate = NULL;
+
+ webkit_glue::WebMediaPlayer* media_player =
+ new webkit_glue::WebMediaPlayerImpl(this);
+ WebViewDelegate* d = media_player->GetWebFrame()->GetView()->GetDelegate();
+
+ m_delegate = d->CreateMediaPlayerDelegate();
+ // In case we couldn't create a delegate.
+ if (m_delegate) {
+ m_delegate->Initialize(media_player);
+ media_player->Initialize(m_delegate);
+
+ m_delegate->Load(webkit_glue::StringToGURL(url));
+ }
+}
+
+void MediaPlayerPrivate::cancelLoad() {
+ if (m_delegate) {
+ m_delegate->CancelLoad();
+ }
+}
+
+IntSize MediaPlayerPrivate::naturalSize() const {
+ if (m_delegate) {
+ return IntSize(m_delegate->GetWidth(), m_delegate->GetHeight());
+ } else {
+ return IntSize(0, 0);
+ }
+}
+
+bool MediaPlayerPrivate::hasVideo() const {
+ if (m_delegate) {
+ return m_delegate->IsVideo();
+ } else {
+ return false;
+ }
+}
+
+void MediaPlayerPrivate::play() {
+ if (m_delegate) {
+ m_delegate->Play();
+ }
+}
+
+void MediaPlayerPrivate::pause() {
+ if (m_delegate) {
+ m_delegate->Pause();
+ }
+}
+
+bool MediaPlayerPrivate::paused() const {
+ if (m_delegate) {
+ return m_delegate->IsPaused();
+ } else {
+ return true;
+ }
+}
+
+bool MediaPlayerPrivate::seeking() const {
+ if (m_delegate) {
+ return m_delegate->IsSeeking();
+ } else {
+ return false;
+ }
+}
+
+float MediaPlayerPrivate::duration() const {
+ if (m_delegate) {
+ return m_delegate->GetDuration();
+ } else {
+ return 0.0f;
+ }
+}
+
+float MediaPlayerPrivate::currentTime() const {
+ if (m_delegate) {
+ return m_delegate->GetCurrentTime();
+ } else {
+ return 0.0f;
+ }
+}
+
+void MediaPlayerPrivate::seek(float time) {
+ if (m_delegate) {
+ m_delegate->Seek(time);
+ }
+}
+
+void MediaPlayerPrivate::setEndTime(float time) {
+ if (m_delegate) {
+ m_delegate->SetEndTime(time);
+ }
+}
+
+void MediaPlayerPrivate::setRate(float rate) {
+ if (m_delegate) {
+ m_delegate->SetPlaybackRate(rate);
+ }
+}
+
+void MediaPlayerPrivate::setVolume(float volume) {
+ if (m_delegate) {
+ m_delegate->SetVolume(volume);
+ }
+}
+
+int MediaPlayerPrivate::dataRate() const {
+ if (m_delegate) {
+ return m_delegate->GetDataRate();
+ } else {
+ return 0;
+ }
+}
+
+MediaPlayer::NetworkState MediaPlayerPrivate::networkState() const {
+ if (m_delegate) {
+ switch (m_delegate->GetNetworkState()) {
+ case webkit_glue::WebMediaPlayer::EMPTY:
+ return MediaPlayer::Empty;
+ case webkit_glue::WebMediaPlayer::LOADED:
+ return MediaPlayer::Loaded;
+ case webkit_glue::WebMediaPlayer::LOADING:
+ return MediaPlayer::Loading;
+ case webkit_glue::WebMediaPlayer::LOAD_FAILED:
+ return MediaPlayer::LoadFailed;
+ case webkit_glue::WebMediaPlayer::LOADED_META_DATA:
+ return MediaPlayer::LoadedMetaData;
+ case webkit_glue::WebMediaPlayer::LOADED_FIRST_FRAME:
+ return MediaPlayer::LoadedFirstFrame;
+ default:
+ return MediaPlayer::Empty;
+ }
+ } else {
+ return MediaPlayer::Empty;
+ }
+}
+
+MediaPlayer::ReadyState MediaPlayerPrivate::readyState() const {
+ if (m_delegate) {
+ switch (m_delegate->GetReadyState()) {
+ case webkit_glue::WebMediaPlayer::CAN_PLAY:
+ return MediaPlayer::CanPlay;
+ case webkit_glue::WebMediaPlayer::CAN_PLAY_THROUGH:
+ return MediaPlayer::CanPlayThrough;
+ case webkit_glue::WebMediaPlayer::CAN_SHOW_CURRENT_FRAME:
+ return MediaPlayer::CanShowCurrentFrame;
+ case webkit_glue::WebMediaPlayer::DATA_UNAVAILABLE:
+ return MediaPlayer::DataUnavailable;
+ default:
+ return MediaPlayer::DataUnavailable;
+ }
+ } else {
+ return MediaPlayer::DataUnavailable;
+ }
+}
+
+float MediaPlayerPrivate::maxTimeBuffered() const {
+ if (m_delegate) {
+ return m_delegate->GetMaxTimeBuffered();
+ } else {
+ return 0.0f;
+ }
+}
+
+float MediaPlayerPrivate::maxTimeSeekable() const {
+ if (m_delegate) {
+ return m_delegate->GetMaxTimeSeekable();
+ } else {
+ return 0.0f;
+ }
+}
+
+unsigned MediaPlayerPrivate::bytesLoaded() const {
+ if (m_delegate) {
+ return static_cast<unsigned>(m_delegate->GetBytesLoaded());
+ } else {
+ return 0;
+ }
+}
+
+bool MediaPlayerPrivate::totalBytesKnown() const {
+ if (m_delegate) {
+ return m_delegate->IsTotalBytesKnown();
+ } else {
+ return false;
+ }
+}
+
+unsigned MediaPlayerPrivate::totalBytes() const {
+ if (m_delegate) {
+ return static_cast<unsigned>(m_delegate->GetTotalBytes());
+ } else {
+ return 0;
+ }
+}
+
+void MediaPlayerPrivate::setVisible(bool visible) {
+ if (m_delegate) {
+ m_delegate->SetVisible(visible);
+ }
+}
+
+void MediaPlayerPrivate::setRect(const IntRect& r) {
+ if (m_delegate) {
+ m_delegate->SetRect(gfx::Rect(r.x(), r.y(), r.width(), r.height()));
+ }
+}
+
+void MediaPlayerPrivate::paint(GraphicsContext* p, const IntRect& r) {
+ if (m_delegate) {
+ gfx::Rect rect(r.x(), r.y(), r.width(), r.height());
+ m_delegate->Paint(p->platformContext()->canvas(), rect);
+ }
+}
+
+// Called from WebMediaPlayer -------------------------------------------------
+FrameView* MediaPlayerPrivate::frameView() {
+ return m_player->m_frameView;
+}
+
+void MediaPlayerPrivate::networkStateChanged() {
+ m_player->networkStateChanged();
+}
+
+void MediaPlayerPrivate::readyStateChanged() {
+ m_player->readyStateChanged();
+}
+
+void MediaPlayerPrivate::timeChanged() {
+ m_player->timeChanged();
+}
+
+void MediaPlayerPrivate::volumeChanged() {
+ m_player->volumeChanged();
+}
+
+void MediaPlayerPrivate::repaint() {
+ m_player->repaint();
+}
+
+// public static methods ------------------------------------------------------
+
+void MediaPlayerPrivate::getSupportedTypes(HashSet<String>& types) {
+ // Do nothing for now.
+}
+
+bool MediaPlayerPrivate::isAvailable() {
+ return webkit_glue::IsMediaPlayerAvailable();
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h
index f865b0f..60052dc 100644
--- a/webkit/glue/webframe.h
+++ b/webkit/glue/webframe.h
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "base/ref_counted.h"
+#include "base/scoped_ptr.h"
#include "base/gfx/size.h"
#include "skia/ext/bitmap_platform_device.h"
#include "skia/ext/platform_canvas.h"
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index 843c6e7..78ad7ee 100644
--- a/webkit/glue/webkit_glue.h
+++ b/webkit/glue/webkit_glue.h
@@ -127,6 +127,10 @@ bool DecodeImage(const std::string& image_data, SkBitmap* image);
//-----------------------------------------------------------------------------
// Functions implemented by the embedder, called by WebKit:
+// This function is called from WebCore::MediaPlayerPrivate,
+// Returns true if media player is available and can be created.
+bool IsMediaPlayerAvailable();
+
// This function is called to request a prefetch of the DNS resolution for the
// provided hostname.
void PrefetchDns(const std::string& hostname);
diff --git a/webkit/glue/webmediaplayer.h b/webkit/glue/webmediaplayer.h
new file mode 100644
index 0000000..3dfbd31
--- /dev/null
+++ b/webkit/glue/webmediaplayer.h
@@ -0,0 +1,63 @@
+// Copyright (c) 2008 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_WEBMEDIAPLAYER_H_
+#define WEBKIT_GLUE_WEBMEDIAPLAYER_H_
+
+#include "base/basictypes.h"
+
+class WebFrame;
+
+namespace webkit_glue {
+
+class WebMediaPlayerDelegate;
+
+class WebMediaPlayer {
+public:
+ enum NetworkState {
+ EMPTY,
+ LOAD_FAILED,
+ LOADING,
+ LOADED_META_DATA,
+ LOADED_FIRST_FRAME,
+ LOADED
+ };
+
+ enum ReadyState {
+ DATA_UNAVAILABLE,
+ CAN_SHOW_CURRENT_FRAME,
+ CAN_PLAY,
+ CAN_PLAY_THROUGH
+ };
+
+ WebMediaPlayer() {}
+ virtual ~WebMediaPlayer() {}
+
+ virtual void Initialize(WebMediaPlayerDelegate* delegate) = 0;
+
+ // Get the web frame associated with the media player
+ virtual WebFrame* GetWebFrame() = 0;
+
+ // Notify the media player about network state change.
+ virtual void NotifynetworkStateChange() = 0;
+
+ // Notify the media player about ready state change.
+ virtual void NotifyReadyStateChange() = 0;
+
+ // Notify the media player about time change.
+ virtual void NotifyTimeChange() = 0;
+
+ // Notify the media player about volume change.
+ virtual void NotifyVolumeChange() = 0;
+
+ // Tell the media player to repaint itself.
+ virtual void Repaint() = 0;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(WebMediaPlayer);
+};
+
+} // namespace webkit_glue
+
+#endif // ifndef WEBKIT_GLUE_WEBMEDIAPLAYER_H_
diff --git a/webkit/glue/webmediaplayer_delegate.h b/webkit/glue/webmediaplayer_delegate.h
new file mode 100644
index 0000000..ee2d553
--- /dev/null
+++ b/webkit/glue/webmediaplayer_delegate.h
@@ -0,0 +1,80 @@
+// Copyright (c) 2008 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_WEBMEDIAPLAYER_DELEGATE_H_
+#define WEBKIT_GLUE_WEBMEDIAPLAYER_DELEGATE_H_
+
+#include "base/gfx/platform_canvas.h"
+#include "webkit/glue/webmediaplayer.h"
+
+class GURL;
+
+namespace gfx {
+class Rect;
+}
+
+namespace webkit_glue {
+
+class WebMediaPlayerDelegate {
+ public:
+ WebMediaPlayerDelegate() {}
+ virtual ~WebMediaPlayerDelegate() {}
+
+ virtual void Initialize(WebMediaPlayer *web_media_player) = 0;
+
+ virtual void Load(const GURL& url) = 0;
+ virtual void CancelLoad() = 0;
+
+ // Playback controls.
+ virtual void Play() = 0;
+ virtual void Pause() = 0;
+ virtual void Stop() = 0;
+ virtual void Seek(float time) = 0;
+ virtual void SetEndTime(float time) = 0;
+ virtual void SetPlaybackRate(float rate) = 0;
+ virtual void SetVolume(float volume) = 0;
+ virtual void SetVisible(bool visible) = 0;
+ virtual bool IsTotalBytesKnown() = 0;
+ virtual float GetMaxTimeBuffered() const = 0;
+ virtual float GetMaxTimeSeekable() const = 0;
+
+ // Methods for painting.
+ virtual void SetRect(const gfx::Rect& rect) = 0;
+
+ // TODO(hclam): Using paint at the moment, maybe we just need to return a
+ // SkiaBitmap?
+ virtual void Paint(skia::PlatformCanvas *canvas, const gfx::Rect& rect) = 0;
+
+ // True if a video is loaded.
+ virtual bool IsVideo() const = 0;
+
+ // Dimension of the video.
+ virtual size_t GetWidth() const = 0;
+ virtual size_t GetHeight() const = 0;
+
+ // Getters fo playback state.
+ virtual bool IsPaused() const = 0;
+ virtual bool IsSeeking() const = 0;
+ virtual float GetDuration() const = 0;
+ virtual float GetCurrentTime() const = 0;
+ virtual float GetPlayBackRate() const = 0;
+ virtual float GetVolume() const = 0;
+
+ // Get rate of loading the resource.
+ virtual int32 GetDataRate() const = 0;
+
+ // Internal states of loading and network.
+ virtual WebMediaPlayer::NetworkState GetNetworkState() const = 0;
+ virtual WebMediaPlayer::ReadyState GetReadyState() const = 0;
+
+ virtual int64 GetBytesLoaded() const = 0;
+ virtual int64 GetTotalBytes() const = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerDelegate);
+};
+
+} // namespace webkit_glue
+
+#endif // ifndef WEBKIT_GLUE_WEBMEDIAPLAYER_DELEGATE_H_
diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc
new file mode 100644
index 0000000..d743886
--- /dev/null
+++ b/webkit/glue/webmediaplayer_impl.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 2008 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 "config.h"
+
+#include "FrameView.h"
+#include "MediaPlayerPrivateChromium.h"
+#undef LOG
+
+#include "webkit/glue/webframe_impl.h"
+#include "webkit/glue/webmediaplayer_impl.h"
+
+#if ENABLE(VIDEO)
+
+namespace webkit_glue {
+
+WebMediaPlayerImpl::WebMediaPlayerImpl(
+ WebCore::MediaPlayerPrivate* media_player_private)
+ : media_player_private_(media_player_private) {
+}
+
+WebMediaPlayerImpl::~WebMediaPlayerImpl() {
+}
+
+void WebMediaPlayerImpl::Initialize(WebMediaPlayerDelegate* delegate){
+ delegate_ = delegate;
+}
+
+WebFrame* WebMediaPlayerImpl::GetWebFrame() {
+ if (media_player_private_->frameView()->frame()) {
+ return WebFrameImpl::FromFrame(
+ media_player_private_->frameView()->frame());
+ } else {
+ return NULL;
+ }
+}
+
+void WebMediaPlayerImpl::NotifynetworkStateChange() {
+ media_player_private_->networkStateChanged();
+}
+
+void WebMediaPlayerImpl::NotifyReadyStateChange() {
+ media_player_private_->readyStateChanged();
+}
+
+void WebMediaPlayerImpl::NotifyTimeChange() {
+ media_player_private_->timeChanged();
+}
+
+void WebMediaPlayerImpl::NotifyVolumeChange() {
+ media_player_private_->volumeChanged();
+}
+
+void WebMediaPlayerImpl::Repaint() {
+ media_player_private_->repaint();
+}
+
+} // namespace webkit_glue
+
+#endif
diff --git a/webkit/glue/webmediaplayer_impl.h b/webkit/glue/webmediaplayer_impl.h
new file mode 100644
index 0000000..e8ed8f2
--- /dev/null
+++ b/webkit/glue/webmediaplayer_impl.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2008 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.
+//
+// Wrapper over WebCore::MediaPlayerPrivate. It also would handle resource
+// loading for the internal media player.
+
+#ifndef WEBKIT_GLUE_WEBMEDIAPLAYER_IMPL_H_
+#define WEBKIT_GLUE_WEBMEDIAPLAYER_IMPL_H_
+
+#include "webkit/glue/webmediaplayer.h"
+
+#if ENABLE(VIDEO)
+
+namespace WebCore {
+class MediaPlayerPrivate;
+}
+
+namespace webkit_glue {
+
+class WebMediaPlayerDelegate;
+
+class WebMediaPlayerImpl : public WebMediaPlayer {
+public:
+ WebMediaPlayerImpl(WebCore::MediaPlayerPrivate* media_player_private);
+
+ virtual ~WebMediaPlayerImpl();
+
+ virtual void Initialize(WebMediaPlayerDelegate* delegate);
+
+ // Get the web frame associated with the media player
+ virtual WebFrame* GetWebFrame();
+
+ // Notify the media player about network state change.
+ virtual void NotifynetworkStateChange();
+
+ // Notify the media player about ready state change.
+ virtual void NotifyReadyStateChange();
+
+ // Notify the media player about time change.
+ virtual void NotifyTimeChange();
+
+ // Notify the media player about volume change.
+ virtual void NotifyVolumeChange();
+
+ // Tell the media player to repaint itself.
+ virtual void Repaint();
+
+private:
+ WebCore::MediaPlayerPrivate* media_player_private_;
+ WebMediaPlayerDelegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
+};
+
+} // namespace webkit_glue
+
+#endif // ENABLE(VIDEO)
+
+#endif // ifndef WEBKIT_GLUE_WEBMEDIAPLAYER_H_
diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h
index cfdc99e..0ffd764 100644
--- a/webkit/glue/webview_delegate.h
+++ b/webkit/glue/webview_delegate.h
@@ -37,8 +37,12 @@
#include "webkit/glue/window_open_disposition.h"
namespace gfx {
- class Point;
- class Rect;
+class Point;
+class Rect;
+}
+
+namespace webkit_glue {
+class WebMediaPlayerDelegate;
}
struct PasswordForm;
@@ -49,6 +53,7 @@ class SkBitmap;
class WebError;
class WebFrame;
class WebHistoryItem;
+class WebMediaPlayerDelegate;
class WebPluginDelegate;
class WebRequest;
class WebResponse;
@@ -128,6 +133,11 @@ class WebViewDelegate : virtual public WebWidgetDelegate {
return NULL;
}
+ // Called when a WebMediaPlayerDelegate is needed.
+ virtual webkit_glue::WebMediaPlayerDelegate* CreateMediaPlayerDelegate() {
+ return NULL;
+ }
+
// This method is called when default plugin has been correctly created and
// initialized, and found that the missing plugin is available to install or
// user has started installation.
diff --git a/webkit/port/platform/graphics/chromium/MediaPlayerPrivateChromium.h b/webkit/port/platform/graphics/chromium/MediaPlayerPrivateChromium.h
index 42280df..06aeeb4 100644
--- a/webkit/port/platform/graphics/chromium/MediaPlayerPrivateChromium.h
+++ b/webkit/port/platform/graphics/chromium/MediaPlayerPrivateChromium.h
@@ -1,5 +1,5 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
+// Copyright (c) 2006-2008 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 MediaPlayerPrivateChromium_h
@@ -9,6 +9,10 @@
#include "MediaPlayer.h"
+namespace webkit_glue {
+class WebMediaPlayerDelegate;
+}
+
namespace WebCore {
class MediaPlayerPrivate : public Noncopyable {
@@ -50,20 +54,25 @@ namespace WebCore {
void setVisible(bool);
void setRect(const IntRect&);
- void loadStateChanged();
- void didEnd();
-
void paint(GraphicsContext*, const IntRect&);
static void getSupportedTypes(HashSet<String>& types);
static bool isAvailable();
+ // Public methods to be called by WebMediaPlayer
+ FrameView* frameView();
+ void networkStateChanged();
+ void readyStateChanged();
+ void timeChanged();
+ void volumeChanged();
+ void repaint();
+
private:
MediaPlayer* m_player;
- MediaPlayer::NetworkState m_networkState;
- MediaPlayer::ReadyState m_readyState;
+ // TODO(hclam): MediaPlayerPrivateChromium should not know
+ // WebMediaPlayerDelegate, will need to get rid of this later.
+ webkit_glue::WebMediaPlayerDelegate* m_delegate;
};
-
}
#endif
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index 4d7404b..b62d62f 100644
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -33,6 +33,7 @@
#include "webkit/glue/webwidget.h"
#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
#include "webkit/tools/test_shell/test_navigation_controller.h"
+#include "webkit/tools/test_shell/test_shell_switches.h"
#if defined(OS_MACOSX)
#include "webkit/glue/bogus_webkit_strings.h"
@@ -442,6 +443,10 @@ void TestShell::SetFocus(WebWidgetHost* host, bool enable) {
namespace webkit_glue {
+bool IsMediaPlayerAvailable() {
+ return CommandLine().HasSwitch(test_shell::kEnableVideo);
+}
+
void PrefetchDns(const std::string& hostname) {}
void PrecacheUrl(const char16* url, int url_length) {}
diff --git a/webkit/tools/test_shell/test_shell_switches.cc b/webkit/tools/test_shell/test_shell_switches.cc
index 214dd96..54e7af3 100644
--- a/webkit/tools/test_shell/test_shell_switches.cc
+++ b/webkit/tools/test_shell/test_shell_switches.cc
@@ -67,5 +67,8 @@ const wchar_t kAllowScriptsToCloseWindows[] = L"allow-scripts-to-close-windows";
extern const wchar_t kCheckLayoutTestSystemDeps[] =
L"check-layout-test-sys-deps";
+// Enable the media player by having this switch.
+extern const wchar_t kEnableVideo[] = L"enable-video";
+
} // namespace test_shell
diff --git a/webkit/tools/test_shell/test_shell_switches.h b/webkit/tools/test_shell/test_shell_switches.h
index 450c5ee..22bc982 100644
--- a/webkit/tools/test_shell/test_shell_switches.h
+++ b/webkit/tools/test_shell/test_shell_switches.h
@@ -29,6 +29,7 @@ extern const wchar_t kUseWinHttp[];
extern const wchar_t kEnableTracing[];
extern const wchar_t kAllowScriptsToCloseWindows[];
extern const wchar_t kCheckLayoutTestSystemDeps[];
+extern const wchar_t kEnableVideo[];
} // namespace test_shell