| 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 #ifndef CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ | 6 #define CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 const content::MediaStreamDevices& devices) {} | 44 const content::MediaStreamDevices& devices) {} |
| 45 | 45 |
| 46 // Handle an information update consisting of a up-to-date video capture | 46 // Handle an information update consisting of a up-to-date video capture |
| 47 // device lists. This happens when a camera is plugged in or unplugged. | 47 // device lists. This happens when a camera is plugged in or unplugged. |
| 48 virtual void OnUpdateVideoDevices( | 48 virtual void OnUpdateVideoDevices( |
| 49 const content::MediaStreamDevices& devices) {} | 49 const content::MediaStreamDevices& devices) {} |
| 50 | 50 |
| 51 // Handle an information update related to a media stream request. | 51 // Handle an information update related to a media stream request. |
| 52 virtual void OnRequestUpdate( | 52 virtual void OnRequestUpdate( |
| 53 int render_process_id, | 53 int render_process_id, |
| 54 int render_view_id, | 54 int render_frame_id, |
| 55 const content::MediaStreamDevice& device, | 55 content::MediaStreamType stream_type, |
| 56 const content::MediaRequestState state) {} | 56 const content::MediaRequestState state) {} |
| 57 | 57 |
| 58 // Handle an information update that a new stream is being created. | 58 // Handle an information update that a new stream is being created. |
| 59 virtual void OnCreatingAudioStream(int render_process_id, | 59 virtual void OnCreatingAudioStream(int render_process_id, |
| 60 int render_frame_id) {} | 60 int render_frame_id) {} |
| 61 | 61 |
| 62 virtual ~Observer() {} | 62 virtual ~Observer() {} |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 static MediaCaptureDevicesDispatcher* GetInstance(); | 65 static MediaCaptureDevicesDispatcher* GetInstance(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // Unittests that do not require actual device enumeration should call this | 109 // Unittests that do not require actual device enumeration should call this |
| 110 // API on the singleton. It is safe to call this multiple times on the | 110 // API on the singleton. It is safe to call this multiple times on the |
| 111 // signleton. | 111 // signleton. |
| 112 void DisableDeviceEnumerationForTesting(); | 112 void DisableDeviceEnumerationForTesting(); |
| 113 | 113 |
| 114 // Overridden from content::MediaObserver: | 114 // Overridden from content::MediaObserver: |
| 115 virtual void OnAudioCaptureDevicesChanged() OVERRIDE; | 115 virtual void OnAudioCaptureDevicesChanged() OVERRIDE; |
| 116 virtual void OnVideoCaptureDevicesChanged() OVERRIDE; | 116 virtual void OnVideoCaptureDevicesChanged() OVERRIDE; |
| 117 virtual void OnMediaRequestStateChanged( | 117 virtual void OnMediaRequestStateChanged( |
| 118 int render_process_id, | 118 int render_process_id, |
| 119 int render_view_id, | 119 int render_frame_id, |
| 120 int page_request_id, | 120 int page_request_id, |
| 121 const GURL& security_origin, | 121 const GURL& security_origin, |
| 122 const content::MediaStreamDevice& device, | 122 content::MediaStreamType stream_type, |
| 123 content::MediaRequestState state) OVERRIDE; | 123 content::MediaRequestState state) OVERRIDE; |
| 124 virtual void OnCreatingAudioStream(int render_process_id, | 124 virtual void OnCreatingAudioStream(int render_process_id, |
| 125 int render_frame_id) OVERRIDE; | 125 int render_frame_id) OVERRIDE; |
| 126 virtual void OnAudioStreamPlaying( | 126 virtual void OnAudioStreamPlaying( |
| 127 int render_process_id, | 127 int render_process_id, |
| 128 int render_frame_id, | 128 int render_frame_id, |
| 129 int stream_id, | 129 int stream_id, |
| 130 const ReadPowerAndClipCallback& power_read_callback) OVERRIDE; | 130 const ReadPowerAndClipCallback& power_read_callback) OVERRIDE; |
| 131 virtual void OnAudioStreamStopped( | 131 virtual void OnAudioStreamStopped( |
| 132 int render_process_id, | 132 int render_process_id, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 void OnAccessRequestResponse(content::WebContents* web_contents, | 196 void OnAccessRequestResponse(content::WebContents* web_contents, |
| 197 const content::MediaStreamDevices& devices, | 197 const content::MediaStreamDevices& devices, |
| 198 content::MediaStreamRequestResult result, | 198 content::MediaStreamRequestResult result, |
| 199 scoped_ptr<content::MediaStreamUI> ui); | 199 scoped_ptr<content::MediaStreamUI> ui); |
| 200 | 200 |
| 201 // Called by the MediaObserver() functions, executed on UI thread. | 201 // Called by the MediaObserver() functions, executed on UI thread. |
| 202 void NotifyAudioDevicesChangedOnUIThread(); | 202 void NotifyAudioDevicesChangedOnUIThread(); |
| 203 void NotifyVideoDevicesChangedOnUIThread(); | 203 void NotifyVideoDevicesChangedOnUIThread(); |
| 204 void UpdateMediaRequestStateOnUIThread( | 204 void UpdateMediaRequestStateOnUIThread( |
| 205 int render_process_id, | 205 int render_process_id, |
| 206 int render_view_id, | 206 int render_frame_id, |
| 207 int page_request_id, | 207 int page_request_id, |
| 208 const GURL& security_origin, | 208 const GURL& security_origin, |
| 209 const content::MediaStreamDevice& device, | 209 content::MediaStreamType stream_type, |
| 210 content::MediaRequestState state); | 210 content::MediaRequestState state); |
| 211 void OnCreatingAudioStreamOnUIThread(int render_process_id, | 211 void OnCreatingAudioStreamOnUIThread(int render_process_id, |
| 212 int render_frame_id); | 212 int render_frame_id); |
| 213 | 213 |
| 214 // Only for testing, a list of cached audio capture devices. | 214 // Only for testing, a list of cached audio capture devices. |
| 215 content::MediaStreamDevices test_audio_devices_; | 215 content::MediaStreamDevices test_audio_devices_; |
| 216 | 216 |
| 217 // Only for testing, a list of cached video capture devices. | 217 // Only for testing, a list of cached video capture devices. |
| 218 content::MediaStreamDevices test_video_devices_; | 218 content::MediaStreamDevices test_video_devices_; |
| 219 | 219 |
| 220 // A list of observers for the device update notifications. | 220 // A list of observers for the device update notifications. |
| 221 ObserverList<Observer> observers_; | 221 ObserverList<Observer> observers_; |
| 222 | 222 |
| 223 // Flag used by unittests to disable device enumeration. | 223 // Flag used by unittests to disable device enumeration. |
| 224 bool is_device_enumeration_disabled_; | 224 bool is_device_enumeration_disabled_; |
| 225 | 225 |
| 226 RequestsQueues pending_requests_; | 226 RequestsQueues pending_requests_; |
| 227 | 227 |
| 228 scoped_refptr<MediaStreamCaptureIndicator> media_stream_capture_indicator_; | 228 scoped_refptr<MediaStreamCaptureIndicator> media_stream_capture_indicator_; |
| 229 | 229 |
| 230 scoped_ptr<DesktopStreamsRegistry> desktop_streams_registry_; | 230 scoped_ptr<DesktopStreamsRegistry> desktop_streams_registry_; |
| 231 | 231 |
| 232 content::NotificationRegistrar notifications_registrar_; | 232 content::NotificationRegistrar notifications_registrar_; |
| 233 | 233 |
| 234 // Tracks MEDIA_DESKTOP_VIDEO_CAPTURE sessions which reach the | 234 // Tracks MEDIA_DESKTOP_VIDEO_CAPTURE sessions which reach the |
| 235 // MEDIA_REQUEST_STATE_DONE state. Sessions are remove when | 235 // MEDIA_REQUEST_STATE_DONE state. Sessions are remove when |
| 236 // MEDIA_REQUEST_STATE_CLOSING is encountered. | 236 // MEDIA_REQUEST_STATE_CLOSING is encountered. |
| 237 struct DesktopCaptureSession { | 237 struct DesktopCaptureSession { |
| 238 int render_process_id; | 238 int render_process_id; |
| 239 int render_view_id; | 239 int render_frame_id; |
| 240 int page_request_id; | 240 int page_request_id; |
| 241 }; | 241 }; |
| 242 typedef std::list<DesktopCaptureSession> DesktopCaptureSessions; | 242 typedef std::list<DesktopCaptureSession> DesktopCaptureSessions; |
| 243 DesktopCaptureSessions desktop_capture_sessions_; | 243 DesktopCaptureSessions desktop_capture_sessions_; |
| 244 | 244 |
| 245 DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher); | 245 DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher); |
| 246 }; | 246 }; |
| 247 | 247 |
| 248 #endif // CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ | 248 #endif // CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ |
| OLD | NEW |