| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_ | 6 #define CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/timer/timer.h" | |
| 12 #include "content/browser/media/capture/cursor_renderer_aura.h" | 11 #include "content/browser/media/capture/cursor_renderer_aura.h" |
| 13 #include "media/capture/content/screen_capture_device_core.h" | 12 #include "media/capture/content/screen_capture_device_core.h" |
| 14 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 15 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
| 16 #include "ui/base/cursor/cursors_aura.h" | 15 #include "ui/base/cursor/cursors_aura.h" |
| 17 #include "ui/compositor/compositor.h" | 16 #include "ui/compositor/compositor.h" |
| 18 | 17 |
| 19 namespace cc { | 18 namespace cc { |
| 20 | 19 |
| 21 class CopyOutputResult; | 20 class CopyOutputResult; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 33 public ui::CompositorObserver { | 32 public ui::CompositorObserver { |
| 34 public: | 33 public: |
| 35 AuraWindowCaptureMachine(); | 34 AuraWindowCaptureMachine(); |
| 36 ~AuraWindowCaptureMachine() override; | 35 ~AuraWindowCaptureMachine() override; |
| 37 | 36 |
| 38 // VideoCaptureMachine overrides. | 37 // VideoCaptureMachine overrides. |
| 39 void Start(const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, | 38 void Start(const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, |
| 40 const media::VideoCaptureParams& params, | 39 const media::VideoCaptureParams& params, |
| 41 const base::Callback<void(bool)> callback) override; | 40 const base::Callback<void(bool)> callback) override; |
| 42 void Stop(const base::Closure& callback) override; | 41 void Stop(const base::Closure& callback) override; |
| 42 void MaybeCaptureForRefresh() override; |
| 43 | 43 |
| 44 // Implements aura::WindowObserver. | 44 // Implements aura::WindowObserver. |
| 45 void OnWindowBoundsChanged(aura::Window* window, | 45 void OnWindowBoundsChanged(aura::Window* window, |
| 46 const gfx::Rect& old_bounds, | 46 const gfx::Rect& old_bounds, |
| 47 const gfx::Rect& new_bounds) override; | 47 const gfx::Rect& new_bounds) override; |
| 48 void OnWindowDestroying(aura::Window* window) override; | 48 void OnWindowDestroying(aura::Window* window) override; |
| 49 void OnWindowAddedToRootWindow(aura::Window* window) override; | 49 void OnWindowAddedToRootWindow(aura::Window* window) override; |
| 50 void OnWindowRemovingFromRootWindow(aura::Window* window, | 50 void OnWindowRemovingFromRootWindow(aura::Window* window, |
| 51 aura::Window* new_root) override; | 51 aura::Window* new_root) override; |
| 52 | 52 |
| 53 // Implements ui::CompositorObserver. | 53 // Implements ui::CompositorObserver. |
| 54 void OnCompositingDidCommit(ui::Compositor* compositor) override {} | 54 void OnCompositingDidCommit(ui::Compositor* compositor) override {} |
| 55 void OnCompositingStarted(ui::Compositor* compositor, | 55 void OnCompositingStarted(ui::Compositor* compositor, |
| 56 base::TimeTicks start_time) override {} | 56 base::TimeTicks start_time) override {} |
| 57 void OnCompositingEnded(ui::Compositor* compositor) override; | 57 void OnCompositingEnded(ui::Compositor* compositor) override; |
| 58 void OnCompositingAborted(ui::Compositor* compositor) override {} | 58 void OnCompositingAborted(ui::Compositor* compositor) override {} |
| 59 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {} | 59 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {} |
| 60 void OnCompositingShuttingDown(ui::Compositor* compositor) override {} | 60 void OnCompositingShuttingDown(ui::Compositor* compositor) override {} |
| 61 | 61 |
| 62 // Sets the window to use for capture. | 62 // Sets the window to use for capture. |
| 63 void SetWindow(aura::Window* window); | 63 void SetWindow(aura::Window* window); |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 bool InternalStart( | 66 bool InternalStart( |
| 67 const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, | 67 const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, |
| 68 const media::VideoCaptureParams& params); | 68 const media::VideoCaptureParams& params); |
| 69 void InternalStop(const base::Closure& callback); | 69 void InternalStop(const base::Closure& callback); |
| 70 | 70 |
| 71 // Captures a frame. | 71 // Captures a frame. |
| 72 // |dirty| is false for timer polls and true for compositor updates. | 72 // |dirty| is false for refresh requests and true for compositor updates. |
| 73 void Capture(bool dirty); | 73 void Capture(bool dirty); |
| 74 | 74 |
| 75 // Update capture size. Must be called on the UI thread. | 75 // Update capture size. Must be called on the UI thread. |
| 76 void UpdateCaptureSize(); | 76 void UpdateCaptureSize(); |
| 77 | 77 |
| 78 using CaptureFrameCallback = | 78 using CaptureFrameCallback = |
| 79 media::ThreadSafeCaptureOracle::CaptureFrameCallback; | 79 media::ThreadSafeCaptureOracle::CaptureFrameCallback; |
| 80 | 80 |
| 81 // Response callback for cc::Layer::RequestCopyOfOutput(). | 81 // Response callback for cc::Layer::RequestCopyOfOutput(). |
| 82 void DidCopyOutput( | 82 void DidCopyOutput( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 98 base::WeakPtr<AuraWindowCaptureMachine> machine, | 98 base::WeakPtr<AuraWindowCaptureMachine> machine, |
| 99 base::TimeTicks start_time, | 99 base::TimeTicks start_time, |
| 100 const CaptureFrameCallback& capture_frame_cb, | 100 const CaptureFrameCallback& capture_frame_cb, |
| 101 const scoped_refptr<media::VideoFrame>& target, | 101 const scoped_refptr<media::VideoFrame>& target, |
| 102 scoped_ptr<cc::SingleReleaseCallback> release_callback, | 102 scoped_ptr<cc::SingleReleaseCallback> release_callback, |
| 103 bool result); | 103 bool result); |
| 104 | 104 |
| 105 // The window associated with the desktop. | 105 // The window associated with the desktop. |
| 106 aura::Window* desktop_window_; | 106 aura::Window* desktop_window_; |
| 107 | 107 |
| 108 // The timer that kicks off period captures. | |
| 109 base::Timer timer_; | |
| 110 | |
| 111 // Whether screen capturing or window capture. | 108 // Whether screen capturing or window capture. |
| 112 bool screen_capture_; | 109 bool screen_capture_; |
| 113 | 110 |
| 114 // Makes all the decisions about which frames to copy, and how. | 111 // Makes all the decisions about which frames to copy, and how. |
| 115 scoped_refptr<media::ThreadSafeCaptureOracle> oracle_proxy_; | 112 scoped_refptr<media::ThreadSafeCaptureOracle> oracle_proxy_; |
| 116 | 113 |
| 117 // The capture parameters for this capture. | 114 // The capture parameters for this capture. |
| 118 media::VideoCaptureParams capture_params_; | 115 media::VideoCaptureParams capture_params_; |
| 119 | 116 |
| 120 // YUV readback pipeline. | 117 // YUV readback pipeline. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 132 // immediately when InternalStop() is called to ensure that no more captured | 129 // immediately when InternalStop() is called to ensure that no more captured |
| 133 // frames will be delivered to the client. | 130 // frames will be delivered to the client. |
| 134 base::WeakPtrFactory<AuraWindowCaptureMachine> weak_factory_; | 131 base::WeakPtrFactory<AuraWindowCaptureMachine> weak_factory_; |
| 135 | 132 |
| 136 DISALLOW_COPY_AND_ASSIGN(AuraWindowCaptureMachine); | 133 DISALLOW_COPY_AND_ASSIGN(AuraWindowCaptureMachine); |
| 137 }; | 134 }; |
| 138 | 135 |
| 139 } // namespace content | 136 } // namespace content |
| 140 | 137 |
| 141 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_ | 138 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_ |
| OLD | NEW |