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 21 matching lines...) Expand all Loading... |
32 // created, wrapping a SurfaceTexture created from the texture reference. The | 32 // created, wrapping a SurfaceTexture created from the texture reference. The |
33 // SurfaceTexture's OnFrameAvailable() callback is tied to StreamTexture's | 33 // SurfaceTexture's OnFrameAvailable() callback is tied to StreamTexture's |
34 // OnFrameAvailable(), which fires an IPC accross the GPU channel. | 34 // OnFrameAvailable(), which fires an IPC accross the GPU channel. |
35 // - We create a StreamTextureProxy in the Renderer process which listens for | 35 // - We create a StreamTextureProxy in the Renderer process which listens for |
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 // | |
43 // TODO(tguilbert): Register the underlying SurfaceTexture for retrieval in the | |
44 // browser process. See crbug.com/627658. | |
45 // | |
46 // TODO(tguilbert): Change StreamTextureProxy's interface to accept a | |
47 // base::Closure instead of requiring a VideoFrameProvider::Client, to simplify | |
48 // the MediaPlayerRendererHost interface. See crbug.com/631178. | |
49 class CONTENT_EXPORT StreamTextureWrapperImpl | 42 class CONTENT_EXPORT StreamTextureWrapperImpl |
50 : public media::StreamTextureWrapper { | 43 : public media::StreamTextureWrapper { |
51 public: | 44 public: |
52 static media::ScopedStreamTextureWrapper Create( | 45 static media::ScopedStreamTextureWrapper Create( |
53 scoped_refptr<StreamTextureFactory> factory, | 46 scoped_refptr<StreamTextureFactory> factory, |
54 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | 47 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); |
55 | 48 |
56 // Creates the underlying StreamTexture, and binds |stream_texture_proxy_| to | 49 // Creates the underlying StreamTexture, and binds |stream_texture_proxy_| to |
57 // |compositor_task_runner|. | 50 // |compositor_task_runner|. |
58 // | 51 // |
(...skipping 12 matching lines...) Expand all Loading... |
71 // Should be called when the Video size changes. | 64 // Should be called when the Video size changes. |
72 // Can be called from any thread, but runs on |main_task_runner_|. | 65 // Can be called from any thread, but runs on |main_task_runner_|. |
73 void UpdateTextureSize(const gfx::Size& natural_size) override; | 66 void UpdateTextureSize(const gfx::Size& natural_size) override; |
74 | 67 |
75 // Returns the latest frame. | 68 // Returns the latest frame. |
76 // N.B: We create a single VideoFrame at initialization time (and update it | 69 // N.B: We create a single VideoFrame at initialization time (and update it |
77 // in UpdateTextureSize()), and repeatedly return it here. The underlying | 70 // in UpdateTextureSize()), and repeatedly return it here. The underlying |
78 // texture's changes are signalled via |client|'s DidReceiveFrame() callback. | 71 // texture's changes are signalled via |client|'s DidReceiveFrame() callback. |
79 scoped_refptr<media::VideoFrame> GetCurrentFrame() override; | 72 scoped_refptr<media::VideoFrame> GetCurrentFrame() override; |
80 | 73 |
| 74 // Sends the StreamTexture to the browser process, to fulfill the request |
| 75 // identified by |request_token|. |
| 76 // Uses the gpu::ScopedSurfaceRequestConduit to forward the underlying |
| 77 // SurfaceTexture to the ScopedSurfaceRequestManager. |
| 78 void ForwardStreamTextureForSurfaceRequest( |
| 79 const base::UnguessableToken& request_token) override; |
| 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(const base::Closure& received_frame_cb, | 90 void InitializeOnMainThread(const base::Closure& received_frame_cb, |
(...skipping 29 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 |