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" |
11 #include "content/browser/media/capture/cursor_renderer_aura.h" | 12 #include "content/browser/media/capture/cursor_renderer_aura.h" |
12 #include "media/capture/content/screen_capture_device_core.h" | 13 #include "media/capture/content/screen_capture_device_core.h" |
13 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
14 #include "ui/aura/window_observer.h" | 15 #include "ui/aura/window_observer.h" |
15 #include "ui/base/cursor/cursors_aura.h" | 16 #include "ui/base/cursor/cursors_aura.h" |
16 #include "ui/compositor/compositor.h" | 17 #include "ui/compositor/compositor.h" |
17 | 18 |
18 namespace cc { | 19 namespace cc { |
19 | 20 |
20 class CopyOutputResult; | 21 class CopyOutputResult; |
(...skipping 11 matching lines...) Expand all Loading... |
32 public ui::CompositorObserver { | 33 public ui::CompositorObserver { |
33 public: | 34 public: |
34 AuraWindowCaptureMachine(); | 35 AuraWindowCaptureMachine(); |
35 ~AuraWindowCaptureMachine() override; | 36 ~AuraWindowCaptureMachine() override; |
36 | 37 |
37 // VideoCaptureMachine overrides. | 38 // VideoCaptureMachine overrides. |
38 void Start(const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, | 39 void Start(const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, |
39 const media::VideoCaptureParams& params, | 40 const media::VideoCaptureParams& params, |
40 const base::Callback<void(bool)> callback) override; | 41 const base::Callback<void(bool)> callback) override; |
41 void Stop(const base::Closure& callback) override; | 42 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 refresh requests and true for compositor updates. | 72 // |dirty| is false for timer polls 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 |
108 // Whether screen capturing or window capture. | 111 // Whether screen capturing or window capture. |
109 bool screen_capture_; | 112 bool screen_capture_; |
110 | 113 |
111 // Makes all the decisions about which frames to copy, and how. | 114 // Makes all the decisions about which frames to copy, and how. |
112 scoped_refptr<media::ThreadSafeCaptureOracle> oracle_proxy_; | 115 scoped_refptr<media::ThreadSafeCaptureOracle> oracle_proxy_; |
113 | 116 |
114 // The capture parameters for this capture. | 117 // The capture parameters for this capture. |
115 media::VideoCaptureParams capture_params_; | 118 media::VideoCaptureParams capture_params_; |
116 | 119 |
117 // YUV readback pipeline. | 120 // YUV readback pipeline. |
(...skipping 11 matching lines...) Expand all Loading... |
129 // immediately when InternalStop() is called to ensure that no more captured | 132 // immediately when InternalStop() is called to ensure that no more captured |
130 // frames will be delivered to the client. | 133 // frames will be delivered to the client. |
131 base::WeakPtrFactory<AuraWindowCaptureMachine> weak_factory_; | 134 base::WeakPtrFactory<AuraWindowCaptureMachine> weak_factory_; |
132 | 135 |
133 DISALLOW_COPY_AND_ASSIGN(AuraWindowCaptureMachine); | 136 DISALLOW_COPY_AND_ASSIGN(AuraWindowCaptureMachine); |
134 }; | 137 }; |
135 | 138 |
136 } // namespace content | 139 } // namespace content |
137 | 140 |
138 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_ | 141 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_ |
OLD | NEW |