Chromium Code Reviews| 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 // 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 class CONTENT_EXPORT MediaStreamManager | 60 class CONTENT_EXPORT MediaStreamManager |
| 61 : public MediaStreamProviderListener, | 61 : public MediaStreamProviderListener, |
| 62 public base::MessageLoop::DestructionObserver, | 62 public base::MessageLoop::DestructionObserver, |
| 63 public base::SystemMonitor::DevicesChangedObserver { | 63 public base::SystemMonitor::DevicesChangedObserver { |
| 64 public: | 64 public: |
| 65 // Callback to deliver the result of a media request. | 65 // Callback to deliver the result of a media request. |
| 66 typedef base::Callback<void(const MediaStreamDevices& devices, | 66 typedef base::Callback<void(const MediaStreamDevices& devices, |
| 67 scoped_ptr<MediaStreamUIProxy> ui)> | 67 scoped_ptr<MediaStreamUIProxy> ui)> |
| 68 MediaRequestResponseCallback; | 68 MediaRequestResponseCallback; |
| 69 | 69 |
| 70 // Callback to log a message to native logs. | |
| 71 typedef base::Callback<void(const std::string& message)> | |
| 72 AddWebRtcLogCallback; | |
| 73 | |
| 70 explicit MediaStreamManager(media::AudioManager* audio_manager); | 74 explicit MediaStreamManager(media::AudioManager* audio_manager); |
| 71 virtual ~MediaStreamManager(); | 75 virtual ~MediaStreamManager(); |
| 72 | 76 |
| 73 // Used to access VideoCaptureManager. | 77 // Used to access VideoCaptureManager. |
| 74 VideoCaptureManager* video_capture_manager(); | 78 VideoCaptureManager* video_capture_manager(); |
| 75 | 79 |
| 76 // Used to access AudioInputDeviceManager. | 80 // Used to access AudioInputDeviceManager. |
| 77 AudioInputDeviceManager* audio_input_device_manager(); | 81 AudioInputDeviceManager* audio_input_device_manager(); |
| 78 | 82 |
| 79 // Creates a new media access request which is identified by a unique string | 83 // Creates a new media access request which is identified by a unique string |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 // This object gets deleted on the UI thread after the IO thread has been | 182 // This object gets deleted on the UI thread after the IO thread has been |
| 179 // destroyed. So we need to know when IO thread is being destroyed so that | 183 // destroyed. So we need to know when IO thread is being destroyed so that |
| 180 // we can delete VideoCaptureManager and AudioInputDeviceManager. Normally | 184 // we can delete VideoCaptureManager and AudioInputDeviceManager. Normally |
| 181 // this is handled by | 185 // this is handled by |
| 182 // base::MessageLoop::DestructionObserver::WillDestroyCurrentMessageLoop. | 186 // base::MessageLoop::DestructionObserver::WillDestroyCurrentMessageLoop. |
| 183 // But for some tests which use TestBrowserThreadBundle, we need to call | 187 // But for some tests which use TestBrowserThreadBundle, we need to call |
| 184 // WillDestroyCurrentMessageLoop explicitly because the notification happens | 188 // WillDestroyCurrentMessageLoop explicitly because the notification happens |
| 185 // too late. (see http://crbug.com/247525#c14). | 189 // too late. (see http://crbug.com/247525#c14). |
| 186 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | 190 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; |
| 187 | 191 |
| 192 // Adds |message| to native logs for outstanding device requests. | |
|
Henrik Grunell
2014/01/17 08:51:25
Is sending the log to all outstanding requests' re
vrk (LEFT CHROMIUM)
2014/01/22 02:25:42
See implementation of AddLogMessageOnUIThread(). T
Henrik Grunell
2014/01/22 07:05:22
Let's discuss offline.
| |
| 193 void AddLogMessageOnUIThread(const std::string& message); | |
| 194 static void AddLogMessage(const std::string& message); | |
| 195 | |
| 188 protected: | 196 protected: |
| 189 // Used for testing. | 197 // Used for testing. |
| 190 MediaStreamManager(); | 198 MediaStreamManager(); |
| 191 | 199 |
| 192 private: | 200 private: |
| 193 // Contains all data needed to keep track of requests. | 201 // Contains all data needed to keep track of requests. |
| 194 class DeviceRequest; | 202 class DeviceRequest; |
| 195 | 203 |
| 196 // Cache enumerated device list. | 204 // Cache enumerated device list. |
| 197 struct EnumerationCache { | 205 struct EnumerationCache { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 DeviceRequest* request); | 286 DeviceRequest* request); |
| 279 void FinalizeRequestFailed(const std::string& label, | 287 void FinalizeRequestFailed(const std::string& label, |
| 280 DeviceRequest* request); | 288 DeviceRequest* request); |
| 281 void FinalizeOpenDevice(const std::string& label, | 289 void FinalizeOpenDevice(const std::string& label, |
| 282 DeviceRequest* request); | 290 DeviceRequest* request); |
| 283 void FinalizeMediaAccessRequest(const std::string& label, | 291 void FinalizeMediaAccessRequest(const std::string& label, |
| 284 DeviceRequest* request, | 292 DeviceRequest* request, |
| 285 const MediaStreamDevices& devices); | 293 const MediaStreamDevices& devices); |
| 286 void FinalizeEnumerateDevices(const std::string& label, | 294 void FinalizeEnumerateDevices(const std::string& label, |
| 287 DeviceRequest* request); | 295 DeviceRequest* request); |
| 296 void DoAddLogMessage(const std::string& message); | |
|
Henrik Grunell
2014/01/17 08:51:25
Remove. Not implemented as a member function.
vrk (LEFT CHROMIUM)
2014/01/22 02:25:42
Thanks, done.
| |
| 288 | 297 |
| 289 // This method is called when an audio or video device is plugged in or | 298 // This method is called when an audio or video device is plugged in or |
| 290 // removed. It make sure all MediaStreams that use a removed device is | 299 // removed. It make sure all MediaStreams that use a removed device is |
| 291 // stopped and that the render process is notified. |old_devices| is the list | 300 // stopped and that the render process is notified. |old_devices| is the list |
| 292 // of previously available devices. |new_devices| is the new | 301 // of previously available devices. |new_devices| is the new |
| 293 // list of currently available devices. | 302 // list of currently available devices. |
| 294 void StopRemovedDevices(const StreamDeviceInfoArray& old_devices, | 303 void StopRemovedDevices(const StreamDeviceInfoArray& old_devices, |
| 295 const StreamDeviceInfoArray& new_devices); | 304 const StreamDeviceInfoArray& new_devices); |
| 296 // Helper method used by StopRemovedDevices to stop the use of a certain | 305 // Helper method used by StopRemovedDevices to stop the use of a certain |
| 297 // device. | 306 // device. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 | 357 |
| 349 bool use_fake_ui_; | 358 bool use_fake_ui_; |
| 350 scoped_ptr<FakeMediaStreamUIProxy> fake_ui_; | 359 scoped_ptr<FakeMediaStreamUIProxy> fake_ui_; |
| 351 | 360 |
| 352 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); | 361 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); |
| 353 }; | 362 }; |
| 354 | 363 |
| 355 } // namespace content | 364 } // namespace content |
| 356 | 365 |
| 357 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 366 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
| OLD | NEW |