| 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. |
| 11 // 3. MediaStreamManager will request the corresponding media device manager(s) | 11 // 3. MediaStreamManager will request the corresponding media device manager(s) |
| 12 // to enumerate available devices. The result will be given to | 12 // to enumerate available devices. The result will be given to |
| 13 // MediaStreamUIController. | 13 // MediaStreamUIController. |
| 14 // 4. MediaStreamUIController will, by posting the request to UI, let the | 14 // 4. MediaStreamUIController will, by posting the request to UI, let the |
| 15 // users to select which devices to use and send callback to | 15 // users to select which devices to use and send callback to |
| 16 // MediaStreamManager with the result. | 16 // MediaStreamManager with the result. |
| 17 // 5. MediaStreamManager will call the proper media device manager to open the | 17 // 5. MediaStreamManager will call the proper media device manager to open the |
| 18 // device and let the MediaStreamRequester know it has been done. | 18 // device and let the MediaStreamRequester know it has been done. |
| 19 | 19 |
| 20 // If either user or test harness selects --use-fake-device-for-media-stream, | 20 // If either user or test harness selects --use-fake-device-for-media-stream, |
| 21 // a fake video device or devices are used instead of real ones. | 21 // a fake video device or devices are used instead of real ones. |
| 22 | 22 |
| 23 // When enumeration and open are done in separate operations, | 23 // When enumeration and open are done in separate operations, |
| 24 // MediaStreamUIController is not involved as in steps. | 24 // MediaStreamUIController is not involved as in steps. |
| 25 | 25 |
| 26 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 26 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
| 27 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 27 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
| 28 | 28 |
| 29 #include <map> | 29 #include <list> |
| 30 #include <set> | 30 #include <set> |
| 31 #include <string> | 31 #include <string> |
| 32 #include <utility> |
| 32 | 33 |
| 33 #include "base/basictypes.h" | 34 #include "base/basictypes.h" |
| 34 #include "base/memory/ref_counted.h" | 35 #include "base/memory/ref_counted.h" |
| 35 #include "base/memory/scoped_ptr.h" | 36 #include "base/memory/scoped_ptr.h" |
| 36 #include "base/message_loop/message_loop.h" | 37 #include "base/message_loop/message_loop.h" |
| 37 #include "base/power_monitor/power_observer.h" | 38 #include "base/power_monitor/power_observer.h" |
| 38 #include "base/system_monitor/system_monitor.h" | 39 #include "base/system_monitor/system_monitor.h" |
| 39 #include "content/browser/renderer_host/media/media_stream_provider.h" | 40 #include "content/browser/renderer_host/media/media_stream_provider.h" |
| 40 #include "content/common/content_export.h" | 41 #include "content/common/content_export.h" |
| 41 #include "content/common/media/media_stream_options.h" | 42 #include "content/common/media/media_stream_options.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 222 |
| 222 // Cache enumerated device list. | 223 // Cache enumerated device list. |
| 223 struct EnumerationCache { | 224 struct EnumerationCache { |
| 224 EnumerationCache(); | 225 EnumerationCache(); |
| 225 ~EnumerationCache(); | 226 ~EnumerationCache(); |
| 226 | 227 |
| 227 bool valid; | 228 bool valid; |
| 228 StreamDeviceInfoArray devices; | 229 StreamDeviceInfoArray devices; |
| 229 }; | 230 }; |
| 230 | 231 |
| 231 typedef std::map<std::string, DeviceRequest*> DeviceRequests; | 232 // |DeviceRequests| is a list to ensure requests are processed in the order |
| 233 // they arrive. The first member of the pair is the label of the |
| 234 // |DeviceRequest|. |
| 235 typedef std::list<std::pair<std::string, DeviceRequest*> > DeviceRequests; |
| 232 | 236 |
| 233 // Initializes the device managers on IO thread. Auto-starts the device | 237 // Initializes the device managers on IO thread. Auto-starts the device |
| 234 // thread and registers this as a listener with the device managers. | 238 // thread and registers this as a listener with the device managers. |
| 235 void InitializeDeviceManagersOnIOThread(); | 239 void InitializeDeviceManagersOnIOThread(); |
| 236 | 240 |
| 237 // Helper for sending up-to-date device lists to media observer when a | 241 // Helper for sending up-to-date device lists to media observer when a |
| 238 // capture device is plugged in or unplugged. | 242 // capture device is plugged in or unplugged. |
| 239 void NotifyDevicesChanged(MediaStreamType stream_type, | 243 void NotifyDevicesChanged(MediaStreamType stream_type, |
| 240 const StreamDeviceInfoArray& devices); | 244 const StreamDeviceInfoArray& devices); |
| 241 | 245 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 | 393 |
| 390 bool use_fake_ui_; | 394 bool use_fake_ui_; |
| 391 scoped_ptr<FakeMediaStreamUIProxy> fake_ui_; | 395 scoped_ptr<FakeMediaStreamUIProxy> fake_ui_; |
| 392 | 396 |
| 393 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); | 397 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); |
| 394 }; | 398 }; |
| 395 | 399 |
| 396 } // namespace content | 400 } // namespace content |
| 397 | 401 |
| 398 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 402 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
| OLD | NEW |