Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ | 6 #define CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 // The proxy class for the gpu thread to notify the compositor thread | 34 // The proxy class for the gpu thread to notify the compositor thread |
| 35 // when a new video frame is available. | 35 // when a new video frame is available. |
| 36 class StreamTextureProxy : public StreamTextureHost::Listener { | 36 class StreamTextureProxy : public StreamTextureHost::Listener { |
| 37 public: | 37 public: |
| 38 ~StreamTextureProxy() override; | 38 ~StreamTextureProxy() override; |
| 39 | 39 |
| 40 // Initialize and bind to |task_runner|, which becomes the thread that the | 40 // Initialize and bind to |task_runner|, which becomes the thread that the |
| 41 // provided callback will be run on. This can be called on any thread, but | 41 // provided callback will be run on. This can be called on any thread, but |
| 42 // must be called with the same |task_runner| every time. | 42 // must be called with the same |task_runner| every time. |
| 43 void BindToTaskRunner( | 43 void BindToTaskRunner( |
| 44 int32_t stream_id, | |
| 45 const base::Closure& received_frame_cb, | 44 const base::Closure& received_frame_cb, |
| 46 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 45 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 47 | 46 |
| 48 // StreamTextureHost::Listener implementation: | 47 // StreamTextureHost::Listener implementation: |
| 49 void OnFrameAvailable() override; | 48 void OnFrameAvailable() override; |
| 50 | 49 |
| 50 // Set the streamTexture size. | |
| 51 void SetStreamTextureSize(const gfx::Size& size); | |
| 52 | |
| 53 // Send an IPC message to the browser process to request a java surface | |
| 54 // object for the given route_id. After the the surface is created, | |
| 55 // it will be passed back to the WebMediaPlayerAndroid object identified by | |
| 56 // the player_id. | |
| 57 void EstablishPeer(int player_id, int frame_id); | |
| 58 | |
| 59 // Sends an IPC to the GPU process. | |
| 60 // Asks the StreamTexture to forward its SurfaceTexture to the | |
| 61 // ScopedSurfaceRequestManager, using the gpu::ScopedSurfaceRequestConduit. | |
| 62 void ForwardStreamTextureForSurfaceRequest( | |
| 63 const base::UnguessableToken& request_token); | |
| 64 | |
| 51 struct Deleter { | 65 struct Deleter { |
| 52 inline void operator()(StreamTextureProxy* ptr) const { ptr->Release(); } | 66 inline void operator()(StreamTextureProxy* ptr) const { ptr->Release(); } |
| 53 }; | 67 }; |
| 54 private: | 68 private: |
| 55 friend class StreamTextureFactory; | 69 friend class StreamTextureFactory; |
| 56 explicit StreamTextureProxy(StreamTextureHost* host); | 70 explicit StreamTextureProxy(StreamTextureHost* host); |
| 57 | 71 |
| 58 void BindOnThread(int32_t stream_id); | 72 void BindOnThread(); |
| 59 void Release(); | 73 void Release(); |
| 60 | 74 |
| 61 const std::unique_ptr<StreamTextureHost> host_; | 75 const std::unique_ptr<StreamTextureHost> host_; |
| 62 | 76 |
| 63 // Protects access to |received_frame_cb_| and |task_runner_|. | 77 // Protects access to |received_frame_cb_| and |task_runner_|. |
| 64 base::Lock lock_; | 78 base::Lock lock_; |
| 65 base::Closure received_frame_cb_; | 79 base::Closure received_frame_cb_; |
| 66 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 80 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 67 | 81 |
| 68 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureProxy); | 82 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureProxy); |
| 69 }; | 83 }; |
| 70 | 84 |
| 71 typedef std::unique_ptr<StreamTextureProxy, StreamTextureProxy::Deleter> | 85 typedef std::unique_ptr<StreamTextureProxy, StreamTextureProxy::Deleter> |
| 72 ScopedStreamTextureProxy; | 86 ScopedStreamTextureProxy; |
| 73 | 87 |
| 74 // Factory class for managing stream textures. | 88 // Factory class for managing stream textures. |
| 75 class CONTENT_EXPORT StreamTextureFactory | 89 class CONTENT_EXPORT StreamTextureFactory |
| 76 : public base::RefCounted<StreamTextureFactory> { | 90 : public base::RefCounted<StreamTextureFactory> { |
| 77 public: | 91 public: |
| 78 static scoped_refptr<StreamTextureFactory> Create( | 92 static scoped_refptr<StreamTextureFactory> Create( |
| 79 scoped_refptr<ContextProviderCommandBuffer> context_provider); | 93 scoped_refptr<ContextProviderCommandBuffer> context_provider); |
| 80 | 94 |
| 81 // Create the StreamTextureProxy object. | 95 // Create the StreamTextureProxy object. |
|
liberato (no reviews please)
2016/10/10 16:46:13
please comment the function args, now that the cal
sivag
2016/10/12 11:25:33
Done.
| |
| 82 StreamTextureProxy* CreateProxy(); | 96 StreamTextureProxy* CreateProxy(unsigned texture_target, |
| 83 | 97 unsigned* texture_id, |
| 84 // Send an IPC message to the browser process to request a java surface | 98 gpu::Mailbox* texture_mailbox); |
| 85 // object for the given stream_id. After the the surface is created, | |
| 86 // it will be passed back to the WebMediaPlayerAndroid object identified by | |
| 87 // the player_id. | |
| 88 void EstablishPeer(int32_t stream_id, int player_id, int frame_id); | |
| 89 | |
| 90 // Sends an IPC to the GPU process. | |
| 91 // Asks the StreamTexture to forward its SurfaceTexture to the | |
| 92 // ScopedSurfaceRequestManager, using the gpu::ScopedSurfaceRequestConduit. | |
| 93 void ForwardStreamTextureForSurfaceRequest( | |
| 94 int32_t stream_id, | |
| 95 const base::UnguessableToken& request_token); | |
| 96 | |
| 97 // Creates a gpu::StreamTexture and returns its id. Sets |*texture_id| to the | |
| 98 // client-side id of the gpu::StreamTexture. The texture is produced into | |
| 99 // a mailbox so it can be shipped in a VideoFrame. | |
| 100 unsigned CreateStreamTexture(unsigned texture_target, | |
| 101 unsigned* texture_id, | |
| 102 gpu::Mailbox* texture_mailbox); | |
| 103 | |
| 104 // Set the streamTexture size for the given stream Id. | |
| 105 void SetStreamTextureSize(int32_t texture_id, const gfx::Size& size); | |
| 106 | 99 |
| 107 gpu::gles2::GLES2Interface* ContextGL(); | 100 gpu::gles2::GLES2Interface* ContextGL(); |
| 108 | 101 |
| 109 private: | 102 private: |
| 110 friend class base::RefCounted<StreamTextureFactory>; | 103 friend class base::RefCounted<StreamTextureFactory>; |
| 111 StreamTextureFactory( | 104 StreamTextureFactory( |
| 112 scoped_refptr<ContextProviderCommandBuffer> context_provider); | 105 scoped_refptr<ContextProviderCommandBuffer> context_provider); |
| 113 ~StreamTextureFactory(); | 106 ~StreamTextureFactory(); |
| 107 // Creates a gpu::StreamTexture and returns its id. Sets |*texture_id| to the | |
| 108 // client-side id of the gpu::StreamTexture. The texture is produced into | |
| 109 // a mailbox so it can be shipped in a VideoFrame. | |
| 110 unsigned CreateStreamTexture(unsigned texture_target, | |
| 111 unsigned* texture_id, | |
| 112 gpu::Mailbox* texture_mailbox); | |
| 114 | 113 |
| 115 scoped_refptr<ContextProviderCommandBuffer> context_provider_; | 114 scoped_refptr<ContextProviderCommandBuffer> context_provider_; |
| 116 scoped_refptr<gpu::GpuChannelHost> channel_; | 115 scoped_refptr<gpu::GpuChannelHost> channel_; |
| 117 | 116 |
| 118 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureFactory); | 117 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureFactory); |
| 119 }; | 118 }; |
| 120 | 119 |
| 121 } // namespace content | 120 } // namespace content |
| 122 | 121 |
| 123 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ | 122 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ |
| OLD | NEW |