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/process/process_handle.h" | 21 #include "base/process/process_handle.h" |
22 #include "content/browser/renderer_host/media/media_stream_provider.h" | 22 #include "content/browser/renderer_host/media/media_stream_provider.h" |
23 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" | 23 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" |
24 #include "content/common/content_export.h" | 24 #include "content/common/content_export.h" |
25 #include "content/common/media/media_stream_options.h" | 25 #include "content/common/media/media_stream_options.h" |
26 #include "media/video/capture/video_capture_device.h" | 26 #include "media/video/capture/video_capture_device.h" |
27 #include "media/video/capture/video_capture_device_factory.h" | 27 #include "media/video/capture/video_capture_device_factory.h" |
28 #include "media/video/capture/video_capture_types.h" | 28 #include "media/video/capture/video_capture_types.h" |
29 #include "ui/gfx/display.h" | |
29 | 30 |
30 namespace content { | 31 namespace content { |
31 class VideoCaptureController; | 32 class VideoCaptureController; |
32 class VideoCaptureControllerEventHandler; | 33 class VideoCaptureControllerEventHandler; |
33 | 34 |
34 // VideoCaptureManager opens/closes and start/stops video capture devices. | 35 // VideoCaptureManager opens/closes and start/stops video capture devices. |
35 class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { | 36 class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
36 public: | 37 public: |
37 // Callback used to signal the completion of a controller lookup. | 38 // Callback used to signal the completion of a controller lookup. |
38 typedef base::Callback< | 39 typedef base::Callback< |
39 void(const base::WeakPtr<VideoCaptureController>&)> DoneCB; | 40 void(const base::WeakPtr<VideoCaptureController>&)> DoneCB; |
40 | 41 |
41 explicit VideoCaptureManager( | 42 explicit VideoCaptureManager( |
42 scoped_ptr<media::VideoCaptureDeviceFactory> factory); | 43 scoped_ptr<media::VideoCaptureDeviceFactory> factory); |
43 | 44 |
45 // Set the Display rotation. | |
46 void SetDisplayRotation(gfx::Display::Rotation rotation); | |
47 | |
44 // Implements MediaStreamProvider. | 48 // Implements MediaStreamProvider. |
45 virtual void Register(MediaStreamProviderListener* listener, | 49 virtual void Register(MediaStreamProviderListener* listener, |
46 const scoped_refptr<base::SingleThreadTaskRunner>& | 50 const scoped_refptr<base::SingleThreadTaskRunner>& |
47 device_task_runner) OVERRIDE; | 51 device_task_runner) OVERRIDE; |
48 | 52 |
49 virtual void Unregister() OVERRIDE; | 53 virtual void Unregister() OVERRIDE; |
50 | 54 |
51 virtual void EnumerateDevices(MediaStreamType stream_type) OVERRIDE; | 55 virtual void EnumerateDevices(MediaStreamType stream_type) OVERRIDE; |
52 | 56 |
53 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; | 57 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 DeviceInfo* FindDeviceInfoById(const std::string& id, | 180 DeviceInfo* FindDeviceInfoById(const std::string& id, |
177 DeviceInfos& device_vector); | 181 DeviceInfos& device_vector); |
178 | 182 |
179 void SetDesktopCaptureWindowIdOnDeviceThread(DeviceEntry* entry, | 183 void SetDesktopCaptureWindowIdOnDeviceThread(DeviceEntry* entry, |
180 gfx::NativeViewId window_id); | 184 gfx::NativeViewId window_id); |
181 | 185 |
182 void SaveDesktopCaptureWindowIdOnDeviceThread( | 186 void SaveDesktopCaptureWindowIdOnDeviceThread( |
183 media::VideoCaptureSessionId session_id, | 187 media::VideoCaptureSessionId session_id, |
184 gfx::NativeViewId window_id); | 188 gfx::NativeViewId window_id); |
185 | 189 |
190 void SetDisplayRotationOnDeviceThread(gfx::Display::Rotation rotation); | |
191 | |
186 // The message loop of media stream device thread, where VCD's live. | 192 // The message loop of media stream device thread, where VCD's live. |
187 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; | 193 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; |
188 | 194 |
189 // Only accessed on Browser::IO thread. | 195 // Only accessed on Browser::IO thread. |
190 MediaStreamProviderListener* listener_; | 196 MediaStreamProviderListener* listener_; |
191 media::VideoCaptureSessionId new_capture_session_id_; | 197 media::VideoCaptureSessionId new_capture_session_id_; |
192 | 198 |
193 typedef std::map<media::VideoCaptureSessionId, MediaStreamDevice> SessionMap; | 199 typedef std::map<media::VideoCaptureSessionId, MediaStreamDevice> SessionMap; |
194 // An entry is kept in this map for every session that has been created via | 200 // An entry is kept in this map for every session that has been created via |
195 // the Open() entry point. The keys are session_id's. This map is used to | 201 // the Open() entry point. The keys are session_id's. This map is used to |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 // from EnumerateDevices()--, and this snapshot is used to update this list in | 240 // from EnumerateDevices()--, and this snapshot is used to update this list in |
235 // OnDevicesInfoEnumerated(). GetDeviceSupportedFormats() will | 241 // OnDevicesInfoEnumerated(). GetDeviceSupportedFormats() will |
236 // use this list if the device is not started, otherwise it will retrieve the | 242 // use this list if the device is not started, otherwise it will retrieve the |
237 // active device capture format from the VideoCaptureController associated. | 243 // active device capture format from the VideoCaptureController associated. |
238 DeviceInfos devices_info_cache_; | 244 DeviceInfos devices_info_cache_; |
239 | 245 |
240 // Accessed on the device thread only. | 246 // Accessed on the device thread only. |
241 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> | 247 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> |
242 notification_window_ids_; | 248 notification_window_ids_; |
243 | 249 |
250 gfx::Display::Rotation display_rotation_; | |
vrk (LEFT CHROMIUM)
2014/05/08 21:43:34
Add comment saying this should be on the device th
Zachary Kuznia
2014/05/08 21:51:22
Done.
| |
251 | |
244 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); | 252 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); |
245 }; | 253 }; |
246 | 254 |
247 } // namespace content | 255 } // namespace content |
248 | 256 |
249 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ | 257 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ |
OLD | NEW |