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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // are available. | 125 // are available. |
126 const content::MediaStreamDevice* GetFirstAvailableAudioDevice(); | 126 const content::MediaStreamDevice* GetFirstAvailableAudioDevice(); |
127 const content::MediaStreamDevice* GetFirstAvailableVideoDevice(); | 127 const content::MediaStreamDevice* GetFirstAvailableVideoDevice(); |
128 | 128 |
129 // Unittests that do not require actual device enumeration should call this | 129 // Unittests that do not require actual device enumeration should call this |
130 // API on the singleton. It is safe to call this multiple times on the | 130 // API on the singleton. It is safe to call this multiple times on the |
131 // signleton. | 131 // signleton. |
132 void DisableDeviceEnumerationForTesting(); | 132 void DisableDeviceEnumerationForTesting(); |
133 | 133 |
134 // Overridden from content::MediaObserver: | 134 // Overridden from content::MediaObserver: |
135 virtual void OnAudioCaptureDevicesChanged() override; | 135 void OnAudioCaptureDevicesChanged() override; |
136 virtual void OnVideoCaptureDevicesChanged() override; | 136 void OnVideoCaptureDevicesChanged() override; |
137 virtual void OnMediaRequestStateChanged( | 137 void OnMediaRequestStateChanged(int render_process_id, |
138 int render_process_id, | 138 int render_frame_id, |
139 int render_frame_id, | 139 int page_request_id, |
140 int page_request_id, | 140 const GURL& security_origin, |
141 const GURL& security_origin, | 141 content::MediaStreamType stream_type, |
142 content::MediaStreamType stream_type, | 142 content::MediaRequestState state) override; |
143 content::MediaRequestState state) override; | 143 void OnCreatingAudioStream(int render_process_id, |
144 virtual void OnCreatingAudioStream(int render_process_id, | 144 int render_frame_id) override; |
145 int render_frame_id) override; | |
146 | 145 |
147 scoped_refptr<MediaStreamCaptureIndicator> GetMediaStreamCaptureIndicator(); | 146 scoped_refptr<MediaStreamCaptureIndicator> GetMediaStreamCaptureIndicator(); |
148 | 147 |
149 DesktopStreamsRegistry* GetDesktopStreamsRegistry(); | 148 DesktopStreamsRegistry* GetDesktopStreamsRegistry(); |
150 | 149 |
151 bool IsDesktopCaptureInProgress(); | 150 bool IsDesktopCaptureInProgress(); |
152 | 151 |
153 // Only for testing. | 152 // Only for testing. |
154 void SetTestAudioCaptureDevices(const content::MediaStreamDevices& devices); | 153 void SetTestAudioCaptureDevices(const content::MediaStreamDevices& devices); |
155 void SetTestVideoCaptureDevices(const content::MediaStreamDevices& devices); | 154 void SetTestVideoCaptureDevices(const content::MediaStreamDevices& devices); |
156 | 155 |
157 private: | 156 private: |
158 friend struct DefaultSingletonTraits<MediaCaptureDevicesDispatcher>; | 157 friend struct DefaultSingletonTraits<MediaCaptureDevicesDispatcher>; |
159 | 158 |
160 struct PendingAccessRequest { | 159 struct PendingAccessRequest { |
161 PendingAccessRequest(const content::MediaStreamRequest& request, | 160 PendingAccessRequest(const content::MediaStreamRequest& request, |
162 const content::MediaResponseCallback& callback); | 161 const content::MediaResponseCallback& callback); |
163 ~PendingAccessRequest(); | 162 ~PendingAccessRequest(); |
164 | 163 |
165 // TODO(gbillock): make the MediaStreamDevicesController owned by | 164 // TODO(gbillock): make the MediaStreamDevicesController owned by |
166 // this object when we're using bubbles. | 165 // this object when we're using bubbles. |
167 content::MediaStreamRequest request; | 166 content::MediaStreamRequest request; |
168 content::MediaResponseCallback callback; | 167 content::MediaResponseCallback callback; |
169 }; | 168 }; |
170 typedef std::deque<PendingAccessRequest> RequestsQueue; | 169 typedef std::deque<PendingAccessRequest> RequestsQueue; |
171 typedef std::map<content::WebContents*, RequestsQueue> RequestsQueues; | 170 typedef std::map<content::WebContents*, RequestsQueue> RequestsQueues; |
172 | 171 |
173 MediaCaptureDevicesDispatcher(); | 172 MediaCaptureDevicesDispatcher(); |
174 virtual ~MediaCaptureDevicesDispatcher(); | 173 ~MediaCaptureDevicesDispatcher() override; |
175 | 174 |
176 // content::NotificationObserver implementation. | 175 // content::NotificationObserver implementation. |
177 virtual void Observe(int type, | 176 void Observe(int type, |
178 const content::NotificationSource& source, | 177 const content::NotificationSource& source, |
179 const content::NotificationDetails& details) override; | 178 const content::NotificationDetails& details) override; |
180 | 179 |
181 // Helpers for ProcessMediaAccessRequest(). | 180 // Helpers for ProcessMediaAccessRequest(). |
182 void ProcessDesktopCaptureAccessRequest( | 181 void ProcessDesktopCaptureAccessRequest( |
183 content::WebContents* web_contents, | 182 content::WebContents* web_contents, |
184 const content::MediaStreamRequest& request, | 183 const content::MediaStreamRequest& request, |
185 const content::MediaResponseCallback& callback, | 184 const content::MediaResponseCallback& callback, |
186 const extensions::Extension* extension); | 185 const extensions::Extension* extension); |
187 void ProcessScreenCaptureAccessRequest( | 186 void ProcessScreenCaptureAccessRequest( |
188 content::WebContents* web_contents, | 187 content::WebContents* web_contents, |
189 const content::MediaStreamRequest& request, | 188 const content::MediaStreamRequest& request, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 int render_frame_id; | 249 int render_frame_id; |
251 int page_request_id; | 250 int page_request_id; |
252 }; | 251 }; |
253 typedef std::list<DesktopCaptureSession> DesktopCaptureSessions; | 252 typedef std::list<DesktopCaptureSession> DesktopCaptureSessions; |
254 DesktopCaptureSessions desktop_capture_sessions_; | 253 DesktopCaptureSessions desktop_capture_sessions_; |
255 | 254 |
256 DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher); | 255 DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher); |
257 }; | 256 }; |
258 | 257 |
259 #endif // CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ | 258 #endif // CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ |
OLD | NEW |