Chromium Code Reviews| OLD | NEW |
|---|---|
| 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. |
| 11 | 11 |
| 12 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ | 12 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ |
| 13 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ | 13 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ |
| 14 | 14 |
| 15 #include <map> | 15 #include <map> |
| 16 #include <set> | 16 #include <set> |
| 17 #include <string> | 17 #include <string> |
| 18 | 18 |
| 19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 21 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
| 22 #include "base/process/process_handle.h" | 22 #include "base/process/process_handle.h" |
| 23 #include "base/timer/elapsed_timer.h" | 23 #include "base/timer/elapsed_timer.h" |
| 24 #include "content/browser/renderer_host/media/media_stream_provider.h" | 24 #include "content/browser/renderer_host/media/media_stream_provider.h" |
| 25 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" | 25 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" |
| 26 #include "content/common/content_export.h" | 26 #include "content/common/content_export.h" |
| 27 #include "content/common/media/media_stream_options.h" | 27 #include "content/common/media/media_stream_options.h" |
| 28 #include "media/video/capture/video_capture_device.h" | 28 #include "media/video/capture/video_capture_device.h" |
| 29 #include "media/video/capture/video_capture_device_factory.h" | 29 #include "media/video/capture/video_capture_device_factory.h" |
| 30 #include "media/video/capture/video_capture_device_info.h" | |
| 30 #include "media/video/capture/video_capture_types.h" | 31 #include "media/video/capture/video_capture_types.h" |
| 31 | 32 |
| 32 namespace content { | 33 namespace content { |
| 33 class VideoCaptureController; | 34 class VideoCaptureController; |
| 34 class VideoCaptureControllerEventHandler; | 35 class VideoCaptureControllerEventHandler; |
| 35 | 36 |
| 36 // VideoCaptureManager opens/closes and start/stops video capture devices. | 37 // VideoCaptureManager opens/closes and start/stops video capture devices. |
| 37 class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { | 38 class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
| 38 public: | 39 public: |
| 39 // Callback used to signal the completion of a controller lookup. | 40 // Callback used to signal the completion of a controller lookup. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 gfx::NativeViewId window_id); | 127 gfx::NativeViewId window_id); |
| 127 | 128 |
| 128 // Gets a weak reference to the device factory, used for tests. | 129 // Gets a weak reference to the device factory, used for tests. |
| 129 media::VideoCaptureDeviceFactory* video_capture_device_factory() const { | 130 media::VideoCaptureDeviceFactory* video_capture_device_factory() const { |
| 130 return video_capture_device_factory_.get(); | 131 return video_capture_device_factory_.get(); |
| 131 } | 132 } |
| 132 | 133 |
| 133 private: | 134 private: |
| 134 virtual ~VideoCaptureManager(); | 135 virtual ~VideoCaptureManager(); |
| 135 struct DeviceEntry; | 136 struct DeviceEntry; |
| 136 | 137 typedef media::VideoCaptureDeviceInfo DeviceInfo; |
|
perkj_chrome
2014/10/08 14:26:36
Please rename all DeviceInfo to VideoCaptureDevice
mcasas
2014/10/08 14:49:39
Done.
| |
| 137 // This data structure is a convenient wrap of a devices' name and associated | 138 typedef media::VideoCaptureDeviceInfos DeviceInfos; |
| 138 // video capture supported formats. | |
| 139 struct DeviceInfo { | |
| 140 DeviceInfo(); | |
| 141 DeviceInfo(const media::VideoCaptureDevice::Name& name, | |
| 142 const media::VideoCaptureFormats& supported_formats); | |
| 143 ~DeviceInfo(); | |
| 144 | |
| 145 media::VideoCaptureDevice::Name name; | |
| 146 media::VideoCaptureFormats supported_formats; | |
| 147 }; | |
| 148 typedef std::vector<DeviceInfo> DeviceInfos; | |
| 149 | 139 |
| 150 // Checks to see if |entry| has no clients left on its controller. If so, | 140 // Checks to see if |entry| has no clients left on its controller. If so, |
| 151 // remove it from the list of devices, and delete it asynchronously. |entry| | 141 // remove it from the list of devices, and delete it asynchronously. |entry| |
| 152 // may be freed by this function. | 142 // may be freed by this function. |
| 153 void DestroyDeviceEntryIfNoClients(DeviceEntry* entry); | 143 void DestroyDeviceEntryIfNoClients(DeviceEntry* entry); |
| 154 | 144 |
| 155 // Helpers to report an event to our Listener. | 145 // Helpers to report an event to our Listener. |
| 156 void OnOpened(MediaStreamType type, | 146 void OnOpened(MediaStreamType type, |
| 157 media::VideoCaptureSessionId capture_session_id); | 147 media::VideoCaptureSessionId capture_session_id); |
| 158 void OnClosed(MediaStreamType type, | 148 void OnClosed(MediaStreamType type, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 // Accessed on the device thread only. | 255 // Accessed on the device thread only. |
| 266 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> | 256 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> |
| 267 notification_window_ids_; | 257 notification_window_ids_; |
| 268 | 258 |
| 269 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); | 259 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); |
| 270 }; | 260 }; |
| 271 | 261 |
| 272 } // namespace content | 262 } // namespace content |
| 273 | 263 |
| 274 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ | 264 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ |
| OLD | NEW |