Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(767)

Side by Side Diff: content/browser/media/capture/aura_window_capture_machine.h

Issue 2364413002: Screen Video Capture: Implement suspend optimization. (Closed)
Patch Set: Unwind ScreenCaptureMachineAndroid changes. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 25 matching lines...) Expand all
36 public aura::WindowObserver, 36 public aura::WindowObserver,
37 public ui::CompositorAnimationObserver { 37 public ui::CompositorAnimationObserver {
38 public: 38 public:
39 AuraWindowCaptureMachine(); 39 AuraWindowCaptureMachine();
40 ~AuraWindowCaptureMachine() override; 40 ~AuraWindowCaptureMachine() override;
41 41
42 // VideoCaptureMachine overrides. 42 // VideoCaptureMachine overrides.
43 void Start(const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, 43 void Start(const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy,
44 const media::VideoCaptureParams& params, 44 const media::VideoCaptureParams& params,
45 const base::Callback<void(bool)> callback) override; 45 const base::Callback<void(bool)> callback) override;
46 void Suspend() override;
47 void Resume() override;
46 void Stop(const base::Closure& callback) override; 48 void Stop(const base::Closure& callback) override;
47 void MaybeCaptureForRefresh() override; 49 void MaybeCaptureForRefresh() override;
48 50
49 // Implements aura::WindowObserver. 51 // Implements aura::WindowObserver.
50 void OnWindowBoundsChanged(aura::Window* window, 52 void OnWindowBoundsChanged(aura::Window* window,
51 const gfx::Rect& old_bounds, 53 const gfx::Rect& old_bounds,
52 const gfx::Rect& new_bounds) override; 54 const gfx::Rect& new_bounds) override;
53 void OnWindowDestroying(aura::Window* window) override; 55 void OnWindowDestroying(aura::Window* window) override;
54 void OnWindowAddedToRootWindow(aura::Window* window) override; 56 void OnWindowAddedToRootWindow(aura::Window* window) override;
55 void OnWindowRemovingFromRootWindow(aura::Window* window, 57 void OnWindowRemovingFromRootWindow(aura::Window* window,
56 aura::Window* new_root) override; 58 aura::Window* new_root) override;
57 59
58 // ui::CompositorAnimationObserver implementation. 60 // ui::CompositorAnimationObserver implementation.
59 void OnAnimationStep(base::TimeTicks timestamp) override; 61 void OnAnimationStep(base::TimeTicks timestamp) override;
60 void OnCompositingShuttingDown(ui::Compositor* compositor) override; 62 void OnCompositingShuttingDown(ui::Compositor* compositor) override;
61 63
62 // Sets the window to use for capture. 64 // Sets the window to use for capture.
63 void SetWindow(aura::Window* window); 65 void SetWindow(aura::Window* window);
64 66
65 private: 67 private:
66 bool InternalStart( 68 bool InternalStart(
67 const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, 69 const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy,
68 const media::VideoCaptureParams& params); 70 const media::VideoCaptureParams& params);
71 void InternalSuspend();
72 void InternalResume();
69 void InternalStop(const base::Closure& callback); 73 void InternalStop(const base::Closure& callback);
70 74
71 // Captures a frame. |event_time| is provided by the compositor, or is null 75 // Captures a frame. |event_time| is provided by the compositor, or is null
72 // for refresh requests. 76 // for refresh requests.
73 void Capture(base::TimeTicks event_time); 77 void Capture(base::TimeTicks event_time);
74 78
75 // Update capture size. Must be called on the UI thread. 79 // Update capture size. Must be called on the UI thread.
76 void UpdateCaptureSize(); 80 void UpdateCaptureSize();
77 81
78 using CaptureFrameCallback = 82 using CaptureFrameCallback =
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 std::unique_ptr<display_compositor::ReadbackYUVInterface> 123 std::unique_ptr<display_compositor::ReadbackYUVInterface>
120 yuv_readback_pipeline_; 124 yuv_readback_pipeline_;
121 125
122 // Renders mouse cursor on frame. 126 // Renders mouse cursor on frame.
123 std::unique_ptr<content::CursorRendererAura> cursor_renderer_; 127 std::unique_ptr<content::CursorRendererAura> cursor_renderer_;
124 128
125 // TODO(jiayl): Remove power_save_blocker_ when there is an API to keep the 129 // TODO(jiayl): Remove power_save_blocker_ when there is an API to keep the
126 // screen from sleeping for the drive-by web. 130 // screen from sleeping for the drive-by web.
127 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_; 131 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_;
128 132
133 // False while frame capture has been suspended. All other aspects of the
134 // machine are maintained.
135 bool frame_capture_active_;
136
129 // WeakPtrs are used for the asynchronous capture callbacks passed to external 137 // WeakPtrs are used for the asynchronous capture callbacks passed to external
130 // modules. They are only valid on the UI thread and become invalidated 138 // modules. They are only valid on the UI thread and become invalidated
131 // immediately when InternalStop() is called to ensure that no more captured 139 // immediately when InternalStop() is called to ensure that no more captured
132 // frames will be delivered to the client. 140 // frames will be delivered to the client.
133 base::WeakPtrFactory<AuraWindowCaptureMachine> weak_factory_; 141 base::WeakPtrFactory<AuraWindowCaptureMachine> weak_factory_;
134 142
135 DISALLOW_COPY_AND_ASSIGN(AuraWindowCaptureMachine); 143 DISALLOW_COPY_AND_ASSIGN(AuraWindowCaptureMachine);
136 }; 144 };
137 145
138 } // namespace content 146 } // namespace content
139 147
140 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_ 148 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698