OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_CONTENT_VIDEO_CAPTURE_DEVICE_CORE_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_DEVICE_CORE_H_ |
6 #define CONTENT_BROWSER_MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_DEVICE_CORE_H_ | 6 #define CONTENT_BROWSER_MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_DEVICE_CORE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // Makes the decision to capture a frame. | 101 // Makes the decision to capture a frame. |
102 VideoCaptureOracle oracle_; | 102 VideoCaptureOracle oracle_; |
103 | 103 |
104 // The video capture parameters used to construct the oracle proxy. | 104 // The video capture parameters used to construct the oracle proxy. |
105 const media::VideoCaptureParams params_; | 105 const media::VideoCaptureParams params_; |
106 | 106 |
107 // The current video capture size. | 107 // The current video capture size. |
108 gfx::Size capture_size_; | 108 gfx::Size capture_size_; |
109 }; | 109 }; |
110 | 110 |
111 // Keeps track of the video capture source frames and executes copying on the | 111 // Keeps track of the video capture source frames and executes copying. |
112 // UI BrowserThread. | |
113 class VideoCaptureMachine { | 112 class VideoCaptureMachine { |
114 public: | 113 public: |
115 VideoCaptureMachine() {} | 114 VideoCaptureMachine() {} |
116 virtual ~VideoCaptureMachine() {} | 115 virtual ~VideoCaptureMachine() {} |
117 | 116 |
118 // Starts capturing. Returns true if succeeded. | 117 // Starts capturing. |
119 // Must be run on the UI BrowserThread. | 118 // |callback| is invoked with true if succeeded. Otherwise, with false. |
120 virtual bool Start(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, | 119 virtual void Start(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, |
121 const media::VideoCaptureParams& params) = 0; | 120 const media::VideoCaptureParams& params, |
| 121 const base::Callback<void(bool)> callback) = 0; |
122 | 122 |
123 // Stops capturing. Must be run on the UI BrowserThread. | 123 // Stops capturing. |
124 // |callback| is invoked after the capturing has stopped. | 124 // |callback| is invoked after the capturing has stopped. |
125 virtual void Stop(const base::Closure& callback) = 0; | 125 virtual void Stop(const base::Closure& callback) = 0; |
126 | 126 |
127 private: | 127 private: |
128 DISALLOW_COPY_AND_ASSIGN(VideoCaptureMachine); | 128 DISALLOW_COPY_AND_ASSIGN(VideoCaptureMachine); |
129 }; | 129 }; |
130 | 130 |
131 // The "meat" of a content video capturer. | 131 // The "meat" of a content video capturer. |
132 // | 132 // |
133 // Separating this from the "shell classes" WebContentsVideoCaptureDevice and | 133 // Separating this from the "shell classes" WebContentsVideoCaptureDevice and |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 // Stops capturing and notifies client_ of an error state. | 167 // Stops capturing and notifies client_ of an error state. |
168 void Error(const std::string& reason); | 168 void Error(const std::string& reason); |
169 | 169 |
170 // Tracks that all activity occurs on the media stream manager's thread. | 170 // Tracks that all activity occurs on the media stream manager's thread. |
171 base::ThreadChecker thread_checker_; | 171 base::ThreadChecker thread_checker_; |
172 | 172 |
173 // Current lifecycle state. | 173 // Current lifecycle state. |
174 State state_; | 174 State state_; |
175 | 175 |
176 // Tracks the CaptureMachine that's doing work on our behalf on the UI thread. | 176 // Tracks the CaptureMachine that's doing work on our behalf |
177 // This value should never be dereferenced by this class, other than to | 177 // on the device thread or UI thread. |
178 // create and destroy it on the UI thread. | 178 // This value should never be dereferenced by this class. |
179 scoped_ptr<VideoCaptureMachine> capture_machine_; | 179 scoped_ptr<VideoCaptureMachine> capture_machine_; |
180 | 180 |
181 // Our thread-safe capture oracle which serves as the gateway to the video | 181 // Our thread-safe capture oracle which serves as the gateway to the video |
182 // capture pipeline. Besides the VideoCaptureDevice itself, it is the only | 182 // capture pipeline. Besides the VideoCaptureDevice itself, it is the only |
183 // component of the system with direct access to |client_|. | 183 // component of the system with direct access to |client_|. |
184 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; | 184 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; |
185 | 185 |
186 DISALLOW_COPY_AND_ASSIGN(ContentVideoCaptureDeviceCore); | 186 DISALLOW_COPY_AND_ASSIGN(ContentVideoCaptureDeviceCore); |
187 }; | 187 }; |
188 | 188 |
189 | 189 |
190 } // namespace content | 190 } // namespace content |
191 | 191 |
192 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_DEVICE_CORE_H_ | 192 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_DEVICE_CORE_H_ |
OLD | NEW |