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

Side by Side Diff: content/browser/renderer_host/media/video_capture_manager.h

Issue 2169013002: Change class VideoCaptureDevice::Name to struct VideoCaptureDeviceDescriptor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactoring of VideoCaptureDeviceFactory interface Created 4 years, 4 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // VideoCaptureManager is used to open/close, start/stop, enumerate available 5 // VideoCaptureManager is used to open/close, start/stop, enumerate available
6 // video capture devices, and manage VideoCaptureController's. 6 // video capture devices, and manage VideoCaptureController's.
7 // All functions are expected to be called from Browser::IO thread. Some helper 7 // All functions are expected to be called from Browser::IO thread. Some helper
8 // functions (*OnDeviceThread) will dispatch operations to the device thread. 8 // functions (*OnDeviceThread) will dispatch operations to the device thread.
9 // VideoCaptureManager will open OS dependent instances of VideoCaptureDevice. 9 // VideoCaptureManager will open OS dependent instances of VideoCaptureDevice.
10 // A device can only be opened once. 10 // A device can only be opened once.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 void OnApplicationStateChange(base::android::ApplicationState state); 173 void OnApplicationStateChange(base::android::ApplicationState state);
174 #endif 174 #endif
175 175
176 private: 176 private:
177 class CaptureDeviceStartRequest; 177 class CaptureDeviceStartRequest;
178 class DeviceEntry; 178 class DeviceEntry;
179 179
180 using SessionMap = std::map<media::VideoCaptureSessionId, MediaStreamDevice>; 180 using SessionMap = std::map<media::VideoCaptureSessionId, MediaStreamDevice>;
181 using DeviceEntries = std::vector<std::unique_ptr<DeviceEntry>>; 181 using DeviceEntries = std::vector<std::unique_ptr<DeviceEntry>>;
182 using DeviceStartQueue = std::list<CaptureDeviceStartRequest>; 182 using DeviceStartQueue = std::list<CaptureDeviceStartRequest>;
183 using VideoCaptureDeviceDescriptor = media::VideoCaptureDeviceDescriptor;
184 using VideoCaptureDeviceDescriptors = media::VideoCaptureDeviceDescriptors;
183 185
184 ~VideoCaptureManager() override; 186 ~VideoCaptureManager() override;
185 187
186 // Helpers to report an event to our Listener. 188 // Helpers to report an event to our Listener.
187 void OnOpened(MediaStreamType type, 189 void OnOpened(MediaStreamType type,
188 media::VideoCaptureSessionId capture_session_id); 190 media::VideoCaptureSessionId capture_session_id);
189 void OnClosed(MediaStreamType type, 191 void OnClosed(MediaStreamType type,
190 media::VideoCaptureSessionId capture_session_id); 192 media::VideoCaptureSessionId capture_session_id);
191 void OnDevicesInfoEnumerated( 193 void OnDevicesInfoEnumerated(
192 MediaStreamType stream_type, 194 MediaStreamType stream_type,
193 base::ElapsedTimer* timer, 195 base::ElapsedTimer* timer,
194 const media::VideoCaptureDeviceInfos& new_devices_info_cache); 196 const media::VideoCaptureDeviceInfos& new_devices_info_cache);
195 197
196 bool IsOnDeviceThread() const; 198 bool IsOnDeviceThread() const;
197 199
198 // Consolidates the cached devices list with the list of currently connected 200 // Consolidates the cached devices list with the list of currently connected
199 // devices in the system |names_snapshot|. Retrieves the supported formats of 201 // devices in the system |names_snapshot|. Retrieves the supported formats of
200 // the new devices and sends the new cache to OnDevicesInfoEnumerated(). 202 // the new devices and sends the new cache to OnDevicesInfoEnumerated().
201 void ConsolidateDevicesInfoOnDeviceThread( 203 void ConsolidateDevicesInfoOnDeviceThread(
202 base::Callback<void(const media::VideoCaptureDeviceInfos&)> 204 base::Callback<void(const media::VideoCaptureDeviceInfos&)>
203 on_devices_enumerated_callback, 205 on_devices_enumerated_callback,
204 MediaStreamType stream_type, 206 MediaStreamType stream_type,
205 const media::VideoCaptureDeviceInfos& old_device_info_cache, 207 const media::VideoCaptureDeviceInfos& old_device_info_cache,
206 std::unique_ptr<VideoCaptureDevice::Names> names_snapshot); 208 std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors_snapshot);
207 209
208 // Checks to see if |entry| has no clients left on its controller. If so, 210 // Checks to see if |entry| has no clients left on its controller. If so,
209 // remove it from the list of devices, and delete it asynchronously. |entry| 211 // remove it from the list of devices, and delete it asynchronously. |entry|
210 // may be freed by this function. 212 // may be freed by this function.
211 void DestroyDeviceEntryIfNoClients(DeviceEntry* entry); 213 void DestroyDeviceEntryIfNoClients(DeviceEntry* entry);
212 214
213 // Retrieve the VideoCaptureDevice associated to |session_id|, or nullptr 215 // Retrieve the VideoCaptureDevice associated to |session_id|, or nullptr
214 // if not found. 216 // if not found.
215 VideoCaptureDevice* GetVideoCaptureDeviceBySessionId(int session_id); 217 VideoCaptureDevice* GetVideoCaptureDeviceBySessionId(int session_id);
216 218
(...skipping 28 matching lines...) Expand all
245 void OnDeviceStarted(int serial_id, 247 void OnDeviceStarted(int serial_id,
246 std::unique_ptr<VideoCaptureDevice> device); 248 std::unique_ptr<VideoCaptureDevice> device);
247 void DoStopDevice(DeviceEntry* entry); 249 void DoStopDevice(DeviceEntry* entry);
248 void HandleQueuedStartRequest(); 250 void HandleQueuedStartRequest();
249 251
250 // Creates and Starts a new VideoCaptureDevice. The resulting 252 // Creates and Starts a new VideoCaptureDevice. The resulting
251 // VideoCaptureDevice is returned to the IO-thread and stored in 253 // VideoCaptureDevice is returned to the IO-thread and stored in
252 // a DeviceEntry in |devices_|. Ownership of |client| passes to 254 // a DeviceEntry in |devices_|. Ownership of |client| passes to
253 // the device. 255 // the device.
254 std::unique_ptr<VideoCaptureDevice> DoStartDeviceCaptureOnDeviceThread( 256 std::unique_ptr<VideoCaptureDevice> DoStartDeviceCaptureOnDeviceThread(
255 const VideoCaptureDevice::Name& name, 257 const VideoCaptureDeviceDescriptor& descriptor,
256 const media::VideoCaptureParams& params, 258 const media::VideoCaptureParams& params,
257 std::unique_ptr<VideoCaptureDevice::Client> client); 259 std::unique_ptr<VideoCaptureDevice::Client> client);
258 260
259 std::unique_ptr<VideoCaptureDevice> DoStartTabCaptureOnDeviceThread( 261 std::unique_ptr<VideoCaptureDevice> DoStartTabCaptureOnDeviceThread(
260 const std::string& device_id, 262 const std::string& device_id,
261 const media::VideoCaptureParams& params, 263 const media::VideoCaptureParams& params,
262 std::unique_ptr<VideoCaptureDevice::Client> client); 264 std::unique_ptr<VideoCaptureDevice::Client> client);
263 265
264 std::unique_ptr<VideoCaptureDevice> DoStartDesktopCaptureOnDeviceThread( 266 std::unique_ptr<VideoCaptureDevice> DoStartDesktopCaptureOnDeviceThread(
265 const std::string& device_id, 267 const std::string& device_id,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // Map used by DesktopCapture. 342 // Map used by DesktopCapture.
341 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> 343 std::map<media::VideoCaptureSessionId, gfx::NativeViewId>
342 notification_window_ids_; 344 notification_window_ids_;
343 345
344 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); 346 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager);
345 }; 347 };
346 348
347 } // namespace content 349 } // namespace content
348 350
349 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ 351 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698