Chromium Code Reviews| 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" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 // the IPC fired by the StreamTexture's OnFrameAvailable() callback. | 36 // the IPC fired by the StreamTexture's OnFrameAvailable() callback. |
| 37 // - We bind the StreamTextureProxy's lifetime to the |compositor_task_runner_|. | 37 // - We bind the StreamTextureProxy's lifetime to the |compositor_task_runner_|. |
| 38 // - We wrap the client texture into a VideoFrame. | 38 // - We wrap the client texture into a VideoFrame. |
| 39 // - When the SurfaceTexture's OnFrameAvailable() callback is fired (and routed | 39 // - When the SurfaceTexture's OnFrameAvailable() callback is fired (and routed |
| 40 // to the StreamTextureProxy living on the compositor thread), we notify | 40 // to the StreamTextureProxy living on the compositor thread), we notify |
| 41 // |client_| that a new frame is available, via the DidReceiveFrame() callback. | 41 // |client_| that a new frame is available, via the DidReceiveFrame() callback. |
| 42 class CONTENT_EXPORT StreamTextureWrapperImpl | 42 class CONTENT_EXPORT StreamTextureWrapperImpl |
| 43 : public media::StreamTextureWrapper { | 43 : public media::StreamTextureWrapper { |
| 44 public: | 44 public: |
| 45 static media::ScopedStreamTextureWrapper Create( | 45 static media::ScopedStreamTextureWrapper Create( |
| 46 bool enable_texture_copy, | |
|
liberato (no reviews please)
2016/11/07 22:35:31
please add a line to document this.
tguilbert
2016/11/07 23:25:01
Done.
| |
| 46 scoped_refptr<StreamTextureFactory> factory, | 47 scoped_refptr<StreamTextureFactory> factory, |
| 47 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | 48 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); |
| 48 | 49 |
| 49 // Creates the underlying StreamTexture, and binds |stream_texture_proxy_| to | 50 // Creates the underlying StreamTexture, and binds |stream_texture_proxy_| to |
| 50 // |compositor_task_runner|. | 51 // |compositor_task_runner|. |
| 51 // | 52 // |
| 52 // Additional threading considerations: | 53 // Additional threading considerations: |
| 53 // - Can be called from any thread. | 54 // - Can be called from any thread. |
| 54 // - Initialization will be posted to |main_task_runner_|. | 55 // - Initialization will be posted to |main_task_runner_|. |
| 55 // - |init_cb| will be run on the calling thread. | 56 // - |init_cb| will be run on the calling thread. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 73 | 74 |
| 74 // Sends the StreamTexture to the browser process, to fulfill the request | 75 // Sends the StreamTexture to the browser process, to fulfill the request |
| 75 // identified by |request_token|. | 76 // identified by |request_token|. |
| 76 // Uses the gpu::ScopedSurfaceRequestConduit to forward the underlying | 77 // Uses the gpu::ScopedSurfaceRequestConduit to forward the underlying |
| 77 // SurfaceTexture to the ScopedSurfaceRequestManager. | 78 // SurfaceTexture to the ScopedSurfaceRequestManager. |
| 78 void ForwardStreamTextureForSurfaceRequest( | 79 void ForwardStreamTextureForSurfaceRequest( |
| 79 const base::UnguessableToken& request_token) override; | 80 const base::UnguessableToken& request_token) override; |
| 80 | 81 |
| 81 private: | 82 private: |
| 82 StreamTextureWrapperImpl( | 83 StreamTextureWrapperImpl( |
| 84 bool enable_texture_copy, | |
| 83 scoped_refptr<StreamTextureFactory> factory, | 85 scoped_refptr<StreamTextureFactory> factory, |
| 84 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | 86 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); |
| 85 ~StreamTextureWrapperImpl() override; | 87 ~StreamTextureWrapperImpl() override; |
| 86 | 88 |
| 87 // Destroys |this| safely on |main_task_runner_|. | 89 // Destroys |this| safely on |main_task_runner_|. |
| 88 void Destroy() override; | 90 void Destroy() override; |
| 89 | 91 |
| 90 void InitializeOnMainThread(const base::Closure& received_frame_cb, | 92 void InitializeOnMainThread(const base::Closure& received_frame_cb, |
| 91 const base::Closure& init_cb); | 93 const base::Closure& init_cb); |
| 92 | 94 |
| 93 void ReallocateVideoFrame(const gfx::Size& natural_size); | 95 void ReallocateVideoFrame(const gfx::Size& natural_size); |
| 94 | 96 |
| 95 void SetCurrentFrameInternal( | 97 void SetCurrentFrameInternal( |
| 96 const scoped_refptr<media::VideoFrame>& video_frame); | 98 const scoped_refptr<media::VideoFrame>& video_frame); |
| 97 | 99 |
| 100 bool enable_texture_copy_; | |
| 101 | |
| 98 // Client GL texture ID allocated to the StreamTexture. | 102 // Client GL texture ID allocated to the StreamTexture. |
| 99 unsigned texture_id_; | 103 unsigned texture_id_; |
| 100 | 104 |
| 101 // GL texture mailbox for |texture_id_|. | 105 // GL texture mailbox for |texture_id_|. |
| 102 gpu::Mailbox texture_mailbox_; | 106 gpu::Mailbox texture_mailbox_; |
| 103 | 107 |
| 104 // Object for calling back the compositor thread to repaint the video when a | 108 // Object for calling back the compositor thread to repaint the video when a |
| 105 // frame is available. It should be bound to |compositor_task_runner_|. | 109 // frame is available. It should be bound to |compositor_task_runner_|. |
| 106 ScopedStreamTextureProxy stream_texture_proxy_; | 110 ScopedStreamTextureProxy stream_texture_proxy_; |
| 107 | 111 |
| 108 // Size of the video frames. | 112 // Size of the video frames. |
| 109 gfx::Size natural_size_; | 113 gfx::Size natural_size_; |
| 110 | 114 |
| 111 scoped_refptr<StreamTextureFactory> factory_; | 115 scoped_refptr<StreamTextureFactory> factory_; |
| 112 | 116 |
| 113 base::Lock current_frame_lock_; | 117 base::Lock current_frame_lock_; |
| 114 scoped_refptr<media::VideoFrame> current_frame_; | 118 scoped_refptr<media::VideoFrame> current_frame_; |
| 115 | 119 |
| 116 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 120 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 117 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; | 121 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; |
| 118 | 122 |
| 119 base::WeakPtrFactory<StreamTextureWrapperImpl> weak_factory_; | 123 base::WeakPtrFactory<StreamTextureWrapperImpl> weak_factory_; |
| 120 | 124 |
| 121 DISALLOW_COPY_AND_ASSIGN(StreamTextureWrapperImpl); | 125 DISALLOW_COPY_AND_ASSIGN(StreamTextureWrapperImpl); |
| 122 }; | 126 }; |
| 123 | 127 |
| 124 } // namespace media | 128 } // namespace media |
| 125 | 129 |
| 126 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_WRAPPER_IMPL_H_ | 130 #endif // CONTENT_RENDERER_MEDIA_ANDROID_STREAM_TEXTURE_WRAPPER_IMPL_H_ |
| OLD | NEW |