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