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 #include "content/browser/renderer_host/media/media_stream_manager.h" | 5 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 requests_.erase(it++); | 210 requests_.erase(it++); |
| 211 } else { | 211 } else { |
| 212 ++it; | 212 ++it; |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| 217 void MediaStreamManager::CancelGenerateStream(const std::string& label) { | |
| 218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 219 | |
| 220 DeviceRequests::iterator it = requests_.find(label); | |
| 221 if (it != requests_.end()) { | |
| 222 // The request isn't complete. | |
| 223 if (!RequestDone(it->second)) { | |
| 224 DeviceRequest* request = &(it->second); | |
| 225 if (request->state[content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE] == | |
| 226 DeviceRequest::kOpening) { | |
| 227 for (StreamDeviceInfoArray::iterator it = | |
| 228 request->audio_devices.begin(); it != request->audio_devices.end(); | |
| 229 ++it) { | |
| 230 if (it->in_use) { | |
|
wjia(left Chromium)
2012/06/06 13:40:24
This check is not needed. |in_use| is a signal for
| |
| 231 audio_input_device_manager()->Close(it->session_id); | |
| 232 } | |
| 233 } | |
| 234 } | |
| 235 if (request->state[content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE] == | |
| 236 DeviceRequest::kOpening) { | |
| 237 for (StreamDeviceInfoArray::iterator it = | |
| 238 request->video_devices.begin(); it != request->video_devices.end(); | |
| 239 ++it) { | |
| 240 if (it->in_use) { | |
|
wjia(left Chromium)
2012/06/06 13:40:24
ditto.
| |
| 241 video_capture_manager()->Close(it->session_id); | |
| 242 } | |
| 243 } | |
| 244 } | |
| 245 requests_.erase(it); | |
| 246 } else { | |
| 247 StopGeneratedStream(label); | |
| 248 } | |
| 249 device_settings_->RemovePendingCaptureRequest(label); | |
| 250 } | |
| 251 } | |
| 252 | |
| 217 void MediaStreamManager::StopGeneratedStream(const std::string& label) { | 253 void MediaStreamManager::StopGeneratedStream(const std::string& label) { |
| 218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 254 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 219 // Find the request and close all open devices for the request. | 255 // Find the request and close all open devices for the request. |
| 220 DeviceRequests::iterator it = requests_.find(label); | 256 DeviceRequests::iterator it = requests_.find(label); |
| 221 if (it != requests_.end()) { | 257 if (it != requests_.end()) { |
| 222 for (StreamDeviceInfoArray::iterator audio_it = | 258 for (StreamDeviceInfoArray::iterator audio_it = |
| 223 it->second.audio_devices.begin(); | 259 it->second.audio_devices.begin(); |
| 224 audio_it != it->second.audio_devices.end(); ++audio_it) { | 260 audio_it != it->second.audio_devices.end(); ++audio_it) { |
| 225 audio_input_device_manager()->Close(audio_it->session_id); | 261 audio_input_device_manager()->Close(audio_it->session_id); |
| 226 } | 262 } |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 656 if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE) { | 692 if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE) { |
| 657 return video_capture_manager(); | 693 return video_capture_manager(); |
| 658 } else if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE) { | 694 } else if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE) { |
| 659 return audio_input_device_manager(); | 695 return audio_input_device_manager(); |
| 660 } | 696 } |
| 661 NOTREACHED(); | 697 NOTREACHED(); |
| 662 return NULL; | 698 return NULL; |
| 663 } | 699 } |
| 664 | 700 |
| 665 } // namespace media_stream | 701 } // namespace media_stream |
| OLD | NEW |