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

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

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