Chromium Code Reviews| 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/layers/video_frame_provider.h" | 12 #include "cc/layers/video_frame_provider.h" |
| 12 #include "ui/gfx/transform.h" | 13 #include "ui/gfx/transform.h" |
| 13 | 14 |
| 14 namespace media { class VideoFrame; } | 15 namespace media { |
| 16 class VideoFrame; | |
| 17 } // namespace media | |
|
danakj
2015/03/24 17:38:01
(this isn't actually needed by the linter for smal
sunnyps
2015/03/24 19:43:38
Done.
| |
| 15 | 18 |
| 16 namespace cc { | 19 namespace cc { |
| 20 | |
|
danakj
2015/03/24 17:38:01
why whitespace?
sunnyps
2015/03/24 19:43:38
Done.
| |
| 17 class VideoLayerImpl; | 21 class VideoLayerImpl; |
| 18 | 22 |
| 19 class VideoFrameProviderClientImpl | 23 // VideoFrameProviderClientImpl liasons with the VideoFrameProvider and the |
| 24 // VideoLayer. It receives updates from the provider and updates the layer as a | |
| 25 // result. It also allows the layer to access the video frame that the provider | |
| 26 // has. | |
| 27 class CC_EXPORT VideoFrameProviderClientImpl | |
| 20 : public VideoFrameProvider::Client, | 28 : public VideoFrameProvider::Client, |
| 21 public base::RefCounted<VideoFrameProviderClientImpl> { | 29 public base::RefCounted<VideoFrameProviderClientImpl> { |
| 22 public: | 30 public: |
| 31 // Must be created on the impl thread while the main thread is blocked. | |
| 23 static scoped_refptr<VideoFrameProviderClientImpl> Create( | 32 static scoped_refptr<VideoFrameProviderClientImpl> Create( |
| 24 VideoFrameProvider* provider); | 33 VideoFrameProvider* provider); |
| 25 | 34 |
| 26 VideoLayerImpl* active_video_layer() { return active_video_layer_; } | 35 // Must be called on the impl thread. |
| 27 void SetActiveVideoLayer(VideoLayerImpl* video_layer); | 36 void Start(VideoLayerImpl* active_video_layer); |
| 37 bool Started() const; | |
| 38 bool Stopped() const; | |
| 28 | 39 |
| 40 // Must be called on the impl thread while the main thread is blocked. It is | |
| 41 // legal to call Stop without calling Start. | |
| 29 void Stop(); | 42 void Stop(); |
| 30 bool Stopped(); | |
| 31 | 43 |
| 32 scoped_refptr<media::VideoFrame> AcquireLockAndCurrentFrame(); | 44 scoped_refptr<media::VideoFrame> AcquireLockAndCurrentFrame(); |
| 33 void PutCurrentFrame(const scoped_refptr<media::VideoFrame>& frame); | 45 void PutCurrentFrame(const scoped_refptr<media::VideoFrame>& frame); |
| 34 void ReleaseLock(); | 46 void ReleaseLock(); |
| 35 const gfx::Transform& stream_texture_matrix() const { | 47 const gfx::Transform& stream_texture_matrix() const { |
| 36 return stream_texture_matrix_; | 48 return stream_texture_matrix_; |
| 37 } | 49 } |
| 38 | 50 |
| 39 // VideoFrameProvider::Client implementation. These methods are all callable | 51 // VideoFrameProvider::Client implementation. |
| 40 // on any thread. | 52 // Called on the main thread. |
| 41 void StopUsingProvider() override; | 53 void StopUsingProvider() override; |
| 54 // Called on the impl thread. | |
| 42 void DidReceiveFrame() override; | 55 void DidReceiveFrame() override; |
| 43 void DidUpdateMatrix(const float* matrix) override; | 56 void DidUpdateMatrix(const float* matrix) override; |
| 44 | 57 |
| 45 private: | 58 private: |
| 46 explicit VideoFrameProviderClientImpl(VideoFrameProvider* provider); | |
| 47 friend class base::RefCounted<VideoFrameProviderClientImpl>; | 59 friend class base::RefCounted<VideoFrameProviderClientImpl>; |
| 60 | |
| 61 VideoFrameProviderClientImpl(VideoFrameProvider* provider); | |
| 48 ~VideoFrameProviderClientImpl() override; | 62 ~VideoFrameProviderClientImpl() override; |
| 49 | 63 |
| 64 VideoFrameProvider* provider_; | |
| 50 VideoLayerImpl* active_video_layer_; | 65 VideoLayerImpl* active_video_layer_; |
| 66 bool stopped_; | |
| 51 | 67 |
| 52 // Guards the destruction of provider_ and the frame that it provides | 68 // Since the provider lives on another thread, it can be destroyed while the |
| 69 // frame controller are accessing it's frame. Before being destroyed the | |
| 70 // provider calls StopUsingProvider. provider_lock_ blocks StopUsingProvider | |
| 71 // from returning till the frame controller is done using the frame. | |
| 53 base::Lock provider_lock_; | 72 base::Lock provider_lock_; |
| 54 VideoFrameProvider* provider_; | |
| 55 base::ThreadChecker thread_checker_; | 73 base::ThreadChecker thread_checker_; |
| 56 | 74 |
| 57 gfx::Transform stream_texture_matrix_; | 75 gfx::Transform stream_texture_matrix_; |
| 58 | 76 |
| 59 DISALLOW_COPY_AND_ASSIGN(VideoFrameProviderClientImpl); | 77 DISALLOW_COPY_AND_ASSIGN(VideoFrameProviderClientImpl); |
| 60 }; | 78 }; |
| 61 | 79 |
| 62 } // namespace cc | 80 } // namespace cc |
| 63 | 81 |
| 64 #endif // CC_LAYERS_VIDEO_FRAME_PROVIDER_CLIENT_IMPL_H_ | 82 #endif // CC_LAYERS_VIDEO_FRAME_PROVIDER_CLIENT_IMPL_H_ |
| OLD | NEW |