Index: content/browser/media/android/browser_media_player_manager.cc |
diff --git a/content/browser/media/android/browser_media_player_manager.cc b/content/browser/media/android/browser_media_player_manager.cc |
index 96f6fcde97cd78e4beb6f7260d4c0b1c1f28d0c2..684020f456459f0749c3467f2e89415bb2bee7ce 100644 |
--- a/content/browser/media/android/browser_media_player_manager.cc |
+++ b/content/browser/media/android/browser_media_player_manager.cc |
@@ -7,6 +7,7 @@ |
#include <utility> |
#include "base/android/scoped_java_ref.h" |
+#include "base/memory/singleton.h" |
#include "content/browser/frame_host/render_frame_host_impl.h" |
#include "content/browser/media/android/browser_demuxer_android.h" |
#include "content/browser/media/android/media_resource_getter_impl.h" |
@@ -27,6 +28,7 @@ |
#include "content/public/browser/web_contents_delegate.h" |
#include "content/public/common/content_client.h" |
#include "content/public/common/content_switches.h" |
+#include "gpu/ipc/common/android/surface_texture_peer.h" |
#include "media/base/android/media_codec_player.h" |
#include "media/base/android/media_player_bridge.h" |
#include "media/base/android/media_source_player.h" |
@@ -46,6 +48,57 @@ using media::MediaSourcePlayer; |
namespace content { |
+namespace { |
+ |
+class BrowserSurfaceTexturePeer : public gpu::SurfaceTexturePeer { |
+ public: |
+ static BrowserSurfaceTexturePeer* GetInstance(); |
+ |
+ private: |
+ friend struct base::DefaultSingletonTraits<BrowserSurfaceTexturePeer>; |
+ |
+ BrowserSurfaceTexturePeer(); |
+ ~BrowserSurfaceTexturePeer() override; |
+ |
+ void EstablishSurfaceTexturePeer( |
+ base::ProcessHandle render_process_handle, |
+ scoped_refptr<gfx::SurfaceTexture> surface_texture, |
+ int render_frame_id, |
+ int player_id) override; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BrowserSurfaceTexturePeer); |
+}; |
+ |
+// static |
+BrowserSurfaceTexturePeer* BrowserSurfaceTexturePeer::GetInstance() { |
+ return base::Singleton< |
+ BrowserSurfaceTexturePeer, |
+ base::LeakySingletonTraits<BrowserSurfaceTexturePeer>>::get(); |
+} |
+ |
+BrowserSurfaceTexturePeer::BrowserSurfaceTexturePeer() { |
+ gpu::SurfaceTexturePeer::InitInstance(this); |
+} |
+ |
+BrowserSurfaceTexturePeer::~BrowserSurfaceTexturePeer() { |
+ gpu::SurfaceTexturePeer::InitInstance(nullptr); |
+} |
+ |
+void BrowserSurfaceTexturePeer::EstablishSurfaceTexturePeer( |
+ base::ProcessHandle render_process_handle, |
+ scoped_refptr<gfx::SurfaceTexture> surface_texture, |
+ int render_frame_id, |
+ int player_id) { |
+ if (!surface_texture.get()) |
+ return; |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, FROM_HERE, |
+ base::Bind(&BrowserMediaPlayerManager::SetSurfacePeer, surface_texture, |
+ render_process_handle, render_frame_id, player_id)); |
+} |
+ |
+} // namespace |
+ |
// Threshold on the number of media players per renderer before we start |
// attempting to release inactive media players. |
const int kMediaPlayerThreshold = 1; |
@@ -71,6 +124,11 @@ void BrowserMediaPlayerManager::RegisterMediaUrlInterceptor( |
} |
// static |
+void BrowserMediaPlayerManager::InitSurfaceTexturePeer() { |
+ BrowserSurfaceTexturePeer::GetInstance(); |
+} |
+ |
+// static |
void BrowserMediaPlayerManager::SetSurfacePeer( |
scoped_refptr<gfx::SurfaceTexture> surface_texture, |
base::ProcessHandle render_process_handle, |