| 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> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "cc/layers/video_frame_provider.h" | 14 #include "cc/layers/video_frame_provider.h" |
| 15 #include "gpu/command_buffer/common/mailbox.h" | 15 #include "gpu/command_buffer/common/mailbox.h" |
| 16 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
| 17 | 17 |
| 18 namespace gpu { | 18 namespace gpu { |
| 19 namespace gles2 { | 19 namespace gles2 { |
| 20 class GLES2Interface; | 20 class GLES2Interface; |
| 21 } // namespace gles2 | 21 } // namespace gles2 |
| 22 } // namespace gpu | 22 } // namespace gpu |
| 23 | 23 |
| 24 // TODO(boliu): Remove interfaces. |
| 24 namespace content { | 25 namespace content { |
| 25 | 26 |
| 26 // The proxy class for the gpu thread to notify the compositor thread | 27 // The proxy class for the gpu thread to notify the compositor thread |
| 27 // when a new video frame is available. | 28 // when a new video frame is available. |
| 28 class StreamTextureProxy { | 29 class StreamTextureProxy { |
| 29 public: | 30 public: |
| 30 virtual ~StreamTextureProxy() {} | 31 virtual ~StreamTextureProxy() {} |
| 31 | 32 |
| 32 // Initialize and bind to the loop, which becomes the thread that | 33 // Initialize and bind to the loop, which becomes the thread that |
| 33 // a connected client will receive callbacks on. This can be called | 34 // a connected client will receive callbacks on. This can be called |
| 34 // on any thread, but must be called with the same loop every time. | 35 // on any thread, but must be called with the same loop every time. |
| 35 virtual void BindToLoop(int32_t stream_id, | 36 virtual void BindToLoop(int32_t stream_id, |
| 36 cc::VideoFrameProvider::Client* client, | 37 cc::VideoFrameProvider::Client* client, |
| 37 scoped_refptr<base::SingleThreadTaskRunner> loop) = 0; | 38 scoped_refptr<base::SingleThreadTaskRunner> loop) = 0; |
| 38 | 39 |
| 39 // Causes this instance to be deleted on the thread it is bound to. | 40 // Causes this instance to be deleted on the thread it is bound to. |
| 40 virtual void Release() = 0; | 41 virtual void Release() = 0; |
| 41 | 42 |
| 42 struct Deleter { | 43 struct Deleter { |
| 43 inline void operator()(StreamTextureProxy* ptr) const { ptr->Release(); } | 44 inline void operator()(StreamTextureProxy* ptr) const { ptr->Release(); } |
| 44 }; | 45 }; |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 typedef std::unique_ptr<StreamTextureProxy, StreamTextureProxy::Deleter> | 48 typedef std::unique_ptr<StreamTextureProxy, StreamTextureProxy::Deleter> |
| 48 ScopedStreamTextureProxy; | 49 ScopedStreamTextureProxy; |
| 49 | 50 |
| 50 class StreamTextureFactoryContextObserver { | |
| 51 public: | |
| 52 virtual ~StreamTextureFactoryContextObserver() {} | |
| 53 virtual void ResetStreamTextureProxy() = 0; | |
| 54 }; | |
| 55 | |
| 56 // Factory class for managing stream textures. | 51 // Factory class for managing stream textures. |
| 57 class StreamTextureFactory : public base::RefCounted<StreamTextureFactory> { | 52 class StreamTextureFactory : public base::RefCounted<StreamTextureFactory> { |
| 58 public: | 53 public: |
| 59 // Create the StreamTextureProxy object. | 54 // Create the StreamTextureProxy object. |
| 60 virtual StreamTextureProxy* CreateProxy() = 0; | 55 virtual StreamTextureProxy* CreateProxy() = 0; |
| 61 | 56 |
| 62 // Send an IPC message to the browser process to request a java surface | 57 // Send an IPC message to the browser process to request a java surface |
| 63 // object for the given stream_id. After the the surface is created, | 58 // object for the given stream_id. After the the surface is created, |
| 64 // it will be passed back to the WebMediaPlayerAndroid object identified by | 59 // it will be passed back to the WebMediaPlayerAndroid object identified by |
| 65 // the player_id. | 60 // the player_id. |
| 66 virtual void EstablishPeer(int32_t stream_id, | 61 virtual void EstablishPeer(int32_t stream_id, |
| 67 int player_id, | 62 int player_id, |
| 68 int frame_id) = 0; | 63 int frame_id) = 0; |
| 69 | 64 |
| 70 // Creates a gpu::StreamTexture and returns its id. Sets |*texture_id| to the | 65 // Creates a gpu::StreamTexture and returns its id. Sets |*texture_id| to the |
| 71 // client-side id of the gpu::StreamTexture. The texture is produced into | 66 // client-side id of the gpu::StreamTexture. The texture is produced into |
| 72 // a mailbox so it can be shipped in a VideoFrame. | 67 // a mailbox so it can be shipped in a VideoFrame. |
| 73 virtual unsigned CreateStreamTexture(unsigned texture_target, | 68 virtual unsigned CreateStreamTexture(unsigned texture_target, |
| 74 unsigned* texture_id, | 69 unsigned* texture_id, |
| 75 gpu::Mailbox* texture_mailbox) = 0; | 70 gpu::Mailbox* texture_mailbox) = 0; |
| 76 | 71 |
| 77 // Set the streamTexture size for the given stream Id. | 72 // Set the streamTexture size for the given stream Id. |
| 78 virtual void SetStreamTextureSize(int32_t texture_id, | 73 virtual void SetStreamTextureSize(int32_t texture_id, |
| 79 const gfx::Size& size) = 0; | 74 const gfx::Size& size) = 0; |
| 80 | 75 |
| 81 virtual gpu::gles2::GLES2Interface* ContextGL() = 0; | 76 virtual gpu::gles2::GLES2Interface* ContextGL() = 0; |
| 82 | 77 |
| 83 virtual void AddObserver(StreamTextureFactoryContextObserver* obs) = 0; | |
| 84 virtual void RemoveObserver(StreamTextureFactoryContextObserver* obs) = 0; | |
| 85 | |
| 86 protected: | 78 protected: |
| 87 friend class base::RefCounted<StreamTextureFactory>; | 79 friend class base::RefCounted<StreamTextureFactory>; |
| 88 virtual ~StreamTextureFactory() {} | 80 virtual ~StreamTextureFactory() {} |
| 89 }; | 81 }; |
| 90 | 82 |
| 91 } // namespace content | 83 } // namespace content |
| 92 | 84 |
| 93 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ | 85 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_H_ |
| OLD | NEW |