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