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 MediaStreamDeviceSettings for permission to | 9 // 2. MediaStreamManager will ask MediaStreamDeviceSettings for permission to |
10 // use devices and for which device to use. | 10 // use devices and for which device to use. |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 virtual void SettingsError(const std::string& label) OVERRIDE; | 126 virtual void SettingsError(const std::string& label) OVERRIDE; |
127 | 127 |
128 // Used by unit test to make sure fake devices are used instead of a real | 128 // Used by unit test to make sure fake devices are used instead of a real |
129 // devices, which is needed for server based testing. | 129 // devices, which is needed for server based testing. |
130 void UseFakeDevice(); | 130 void UseFakeDevice(); |
131 | 131 |
132 private: | 132 private: |
133 // Contains all data needed to keep track of requests. | 133 // Contains all data needed to keep track of requests. |
134 struct DeviceRequest; | 134 struct DeviceRequest; |
135 | 135 |
| 136 // Helpers for signaling the media observer that new capture devices are |
| 137 // opened/closed. |
| 138 void NotifyObserverDevicesOpened(DeviceRequest* request); |
| 139 void NotifyObserverDevicesClosed(DeviceRequest* request); |
| 140 void DevicesFromRequest(DeviceRequest* request, |
| 141 content::MediaStreamDevices* devices); |
| 142 |
136 // Helpers. | 143 // Helpers. |
137 bool RequestDone(const MediaStreamManager::DeviceRequest& request) const; | 144 bool RequestDone(const MediaStreamManager::DeviceRequest& request) const; |
138 MediaStreamProvider* GetDeviceManager(MediaStreamType stream_type); | 145 MediaStreamProvider* GetDeviceManager(MediaStreamType stream_type); |
139 void StartEnumeration(DeviceRequest* new_request, | 146 void StartEnumeration(DeviceRequest* new_request, |
140 int render_process_id, | |
141 int render_view_id, | |
142 const std::string& security_origin, | |
143 std::string* label); | 147 std::string* label); |
144 | 148 |
145 scoped_ptr<MediaStreamDeviceSettings> device_settings_; | 149 scoped_ptr<MediaStreamDeviceSettings> device_settings_; |
146 scoped_refptr<VideoCaptureManager> video_capture_manager_; | 150 scoped_refptr<VideoCaptureManager> video_capture_manager_; |
147 scoped_refptr<AudioInputDeviceManager> audio_input_device_manager_; | 151 scoped_refptr<AudioInputDeviceManager> audio_input_device_manager_; |
148 | 152 |
149 // Keeps track of device types currently being enumerated to not enumerate | 153 // Keeps track of device types currently being enumerated to not enumerate |
150 // when not necessary. | 154 // when not necessary. |
151 std::vector<bool> enumeration_in_progress_; | 155 std::vector<bool> enumeration_in_progress_; |
152 | 156 |
153 // All non-closed request. | 157 // All non-closed request. |
154 typedef std::map<std::string, DeviceRequest> DeviceRequests; | 158 typedef std::map<std::string, DeviceRequest> DeviceRequests; |
155 DeviceRequests requests_; | 159 DeviceRequests requests_; |
156 media::AudioManager* audio_manager_; | 160 media::AudioManager* audio_manager_; |
157 | 161 |
158 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); | 162 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); |
159 }; | 163 }; |
160 | 164 |
161 } // namespace media_stream | 165 } // namespace media_stream |
162 | 166 |
163 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 167 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
OLD | NEW |