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

Side by Side Diff: media/capture/screen_capture_device_core.h

Issue 1162863003: Move ContentVideoCaptureDeviceCore from src/content to src/media (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile error Created 5 years, 6 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 2014 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 #ifndef MEDIA_CAPTURE_SCREEN_CAPTURE_DEVICE_CORE_H_
6 #define MEDIA_CAPTURE_SCREEN_CAPTURE_DEVICE_CORE_H_
7
8 #include <string>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/thread_checker.h"
13 #include "media/base/media_export.h"
14 #include "media/capture/thread_safe_capture_oracle.h"
15 #include "media/video/capture/video_capture_device.h"
16
17 namespace media {
18
19 class VideoCaptureParams;
20
21 class ThreadSafeCaptureOracle;
22
23 // Keeps track of the video capture source frames and executes copying.
24 class VideoCaptureMachine {
25 public:
26 VideoCaptureMachine() {}
27 virtual ~VideoCaptureMachine() {}
28
29 // Starts capturing.
30 // |callback| is invoked with true if succeeded. Otherwise, with false.
31 virtual void Start(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy,
32 const VideoCaptureParams& params,
33 const base::Callback<void(bool)> callback) = 0;
34
35 // Stops capturing.
36 // |callback| is invoked after the capturing has stopped.
37 virtual void Stop(const base::Closure& callback) = 0;
38
39 private:
40 DISALLOW_COPY_AND_ASSIGN(VideoCaptureMachine);
41 };
42
43 // The "meat" of a content video capturer.
44 //
45 // Separating this from the "shell classes" WebContentsVideoCaptureDevice and
46 // DesktopCaptureDeviceAura allows safe destruction without needing to block any
47 // threads, as well as code sharing.
48 //
49 // ScreenCaptureDeviceCore manages a simple state machine and the pipeline
50 // (see notes at top of this file). It times the start of successive captures
51 // and facilitates the processing of each through the stages of the
52 // pipeline.
53 class MEDIA_EXPORT ScreenCaptureDeviceCore
54 : public base::SupportsWeakPtr<ScreenCaptureDeviceCore> {
55 public:
56 ScreenCaptureDeviceCore(
57 scoped_ptr<VideoCaptureMachine> capture_machine);
58 virtual ~ScreenCaptureDeviceCore();
59
60 // Asynchronous requests to change ScreenCaptureDeviceCore state.
61 void AllocateAndStart(const VideoCaptureParams& params,
62 scoped_ptr<VideoCaptureDevice::Client> client);
63 void StopAndDeAllocate();
64
65 private:
66 // Flag indicating current state.
67 enum State {
68 kIdle,
69 kCapturing,
70 kError
71 };
72
73 void TransitionStateTo(State next_state);
74
75 // Called back in response to StartCaptureMachine(). |success| is true if
76 // capture machine succeeded to start.
77 void CaptureStarted(bool success);
78
79 // Stops capturing and notifies client_ of an error state.
80 void Error(const std::string& reason);
81
82 // Tracks that all activity occurs on the media stream manager's thread.
83 base::ThreadChecker thread_checker_;
84
85 // Current lifecycle state.
86 State state_;
87
88 // Tracks the CaptureMachine that's doing work on our behalf
89 // on the device thread or UI thread.
90 // This value should never be dereferenced by this class.
91 scoped_ptr<VideoCaptureMachine> capture_machine_;
92
93 // Our thread-safe capture oracle which serves as the gateway to the video
94 // capture pipeline. Besides the VideoCaptureDevice itself, it is the only
95 // component of the system with direct access to |client_|.
96 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_;
97
98 DISALLOW_COPY_AND_ASSIGN(ScreenCaptureDeviceCore);
99 };
100
101
102 } // namespace media
103
104 #endif // MEDIA_CAPTURE_SCREEN_CAPTURE_DEVICE_CORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698