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. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 const DoneCB& done_cb); | 75 const DoneCB& done_cb); |
76 | 76 |
77 // Called by VideoCaptureHost to remove |client_handler|. If this is the last | 77 // Called by VideoCaptureHost to remove |client_handler|. If this is the last |
78 // client of the device, the |controller| and its VideoCaptureDevice may be | 78 // client of the device, the |controller| and its VideoCaptureDevice may be |
79 // destroyed. The client must not access |controller| after calling this | 79 // destroyed. The client must not access |controller| after calling this |
80 // function. | 80 // function. |
81 void StopCaptureForClient(VideoCaptureController* controller, | 81 void StopCaptureForClient(VideoCaptureController* controller, |
82 VideoCaptureControllerID client_id, | 82 VideoCaptureControllerID client_id, |
83 VideoCaptureControllerEventHandler* client_handler); | 83 VideoCaptureControllerEventHandler* client_handler); |
84 | 84 |
85 // Retrieve the available capture capabilities for a particular device. The | |
86 // capabilities are cached during GetAvailableDevicesOnDeviceThread() and | |
87 // updated on DoStartDeviceOnDeviceThread(). The call is asynchronous and the | |
88 // reply comes via OnDeviceCapabilitiesEnumerated(). | |
tommi (sloooow) - chröme
2013/10/25 14:15:34
nit: nice comment in general but I don't think you
mcasas
2013/10/28 12:50:08
Boosted prosaic skills :) + corrected callback nam
| |
89 void EnumerateDeviceCapabilities(const StreamDeviceInfo& device_info); | |
90 | |
85 private: | 91 private: |
86 virtual ~VideoCaptureManager(); | 92 virtual ~VideoCaptureManager(); |
87 struct DeviceEntry; | 93 struct DeviceEntry; |
88 | 94 |
89 // Check to see if |entry| has no clients left on its controller. If so, | 95 // Check to see if |entry| has no clients left on its controller. If so, |
90 // remove it from the list of devices, and delete it asynchronously. |entry| | 96 // remove it from the list of devices, and delete it asynchronously. |entry| |
91 // may be freed by this function. | 97 // may be freed by this function. |
92 void DestroyDeviceEntryIfNoClients(DeviceEntry* entry); | 98 void DestroyDeviceEntryIfNoClients(DeviceEntry* entry); |
93 | 99 |
94 // Helpers to report an event to our Listener. | 100 // Helpers to report an event to our Listener. |
95 void OnOpened(MediaStreamType type, int capture_session_id); | 101 void OnOpened(MediaStreamType type, int capture_session_id); |
96 void OnClosed(MediaStreamType type, int capture_session_id); | 102 void OnClosed(MediaStreamType type, int capture_session_id); |
97 void OnDevicesEnumerated(MediaStreamType stream_type, | 103 void OnDevicesEnumerated(MediaStreamType stream_type, |
98 const media::VideoCaptureDevice::Names& names); | 104 const media::VideoCaptureDevice::Names& names); |
105 void OnDeviceCapabilitiesEnumerated( | |
106 const StreamDeviceInfo& device_info, | |
107 const media::VideoCaptureCapabilities& capabilities); | |
99 | 108 |
100 // Find a DeviceEntry by its device ID and type, if it is already opened. | 109 // Find a DeviceEntry by its device ID and type, if it is already opened. |
101 DeviceEntry* GetDeviceEntryForMediaStreamDevice( | 110 DeviceEntry* GetDeviceEntryForMediaStreamDevice( |
102 const MediaStreamDevice& device_info); | 111 const MediaStreamDevice& device_info); |
103 | 112 |
104 // Find a DeviceEntry entry for the indicated session, creating a fresh one | 113 // Find a DeviceEntry entry for the indicated session, creating a fresh one |
105 // if necessary. Returns NULL if the session id is invalid. | 114 // if necessary. Returns NULL if the session id is invalid. |
106 DeviceEntry* GetOrCreateDeviceEntry(int capture_session_id); | 115 DeviceEntry* GetOrCreateDeviceEntry(int capture_session_id); |
107 | 116 |
108 // Find the DeviceEntry that owns a particular controller pointer. | 117 // Find the DeviceEntry that owns a particular controller pointer. |
109 DeviceEntry* GetDeviceEntryForController( | 118 DeviceEntry* GetDeviceEntryForController( |
110 const VideoCaptureController* controller); | 119 const VideoCaptureController* controller); |
111 | 120 |
112 bool IsOnDeviceThread() const; | 121 bool IsOnDeviceThread() const; |
113 | 122 |
114 // Queries and returns the available device IDs. | 123 // Queries and returns the available device IDs. |
115 media::VideoCaptureDevice::Names GetAvailableDevicesOnDeviceThread( | 124 media::VideoCaptureDevice::Names GetAvailableDevicesOnDeviceThread( |
116 MediaStreamType stream_type); | 125 MediaStreamType stream_type); |
117 | 126 |
127 // Queries and returns the video capture capabilities of a device. | |
128 media::VideoCaptureCapabilities GetDeviceCapabilitiesOnDeviceThread( | |
129 const StreamDeviceInfo& device_info) const; | |
130 | |
118 // Create and Start a new VideoCaptureDevice, storing the result in | 131 // Create and Start a new VideoCaptureDevice, storing the result in |
119 // |entry->video_capture_device|. Ownership of |client| passes to | 132 // |entry->video_capture_device|. Ownership of |client| passes to |
120 // the device. | 133 // the device. |
121 void DoStartDeviceOnDeviceThread( | 134 void DoStartDeviceOnDeviceThread( |
122 DeviceEntry* entry, | 135 DeviceEntry* entry, |
123 const media::VideoCaptureCapability& capture_params, | 136 const media::VideoCaptureCapability& capture_params, |
124 scoped_ptr<media::VideoCaptureDevice::Client> client); | 137 scoped_ptr<media::VideoCaptureDevice::Client> client); |
125 | 138 |
126 // Stop and destroy the VideoCaptureDevice held in | 139 // Stop and destroy the VideoCaptureDevice held in |
127 // |entry->video_capture_device|. | 140 // |entry->video_capture_device|. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 // Set to true if using fake video capture devices for testing, false by | 183 // Set to true if using fake video capture devices for testing, false by |
171 // default. This is only used for the MEDIA_DEVICE_VIDEO_CAPTURE device type. | 184 // default. This is only used for the MEDIA_DEVICE_VIDEO_CAPTURE device type. |
172 bool use_fake_device_; | 185 bool use_fake_device_; |
173 | 186 |
174 // We cache the enumerated video capture devices in | 187 // We cache the enumerated video capture devices in |
175 // GetAvailableDevicesOnDeviceThread() and then later look up the requested ID | 188 // GetAvailableDevicesOnDeviceThread() and then later look up the requested ID |
176 // when a device is created in DoStartDeviceOnDeviceThread(). Used only on the | 189 // when a device is created in DoStartDeviceOnDeviceThread(). Used only on the |
177 // device thread. | 190 // device thread. |
178 media::VideoCaptureDevice::Names video_capture_devices_; | 191 media::VideoCaptureDevice::Names video_capture_devices_; |
179 | 192 |
193 // Local cache of video capture capabilities, indexed by unique id. It is | |
194 // created in GetAvailableDevicesOnDeviceThread(), updated in | |
195 // DoStartDeviceOnDeviceThread() and retrieved for a particular device id in | |
196 // EnumerateDeviceCapabilities(), read only. | |
tommi (sloooow) - chröme
2013/10/25 14:15:34
is this last part true? It looks like EnumerateDe
mcasas
2013/10/28 12:50:08
Correct, this comment has not been updated after I
| |
197 std::map<std::string, media::VideoCaptureCapabilities> | |
198 video_capture_capabilities_; | |
tommi (sloooow) - chröme
2013/10/25 14:15:34
Instead of an extra map, can we change video_captu
mcasas
2013/10/28 12:50:08
Done. It turned out to be a class - first due to C
| |
199 | |
180 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); | 200 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); |
181 }; | 201 }; |
182 | 202 |
183 } // namespace content | 203 } // namespace content |
184 | 204 |
185 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ | 205 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ |
OLD | NEW |