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 27 matching lines...) Expand all Loading... |
38 class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { | 38 class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { |
39 public: | 39 public: |
40 // Callback used to signal the completion of a controller lookup. | 40 // Callback used to signal the completion of a controller lookup. |
41 typedef base::Callback< | 41 typedef base::Callback< |
42 void(const base::WeakPtr<VideoCaptureController>&)> DoneCB; | 42 void(const base::WeakPtr<VideoCaptureController>&)> DoneCB; |
43 | 43 |
44 explicit VideoCaptureManager( | 44 explicit VideoCaptureManager( |
45 scoped_ptr<media::VideoCaptureDeviceFactory> factory); | 45 scoped_ptr<media::VideoCaptureDeviceFactory> factory); |
46 | 46 |
47 // Implements MediaStreamProvider. | 47 // Implements MediaStreamProvider. |
48 virtual void Register(MediaStreamProviderListener* listener, | 48 void Register(MediaStreamProviderListener* listener, |
49 const scoped_refptr<base::SingleThreadTaskRunner>& | 49 const scoped_refptr<base::SingleThreadTaskRunner>& |
50 device_task_runner) override; | 50 device_task_runner) override; |
51 | 51 |
52 virtual void Unregister() override; | 52 void Unregister() override; |
53 | 53 |
54 virtual void EnumerateDevices(MediaStreamType stream_type) override; | 54 void EnumerateDevices(MediaStreamType stream_type) override; |
55 | 55 |
56 virtual int Open(const StreamDeviceInfo& device) override; | 56 int Open(const StreamDeviceInfo& device) override; |
57 | 57 |
58 virtual void Close(int capture_session_id) override; | 58 void Close(int capture_session_id) override; |
59 | 59 |
60 // Called by VideoCaptureHost to locate a capture device for |capture_params|, | 60 // Called by VideoCaptureHost to locate a capture device for |capture_params|, |
61 // adding the Host as a client of the device's controller if successful. The | 61 // adding the Host as a client of the device's controller if successful. The |
62 // value of |session_id| controls which device is selected; | 62 // value of |session_id| controls which device is selected; |
63 // this value should be a session id previously returned by Open(). | 63 // this value should be a session id previously returned by Open(). |
64 // | 64 // |
65 // If the device is not already started (i.e., no other client is currently | 65 // If the device is not already started (i.e., no other client is currently |
66 // capturing from this device), this call will cause a VideoCaptureController | 66 // capturing from this device), this call will cause a VideoCaptureController |
67 // and VideoCaptureDevice to be created, possibly asynchronously. | 67 // and VideoCaptureDevice to be created, possibly asynchronously. |
68 // | 68 // |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // UI for the given session. | 125 // UI for the given session. |
126 void SetDesktopCaptureWindowId(media::VideoCaptureSessionId session_id, | 126 void SetDesktopCaptureWindowId(media::VideoCaptureSessionId session_id, |
127 gfx::NativeViewId window_id); | 127 gfx::NativeViewId window_id); |
128 | 128 |
129 // Gets a weak reference to the device factory, used for tests. | 129 // Gets a weak reference to the device factory, used for tests. |
130 media::VideoCaptureDeviceFactory* video_capture_device_factory() const { | 130 media::VideoCaptureDeviceFactory* video_capture_device_factory() const { |
131 return video_capture_device_factory_.get(); | 131 return video_capture_device_factory_.get(); |
132 } | 132 } |
133 | 133 |
134 private: | 134 private: |
135 virtual ~VideoCaptureManager(); | 135 ~VideoCaptureManager() override; |
136 struct DeviceEntry; | 136 struct DeviceEntry; |
137 | 137 |
138 // Checks to see if |entry| has no clients left on its controller. If so, | 138 // Checks to see if |entry| has no clients left on its controller. If so, |
139 // remove it from the list of devices, and delete it asynchronously. |entry| | 139 // remove it from the list of devices, and delete it asynchronously. |entry| |
140 // may be freed by this function. | 140 // may be freed by this function. |
141 void DestroyDeviceEntryIfNoClients(DeviceEntry* entry); | 141 void DestroyDeviceEntryIfNoClients(DeviceEntry* entry); |
142 | 142 |
143 // Helpers to report an event to our Listener. | 143 // Helpers to report an event to our Listener. |
144 void OnOpened(MediaStreamType type, | 144 void OnOpened(MediaStreamType type, |
145 media::VideoCaptureSessionId capture_session_id); | 145 media::VideoCaptureSessionId capture_session_id); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // Accessed on the device thread only. | 256 // Accessed on the device thread only. |
257 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> | 257 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> |
258 notification_window_ids_; | 258 notification_window_ids_; |
259 | 259 |
260 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); | 260 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); |
261 }; | 261 }; |
262 | 262 |
263 } // namespace content | 263 } // namespace content |
264 | 264 |
265 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ | 265 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ |
OLD | NEW |