summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqinmin@chromium.org <qinmin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-26 23:32:19 +0000
committerqinmin@chromium.org <qinmin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-26 23:32:19 +0000
commit105144399acf8a52f8793ed72b71a842573a0f65 (patch)
tree246b823690b3f497a8c3cfcd9d80a56bbb8a78e1
parentd87a294ccb29c6680b6bb1f88ee0e3672b67ddfa (diff)
downloadchromium_src-105144399acf8a52f8793ed72b71a842573a0f65.zip
chromium_src-105144399acf8a52f8793ed72b71a842573a0f65.tar.gz
chromium_src-105144399acf8a52f8793ed72b71a842573a0f65.tar.bz2
Merge MediaPlayerAndroid with MediaPlayerImplAndroid.
After deleting the MediaPlayerInProcessAndroid, we no longer need to have a base WMPA class for android. Merging these 2 classes into a single one. Review URL: https://chromiumcodereview.appspot.com/14203003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196877 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/renderer/media/webmediaplayer_proxy_impl_android.cc42
-rw-r--r--content/renderer/media/webmediaplayer_proxy_impl_android.h8
-rw-r--r--content/renderer/render_view_impl.cc3
-rw-r--r--webkit/media/android/webmediaplayer_android.cc97
-rw-r--r--webkit/media/android/webmediaplayer_android.h100
-rw-r--r--webkit/media/android/webmediaplayer_impl_android.cc141
-rw-r--r--webkit/media/android/webmediaplayer_impl_android.h92
-rw-r--r--webkit/media/webkit_media.gypi2
8 files changed, 158 insertions, 327 deletions
diff --git a/content/renderer/media/webmediaplayer_proxy_impl_android.cc b/content/renderer/media/webmediaplayer_proxy_impl_android.cc
index d89ec3f..0a164ae 100644
--- a/content/renderer/media/webmediaplayer_proxy_impl_android.cc
+++ b/content/renderer/media/webmediaplayer_proxy_impl_android.cc
@@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/message_loop.h"
#include "content/common/media/media_player_messages.h"
-#include "webkit/media/android/webmediaplayer_impl_android.h"
+#include "webkit/media/android/webmediaplayer_android.h"
#include "webkit/media/android/webmediaplayer_manager_android.h"
namespace content {
@@ -81,94 +81,82 @@ void WebMediaPlayerProxyImplAndroid::OnMediaMetadataChanged(
int width,
int height,
bool success) {
- webkit_media::WebMediaPlayerImplAndroid* player =
- GetWebMediaPlayer(player_id);
+ webkit_media::WebMediaPlayerAndroid* player = GetWebMediaPlayer(player_id);
if (player)
player->OnMediaMetadataChanged(duration, width, height, success);
}
void WebMediaPlayerProxyImplAndroid::OnMediaPlaybackCompleted(
int player_id) {
- webkit_media::WebMediaPlayerImplAndroid* player =
- GetWebMediaPlayer(player_id);
+ webkit_media::WebMediaPlayerAndroid* player = GetWebMediaPlayer(player_id);
if (player)
player->OnPlaybackComplete();
}
void WebMediaPlayerProxyImplAndroid::OnMediaBufferingUpdate(
int player_id, int percent) {
- webkit_media::WebMediaPlayerImplAndroid* player =
- GetWebMediaPlayer(player_id);
+ webkit_media::WebMediaPlayerAndroid* player = GetWebMediaPlayer(player_id);
if (player)
player->OnBufferingUpdate(percent);
}
void WebMediaPlayerProxyImplAndroid::OnMediaSeekCompleted(
int player_id, base::TimeDelta current_time) {
- webkit_media::WebMediaPlayerImplAndroid* player =
- GetWebMediaPlayer(player_id);
+ webkit_media::WebMediaPlayerAndroid* player = GetWebMediaPlayer(player_id);
if (player)
player->OnSeekComplete(current_time);
}
void WebMediaPlayerProxyImplAndroid::OnMediaError(
int player_id, int error) {
- webkit_media::WebMediaPlayerImplAndroid* player =
- GetWebMediaPlayer(player_id);
+ webkit_media::WebMediaPlayerAndroid* player = GetWebMediaPlayer(player_id);
if (player)
player->OnMediaError(error);
}
void WebMediaPlayerProxyImplAndroid::OnVideoSizeChanged(
int player_id, int width, int height) {
- webkit_media::WebMediaPlayerImplAndroid* player =
- GetWebMediaPlayer(player_id);
+ webkit_media::WebMediaPlayerAndroid* player = GetWebMediaPlayer(player_id);
if (player)
player->OnVideoSizeChanged(width, height);
}
void WebMediaPlayerProxyImplAndroid::OnTimeUpdate(
int player_id, base::TimeDelta current_time) {
- webkit_media::WebMediaPlayerImplAndroid* player =
- GetWebMediaPlayer(player_id);
+ webkit_media::WebMediaPlayerAndroid* player = GetWebMediaPlayer(player_id);
if (player)
player->OnTimeUpdate(current_time);
}
void WebMediaPlayerProxyImplAndroid::OnMediaPlayerReleased(
int player_id) {
- webkit_media::WebMediaPlayerImplAndroid* player =
- GetWebMediaPlayer(player_id);
+ webkit_media::WebMediaPlayerAndroid* player = GetWebMediaPlayer(player_id);
if (player)
player->OnPlayerReleased();
}
void WebMediaPlayerProxyImplAndroid::OnDidEnterFullscreen(
int player_id) {
- webkit_media::WebMediaPlayerImplAndroid* player =
- GetWebMediaPlayer(player_id);
+ webkit_media::WebMediaPlayerAndroid* player = GetWebMediaPlayer(player_id);
if (player)
player->OnDidEnterFullscreen();
}
void WebMediaPlayerProxyImplAndroid::OnDidExitFullscreen(
int player_id) {
- webkit_media::WebMediaPlayerImplAndroid* player =
- GetWebMediaPlayer(player_id);
+ webkit_media::WebMediaPlayerAndroid* player = GetWebMediaPlayer(player_id);
if (player)
player->OnDidExitFullscreen();
}
void WebMediaPlayerProxyImplAndroid::OnPlayerPlay(int player_id) {
- webkit_media::WebMediaPlayerImplAndroid* player =
- GetWebMediaPlayer(player_id);
+ webkit_media::WebMediaPlayerAndroid* player = GetWebMediaPlayer(player_id);
if (player)
player->OnMediaPlayerPlay();
}
void WebMediaPlayerProxyImplAndroid::OnPlayerPause(int player_id) {
- webkit_media::WebMediaPlayerImplAndroid* player =
- GetWebMediaPlayer(player_id);
+ webkit_media::WebMediaPlayerAndroid* player = GetWebMediaPlayer(player_id);
if (player)
player->OnMediaPlayerPause();
}
@@ -199,9 +187,9 @@ void WebMediaPlayerProxyImplAndroid::DidCommitCompositorFrame() {
}
#endif
-webkit_media::WebMediaPlayerImplAndroid*
+webkit_media::WebMediaPlayerAndroid*
WebMediaPlayerProxyImplAndroid::GetWebMediaPlayer(int player_id) {
- return static_cast<webkit_media::WebMediaPlayerImplAndroid*>(
+ return static_cast<webkit_media::WebMediaPlayerAndroid*>(
manager_->GetMediaPlayer(player_id));
}
diff --git a/content/renderer/media/webmediaplayer_proxy_impl_android.h b/content/renderer/media/webmediaplayer_proxy_impl_android.h
index 2175b3d..74830cd 100644
--- a/content/renderer/media/webmediaplayer_proxy_impl_android.h
+++ b/content/renderer/media/webmediaplayer_proxy_impl_android.h
@@ -11,14 +11,14 @@
#include "webkit/media/android/webmediaplayer_proxy_android.h"
namespace webkit_media {
-class WebMediaPlayerImplAndroid;
+class WebMediaPlayerAndroid;
class WebMediaPlayerManagerAndroid;
}
namespace content {
// This class manages all the IPC communications between
-// WebMediaPlayerImplAndroid and the MediaPlayerManagerAndroid in the browser
+// WebMediaPlayerAndroid and the MediaPlayerManagerAndroid in the browser
// process.
class WebMediaPlayerProxyImplAndroid
: public RenderViewObserver,
@@ -26,7 +26,7 @@ class WebMediaPlayerProxyImplAndroid
public:
// Construct a WebMediaPlayerProxyImplAndroid object for the |render_view|.
// |manager| is passed to this class so that it can find the right
- // WebMediaPlayerImplAndroid using player IDs.
+ // WebMediaPlayerAndroid using player IDs.
WebMediaPlayerProxyImplAndroid(
RenderView* render_view,
webkit_media::WebMediaPlayerManagerAndroid* manager);
@@ -52,7 +52,7 @@ class WebMediaPlayerProxyImplAndroid
#endif
private:
- webkit_media::WebMediaPlayerImplAndroid* GetWebMediaPlayer(int player_id);
+ webkit_media::WebMediaPlayerAndroid* GetWebMediaPlayer(int player_id);
// Message handlers.
void OnMediaMetadataChanged(int player_id, base::TimeDelta duration,
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 6f1b764..0a2d66c 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -225,7 +225,6 @@
#include "ui/gfx/rect_f.h"
#include "webkit/media/android/media_player_bridge_manager_impl.h"
#include "webkit/media/android/webmediaplayer_android.h"
-#include "webkit/media/android/webmediaplayer_impl_android.h"
#include "webkit/media/android/webmediaplayer_manager_android.h"
#elif defined(OS_WIN)
// TODO(port): these files are currently Windows only because they concern:
@@ -2700,7 +2699,7 @@ WebMediaPlayer* RenderViewImpl::createMediaPlayer(
media_player_proxy_ = new WebMediaPlayerProxyImplAndroid(
this, media_player_manager_.get());
}
- return new webkit_media::WebMediaPlayerImplAndroid(
+ return new webkit_media::WebMediaPlayerAndroid(
frame,
client,
media_player_manager_.get(),
diff --git a/webkit/media/android/webmediaplayer_android.cc b/webkit/media/android/webmediaplayer_android.cc
index 728dfcbe..317c256 100644
--- a/webkit/media/android/webmediaplayer_android.cc
+++ b/webkit/media/android/webmediaplayer_android.cc
@@ -13,9 +13,13 @@
#include "media/base/android/media_player_bridge.h"
#include "media/base/video_frame.h"
#include "net/base/mime_util.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerClient.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "webkit/compositor_bindings/web_layer_impl.h"
#include "webkit/media/android/webmediaplayer_manager_android.h"
+#include "webkit/media/android/webmediaplayer_proxy_android.h"
#include "webkit/media/media_switches.h"
#include "webkit/media/webmediaplayer_util.h"
@@ -32,10 +36,13 @@ using media::VideoFrame;
namespace webkit_media {
WebMediaPlayerAndroid::WebMediaPlayerAndroid(
+ WebKit::WebFrame* frame,
WebKit::WebMediaPlayerClient* client,
WebMediaPlayerManagerAndroid* manager,
+ WebMediaPlayerProxyAndroid* proxy,
StreamTextureFactory* factory)
- : client_(client),
+ : frame_(frame),
+ client_(client),
buffered_(1u),
main_loop_(base::MessageLoop::current()),
pending_seek_(0),
@@ -49,7 +56,9 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid(
has_size_info_(false),
stream_texture_factory_(factory),
needs_external_surface_(false),
- video_frame_provider_client_(NULL) {
+ video_frame_provider_client_(NULL),
+ proxy_(proxy),
+ current_time_(0) {
main_loop_->AddDestructionObserver(this);
if (manager_)
player_id_ = manager_->RegisterMediaPlayer(this);
@@ -65,6 +74,9 @@ WebMediaPlayerAndroid::~WebMediaPlayerAndroid() {
SetVideoFrameProviderClient(NULL);
client_->setWebLayer(NULL);
+ if (proxy_)
+ proxy_->DestroyPlayer(player_id_);
+
if (stream_id_)
stream_texture_factory_->DestroyStreamTexture(texture_id_);
@@ -80,8 +92,15 @@ void WebMediaPlayerAndroid::load(const WebURL& url, CORSMode cors_mode) {
NOTIMPLEMENTED() << "No CORS support";
url_ = url;
+ GURL first_party_url = frame_->document().firstPartyForCookies();
+ if (proxy_) {
+ proxy_->Initialize(player_id_, url_, first_party_url);
+ if (manager_->IsInFullscreen(frame_))
+ proxy_->EnterFullscreen(player_id_);
+ }
- InitializeMediaPlayer(url_);
+ UpdateNetworkState(WebMediaPlayer::NetworkStateLoading);
+ UpdateReadyState(WebMediaPlayer::ReadyStateHaveNothing);
}
void WebMediaPlayerAndroid::load(const WebURL& url,
@@ -98,18 +117,21 @@ void WebMediaPlayerAndroid::play() {
#if defined(GOOGLE_TV)
if (hasVideo() && needs_external_surface_) {
DCHECK(!needs_establish_peer_);
- RequestExternalSurface();
+ if (proxy_)
+ proxy_->RequestExternalSurface(player_id_);
}
#endif
if (hasVideo() && needs_establish_peer_)
EstablishSurfaceTexturePeer();
- PlayInternal();
+ if (paused() && proxy_)
+ proxy_->Start(player_id_);
is_playing_ = true;
}
void WebMediaPlayerAndroid::pause() {
- PauseInternal();
+ if (proxy_)
+ proxy_->Pause(player_id_);
is_playing_ = false;
}
@@ -117,7 +139,8 @@ void WebMediaPlayerAndroid::seek(double seconds) {
pending_seek_ = seconds;
seeking_ = true;
- SeekInternal(ConvertSecondsToTimestamp(seconds));
+ if (proxy_)
+ proxy_->Seek(player_id_, ConvertSecondsToTimestamp(seconds));
}
bool WebMediaPlayerAndroid::supportsFullscreen() const {
@@ -189,7 +212,7 @@ double WebMediaPlayerAndroid::currentTime() const {
if (seeking())
return pending_seek_;
- return GetCurrentTimeInternal();
+ return current_time_;
}
int WebMediaPlayerAndroid::dataRate() const {
@@ -407,6 +430,41 @@ void WebMediaPlayerAndroid::OnVideoSizeChanged(int width, int height) {
ReallocateVideoFrame();
}
+void WebMediaPlayerAndroid::OnTimeUpdate(base::TimeDelta current_time) {
+ current_time_ = static_cast<float>(current_time.InSecondsF());
+}
+
+void WebMediaPlayerAndroid::OnDidEnterFullscreen() {
+ if (!manager_->IsInFullscreen(frame_)) {
+ frame_->view()->willEnterFullScreen();
+ frame_->view()->didEnterFullScreen();
+ manager_->DidEnterFullscreen(frame_);
+ }
+}
+
+void WebMediaPlayerAndroid::OnDidExitFullscreen() {
+ SetNeedsEstablishPeer(true);
+ // We had the fullscreen surface connected to Android MediaPlayer,
+ // so reconnect our surface texture for embedded playback.
+ if (!paused())
+ EstablishSurfaceTexturePeer();
+
+ frame_->view()->willExitFullScreen();
+ frame_->view()->didExitFullScreen();
+ manager_->DidExitFullscreen();
+ client_->repaint();
+}
+
+void WebMediaPlayerAndroid::OnMediaPlayerPlay() {
+ UpdatePlayingState(true);
+ client_->playbackStateChanged();
+}
+
+void WebMediaPlayerAndroid::OnMediaPlayerPause() {
+ UpdatePlayingState(false);
+ client_->playbackStateChanged();
+}
+
void WebMediaPlayerAndroid::UpdateNetworkState(
WebMediaPlayer::NetworkState state) {
network_state_ = state;
@@ -442,7 +500,8 @@ void WebMediaPlayerAndroid::ReleaseMediaResources() {
case WebMediaPlayer::NetworkStateDecodeError:
break;
}
- ReleaseResourcesInternal();
+ if (proxy_)
+ proxy_->ReleaseResources(player_id_);
OnPlayerReleased();
}
@@ -454,16 +513,14 @@ void WebMediaPlayerAndroid::WillDestroyCurrentMessageLoop() {
}
void WebMediaPlayerAndroid::Detach() {
- Destroy();
-
if (stream_id_) {
stream_texture_factory_->DestroyStreamTexture(texture_id_);
stream_id_ = 0;
}
current_frame_ = NULL;
-
manager_ = NULL;
+ proxy_ = NULL;
}
void WebMediaPlayerAndroid::ReallocateVideoFrame() {
@@ -548,4 +605,20 @@ bool WebMediaPlayerAndroid::RetrieveGeometryChange(gfx::RectF* rect) {
}
#endif
+void WebMediaPlayerAndroid::enterFullscreen() {
+ if (proxy_ && manager_->CanEnterFullscreen(frame_)) {
+ proxy_->EnterFullscreen(player_id_);
+ SetNeedsEstablishPeer(false);
+ }
+}
+
+void WebMediaPlayerAndroid::exitFullscreen() {
+ if (proxy_)
+ proxy_->ExitFullscreen(player_id_);
+}
+
+bool WebMediaPlayerAndroid::canEnterFullscreen() const {
+ return manager_->CanEnterFullscreen(frame_);
+}
+
} // namespace webkit_media
diff --git a/webkit/media/android/webmediaplayer_android.h b/webkit/media/android/webmediaplayer_android.h
index 9d01e60..d488786 100644
--- a/webkit/media/android/webmediaplayer_android.h
+++ b/webkit/media/android/webmediaplayer_android.h
@@ -20,6 +20,10 @@
#include "ui/gfx/rect_f.h"
#include "webkit/media/android/stream_texture_factory_android.h"
+namespace WebKit {
+class WebFrame;
+}
+
namespace webkit {
class WebLayerImpl;
}
@@ -27,14 +31,36 @@ class WebLayerImpl;
namespace webkit_media {
class WebMediaPlayerManagerAndroid;
+class WebMediaPlayerProxyAndroid;
-// An abstract class that serves as the common base class for implementing
-// WebKit::WebMediaPlayer on Android.
+// This class implements WebKit::WebMediaPlayer by keeping the android
+// media player in the browser process. It listens to all the status changes
+// sent from the browser process and sends playback controls to the media
+// player.
class WebMediaPlayerAndroid
: public WebKit::WebMediaPlayer,
public cc::VideoFrameProvider,
public base::MessageLoop::DestructionObserver {
public:
+ // Construct a WebMediaPlayerAndroid object. This class communicates
+ // with the MediaPlayerBridge object in the browser process through
+ // |proxy|.
+ // TODO(qinmin): |frame| argument is used to determine whether the current
+ // player can enter fullscreen. This logic should probably be moved into
+ // blink, so that enterFullscreen() will not be called if another video is
+ // already in fullscreen.
+ WebMediaPlayerAndroid(WebKit::WebFrame* frame,
+ WebKit::WebMediaPlayerClient* client,
+ WebMediaPlayerManagerAndroid* manager,
+ WebMediaPlayerProxyAndroid* proxy,
+ StreamTextureFactory* factory);
+ virtual ~WebMediaPlayerAndroid();
+
+ // WebKit::WebMediaPlayer implementation.
+ virtual void enterFullscreen();
+ virtual void exitFullscreen();
+ virtual bool canEnterFullscreen() const;
+
// Resource loading.
virtual void load(const WebKit::WebURL& url, CORSMode cors_mode);
virtual void load(const WebKit::WebURL& url,
@@ -122,7 +148,13 @@ class WebMediaPlayerAndroid
virtual void OnVideoSizeChanged(int width, int height);
// Called to update the current time.
- virtual void OnTimeUpdate(base::TimeDelta current_time) = 0;
+ virtual void OnTimeUpdate(base::TimeDelta current_time);
+
+ // Functions called when media player status changes.
+ void OnMediaPlayerPlay();
+ void OnMediaPlayerPause();
+ void OnDidEnterFullscreen();
+ void OnDidExitFullscreen();
// Called when the player is released.
virtual void OnPlayerReleased();
@@ -132,9 +164,6 @@ class WebMediaPlayerAndroid
// However, the actual GlTexture is not released to keep the video screenshot.
virtual void ReleaseMediaResources();
- // Method to set the surface for video.
- virtual void SetVideoSurface(jobject j_surface) = 0;
-
// Method inherited from DestructionObserver.
virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
@@ -149,63 +178,30 @@ class WebMediaPlayerAndroid
#endif
protected:
- // Construct a WebMediaPlayerAndroid object with reference to the
- // client, manager and stream texture factory.
- WebMediaPlayerAndroid(WebKit::WebMediaPlayerClient* client,
- WebMediaPlayerManagerAndroid* manager,
- StreamTextureFactory* factory);
- virtual ~WebMediaPlayerAndroid();
-
// Helper method to update the playing state.
- virtual void UpdatePlayingState(bool is_playing_);
+ void UpdatePlayingState(bool is_playing_);
// Helper methods for posting task for setting states and update WebKit.
- virtual void UpdateNetworkState(WebKit::WebMediaPlayer::NetworkState state);
- virtual void UpdateReadyState(WebKit::WebMediaPlayer::ReadyState state);
+ void UpdateNetworkState(WebKit::WebMediaPlayer::NetworkState state);
+ void UpdateReadyState(WebKit::WebMediaPlayer::ReadyState state);
// Helper method to reestablish the surface texture peer for android
// media player.
- virtual void EstablishSurfaceTexturePeer();
+ void EstablishSurfaceTexturePeer();
// Requesting whether the surface texture peer needs to be reestablished.
- virtual void SetNeedsEstablishPeer(bool needs_establish_peer);
-
- // Method to be implemented by child classes.
- // Initialize the media player bridge object.
- virtual void InitializeMediaPlayer(GURL url) = 0;
-
- // Inform the media player to start playing.
- virtual void PlayInternal() = 0;
-
- // Inform the media player to pause.
- virtual void PauseInternal() = 0;
-
- // Inform the media player to seek to a particular position.
- virtual void SeekInternal(base::TimeDelta time) = 0;
-
- // Get the current time from the media player.
- virtual double GetCurrentTimeInternal() const = 0;
-
- // Release the Android Media player.
- virtual void ReleaseResourcesInternal() = 0;
-
- // Cleaning up all remaining resources as this object is about to get deleted.
- virtual void Destroy() = 0;
-
- WebKit::WebMediaPlayerClient* client() { return client_; }
-
- int player_id() const { return player_id_; }
-
- WebMediaPlayerManagerAndroid* manager() const { return manager_; }
+ void SetNeedsEstablishPeer(bool needs_establish_peer);
#if defined(GOOGLE_TV)
// Request external surface for out-of-band composition.
- virtual void RequestExternalSurface() = 0;
+ void RequestExternalSurface();
#endif
private:
void ReallocateVideoFrame();
+ WebKit::WebFrame* const frame_;
+
WebKit::WebMediaPlayerClient* const client_;
// Save the list of buffered time ranges.
@@ -282,6 +278,16 @@ class WebMediaPlayerAndroid
gfx::RectF last_computed_rect_;
#endif
+ // Proxy object that delegates method calls on Render Thread.
+ // This object is created on the Render Thread and is only called in the
+ // destructor.
+ WebMediaPlayerProxyAndroid* proxy_;
+
+ // The current playing time. Because the media player is in the browser
+ // process, it will regularly update the |current_time_| by calling
+ // OnTimeUpdate().
+ float current_time_;
+
DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid);
};
diff --git a/webkit/media/android/webmediaplayer_impl_android.cc b/webkit/media/android/webmediaplayer_impl_android.cc
deleted file mode 100644
index 4011885..0000000
--- a/webkit/media/android/webmediaplayer_impl_android.cc
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright (c) 2012 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 "webkit/media/android/webmediaplayer_impl_android.h"
-
-#include "base/bind.h"
-#include "base/logging.h"
-#include "media/base/android/media_player_bridge.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerClient.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
-#include "webkit/media/android/stream_texture_factory_android.h"
-#include "webkit/media/android/webmediaplayer_manager_android.h"
-#include "webkit/media/android/webmediaplayer_proxy_android.h"
-
-using WebKit::WebMediaPlayerClient;
-using WebKit::WebMediaPlayer;
-
-namespace webkit_media {
-
-WebMediaPlayerImplAndroid::WebMediaPlayerImplAndroid(
- WebKit::WebFrame* frame,
- WebMediaPlayerClient* client,
- WebMediaPlayerManagerAndroid* manager,
- WebMediaPlayerProxyAndroid* proxy,
- StreamTextureFactory* factory)
- : WebMediaPlayerAndroid(client, manager, factory),
- frame_(frame),
- proxy_(proxy),
- current_time_(0) {
-}
-
-WebMediaPlayerImplAndroid::~WebMediaPlayerImplAndroid() {
- if (proxy_)
- proxy_->DestroyPlayer(player_id());
-}
-
-void WebMediaPlayerImplAndroid::enterFullscreen() {
- if (proxy_ && manager()->CanEnterFullscreen(frame_)) {
- proxy_->EnterFullscreen(player_id());
- SetNeedsEstablishPeer(false);
- }
-}
-
-void WebMediaPlayerImplAndroid::exitFullscreen() {
- if (proxy_)
- proxy_->ExitFullscreen(player_id());
-}
-
-bool WebMediaPlayerImplAndroid::canEnterFullscreen() const {
- return manager()->CanEnterFullscreen(frame_);
-}
-
-void WebMediaPlayerImplAndroid::InitializeMediaPlayer(GURL url) {
- GURL first_party_url = frame_->document().firstPartyForCookies();
- if (proxy_) {
- proxy_->Initialize(player_id(), url, first_party_url);
- if (manager()->IsInFullscreen(frame_))
- proxy_->EnterFullscreen(player_id());
- }
-
- UpdateNetworkState(WebMediaPlayer::NetworkStateLoading);
- UpdateReadyState(WebMediaPlayer::ReadyStateHaveNothing);
-}
-
-void WebMediaPlayerImplAndroid::PlayInternal() {
- if (paused() && proxy_)
- proxy_->Start(player_id());
-}
-
-void WebMediaPlayerImplAndroid::PauseInternal() {
- if (proxy_)
- proxy_->Pause(player_id());
-}
-
-void WebMediaPlayerImplAndroid::SeekInternal(base::TimeDelta time) {
- if (proxy_)
- proxy_->Seek(player_id(), time);
-}
-
-double WebMediaPlayerImplAndroid::GetCurrentTimeInternal() const {
- return current_time_;
-}
-
-void WebMediaPlayerImplAndroid::ReleaseResourcesInternal() {
- if (proxy_)
- proxy_->ReleaseResources(player_id());
-}
-
-void WebMediaPlayerImplAndroid::OnTimeUpdate(base::TimeDelta current_time) {
- current_time_ = current_time.InSecondsF();
-}
-
-void WebMediaPlayerImplAndroid::OnDidEnterFullscreen() {
- if (!manager()->IsInFullscreen(frame_)) {
- frame_->view()->willEnterFullScreen();
- frame_->view()->didEnterFullScreen();
- manager()->DidEnterFullscreen(frame_);
- }
-}
-
-void WebMediaPlayerImplAndroid::OnDidExitFullscreen() {
- SetNeedsEstablishPeer(true);
- // We had the fullscreen surface connected to Android MediaPlayer,
- // so reconnect our surface texture for embedded playback.
- if (!paused())
- EstablishSurfaceTexturePeer();
-
- frame_->view()->willExitFullScreen();
- frame_->view()->didExitFullScreen();
- manager()->DidExitFullscreen();
- client()->repaint();
-}
-
-void WebMediaPlayerImplAndroid::OnMediaPlayerPlay() {
- UpdatePlayingState(true);
- client()->playbackStateChanged();
-}
-
-void WebMediaPlayerImplAndroid::OnMediaPlayerPause() {
- UpdatePlayingState(false);
- client()->playbackStateChanged();
-}
-
-void WebMediaPlayerImplAndroid::Destroy() {
- proxy_ = NULL;
-}
-
-#if defined(GOOGLE_TV)
-void WebMediaPlayerImplAndroid::RequestExternalSurface() {
- if (proxy_)
- proxy_->RequestExternalSurface(player_id());
-}
-#endif
-
-void WebMediaPlayerImplAndroid::SetVideoSurface(jobject j_surface) {}
-
-} // namespace webkit_media
diff --git a/webkit/media/android/webmediaplayer_impl_android.h b/webkit/media/android/webmediaplayer_impl_android.h
deleted file mode 100644
index ba2ef4d..0000000
--- a/webkit/media/android/webmediaplayer_impl_android.h
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright (c) 2012 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_MEDIA_ANDROID_WEBMEDIAPLAYER_IMPL_ANDROID_H_
-#define WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_IMPL_ANDROID_H_
-
-#include <string>
-
-#include <jni.h>
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h"
-#include "webkit/media/android/webmediaplayer_android.h"
-
-namespace WebKit {
-class WebFrame;
-}
-
-namespace webkit_media {
-
-class StreamTextureFactory;
-class WebMediaPlayerManagerAndroid;
-class WebMediaPlayerProxyAndroid;
-
-// This class implements WebKit::WebMediaPlayer by keeping the android
-// media player in the browser process. It listens to all the status changes
-// sent from the browser process and sends playback controls to the media
-// player.
-class WebMediaPlayerImplAndroid : public WebMediaPlayerAndroid {
- public:
- // Construct a WebMediaPlayerImplAndroid object. This class communicates
- // with the MediaPlayerBridge object in the browser process through
- // |proxy|.
- // TODO(qinmin): |frame| argument is used to determine whether the current
- // player can enter fullscreen.
- WebMediaPlayerImplAndroid(WebKit::WebFrame* frame,
- WebKit::WebMediaPlayerClient* client,
- WebMediaPlayerManagerAndroid* manager,
- WebMediaPlayerProxyAndroid* proxy,
- StreamTextureFactory* factory);
- virtual ~WebMediaPlayerImplAndroid();
-
- // WebKit::WebMediaPlayer implementation.
- virtual void enterFullscreen();
- virtual void exitFullscreen();
- virtual bool canEnterFullscreen() const;
-
- // Functions called when media player status changes.
- void OnMediaPlayerPlay();
- void OnMediaPlayerPause();
- void OnDidEnterFullscreen();
- void OnDidExitFullscreen();
-
- // WebMediaPlayerAndroid implementation.
- virtual void OnTimeUpdate(base::TimeDelta current_time) OVERRIDE;
- virtual void SetVideoSurface(jobject j_surface) OVERRIDE;
-
- private:
- // Methods inherited from WebMediaPlayerAndroid.
- virtual void InitializeMediaPlayer(GURL url) OVERRIDE;
- virtual void PlayInternal() OVERRIDE;
- virtual void PauseInternal() OVERRIDE;
- virtual void SeekInternal(base::TimeDelta time) OVERRIDE;
- virtual double GetCurrentTimeInternal() const OVERRIDE;
- virtual void ReleaseResourcesInternal() OVERRIDE;
- virtual void Destroy() OVERRIDE;
-#if defined(GOOGLE_TV)
- virtual void RequestExternalSurface() OVERRIDE;
-#endif
-
- WebKit::WebFrame* const frame_;
-
- // Proxy object that delegates method calls on Render Thread.
- // This object is created on the Render Thread and is only called in the
- // destructor.
- WebMediaPlayerProxyAndroid* proxy_;
-
- // The current playing time. Because the mediaplayer is in the browser
- // process, it will regularly update the |current_time_| by calling
- // OnTimeUpdate().
- double current_time_;
-
- DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImplAndroid);
-};
-
-} // namespace webkit_media
-
-#endif // WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_IMPL_ANDROID_H_
diff --git a/webkit/media/webkit_media.gypi b/webkit/media/webkit_media.gypi
index 2d57dfb..60cfd69 100644
--- a/webkit/media/webkit_media.gypi
+++ b/webkit/media/webkit_media.gypi
@@ -50,8 +50,6 @@
'android/stream_texture_factory_android.h',
'android/webmediaplayer_android.cc',
'android/webmediaplayer_android.h',
- 'android/webmediaplayer_impl_android.cc',
- 'android/webmediaplayer_impl_android.h',
'android/webmediaplayer_manager_android.cc',
'android/webmediaplayer_manager_android.h',
'android/webmediaplayer_proxy_android.cc',