summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-23 06:59:03 +0000
committeravayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-23 06:59:03 +0000
commit9096c992a09f40feeeda4ba5a7001a1ccd034c3f (patch)
treeb2be27f4b50374e4bb0c46b41fb8e197441f1a8d
parent232005abbc32dfaf8498ef8ee9c15e4f30d1e7e7 (diff)
downloadchromium_src-9096c992a09f40feeeda4ba5a7001a1ccd034c3f.zip
chromium_src-9096c992a09f40feeeda4ba5a7001a1ccd034c3f.tar.gz
chromium_src-9096c992a09f40feeeda4ba5a7001a1ccd034c3f.tar.bz2
[Android] Added ability to inject a custom implementation of MediaPlayerManager to RenderViewHostImpl.
Inlined MediaPlayerManager interface's virtual destructor to remove a single method .cc file. Added a few missing methods to the interface. Fixed includes in the files calling to these methods. Refactoring, thus no new tests. R=bulach@chromium.org, qinmin@chromium.org TBR=scherkus@chromium.org BUG=178307 Review URL: https://chromiumcodereview.appspot.com/15341003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201724 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/android/child_process_launcher_android.cc2
-rw-r--r--content/browser/android/media_player_manager_impl.cc20
-rw-r--r--content/browser/android/media_player_manager_impl.h17
-rw-r--r--content/browser/android/surface_texture_peer_browser_impl.cc2
-rw-r--r--content/browser/renderer_host/render_view_host_impl.cc4
-rw-r--r--content/browser/renderer_host/render_view_host_impl.h14
-rw-r--r--content/browser/web_contents/web_contents_view_android.cc2
-rw-r--r--media/base/android/media_player_manager.cc11
-rw-r--r--media/base/android/media_player_manager.h33
-rw-r--r--media/media.gyp1
10 files changed, 74 insertions, 32 deletions
diff --git a/content/browser/android/child_process_launcher_android.cc b/content/browser/android/child_process_launcher_android.cc
index e14813a..fe91f0f 100644
--- a/content/browser/android/child_process_launcher_android.cc
+++ b/content/browser/android/child_process_launcher_android.cc
@@ -8,13 +8,13 @@
#include "base/android/jni_array.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
-#include "content/browser/android/media_player_manager_impl.h"
#include "content/browser/renderer_host/compositor_impl_android.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "jni/ChildProcessLauncher_jni.h"
#include "media/base/android/media_player_android.h"
+#include "media/base/android/media_player_manager.h"
#include "ui/gl/android/scoped_java_surface.h"
using base::android::AttachCurrentThread;
diff --git a/content/browser/android/media_player_manager_impl.cc b/content/browser/android/media_player_manager_impl.cc
index 461e11d..a97250e 100644
--- a/content/browser/android/media_player_manager_impl.cc
+++ b/content/browser/android/media_player_manager_impl.cc
@@ -18,6 +18,26 @@ using media::MediaPlayerAndroid;
// attempting to release inactive media players.
static const int kMediaPlayerThreshold = 1;
+namespace media {
+
+static MediaPlayerManager::FactoryFunction g_factory_function = NULL;
+
+// static
+void MediaPlayerManager::RegisterFactoryFunction(
+ FactoryFunction factory_function) {
+ g_factory_function = factory_function;
+}
+
+// static
+media::MediaPlayerManager* MediaPlayerManager::Create(
+ content::RenderViewHost* render_view_host) {
+ if (g_factory_function)
+ return g_factory_function(render_view_host);
+ return new content::MediaPlayerManagerImpl(render_view_host);
+}
+
+} // namespace media
+
namespace content {
MediaPlayerManagerImpl::MediaPlayerManagerImpl(
diff --git a/content/browser/android/media_player_manager_impl.h b/content/browser/android/media_player_manager_impl.h
index 7c07679..61c1557 100644
--- a/content/browser/android/media_player_manager_impl.h
+++ b/content/browser/android/media_player_manager_impl.h
@@ -32,8 +32,6 @@ class MediaPlayerManagerImpl
: public RenderViewHostObserver,
public media::MediaPlayerManager {
public:
- // Create a MediaPlayerManagerImpl object for the |render_view_host|.
- explicit MediaPlayerManagerImpl(RenderViewHost* render_view_host);
virtual ~MediaPlayerManagerImpl();
// RenderViewHostObserver overrides.
@@ -72,17 +70,22 @@ class MediaPlayerManagerImpl
virtual void ReleaseMediaResources(
media::MediaPlayerAndroid* player) OVERRIDE;
virtual media::MediaResourceGetter* GetMediaResourceGetter() OVERRIDE;
-
- // Release all the players managed by this object.
- void DestroyAllMediaPlayers();
+ virtual media::MediaPlayerAndroid* GetFullscreenPlayer() OVERRIDE;
+ virtual media::MediaPlayerAndroid* GetPlayer(int player_id) OVERRIDE;
+ virtual void DestroyAllMediaPlayers() OVERRIDE;
#if defined(GOOGLE_TV)
void AttachExternalVideoSurface(int player_id, jobject surface);
void DetachExternalVideoSurface(int player_id);
#endif
- media::MediaPlayerAndroid* GetFullscreenPlayer();
- media::MediaPlayerAndroid* GetPlayer(int player_id);
+ protected:
+ friend MediaPlayerManager* MediaPlayerManager::Create(
+ content::RenderViewHost*);
+
+ // The instance of this class is supposed to be created by either Create()
+ // method of MediaPlayerManager or the derived classes constructors.
+ explicit MediaPlayerManagerImpl(RenderViewHost* render_view_host);
private:
// Message handlers.
diff --git a/content/browser/android/surface_texture_peer_browser_impl.cc b/content/browser/android/surface_texture_peer_browser_impl.cc
index fecc317..ee3e00a 100644
--- a/content/browser/android/surface_texture_peer_browser_impl.cc
+++ b/content/browser/android/surface_texture_peer_browser_impl.cc
@@ -4,11 +4,11 @@
#include "content/browser/android/surface_texture_peer_browser_impl.h"
-#include "content/browser/android/media_player_manager_impl.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "media/base/android/media_player_android.h"
+#include "media/base/android/media_player_manager.h"
#include "ui/gl/android/scoped_java_surface.h"
namespace content {
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index 166a4ff..c8493ed 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -78,7 +78,7 @@
#elif defined(OS_MACOSX)
#include "content/browser/renderer_host/popup_menu_helper_mac.h"
#elif defined(OS_ANDROID)
-#include "content/browser/android/media_player_manager_impl.h"
+#include "media/base/android/media_player_manager.h"
#endif
using base::TimeDelta;
@@ -198,7 +198,7 @@ RenderViewHostImpl::RenderViewHostImpl(
g_created_callbacks.Get().at(i).Run(this);
#if defined(OS_ANDROID)
- media_player_manager_ = new MediaPlayerManagerImpl(this);
+ media_player_manager_ = media::MediaPlayerManager::Create(this);
#endif
}
diff --git a/content/browser/renderer_host/render_view_host_impl.h b/content/browser/renderer_host/render_view_host_impl.h
index c96e0f3..d4a6e5d 100644
--- a/content/browser/renderer_host/render_view_host_impl.h
+++ b/content/browser/renderer_host/render_view_host_impl.h
@@ -51,6 +51,12 @@ class Range;
struct SelectedFileInfo;
}
+#if defined(OS_ANDROID)
+namespace media {
+class MediaPlayerManager;
+}
+#endif
+
namespace content {
class ChildProcessSecurityPolicyImpl;
@@ -65,10 +71,6 @@ struct FileChooserParams;
struct Referrer;
struct ShowDesktopNotificationHostMsgParams;
-#if defined(OS_ANDROID)
-class MediaPlayerManagerImpl;
-#endif
-
#if defined(COMPILER_MSVC)
// RenderViewHostImpl is the bottom of a diamond-shaped hierarchy,
// with RenderWidgetHost at the root. VS warns when methods from the
@@ -378,7 +380,7 @@ class CONTENT_EXPORT RenderViewHostImpl
#endif
#if defined(OS_ANDROID)
- MediaPlayerManagerImpl* media_player_manager() {
+ media::MediaPlayerManager* media_player_manager() {
return media_player_manager_;
}
@@ -688,7 +690,7 @@ class CONTENT_EXPORT RenderViewHostImpl
#if defined(OS_ANDROID)
// Manages all the android mediaplayer objects and handling IPCs for video.
// This class inherits from RenderViewHostObserver.
- MediaPlayerManagerImpl* media_player_manager_;
+ media::MediaPlayerManager* media_player_manager_;
#endif
DISALLOW_COPY_AND_ASSIGN(RenderViewHostImpl);
diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc
index bd60290..6f7baf3 100644
--- a/content/browser/web_contents/web_contents_view_android.cc
+++ b/content/browser/web_contents/web_contents_view_android.cc
@@ -6,13 +6,13 @@
#include "base/logging.h"
#include "content/browser/android/content_view_core_impl.h"
-#include "content/browser/android/media_player_manager_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_android.h"
#include "content/browser/renderer_host/render_view_host_factory.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/web_contents/interstitial_page_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/web_contents_delegate.h"
+#include "media/base/android/media_player_manager.h"
namespace content {
WebContentsViewPort* CreateWebContentsView(
diff --git a/media/base/android/media_player_manager.cc b/media/base/android/media_player_manager.cc
deleted file mode 100644
index 45e8fa4..0000000
--- a/media/base/android/media_player_manager.cc
+++ /dev/null
@@ -1,11 +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 "media/base/android/media_player_manager.h"
-
-namespace media {
-
-MediaPlayerManager::~MediaPlayerManager() {}
-
-} // namespace media
diff --git a/media/base/android/media_player_manager.h b/media/base/android/media_player_manager.h
index bef25e5..ed78252 100644
--- a/media/base/android/media_player_manager.h
+++ b/media/base/android/media_player_manager.h
@@ -9,16 +9,36 @@
#include "media/base/media_export.h"
#include "media/base/android/demuxer_stream_player_params.h"
+namespace content {
+class RenderViewHost;
+}
+
namespace media {
class MediaPlayerAndroid;
class MediaResourceGetter;
// This class is responsible for managing active MediaPlayerAndroid objects.
-// It is implemented by content::MediaPlayerManagerImpl.
+// Objects implementing this interface a created via
+// MediaPlayerManager::Create(), allowing embedders to provide their
+// implementation.
class MEDIA_EXPORT MediaPlayerManager {
public:
- virtual ~MediaPlayerManager();
+ // The type of the factory function that returns a new instance of the
+ // MediaPlayerManager implementation.
+ typedef MediaPlayerManager* (*FactoryFunction)(content::RenderViewHost*);
+
+ // Allows to override the default factory function in order to provide
+ // a custom implementation to the RenderViewHost instance.
+ // Must be called from the main thread.
+ static void RegisterFactoryFunction(FactoryFunction factory_function);
+
+ // Returns a new instance of MediaPlayerManager interface implementation.
+ // The returned object is owned by the caller. Must be called on the main
+ // thread.
+ static MediaPlayerManager* Create(content::RenderViewHost* render_view_host);
+
+ virtual ~MediaPlayerManager() {}
// Called by a MediaPlayerAndroid object when it is going to decode
// media streams. This helps the manager object maintain an array
@@ -65,6 +85,15 @@ class MEDIA_EXPORT MediaPlayerManager {
// Called when video size has changed. Args: player ID, width, height.
virtual void OnVideoSizeChanged(int player_id, int width, int height) = 0;
+ // Returns the player that's in the fullscreen mode currently.
+ virtual MediaPlayerAndroid* GetFullscreenPlayer() = 0;
+
+ // Returns the player with the specified id.
+ virtual MediaPlayerAndroid* GetPlayer(int player_id) = 0;
+
+ // Release all the players managed by this object.
+ virtual void DestroyAllMediaPlayers() = 0;
+
// Callback when DemuxerStreamPlayer wants to read data from the demuxer.
virtual void OnReadFromDemuxer(
int player_id, media::DemuxerStream::Type type, bool seek_done) = 0;
diff --git a/media/media.gyp b/media/media.gyp
index 966c979..bb2ab75 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -200,7 +200,6 @@
'audio/win/waveout_output_win.h',
'base/android/demuxer_stream_player_params.cc',
'base/android/demuxer_stream_player_params.h',
- 'base/android/media_player_manager.cc',
'base/android/media_player_manager.h',
'base/android/media_resource_getter.cc',
'base/android/media_resource_getter.h',