| 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 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 406 |
| 407 std::string MediaStreamManager::EnumerateDevices( | 407 std::string MediaStreamManager::EnumerateDevices( |
| 408 MediaStreamRequester* requester, | 408 MediaStreamRequester* requester, |
| 409 int render_process_id, | 409 int render_process_id, |
| 410 int render_view_id, | 410 int render_view_id, |
| 411 ResourceContext* rc, | 411 ResourceContext* rc, |
| 412 int page_request_id, | 412 int page_request_id, |
| 413 MediaStreamType type, | 413 MediaStreamType type, |
| 414 const GURL& security_origin) { | 414 const GURL& security_origin) { |
| 415 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 415 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 416 DCHECK(requester); |
| 416 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE || | 417 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE || |
| 417 type == MEDIA_DEVICE_VIDEO_CAPTURE); | 418 type == MEDIA_DEVICE_VIDEO_CAPTURE); |
| 418 | 419 |
| 419 // When the requester is NULL, the request is made by the UI to ensure MSM | |
| 420 // starts monitoring devices. | |
| 421 if (!requester) { | |
| 422 if (!monitoring_started_) | |
| 423 StartMonitoring(); | |
| 424 | |
| 425 return std::string(); | |
| 426 } | |
| 427 | |
| 428 // Create a new request. | 420 // Create a new request. |
| 429 StreamOptions options; | 421 StreamOptions options; |
| 430 if (type == MEDIA_DEVICE_AUDIO_CAPTURE) { | 422 if (type == MEDIA_DEVICE_AUDIO_CAPTURE) { |
| 431 options.audio_type = type; | 423 options.audio_type = type; |
| 432 } else if (type == MEDIA_DEVICE_VIDEO_CAPTURE) { | 424 } else if (type == MEDIA_DEVICE_VIDEO_CAPTURE) { |
| 433 options.video_type = type; | 425 options.video_type = type; |
| 434 } else { | 426 } else { |
| 435 NOTREACHED(); | 427 NOTREACHED(); |
| 436 return std::string(); | 428 return std::string(); |
| 437 } | 429 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 // been stopped. | 519 // been stopped. |
| 528 BrowserThread::PostTask( | 520 BrowserThread::PostTask( |
| 529 BrowserThread::IO, FROM_HERE, | 521 BrowserThread::IO, FROM_HERE, |
| 530 base::Bind(&MediaStreamManager::SetupRequest, | 522 base::Bind(&MediaStreamManager::SetupRequest, |
| 531 base::Unretained(this), label)); | 523 base::Unretained(this), label)); |
| 532 | 524 |
| 533 DVLOG(1) << "OpenDevice ({label = " << label << "})"; | 525 DVLOG(1) << "OpenDevice ({label = " << label << "})"; |
| 534 return label; | 526 return label; |
| 535 } | 527 } |
| 536 | 528 |
| 529 void MediaStreamManager::EnsureDeviceMonitorStarted() { |
| 530 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 531 if (!monitoring_started_) |
| 532 StartMonitoring(); |
| 533 } |
| 534 |
| 537 void MediaStreamManager::StopRemovedDevices( | 535 void MediaStreamManager::StopRemovedDevices( |
| 538 const StreamDeviceInfoArray& old_devices, | 536 const StreamDeviceInfoArray& old_devices, |
| 539 const StreamDeviceInfoArray& new_devices) { | 537 const StreamDeviceInfoArray& new_devices) { |
| 540 DVLOG(1) << "StopRemovedDevices(" | 538 DVLOG(1) << "StopRemovedDevices(" |
| 541 << "{#old_devices = " << old_devices.size() << "} " | 539 << "{#old_devices = " << old_devices.size() << "} " |
| 542 << "{#new_devices = " << new_devices.size() << "})"; | 540 << "{#new_devices = " << new_devices.size() << "})"; |
| 543 for (StreamDeviceInfoArray::const_iterator old_dev_it = old_devices.begin(); | 541 for (StreamDeviceInfoArray::const_iterator old_dev_it = old_devices.begin(); |
| 544 old_dev_it != old_devices.end(); ++old_dev_it) { | 542 old_dev_it != old_devices.end(); ++old_dev_it) { |
| 545 bool device_found = false; | 543 bool device_found = false; |
| 546 for (StreamDeviceInfoArray::const_iterator new_dev_it = new_devices.begin(); | 544 for (StreamDeviceInfoArray::const_iterator new_dev_it = new_devices.begin(); |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 } | 1416 } |
| 1419 | 1417 |
| 1420 // Always do enumeration even though some enumeration is in progress, | 1418 // Always do enumeration even though some enumeration is in progress, |
| 1421 // because those enumeration commands could be sent before these devices | 1419 // because those enumeration commands could be sent before these devices |
| 1422 // change. | 1420 // change. |
| 1423 ++active_enumeration_ref_count_[stream_type]; | 1421 ++active_enumeration_ref_count_[stream_type]; |
| 1424 GetDeviceManager(stream_type)->EnumerateDevices(stream_type); | 1422 GetDeviceManager(stream_type)->EnumerateDevices(stream_type); |
| 1425 } | 1423 } |
| 1426 | 1424 |
| 1427 } // namespace content | 1425 } // namespace content |
| OLD | NEW |