Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: chrome/browser/media/media_capture_devices_dispatcher.h

Issue 183743021: Implement MediaCaptureDevices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try again Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/media/media_capture_devices_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // are available. 105 // are available.
106 const content::MediaStreamDevice* GetFirstAvailableAudioDevice(); 106 const content::MediaStreamDevice* GetFirstAvailableAudioDevice();
107 const content::MediaStreamDevice* GetFirstAvailableVideoDevice(); 107 const content::MediaStreamDevice* GetFirstAvailableVideoDevice();
108 108
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( 115 virtual void OnAudioCaptureDevicesChanged() OVERRIDE;
116 const content::MediaStreamDevices& devices) OVERRIDE; 116 virtual void OnVideoCaptureDevicesChanged() OVERRIDE;
117 virtual void OnVideoCaptureDevicesChanged(
118 const content::MediaStreamDevices& devices) OVERRIDE;
119 virtual void OnMediaRequestStateChanged( 117 virtual void OnMediaRequestStateChanged(
120 int render_process_id, 118 int render_process_id,
121 int render_view_id, 119 int render_view_id,
122 int page_request_id, 120 int page_request_id,
123 const GURL& security_origin, 121 const GURL& security_origin,
124 const content::MediaStreamDevice& device, 122 const content::MediaStreamDevice& device,
125 content::MediaRequestState state) OVERRIDE; 123 content::MediaRequestState state) OVERRIDE;
126 virtual void OnCreatingAudioStream(int render_process_id, 124 virtual void OnCreatingAudioStream(int render_process_id,
127 int render_frame_id) OVERRIDE; 125 int render_frame_id) OVERRIDE;
128 virtual void OnAudioStreamPlaying( 126 virtual void OnAudioStreamPlaying(
129 int render_process_id, 127 int render_process_id,
130 int render_frame_id, 128 int render_frame_id,
131 int stream_id, 129 int stream_id,
132 const ReadPowerAndClipCallback& power_read_callback) OVERRIDE; 130 const ReadPowerAndClipCallback& power_read_callback) OVERRIDE;
133 virtual void OnAudioStreamStopped( 131 virtual void OnAudioStreamStopped(
134 int render_process_id, 132 int render_process_id,
135 int render_frame_id, 133 int render_frame_id,
136 int stream_id) OVERRIDE; 134 int stream_id) OVERRIDE;
137 135
138 scoped_refptr<MediaStreamCaptureIndicator> GetMediaStreamCaptureIndicator(); 136 scoped_refptr<MediaStreamCaptureIndicator> GetMediaStreamCaptureIndicator();
139 137
140 DesktopStreamsRegistry* GetDesktopStreamsRegistry(); 138 DesktopStreamsRegistry* GetDesktopStreamsRegistry();
141 139
142 bool IsDesktopCaptureInProgress(); 140 bool IsDesktopCaptureInProgress();
143 141
142 // Only for testing.
143 void SetTestAudioCaptureDevices(const content::MediaStreamDevices& devices);
144 void SetTestVideoCaptureDevices(const content::MediaStreamDevices& devices);
145
144 private: 146 private:
145 friend struct DefaultSingletonTraits<MediaCaptureDevicesDispatcher>; 147 friend struct DefaultSingletonTraits<MediaCaptureDevicesDispatcher>;
146 148
147 struct PendingAccessRequest { 149 struct PendingAccessRequest {
148 PendingAccessRequest(const content::MediaStreamRequest& request, 150 PendingAccessRequest(const content::MediaStreamRequest& request,
149 const content::MediaResponseCallback& callback); 151 const content::MediaResponseCallback& callback);
150 ~PendingAccessRequest(); 152 ~PendingAccessRequest();
151 153
152 // TODO(gbillock): make the MediaStreamDevicesController owned by 154 // TODO(gbillock): make the MediaStreamDevicesController owned by
153 // this object when we're using bubbles. 155 // this object when we're using bubbles.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 void ProcessRegularMediaAccessRequest( 191 void ProcessRegularMediaAccessRequest(
190 content::WebContents* web_contents, 192 content::WebContents* web_contents,
191 const content::MediaStreamRequest& request, 193 const content::MediaStreamRequest& request,
192 const content::MediaResponseCallback& callback); 194 const content::MediaResponseCallback& callback);
193 void ProcessQueuedAccessRequest(content::WebContents* web_contents); 195 void ProcessQueuedAccessRequest(content::WebContents* web_contents);
194 void OnAccessRequestResponse(content::WebContents* web_contents, 196 void OnAccessRequestResponse(content::WebContents* web_contents,
195 const content::MediaStreamDevices& devices, 197 const content::MediaStreamDevices& devices,
196 scoped_ptr<content::MediaStreamUI> ui); 198 scoped_ptr<content::MediaStreamUI> ui);
197 199
198 // Called by the MediaObserver() functions, executed on UI thread. 200 // Called by the MediaObserver() functions, executed on UI thread.
199 void UpdateAudioDevicesOnUIThread(const content::MediaStreamDevices& devices); 201 void NotifyAudioDevicesChangedOnUIThread();
200 void UpdateVideoDevicesOnUIThread(const content::MediaStreamDevices& devices); 202 void NotifyVideoDevicesChangedOnUIThread();
201 void UpdateMediaRequestStateOnUIThread( 203 void UpdateMediaRequestStateOnUIThread(
202 int render_process_id, 204 int render_process_id,
203 int render_view_id, 205 int render_view_id,
204 int page_request_id, 206 int page_request_id,
205 const GURL& security_origin, 207 const GURL& security_origin,
206 const content::MediaStreamDevice& device, 208 const content::MediaStreamDevice& device,
207 content::MediaRequestState state); 209 content::MediaRequestState state);
208 void OnCreatingAudioStreamOnUIThread(int render_process_id, 210 void OnCreatingAudioStreamOnUIThread(int render_process_id,
209 int render_frame_id); 211 int render_frame_id);
210 212
211 // A list of cached audio capture devices. 213 // Only for testing, a list of cached audio capture devices.
212 content::MediaStreamDevices audio_devices_; 214 content::MediaStreamDevices test_audio_devices_;
213 215
214 // A list of cached video capture devices. 216 // Only for testing, a list of cached video capture devices.
215 content::MediaStreamDevices video_devices_; 217 content::MediaStreamDevices test_video_devices_;
216 218
217 // A list of observers for the device update notifications. 219 // A list of observers for the device update notifications.
218 ObserverList<Observer> observers_; 220 ObserverList<Observer> observers_;
219 221
220 // Flag to indicate if device enumeration has been done/doing.
221 // Only accessed on UI thread.
222 bool devices_enumerated_;
223
224 // Flag used by unittests to disable device enumeration. 222 // Flag used by unittests to disable device enumeration.
225 bool is_device_enumeration_disabled_; 223 bool is_device_enumeration_disabled_;
226 224
227 RequestsQueues pending_requests_; 225 RequestsQueues pending_requests_;
228 226
229 scoped_refptr<MediaStreamCaptureIndicator> media_stream_capture_indicator_; 227 scoped_refptr<MediaStreamCaptureIndicator> media_stream_capture_indicator_;
230 228
231 scoped_ptr<DesktopStreamsRegistry> desktop_streams_registry_; 229 scoped_ptr<DesktopStreamsRegistry> desktop_streams_registry_;
232 230
233 content::NotificationRegistrar notifications_registrar_; 231 content::NotificationRegistrar notifications_registrar_;
234 232
235 // Tracks MEDIA_DESKTOP_VIDEO_CAPTURE sessions which reach the 233 // Tracks MEDIA_DESKTOP_VIDEO_CAPTURE sessions which reach the
236 // MEDIA_REQUEST_STATE_DONE state. Sessions are remove when 234 // MEDIA_REQUEST_STATE_DONE state. Sessions are remove when
237 // MEDIA_REQUEST_STATE_CLOSING is encountered. 235 // MEDIA_REQUEST_STATE_CLOSING is encountered.
238 struct DesktopCaptureSession { 236 struct DesktopCaptureSession {
239 int render_process_id; 237 int render_process_id;
240 int render_view_id; 238 int render_view_id;
241 int page_request_id; 239 int page_request_id;
242 }; 240 };
243 typedef std::list<DesktopCaptureSession> DesktopCaptureSessions; 241 typedef std::list<DesktopCaptureSession> DesktopCaptureSessions;
244 DesktopCaptureSessions desktop_capture_sessions_; 242 DesktopCaptureSessions desktop_capture_sessions_;
245 243
246 DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher); 244 DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher);
247 }; 245 };
248 246
249 #endif // CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ 247 #endif // CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media/media_capture_devices_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698