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

Side by Side Diff: content/browser/renderer_host/media/media_stream_manager.h

Issue 54863002: Implement a salt for MediaSource IDs that can be cleared by a user. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed jois nit. Created 7 years 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 | Annotate | Revision Log
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 // MediaStreamManager is used to open/enumerate media capture devices (video 5 // MediaStreamManager is used to open/enumerate media capture devices (video
6 // supported now). Call flow: 6 // supported now). Call flow:
7 // 1. GenerateStream is called when a render process wants to use a capture 7 // 1. GenerateStream is called when a render process wants to use a capture
8 // device. 8 // device.
9 // 2. MediaStreamManager will ask MediaStreamUIController for permission to 9 // 2. MediaStreamManager will ask MediaStreamUIController for permission to
10 // use devices and for which device to use. 10 // use devices and for which device to use.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 class AudioManager; 44 class AudioManager;
45 } 45 }
46 46
47 namespace content { 47 namespace content {
48 48
49 class AudioInputDeviceManager; 49 class AudioInputDeviceManager;
50 class FakeMediaStreamUIProxy; 50 class FakeMediaStreamUIProxy;
51 class MediaStreamDeviceSettings; 51 class MediaStreamDeviceSettings;
52 class MediaStreamRequester; 52 class MediaStreamRequester;
53 class MediaStreamUIProxy; 53 class MediaStreamUIProxy;
54 class ResourceContext;
54 class VideoCaptureManager; 55 class VideoCaptureManager;
55 56
56 // MediaStreamManager is used to generate and close new media devices, not to 57 // MediaStreamManager is used to generate and close new media devices, not to
57 // start the media flow. The classes requesting new media streams are answered 58 // start the media flow. The classes requesting new media streams are answered
58 // using MediaStreamRequester. 59 // using MediaStreamRequester.
59 class CONTENT_EXPORT MediaStreamManager 60 class CONTENT_EXPORT MediaStreamManager
60 : public MediaStreamProviderListener, 61 : public MediaStreamProviderListener,
61 public base::MessageLoop::DestructionObserver, 62 public base::MessageLoop::DestructionObserver,
62 public base::SystemMonitor::DevicesChangedObserver { 63 public base::SystemMonitor::DevicesChangedObserver {
63 public: 64 public:
(...skipping 25 matching lines...) Expand all
89 const GURL& security_origin, 90 const GURL& security_origin,
90 const MediaRequestResponseCallback& callback); 91 const MediaRequestResponseCallback& callback);
91 92
92 // GenerateStream opens new media devices according to |components|. It 93 // GenerateStream opens new media devices according to |components|. It
93 // creates a new request which is identified by a unique string that's 94 // creates a new request which is identified by a unique string that's
94 // returned to the caller. |render_process_id| and |render_view_id| refer to 95 // returned to the caller. |render_process_id| and |render_view_id| refer to
95 // the view where the infobar will appear to the user. 96 // the view where the infobar will appear to the user.
96 std::string GenerateStream(MediaStreamRequester* requester, 97 std::string GenerateStream(MediaStreamRequester* requester,
97 int render_process_id, 98 int render_process_id,
98 int render_view_id, 99 int render_view_id,
100 ResourceContext* rc,
99 int page_request_id, 101 int page_request_id,
100 const StreamOptions& components, 102 const StreamOptions& components,
101 const GURL& security_origin); 103 const GURL& security_origin);
102 104
103 virtual void CancelRequest(const std::string& label); 105 virtual void CancelRequest(const std::string& label);
104 void CancelAllRequests(int render_process_id); 106 void CancelAllRequests(int render_process_id);
105 107
106 // Closes the stream device for a certain render view. The stream must have 108 // Closes the stream device for a certain render view. The stream must have
107 // been opened by a call to GenerateStream. 109 // been opened by a call to GenerateStream.
108 void StopStreamDevice(int render_process_id, 110 void StopStreamDevice(int render_process_id,
109 int render_view_id, 111 int render_view_id,
110 const std::string& device_id); 112 const std::string& device_id);
111 113
112 // Gets a list of devices of |type|, which must be MEDIA_DEVICE_AUDIO_CAPTURE 114 // Gets a list of devices of |type|, which must be MEDIA_DEVICE_AUDIO_CAPTURE
113 // or MEDIA_DEVICE_VIDEO_CAPTURE. 115 // or MEDIA_DEVICE_VIDEO_CAPTURE.
114 // The request is identified using the string returned to the caller. 116 // The request is identified using the string returned to the caller.
115 // When the |requester| is NULL, MediaStreamManager will enumerate both audio 117 // When the |requester| is NULL, MediaStreamManager will enumerate both audio
116 // and video devices and also start monitoring device changes, such as 118 // and video devices and also start monitoring device changes, such as
117 // plug/unplug. The new device lists will be delivered via media observer to 119 // plug/unplug. The new device lists will be delivered via media observer to
118 // MediaCaptureDevicesDispatcher. 120 // MediaCaptureDevicesDispatcher.
119 virtual std::string EnumerateDevices(MediaStreamRequester* requester, 121 virtual std::string EnumerateDevices(MediaStreamRequester* requester,
120 int render_process_id, 122 int render_process_id,
121 int render_view_id, 123 int render_view_id,
124 ResourceContext* rc,
122 int page_request_id, 125 int page_request_id,
123 MediaStreamType type, 126 MediaStreamType type,
124 const GURL& security_origin); 127 const GURL& security_origin);
125 128
126 // Open a device identified by |device_id|. |type| must be either 129 // Open a device identified by |device_id|. |type| must be either
127 // MEDIA_DEVICE_AUDIO_CAPTURE or MEDIA_DEVICE_VIDEO_CAPTURE. 130 // MEDIA_DEVICE_AUDIO_CAPTURE or MEDIA_DEVICE_VIDEO_CAPTURE.
128 // The request is identified using string returned to the caller. 131 // The request is identified using string returned to the caller.
129 std::string OpenDevice(MediaStreamRequester* requester, 132 std::string OpenDevice(MediaStreamRequester* requester,
130 int render_process_id, 133 int render_process_id,
131 int render_view_id, 134 int render_view_id,
135 ResourceContext* rc,
132 int page_request_id, 136 int page_request_id,
133 const std::string& device_id, 137 const std::string& device_id,
134 MediaStreamType type, 138 MediaStreamType type,
135 const GURL& security_origin); 139 const GURL& security_origin);
136 140
137 // Implements MediaStreamProviderListener. 141 // Implements MediaStreamProviderListener.
138 virtual void Opened(MediaStreamType stream_type, 142 virtual void Opened(MediaStreamType stream_type,
139 int capture_session_id) OVERRIDE; 143 int capture_session_id) OVERRIDE;
140 virtual void Closed(MediaStreamType stream_type, 144 virtual void Closed(MediaStreamType stream_type,
141 int capture_session_id) OVERRIDE; 145 int capture_session_id) OVERRIDE;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 void ClearEnumerationCache(EnumerationCache* cache); 231 void ClearEnumerationCache(EnumerationCache* cache);
228 // Prepare the request with label |label| by starting device enumeration if 232 // Prepare the request with label |label| by starting device enumeration if
229 // needed. 233 // needed.
230 void SetupRequest(const std::string& label); 234 void SetupRequest(const std::string& label);
231 bool SetupTabCaptureRequest(DeviceRequest* request); 235 bool SetupTabCaptureRequest(DeviceRequest* request);
232 bool SetupScreenCaptureRequest(DeviceRequest* request); 236 bool SetupScreenCaptureRequest(DeviceRequest* request);
233 // Called when a request has been setup and devices have been enumerated if 237 // Called when a request has been setup and devices have been enumerated if
234 // needed. If a certain source id has been requested, the source id is 238 // needed. If a certain source id has been requested, the source id is
235 // translated to a real device id before the request is posted to UI. 239 // translated to a real device id before the request is posted to UI.
236 void PostRequestToUI(const std::string& label, DeviceRequest* request); 240 void PostRequestToUI(const std::string& label, DeviceRequest* request);
237 // Returns true if a device with |device_id| has already been requested by 241 // Returns true if a device with |device_id| has already been requested with
238 // |render_process_id| and |render_view_id| of type |type|. If it has been 242 // a render procecss_id and render_view_id and type equal to the the values
239 // requested, |device_info| contain information about the device. 243 // in |request|. If it has been requested, |device_info| contain information
240 bool FindExistingRequestedDeviceInfo(int render_process_id, 244 // about the device.
241 int render_view_id, 245 bool FindExistingRequestedDeviceInfo(
242 const GURL& security_origin, 246 const DeviceRequest& new_request,
243 MediaStreamRequestType type, 247 const MediaStreamDevice& new_device_info,
244 const std::string& device_id, 248 StreamDeviceInfo* existing_device_info,
245 MediaStreamType device_type, 249 MediaRequestState* existing_request_state) const;
246 StreamDeviceInfo* device_info,
247 MediaRequestState* request_state) const;
248 250
249 void FinalizeGenerateStream(const std::string& label, 251 void FinalizeGenerateStream(const std::string& label,
250 DeviceRequest* request); 252 DeviceRequest* request);
251 void FinalizeRequestFailed(const std::string& label, 253 void FinalizeRequestFailed(const std::string& label,
252 DeviceRequest* request); 254 DeviceRequest* request);
253 void FinalizeOpenDevice(const std::string& label, 255 void FinalizeOpenDevice(const std::string& label,
254 DeviceRequest* request); 256 DeviceRequest* request);
255 void FinalizeMediaAccessRequest(const std::string& label, 257 void FinalizeMediaAccessRequest(const std::string& label,
256 DeviceRequest* request, 258 DeviceRequest* request,
257 const MediaStreamDevices& devices); 259 const MediaStreamDevices& devices);
258 void FinalizeEnumerateDevices(const std::string& label, 260 void FinalizeEnumerateDevices(const std::string& label,
259 DeviceRequest* request); 261 DeviceRequest* request);
260 262
261 // This method is called when an audio or video device is plugged in or 263 // This method is called when an audio or video device is plugged in or
262 // removed. It make sure all MediaStreams that use a removed device is 264 // removed. It make sure all MediaStreams that use a removed device is
263 // stopped and that the render process is notified. |old_devices| is the list 265 // stopped and that the render process is notified. |old_devices| is the list
264 // of previously available devices. |new_devices| is the new 266 // of previously available devices. |new_devices| is the new
265 // list of currently available devices. 267 // list of currently available devices.
266 void StopRemovedDevices(const StreamDeviceInfoArray& old_devices, 268 void StopRemovedDevices(const StreamDeviceInfoArray& old_devices,
267 const StreamDeviceInfoArray& new_devices); 269 const StreamDeviceInfoArray& new_devices);
268 // Helper method used by StopRemovedDevices to stop the use of a certain 270 // Helper method used by StopRemovedDevices to stop the use of a certain
269 // device. 271 // device.
270 void StopRemovedDevice(const MediaStreamDevice& device); 272 void StopRemovedDevice(const MediaStreamDevice& device);
271 273
272 // Helpers to start and stop monitoring devices. 274 // Helpers to start and stop monitoring devices.
273 void StartMonitoring(); 275 void StartMonitoring();
274 void StopMonitoring(); 276 void StopMonitoring();
275 277
276 bool TranslateRequestedSourceIdToDeviceId(MediaStreamRequest* request); 278 bool TranslateRequestedSourceIdToDeviceId(DeviceRequest* request);
277 void TranslateDeviceIdToSourceId(const MediaStreamRequest& request, 279 void TranslateDeviceIdToSourceId(DeviceRequest* request,
278 MediaStreamDevice* device); 280 MediaStreamDevice* device);
279 281
280 // Finds and returns the device id corresponding to the given 282 // Finds and returns the device id corresponding to the given
281 // |source_id|. Returns true if there was a raw device id that matched the 283 // |source_id|. Returns true if there was a raw device id that matched the
282 // given |source_id|, false if nothing matched it. 284 // given |source_id|, false if nothing matched it.
283 bool TranslateSourceIdToDeviceId( 285 bool TranslateSourceIdToDeviceId(
284 MediaStreamType stream_type, 286 MediaStreamType stream_type,
287 ResourceContext* rc,
285 const GURL& security_origin, 288 const GURL& security_origin,
286 const std::string& source_id, 289 const std::string& source_id,
287 std::string* device_id); 290 std::string* device_id);
288 291
289 // Device thread shared by VideoCaptureManager and AudioInputDeviceManager. 292 // Device thread shared by VideoCaptureManager and AudioInputDeviceManager.
290 scoped_ptr<base::Thread> device_thread_; 293 scoped_ptr<base::Thread> device_thread_;
291 294
292 media::AudioManager* const audio_manager_; // not owned 295 media::AudioManager* const audio_manager_; // not owned
293 scoped_refptr<AudioInputDeviceManager> audio_input_device_manager_; 296 scoped_refptr<AudioInputDeviceManager> audio_input_device_manager_;
294 scoped_refptr<VideoCaptureManager> video_capture_manager_; 297 scoped_refptr<VideoCaptureManager> video_capture_manager_;
(...skipping 19 matching lines...) Expand all
314 317
315 bool use_fake_ui_; 318 bool use_fake_ui_;
316 scoped_ptr<FakeMediaStreamUIProxy> fake_ui_; 319 scoped_ptr<FakeMediaStreamUIProxy> fake_ui_;
317 320
318 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); 321 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager);
319 }; 322 };
320 323
321 } // namespace content 324 } // namespace content
322 325
323 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ 326 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698