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

Unified 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: Fix non-aura mac build 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/browser/media/capture/aura_window_capture_machine.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/capture/aura_window_capture_machine.h
diff --git a/content/browser/media/capture/aura_window_capture_machine.h b/content/browser/media/capture/aura_window_capture_machine.h
new file mode 100644
index 0000000000000000000000000000000000000000..f41e73ce460af2a7bdcf3bfe6739b037aa01307f
--- /dev/null
+++ b/content/browser/media/capture/aura_window_capture_machine.h
@@ -0,0 +1,128 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_
+#define CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/timer/timer.h"
+#include "content/browser/media/capture/content_video_capture_device_core.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_observer.h"
+#include "ui/base/cursor/cursors_aura.h"
+#include "ui/compositor/compositor.h"
+
+namespace cc {
+
+class CopyOutputResult;
+
+} // namespace cc
+
+namespace content {
+
+class PowerSaveBlocker;
+class ReadbackYUVInterface;
+
+class AuraWindowCaptureMachine
+ : public VideoCaptureMachine,
+ public aura::WindowObserver,
+ public ui::CompositorObserver,
+ public base::SupportsWeakPtr<AuraWindowCaptureMachine> {
+ public:
+ AuraWindowCaptureMachine();
+ ~AuraWindowCaptureMachine() override;
+
+ // VideoCaptureFrameSource overrides.
+ bool Start(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy,
+ const media::VideoCaptureParams& params) override;
+ void Stop(const base::Closure& callback) override;
+
+ // Implements aura::WindowObserver.
+ void OnWindowBoundsChanged(aura::Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) override;
+ void OnWindowDestroyed(aura::Window* window) override;
+ void OnWindowAddedToRootWindow(aura::Window* window) override;
+ void OnWindowRemovingFromRootWindow(aura::Window* window,
+ aura::Window* new_root) override;
+
+ // Implements ui::CompositorObserver.
+ void OnCompositingDidCommit(ui::Compositor* compositor) override {}
+ void OnCompositingStarted(ui::Compositor* compositor,
+ base::TimeTicks start_time) override {}
+ void OnCompositingEnded(ui::Compositor* compositor) override;
+ void OnCompositingAborted(ui::Compositor* compositor) override {}
+ void OnCompositingLockStateChanged(ui::Compositor* compositor) override {}
+ void OnCompositingShuttingDown(ui::Compositor* compositor) override {}
+
+ // Sets the window to use for capture.
+ void SetWindow(aura::Window* window);
+
+ private:
+ // Captures a frame.
+ // |dirty| is false for timer polls and true for compositor updates.
+ void Capture(bool dirty);
+
+ // Update capture size. Must be called on the UI thread.
+ void UpdateCaptureSize();
+
+ // Response callback for cc::Layer::RequestCopyOfOutput().
+ void DidCopyOutput(
+ scoped_refptr<media::VideoFrame> video_frame,
+ base::TimeTicks start_time,
+ const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb,
+ scoped_ptr<cc::CopyOutputResult> result);
+
+ // A helper which does the real work for DidCopyOutput. Returns true if
+ // succeeded.
+ bool ProcessCopyOutputResponse(
+ scoped_refptr<media::VideoFrame> video_frame,
+ base::TimeTicks start_time,
+ const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb,
+ scoped_ptr<cc::CopyOutputResult> result);
+
+ // Helper function to update cursor state.
+ // |region_in_frame| defines where the desktop is rendered in the captured
+ // frame.
+ // Returns the current cursor position in captured frame.
+ gfx::Point UpdateCursorState(const gfx::Rect& region_in_frame);
+
+ // Clears cursor state.
+ void ClearCursorState();
+
+ // The window associated with the desktop.
+ aura::Window* desktop_window_;
+
+ // The timer that kicks off period captures.
+ base::Timer timer_;
+
+ // Whether screen capturing or window capture.
+ bool screen_capture_;
+
+ // Makes all the decisions about which frames to copy, and how.
+ scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_;
+
+ // The capture parameters for this capture.
+ media::VideoCaptureParams capture_params_;
+
+ // YUV readback pipeline.
+ scoped_ptr<content::ReadbackYUVInterface> yuv_readback_pipeline_;
+
+ // Cursor state.
+ ui::Cursor last_cursor_;
+ gfx::Size desktop_size_when_cursor_last_updated_;
+ gfx::Point cursor_hot_point_;
+ SkBitmap scaled_cursor_bitmap_;
+
+ // TODO(jiayl): Remove power_save_blocker_ when there is an API to keep the
+ // screen from sleeping for the drive-by web.
+ scoped_ptr<PowerSaveBlocker> power_save_blocker_;
+
+ DISALLOW_COPY_AND_ASSIGN(AuraWindowCaptureMachine);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/browser/media/capture/aura_window_capture_machine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698