| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_WRAPPER_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_WRAPPER_IMPL_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_WRAPPER_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_WRAPPER_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 #include "content/renderer/media/android/stream_texture_factory.h" | 11 #include "content/renderer/media/android/stream_texture_factory.h" |
| 12 #include "gpu/command_buffer/common/mailbox.h" | 12 #include "gpu/command_buffer/common/mailbox.h" |
| 13 #include "media/base/android/stream_texture_wrapper.h" |
| 13 #include "media/base/video_frame.h" | 14 #include "media/base/video_frame.h" |
| 14 #include "media/blink/stream_texture_wrapper.h" | |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 // Concrete implementation of StreamTextureWrapper. Any method can be called on | 18 // Concrete implementation of StreamTextureWrapper. Any method can be called on |
| 19 // any thread, but additional threading considerations are listed in the | 19 // any thread, but additional threading considerations are listed in the |
| 20 // comments of individual methods. | 20 // comments of individual methods. |
| 21 // | 21 // |
| 22 // The StreamTexture is an abstraction allowing Chrome to wrap a SurfaceTexture | 22 // The StreamTexture is an abstraction allowing Chrome to wrap a SurfaceTexture |
| 23 // living in the GPU process. It allows VideoFrames to be created from the | 23 // living in the GPU process. It allows VideoFrames to be created from the |
| 24 // SurfaceTexture's texture, in the Renderer process. | 24 // SurfaceTexture's texture, in the Renderer process. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // Creates the underlying StreamTexture, and binds |stream_texture_proxy_| to | 56 // Creates the underlying StreamTexture, and binds |stream_texture_proxy_| to |
| 57 // |compositor_task_runner|. | 57 // |compositor_task_runner|. |
| 58 // | 58 // |
| 59 // Additional threading considerations: | 59 // Additional threading considerations: |
| 60 // - Can be called from any thread. | 60 // - Can be called from any thread. |
| 61 // - Initialization will be posted to |main_task_runner_|. | 61 // - Initialization will be posted to |main_task_runner_|. |
| 62 // - |init_cb| will be run on the calling thread. | 62 // - |init_cb| will be run on the calling thread. |
| 63 // - New frames will be signaled on |compositor_task_runner| via |client|'s | 63 // - New frames will be signaled on |compositor_task_runner| via |client|'s |
| 64 // DidReceiveFrame() method. | 64 // DidReceiveFrame() method. |
| 65 void Initialize( | 65 void Initialize( |
| 66 cc::VideoFrameProvider::Client* client, | 66 const base::Closure& received_frame_cb, |
| 67 const gfx::Size& natural_size, | 67 const gfx::Size& natural_size, |
| 68 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner, | 68 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner, |
| 69 const base::Closure& init_cb) override; | 69 const base::Closure& init_cb) override; |
| 70 | 70 |
| 71 // Should be called when the Video size changes. | 71 // Should be called when the Video size changes. |
| 72 // Can be called from any thread, but runs on |main_task_runner_|. | 72 // Can be called from any thread, but runs on |main_task_runner_|. |
| 73 void UpdateTextureSize(const gfx::Size& natural_size) override; | 73 void UpdateTextureSize(const gfx::Size& natural_size) override; |
| 74 | 74 |
| 75 // Returns the latest frame. | 75 // Returns the latest frame. |
| 76 // N.B: We create a single VideoFrame at initialization time (and update it | 76 // N.B: We create a single VideoFrame at initialization time (and update it |
| 77 // in UpdateTextureSize()), and repeatedly return it here. The underlying | 77 // in UpdateTextureSize()), and repeatedly return it here. The underlying |
| 78 // texture's changes are signalled via |client|'s DidReceiveFrame() callback. | 78 // texture's changes are signalled via |client|'s DidReceiveFrame() callback. |
| 79 scoped_refptr<media::VideoFrame> GetCurrentFrame() override; | 79 scoped_refptr<media::VideoFrame> GetCurrentFrame() override; |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 StreamTextureWrapperImpl( | 82 StreamTextureWrapperImpl( |
| 83 scoped_refptr<StreamTextureFactory> factory, | 83 scoped_refptr<StreamTextureFactory> factory, |
| 84 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | 84 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); |
| 85 ~StreamTextureWrapperImpl() override; | 85 ~StreamTextureWrapperImpl() override; |
| 86 | 86 |
| 87 // Destroys |this| safely on |main_task_runner_|. | 87 // Destroys |this| safely on |main_task_runner_|. |
| 88 void Destroy() override; | 88 void Destroy() override; |
| 89 | 89 |
| 90 void InitializeOnMainThread(cc::VideoFrameProvider::Client* client, | 90 void InitializeOnMainThread(const base::Closure& received_frame_cb, |
| 91 const base::Closure& init_cb); | 91 const base::Closure& init_cb); |
| 92 | 92 |
| 93 void ReallocateVideoFrame(const gfx::Size& natural_size); | 93 void ReallocateVideoFrame(const gfx::Size& natural_size); |
| 94 | 94 |
| 95 void SetCurrentFrameInternal( | 95 void SetCurrentFrameInternal( |
| 96 const scoped_refptr<media::VideoFrame>& video_frame); | 96 const scoped_refptr<media::VideoFrame>& video_frame); |
| 97 | 97 |
| 98 // Client GL texture ID allocated to the StreamTexture. | 98 // Client GL texture ID allocated to the StreamTexture. |
| 99 unsigned texture_id_; | 99 unsigned texture_id_; |
| 100 | 100 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 120 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; | 120 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; |
| 121 | 121 |
| 122 base::WeakPtrFactory<StreamTextureWrapperImpl> weak_factory_; | 122 base::WeakPtrFactory<StreamTextureWrapperImpl> weak_factory_; |
| 123 | 123 |
| 124 DISALLOW_COPY_AND_ASSIGN(StreamTextureWrapperImpl); | 124 DISALLOW_COPY_AND_ASSIGN(StreamTextureWrapperImpl); |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 } // namespace media | 127 } // namespace media |
| 128 | 128 |
| 129 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_WRAPPER_IMPL_H_ | 129 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_WRAPPER_IMPL_H_ |
| OLD | NEW |