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

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 more comments. Created 7 years, 1 month 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 MediaStreamProvider* GetDeviceManager(MediaStreamType stream_type); 235 MediaStreamProvider* GetDeviceManager(MediaStreamType stream_type);
232 void StartEnumeration(DeviceRequest* request); 236 void StartEnumeration(DeviceRequest* request);
233 std::string AddRequest(DeviceRequest* request); 237 std::string AddRequest(DeviceRequest* request);
234 DeviceRequest* FindRequest(const std::string& label); 238 DeviceRequest* FindRequest(const std::string& label);
235 void DeleteRequest(const std::string& label); 239 void DeleteRequest(const std::string& label);
236 void ClearEnumerationCache(EnumerationCache* cache); 240 void ClearEnumerationCache(EnumerationCache* cache);
237 void PostRequestToUI(const std::string& label); 241 void PostRequestToUI(const std::string& label);
238 void HandleRequest(const std::string& label); 242 void HandleRequest(const std::string& label);
239 bool SetupTabCaptureRequest(DeviceRequest* request); 243 bool SetupTabCaptureRequest(DeviceRequest* request);
240 bool SetupScreenCaptureRequest(DeviceRequest* request); 244 bool SetupScreenCaptureRequest(DeviceRequest* request);
241 // Returns true if a device with |device_id| has already been requested by 245 // Returns true if a device with |device_id| has already been requested with
242 // |render_process_id| and |render_view_id| of type |type|. If it has been 246 // a render procecss_id and render_view_id and type equal to the the values
243 // requested, |device_info| contain information about the device. 247 // in |request|. If it has been requested, |device_info| contain information
244 bool FindExistingRequestedDeviceInfo(int render_process_id, 248 // about the device.
245 int render_view_id, 249 bool FindExistingRequestedDeviceInfo(
246 const GURL& security_origin, 250 const DeviceRequest* new_request,
tommi (sloooow) - chröme 2013/11/01 17:21:37 is new_request past as a pointer since it can be n
perkj_chrome 2013/11/01 19:01:56 Done.
247 MediaStreamRequestType type, 251 const MediaStreamDevice& new_device_info,
248 const std::string& device_id, 252 StreamDeviceInfo* existing_device_info,
249 MediaStreamType device_type, 253 MediaRequestState* existing_request_state) const;
250 StreamDeviceInfo* device_info,
251 MediaRequestState* request_state) const;
252 254
253 void FinalizeGenerateStream(const std::string& label, 255 void FinalizeGenerateStream(const std::string& label,
254 DeviceRequest* request); 256 DeviceRequest* request);
255 void FinalizeRequestFailed(const std::string& label, 257 void FinalizeRequestFailed(const std::string& label,
256 DeviceRequest* request); 258 DeviceRequest* request);
257 void FinalizeOpenDevice(const std::string& label, 259 void FinalizeOpenDevice(const std::string& label,
258 DeviceRequest* request); 260 DeviceRequest* request);
259 void FinalizeMediaAccessRequest(const std::string& label, 261 void FinalizeMediaAccessRequest(const std::string& label,
260 DeviceRequest* request, 262 DeviceRequest* request,
261 const MediaStreamDevices& devices); 263 const MediaStreamDevices& devices);
262 void FinalizeEnumerateDevices(const std::string& label, 264 void FinalizeEnumerateDevices(const std::string& label,
263 DeviceRequest* request); 265 DeviceRequest* request);
264 266
265 // Helpers to start and stop monitoring devices. 267 // Helpers to start and stop monitoring devices.
266 void StartMonitoring(); 268 void StartMonitoring();
267 void StopMonitoring(); 269 void StopMonitoring();
268 270
269 bool TranslateRequestedSourceIdToDeviceId(MediaStreamRequest* request); 271 bool TranslateRequestedSourceIdToDeviceId(DeviceRequest* request);
270 void TranslateDeviceIdToSourceId(const MediaStreamRequest& request, 272 void TranslateDeviceIdToSourceId(DeviceRequest* request,
271 MediaStreamDevice* device); 273 MediaStreamDevice* device);
272 274
273 // Finds and returns the device id corresponding to the given 275 // Finds and returns the device id corresponding to the given
274 // |source_id|. Returns true if there was a raw device id that matched the 276 // |source_id|. Returns true if there was a raw device id that matched the
275 // given |source_id|, false if nothing matched it. 277 // given |source_id|, false if nothing matched it.
276 bool TranslateSourceIdToDeviceId( 278 bool TranslateSourceIdToDeviceId(
277 MediaStreamType stream_type, 279 MediaStreamType stream_type,
280 ResourceContext* rc,
278 const GURL& security_origin, 281 const GURL& security_origin,
279 const std::string& source_id, 282 const std::string& source_id,
280 std::string* device_id); 283 std::string* device_id);
281 284
282 // Device thread shared by VideoCaptureManager and AudioInputDeviceManager. 285 // Device thread shared by VideoCaptureManager and AudioInputDeviceManager.
283 scoped_ptr<base::Thread> device_thread_; 286 scoped_ptr<base::Thread> device_thread_;
284 287
285 media::AudioManager* const audio_manager_; // not owned 288 media::AudioManager* const audio_manager_; // not owned
286 scoped_refptr<AudioInputDeviceManager> audio_input_device_manager_; 289 scoped_refptr<AudioInputDeviceManager> audio_input_device_manager_;
287 scoped_refptr<VideoCaptureManager> video_capture_manager_; 290 scoped_refptr<VideoCaptureManager> video_capture_manager_;
(...skipping 24 matching lines...) Expand all
312 315
313 bool use_fake_ui_; 316 bool use_fake_ui_;
314 scoped_ptr<FakeMediaStreamUIProxy> fake_ui_; 317 scoped_ptr<FakeMediaStreamUIProxy> fake_ui_;
315 318
316 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); 319 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager);
317 }; 320 };
318 321
319 } // namespace content 322 } // namespace content
320 323
321 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ 324 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698