| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CC_LAYERS_VIDEO_FRAME_PROVIDER_CLIENT_IMPL_H_ | 5 #ifndef CC_LAYERS_VIDEO_FRAME_PROVIDER_CLIENT_IMPL_H_ |
| 6 #define CC_LAYERS_VIDEO_FRAME_PROVIDER_CLIENT_IMPL_H_ | 6 #define CC_LAYERS_VIDEO_FRAME_PROVIDER_CLIENT_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| 11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
| 12 #include "cc/layers/video_frame_provider.h" | 12 #include "cc/layers/video_frame_provider.h" |
| 13 #include "cc/scheduler/video_frame_controller.h" |
| 13 #include "ui/gfx/transform.h" | 14 #include "ui/gfx/transform.h" |
| 14 | 15 |
| 15 namespace media { class VideoFrame; } | 16 namespace media { class VideoFrame; } |
| 16 | 17 |
| 17 namespace cc { | 18 namespace cc { |
| 18 class VideoLayerImpl; | 19 class VideoLayerImpl; |
| 19 | 20 |
| 20 // VideoFrameProviderClientImpl liasons with the VideoFrameProvider and the | 21 // VideoFrameProviderClientImpl liasons with the VideoFrameProvider and the |
| 21 // VideoLayer. It receives updates from the provider and updates the layer as a | 22 // VideoLayer. It receives updates from the provider and updates the layer as a |
| 22 // result. It also allows the layer to access the video frame that the provider | 23 // result. It also allows the layer to access the video frame that the provider |
| 23 // has. | 24 // has. |
| 24 class CC_EXPORT VideoFrameProviderClientImpl | 25 class CC_EXPORT VideoFrameProviderClientImpl |
| 25 : public VideoFrameProvider::Client, | 26 : public VideoFrameProvider::Client, |
| 27 public VideoFrameController, |
| 26 public base::RefCounted<VideoFrameProviderClientImpl> { | 28 public base::RefCounted<VideoFrameProviderClientImpl> { |
| 27 public: | 29 public: |
| 28 // Must be created on the impl thread while the main thread is blocked. | 30 // Must be created on the impl thread while the main thread is blocked. |
| 29 static scoped_refptr<VideoFrameProviderClientImpl> Create( | 31 static scoped_refptr<VideoFrameProviderClientImpl> Create( |
| 30 VideoFrameProvider* provider); | 32 VideoFrameProvider* provider, |
| 33 VideoFrameControllerClient* client); |
| 31 | 34 |
| 32 VideoLayerImpl* ActiveVideoLayer() const; | 35 VideoLayerImpl* ActiveVideoLayer() const; |
| 33 void SetActiveVideoLayer(VideoLayerImpl* video_layer); | 36 void SetActiveVideoLayer(VideoLayerImpl* video_layer); |
| 34 | 37 |
| 35 bool Stopped() const; | 38 bool Stopped() const; |
| 36 // Must be called on the impl thread while the main thread is blocked. | 39 // Must be called on the impl thread while the main thread is blocked. |
| 37 void Stop(); | 40 void Stop(); |
| 38 | 41 |
| 39 scoped_refptr<media::VideoFrame> AcquireLockAndCurrentFrame(); | 42 scoped_refptr<media::VideoFrame> AcquireLockAndCurrentFrame(); |
| 40 void PutCurrentFrame(const scoped_refptr<media::VideoFrame>& frame); | 43 void PutCurrentFrame(const scoped_refptr<media::VideoFrame>& frame); |
| 41 void ReleaseLock(); | 44 void ReleaseLock(); |
| 42 | 45 |
| 43 const gfx::Transform& StreamTextureMatrix() const; | 46 const gfx::Transform& StreamTextureMatrix() const; |
| 44 | 47 |
| 48 // VideoBeginFrameObserver implementation. |
| 49 void OnBeginFrame(const BeginFrameArgs& args) override; |
| 50 |
| 45 // VideoFrameProvider::Client implementation. | 51 // VideoFrameProvider::Client implementation. |
| 46 // Called on the main thread. | 52 // Called on the main thread. |
| 47 void StopUsingProvider() override; | 53 void StopUsingProvider() override; |
| 48 // Called on the impl thread. | 54 // Called on the impl thread. |
| 49 void DidReceiveFrame() override; | 55 void DidReceiveFrame() override; |
| 50 void DidUpdateMatrix(const float* matrix) override; | 56 void DidUpdateMatrix(const float* matrix) override; |
| 51 | 57 |
| 52 private: | 58 private: |
| 53 friend class base::RefCounted<VideoFrameProviderClientImpl>; | 59 friend class base::RefCounted<VideoFrameProviderClientImpl>; |
| 54 | 60 |
| 55 explicit VideoFrameProviderClientImpl(VideoFrameProvider* provider); | 61 VideoFrameProviderClientImpl(VideoFrameProvider* provider, |
| 62 VideoFrameControllerClient* client); |
| 56 ~VideoFrameProviderClientImpl() override; | 63 ~VideoFrameProviderClientImpl() override; |
| 57 | 64 |
| 58 VideoFrameProvider* provider_; | 65 VideoFrameProvider* provider_; |
| 66 VideoFrameControllerClient* client_; |
| 59 VideoLayerImpl* active_video_layer_; | 67 VideoLayerImpl* active_video_layer_; |
| 60 bool stopped_; | 68 bool stopped_; |
| 61 | 69 |
| 62 // Since the provider lives on another thread, it can be destroyed while the | 70 // Since the provider lives on another thread, it can be destroyed while the |
| 63 // frame controller are accessing its frame. Before being destroyed the | 71 // frame controller are accessing its frame. Before being destroyed the |
| 64 // provider calls StopUsingProvider. provider_lock_ blocks StopUsingProvider | 72 // provider calls StopUsingProvider. provider_lock_ blocks StopUsingProvider |
| 65 // from returning until the frame controller is done using the frame. | 73 // from returning until the frame controller is done using the frame. |
| 66 base::Lock provider_lock_; | 74 base::Lock provider_lock_; |
| 67 base::ThreadChecker thread_checker_; | 75 base::ThreadChecker thread_checker_; |
| 68 | 76 |
| 69 gfx::Transform stream_texture_matrix_; | 77 gfx::Transform stream_texture_matrix_; |
| 70 | 78 |
| 71 DISALLOW_COPY_AND_ASSIGN(VideoFrameProviderClientImpl); | 79 DISALLOW_COPY_AND_ASSIGN(VideoFrameProviderClientImpl); |
| 72 }; | 80 }; |
| 73 | 81 |
| 74 } // namespace cc | 82 } // namespace cc |
| 75 | 83 |
| 76 #endif // CC_LAYERS_VIDEO_FRAME_PROVIDER_CLIENT_IMPL_H_ | 84 #endif // CC_LAYERS_VIDEO_FRAME_PROVIDER_CLIENT_IMPL_H_ |
| OLD | NEW |