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 23 matching lines...) Expand all Loading... |
34 class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { | 34 class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
35 public: | 35 public: |
36 // Callback used to signal the completion of a controller lookup. | 36 // Callback used to signal the completion of a controller lookup. |
37 typedef base::Callback< | 37 typedef base::Callback< |
38 void(const base::WeakPtr<VideoCaptureController>&)> DoneCB; | 38 void(const base::WeakPtr<VideoCaptureController>&)> DoneCB; |
39 | 39 |
40 VideoCaptureManager(); | 40 VideoCaptureManager(); |
41 | 41 |
42 // Implements MediaStreamProvider. | 42 // Implements MediaStreamProvider. |
43 virtual void Register(MediaStreamProviderListener* listener, | 43 virtual void Register(MediaStreamProviderListener* listener, |
44 base::MessageLoopProxy* device_thread_loop) OVERRIDE; | 44 const scoped_refptr<base::SingleThreadTaskRunner>& |
| 45 device_task_runner) OVERRIDE; |
45 | 46 |
46 virtual void Unregister() OVERRIDE; | 47 virtual void Unregister() OVERRIDE; |
47 | 48 |
48 virtual void EnumerateDevices(MediaStreamType stream_type) OVERRIDE; | 49 virtual void EnumerateDevices(MediaStreamType stream_type) OVERRIDE; |
49 | 50 |
50 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; | 51 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; |
51 | 52 |
52 virtual void Close(int capture_session_id) OVERRIDE; | 53 virtual void Close(int capture_session_id) OVERRIDE; |
53 | 54 |
54 // Used by unit test to make sure a fake device is used instead of a real | 55 // Used by unit test to make sure a fake device is used instead of a real |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 scoped_ptr<media::VideoCaptureDevice::Client> client); | 160 scoped_ptr<media::VideoCaptureDevice::Client> client); |
160 | 161 |
161 // Stop and destroy the VideoCaptureDevice held in | 162 // Stop and destroy the VideoCaptureDevice held in |
162 // |entry->video_capture_device|. | 163 // |entry->video_capture_device|. |
163 void DoStopDeviceOnDeviceThread(DeviceEntry* entry); | 164 void DoStopDeviceOnDeviceThread(DeviceEntry* entry); |
164 | 165 |
165 DeviceInfo* FindDeviceInfoById(const std::string& id, | 166 DeviceInfo* FindDeviceInfoById(const std::string& id, |
166 DeviceInfos& device_vector); | 167 DeviceInfos& device_vector); |
167 | 168 |
168 // The message loop of media stream device thread, where VCD's live. | 169 // The message loop of media stream device thread, where VCD's live. |
169 scoped_refptr<base::MessageLoopProxy> device_loop_; | 170 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; |
170 | 171 |
171 // Only accessed on Browser::IO thread. | 172 // Only accessed on Browser::IO thread. |
172 MediaStreamProviderListener* listener_; | 173 MediaStreamProviderListener* listener_; |
173 media::VideoCaptureSessionId new_capture_session_id_; | 174 media::VideoCaptureSessionId new_capture_session_id_; |
174 | 175 |
175 // An entry is kept in this map for every session that has been created via | 176 // An entry is kept in this map for every session that has been created via |
176 // the Open() entry point. The keys are session_id's. This map is used to | 177 // the Open() entry point. The keys are session_id's. This map is used to |
177 // determine which device to use when StartCaptureForClient() occurs. Used | 178 // determine which device to use when StartCaptureForClient() occurs. Used |
178 // only on the IO thread. | 179 // only on the IO thread. |
179 std::map<media::VideoCaptureSessionId, MediaStreamDevice> sessions_; | 180 std::map<media::VideoCaptureSessionId, MediaStreamDevice> sessions_; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 TEST_PATTERN, | 224 TEST_PATTERN, |
224 Y4M_FILE | 225 Y4M_FILE |
225 } artificial_device_source_for_testing_; | 226 } artificial_device_source_for_testing_; |
226 | 227 |
227 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); | 228 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); |
228 }; | 229 }; |
229 | 230 |
230 } // namespace content | 231 } // namespace content |
231 | 232 |
232 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ | 233 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ |
OLD | NEW |