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 MEDIA_BASE_ANDROID_STREAM_TEXTURE_WRAPPER_H_ | 5 #ifndef MEDIA_BASE_ANDROID_STREAM_TEXTURE_WRAPPER_H_ |
6 #define MEDIA_BASE_ANDROID_STREAM_TEXTURE_WRAPPER_H_ | 6 #define MEDIA_BASE_ANDROID_STREAM_TEXTURE_WRAPPER_H_ |
7 | 7 |
| 8 #include "base/unguessable_token.h" |
8 #include "media/base/video_frame.h" | 9 #include "media/base/video_frame.h" |
9 | 10 |
10 namespace media { | 11 namespace media { |
11 class VideoFrame; | |
12 | 12 |
13 // StreamTextureWrapper encapsulates a StreamTexture's creation, initialization | 13 // StreamTextureWrapper encapsulates a StreamTexture's creation, initialization |
14 // and registration for later retrieval (in the Browser process). | 14 // and registration for later retrieval (in the Browser process). |
15 // | |
16 // TODO(tguilbert): Support registering the underlying SurfaceTexture so it can | |
17 // be used by a MediaPlayer in the browser process. See crbug.com/627658. | |
18 class MEDIA_EXPORT StreamTextureWrapper { | 15 class MEDIA_EXPORT StreamTextureWrapper { |
19 public: | 16 public: |
20 StreamTextureWrapper() {} | 17 StreamTextureWrapper() {} |
21 | 18 |
22 // Initialize the underlying StreamTexture. | 19 // Initialize the underlying StreamTexture. |
23 // See StreamTextureWrapperImpl. | 20 // See StreamTextureWrapperImpl. |
24 virtual void Initialize( | 21 virtual void Initialize( |
25 const base::Closure& received_frame_cb, | 22 const base::Closure& received_frame_cb, |
26 const gfx::Size& natural_size, | 23 const gfx::Size& natural_size, |
27 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner, | 24 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner, |
28 const base::Closure& init_cb) = 0; | 25 const base::Closure& init_cb) = 0; |
29 | 26 |
30 // Called whenever the video's natural size changes. | 27 // Called whenever the video's natural size changes. |
31 // See StreamTextureWrapperImpl. | 28 // See StreamTextureWrapperImpl. |
32 virtual void UpdateTextureSize(const gfx::Size& natural_size) = 0; | 29 virtual void UpdateTextureSize(const gfx::Size& natural_size) = 0; |
33 | 30 |
34 // Returns the latest frame. | 31 // Returns the latest frame. |
35 // See StreamTextureWrapperImpl. | 32 // See StreamTextureWrapperImpl. |
36 virtual scoped_refptr<VideoFrame> GetCurrentFrame() = 0; | 33 virtual scoped_refptr<VideoFrame> GetCurrentFrame() = 0; |
37 | 34 |
| 35 // Sends the StreamTexture to the browser process, to fulfill the request |
| 36 // identified by |request_token|. |
| 37 // See StreamTextureWrapperImpl. |
| 38 virtual void ForwardStreamTextureForSurfaceRequest( |
| 39 const base::UnguessableToken& request_token) = 0; |
| 40 |
38 struct Deleter { | 41 struct Deleter { |
39 inline void operator()(StreamTextureWrapper* ptr) const { ptr->Destroy(); } | 42 inline void operator()(StreamTextureWrapper* ptr) const { ptr->Destroy(); } |
40 }; | 43 }; |
41 | 44 |
42 protected: | 45 protected: |
43 virtual ~StreamTextureWrapper() {} | 46 virtual ~StreamTextureWrapper() {} |
44 | 47 |
45 // Safely destroys the StreamTextureWrapper. | 48 // Safely destroys the StreamTextureWrapper. |
46 // See StreamTextureWrapperImpl. | 49 // See StreamTextureWrapperImpl. |
47 virtual void Destroy() = 0; | 50 virtual void Destroy() = 0; |
48 }; | 51 }; |
49 | 52 |
50 typedef std::unique_ptr<StreamTextureWrapper, StreamTextureWrapper::Deleter> | 53 typedef std::unique_ptr<StreamTextureWrapper, StreamTextureWrapper::Deleter> |
51 ScopedStreamTextureWrapper; | 54 ScopedStreamTextureWrapper; |
52 | 55 |
53 } // namespace media | 56 } // namespace media |
54 | 57 |
55 #endif // MEDIA_BASE_ANDROID_STREAM_TEXTURE_WRAPPER_H_ | 58 #endif // MEDIA_BASE_ANDROID_STREAM_TEXTURE_WRAPPER_H_ |
OLD | NEW |