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

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

Issue 1942493002: Short-term fix for Aura Desktop/Window capture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | content/browser/media/capture/aura_window_capture_machine.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "content/browser/media/capture/cursor_renderer_aura.h" 12 #include "content/browser/media/capture/cursor_renderer_aura.h"
13 #include "media/capture/content/screen_capture_device_core.h" 13 #include "media/capture/content/screen_capture_device_core.h"
14 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
15 #include "ui/aura/window_observer.h" 15 #include "ui/aura/window_observer.h"
16 #include "ui/base/cursor/cursors_aura.h" 16 #include "ui/base/cursor/cursors_aura.h"
17 #include "ui/compositor/compositor.h" 17 #include "ui/compositor/compositor.h"
18 #include "ui/compositor/compositor_animation_observer.h"
18 19
19 namespace cc { 20 namespace cc {
20 21
21 class CopyOutputResult; 22 class CopyOutputResult;
22 23
23 } // namespace cc 24 } // namespace cc
24 25
25 namespace content { 26 namespace content {
26 27
27 class PowerSaveBlocker; 28 class PowerSaveBlocker;
28 class ReadbackYUVInterface; 29 class ReadbackYUVInterface;
29 30
30 class AuraWindowCaptureMachine 31 class AuraWindowCaptureMachine
31 : public media::VideoCaptureMachine, 32 : public media::VideoCaptureMachine,
32 public aura::WindowObserver, 33 public aura::WindowObserver,
33 public ui::CompositorObserver { 34 public ui::CompositorAnimationObserver {
34 public: 35 public:
35 AuraWindowCaptureMachine(); 36 AuraWindowCaptureMachine();
36 ~AuraWindowCaptureMachine() override; 37 ~AuraWindowCaptureMachine() override;
37 38
38 // VideoCaptureMachine overrides. 39 // VideoCaptureMachine overrides.
39 void Start(const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, 40 void Start(const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy,
40 const media::VideoCaptureParams& params, 41 const media::VideoCaptureParams& params,
41 const base::Callback<void(bool)> callback) override; 42 const base::Callback<void(bool)> callback) override;
42 void Stop(const base::Closure& callback) override; 43 void Stop(const base::Closure& callback) override;
43 void MaybeCaptureForRefresh() override; 44 void MaybeCaptureForRefresh() override;
44 45
45 // Implements aura::WindowObserver. 46 // Implements aura::WindowObserver.
46 void OnWindowBoundsChanged(aura::Window* window, 47 void OnWindowBoundsChanged(aura::Window* window,
47 const gfx::Rect& old_bounds, 48 const gfx::Rect& old_bounds,
48 const gfx::Rect& new_bounds) override; 49 const gfx::Rect& new_bounds) override;
49 void OnWindowDestroying(aura::Window* window) override; 50 void OnWindowDestroying(aura::Window* window) override;
50 void OnWindowAddedToRootWindow(aura::Window* window) override; 51 void OnWindowAddedToRootWindow(aura::Window* window) override;
51 void OnWindowRemovingFromRootWindow(aura::Window* window, 52 void OnWindowRemovingFromRootWindow(aura::Window* window,
52 aura::Window* new_root) override; 53 aura::Window* new_root) override;
53 54
54 // Implements ui::CompositorObserver. 55 // ui::CompositorAnimationObserver implementation.
55 void OnCompositingDidCommit(ui::Compositor* compositor) override {} 56 void OnAnimationStep(base::TimeTicks timestamp) override;
56 void OnCompositingStarted(ui::Compositor* compositor, 57 void OnCompositingShuttingDown(ui::Compositor* compositor) override;
57 base::TimeTicks start_time) override {}
58 void OnCompositingEnded(ui::Compositor* compositor) override;
59 void OnCompositingAborted(ui::Compositor* compositor) override {}
60 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {}
61 void OnCompositingShuttingDown(ui::Compositor* compositor) override {}
62 58
63 // Sets the window to use for capture. 59 // Sets the window to use for capture.
64 void SetWindow(aura::Window* window); 60 void SetWindow(aura::Window* window);
65 61
66 private: 62 private:
67 bool InternalStart( 63 bool InternalStart(
68 const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, 64 const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy,
69 const media::VideoCaptureParams& params); 65 const media::VideoCaptureParams& params);
70 void InternalStop(const base::Closure& callback); 66 void InternalStop(const base::Closure& callback);
71 67
72 // Captures a frame. 68 // Captures a frame. |event_time| is provided by the compositor, or is null
73 // |dirty| is false for refresh requests and true for compositor updates. 69 // for refresh requests.
74 void Capture(bool dirty); 70 void Capture(base::TimeTicks event_time);
75 71
76 // Update capture size. Must be called on the UI thread. 72 // Update capture size. Must be called on the UI thread.
77 void UpdateCaptureSize(); 73 void UpdateCaptureSize();
78 74
79 using CaptureFrameCallback = 75 using CaptureFrameCallback =
80 media::ThreadSafeCaptureOracle::CaptureFrameCallback; 76 media::ThreadSafeCaptureOracle::CaptureFrameCallback;
81 77
82 // Response callback for cc::Layer::RequestCopyOfOutput(). 78 // Response callback for cc::Layer::RequestCopyOfOutput().
83 void DidCopyOutput(scoped_refptr<media::VideoFrame> video_frame, 79 void DidCopyOutput(scoped_refptr<media::VideoFrame> video_frame,
80 base::TimeTicks event_time,
84 base::TimeTicks start_time, 81 base::TimeTicks start_time,
85 const CaptureFrameCallback& capture_frame_cb, 82 const CaptureFrameCallback& capture_frame_cb,
86 std::unique_ptr<cc::CopyOutputResult> result); 83 std::unique_ptr<cc::CopyOutputResult> result);
87 84
88 // A helper which does the real work for DidCopyOutput. Returns true if 85 // A helper which does the real work for DidCopyOutput. Returns true if
89 // succeeded and |capture_frame_cb| will be run at some future point. Returns 86 // succeeded and |capture_frame_cb| will be run at some future point. Returns
90 // false on error, and |capture_frame_cb| should be run by the caller (with 87 // false on error, and |capture_frame_cb| should be run by the caller (with
91 // failure status). 88 // failure status).
92 bool ProcessCopyOutputResponse(scoped_refptr<media::VideoFrame> video_frame, 89 bool ProcessCopyOutputResponse(scoped_refptr<media::VideoFrame> video_frame,
93 base::TimeTicks start_time, 90 base::TimeTicks event_time,
94 const CaptureFrameCallback& capture_frame_cb, 91 const CaptureFrameCallback& capture_frame_cb,
95 std::unique_ptr<cc::CopyOutputResult> result); 92 std::unique_ptr<cc::CopyOutputResult> result);
96 93
97 // Renders the cursor if needed and then delivers the captured frame. 94 // Renders the cursor if needed and then delivers the captured frame.
98 static void CopyOutputFinishedForVideo( 95 static void CopyOutputFinishedForVideo(
99 base::WeakPtr<AuraWindowCaptureMachine> machine, 96 base::WeakPtr<AuraWindowCaptureMachine> machine,
100 base::TimeTicks start_time, 97 base::TimeTicks event_time,
101 const CaptureFrameCallback& capture_frame_cb, 98 const CaptureFrameCallback& capture_frame_cb,
102 const scoped_refptr<media::VideoFrame>& target, 99 const scoped_refptr<media::VideoFrame>& target,
103 std::unique_ptr<cc::SingleReleaseCallback> release_callback, 100 std::unique_ptr<cc::SingleReleaseCallback> release_callback,
104 bool result); 101 bool result);
105 102
106 // The window associated with the desktop. 103 // The window associated with the desktop.
107 aura::Window* desktop_window_; 104 aura::Window* desktop_window_;
108 105
109 // Whether screen capturing or window capture. 106 // Whether screen capturing or window capture.
110 bool screen_capture_; 107 bool screen_capture_;
(...skipping 19 matching lines...) Expand all
130 // immediately when InternalStop() is called to ensure that no more captured 127 // immediately when InternalStop() is called to ensure that no more captured
131 // frames will be delivered to the client. 128 // frames will be delivered to the client.
132 base::WeakPtrFactory<AuraWindowCaptureMachine> weak_factory_; 129 base::WeakPtrFactory<AuraWindowCaptureMachine> weak_factory_;
133 130
134 DISALLOW_COPY_AND_ASSIGN(AuraWindowCaptureMachine); 131 DISALLOW_COPY_AND_ASSIGN(AuraWindowCaptureMachine);
135 }; 132 };
136 133
137 } // namespace content 134 } // namespace content
138 135
139 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_ 136 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/media/capture/aura_window_capture_machine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698