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

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

Issue 974513002: content: Split out VideoCaptureMachine from DesktopCaptureDeviceAura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename to AuraCaptureMachine and move to own file Created 5 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/memory/scoped_ptr.h"
6 #include "base/memory/weak_ptr.h"
7 #include "base/timer/timer.h"
8 #include "content/browser/media/capture/content_video_capture_device_core.h"
9 #include "ui/aura/window.h"
10 #include "ui/aura/window_observer.h"
11 #include "ui/base/cursor/cursors_aura.h"
12 #include "ui/compositor/compositor.h"
13
14 namespace cc {
15
16 class CopyOutputResult;
17
18 } // namespace cc
19
20 namespace content {
21
22 class PowerSaveBlocker;
23 class ReadbackYUVInterface;
24
25 // Provides the VideoCaptureMachine for capturing from an AuraWindow.
26 class AuraWindowCaptureMachine
27 : public VideoCaptureMachine,
28 public aura::WindowObserver,
29 public ui::CompositorObserver,
30 public base::SupportsWeakPtr<AuraWindowCaptureMachine> {
31 public:
32 AuraWindowCaptureMachine();
33 ~AuraWindowCaptureMachine() override;
34
35 // VideoCaptureFrameSource overrides.
36 bool Start(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy,
37 const media::VideoCaptureParams& params) override;
38 void Stop(const base::Closure& callback) override;
39
40 // Implements aura::WindowObserver.
41 void OnWindowBoundsChanged(aura::Window* window,
42 const gfx::Rect& old_bounds,
43 const gfx::Rect& new_bounds) override;
44 void OnWindowDestroyed(aura::Window* window) override;
45 void OnWindowAddedToRootWindow(aura::Window* window) override;
46 void OnWindowRemovingFromRootWindow(aura::Window* window,
47 aura::Window* new_root) override;
48
49 // Implements ui::CompositorObserver.
50 void OnCompositingDidCommit(ui::Compositor* compositor) override {}
51 void OnCompositingStarted(ui::Compositor* compositor,
52 base::TimeTicks start_time) override {}
53 void OnCompositingEnded(ui::Compositor* compositor) override;
54 void OnCompositingAborted(ui::Compositor* compositor) override {}
55 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {}
56 void OnCompositingShuttingDown(ui::Compositor* compositor) override {}
57
58 // Sets the window to use for capture.
59 void SetWindow(aura::Window* window);
60
61 private:
62 // Captures a frame.
63 // |dirty| is false for timer polls and true for compositor updates.
64 void Capture(bool dirty);
65
66 // Update capture size. Must be called on the UI thread.
67 void UpdateCaptureSize();
68
69 // Response callback for cc::Layer::RequestCopyOfOutput().
70 void DidCopyOutput(
71 scoped_refptr<media::VideoFrame> video_frame,
72 base::TimeTicks start_time,
73 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb,
74 scoped_ptr<cc::CopyOutputResult> result);
75
76 // A helper which does the real work for DidCopyOutput. Returns true if
77 // succeeded.
78 bool ProcessCopyOutputResponse(
79 scoped_refptr<media::VideoFrame> video_frame,
80 base::TimeTicks start_time,
81 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb,
82 scoped_ptr<cc::CopyOutputResult> result);
83
84 // Helper function to update cursor state.
85 // |region_in_frame| defines the desktop bound in the captured frame.
86 // Returns the current cursor position in captured frame.
87 gfx::Point UpdateCursorState(const gfx::Rect& region_in_frame);
88
89 // Clears cursor state.
90 void ClearCursorState();
91
92 // The window associated with the desktop.
93 aura::Window* desktop_window_;
94
95 // The timer that kicks off period captures.
96 base::Timer timer_;
97
98 // Whether screen capturing or window capture.
99 bool screen_capture_;
100
101 // Makes all the decisions about which frames to copy, and how.
102 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_;
103
104 // The capture parameters for this capture.
105 media::VideoCaptureParams capture_params_;
106
107 // YUV readback pipeline.
108 scoped_ptr<ReadbackYUVInterface> yuv_readback_pipeline_;
109
110 // Cursor state.
111 ui::Cursor last_cursor_;
112 gfx::Point cursor_hot_point_;
113 SkBitmap scaled_cursor_bitmap_;
114
115 // TODO(jiayl): Remove power_save_blocker_ when there is an API to keep the
116 // screen from sleeping for the drive-by web.
117 scoped_ptr<PowerSaveBlocker> power_save_blocker_;
118
119 DISALLOW_COPY_AND_ASSIGN(AuraWindowCaptureMachine);
120 };
121
122 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698