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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 | 353 |
354 MediaStreamManager::EnumerationCache::EnumerationCache() | 354 MediaStreamManager::EnumerationCache::EnumerationCache() |
355 : valid(false) { | 355 : valid(false) { |
356 } | 356 } |
357 | 357 |
358 MediaStreamManager::EnumerationCache::~EnumerationCache() { | 358 MediaStreamManager::EnumerationCache::~EnumerationCache() { |
359 } | 359 } |
360 | 360 |
361 MediaStreamManager::MediaStreamManager() | 361 MediaStreamManager::MediaStreamManager() |
362 : audio_manager_(NULL), | 362 : audio_manager_(NULL), |
| 363 #if defined(OS_WIN) |
| 364 video_capture_thread_("VideoCaptureThread"), |
| 365 #endif |
363 monitoring_started_(false), | 366 monitoring_started_(false), |
364 #if defined(OS_CHROMEOS) | 367 #if defined(OS_CHROMEOS) |
365 has_checked_keyboard_mic_(false), | 368 has_checked_keyboard_mic_(false), |
366 #endif | 369 #endif |
367 io_loop_(NULL), | 370 io_loop_(NULL), |
368 use_fake_ui_(false) {} | 371 use_fake_ui_(false) {} |
369 | 372 |
370 MediaStreamManager::MediaStreamManager(media::AudioManager* audio_manager) | 373 MediaStreamManager::MediaStreamManager(media::AudioManager* audio_manager) |
371 : audio_manager_(audio_manager), | 374 : audio_manager_(audio_manager), |
| 375 #if defined(OS_WIN) |
| 376 video_capture_thread_("VideoCaptureThread"), |
| 377 #endif |
372 monitoring_started_(false), | 378 monitoring_started_(false), |
373 #if defined(OS_CHROMEOS) | 379 #if defined(OS_CHROMEOS) |
374 has_checked_keyboard_mic_(false), | 380 has_checked_keyboard_mic_(false), |
375 #endif | 381 #endif |
376 io_loop_(NULL), | 382 io_loop_(NULL), |
377 use_fake_ui_(false) { | 383 use_fake_ui_(false) { |
378 DCHECK(audio_manager_); | 384 DCHECK(audio_manager_); |
379 memset(active_enumeration_ref_count_, 0, | 385 memset(active_enumeration_ref_count_, 0, |
380 sizeof(active_enumeration_ref_count_)); | 386 sizeof(active_enumeration_ref_count_)); |
381 | 387 |
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1588 io_loop_->AddDestructionObserver(this); | 1594 io_loop_->AddDestructionObserver(this); |
1589 | 1595 |
1590 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1596 if (CommandLine::ForCurrentProcess()->HasSwitch( |
1591 switches::kUseFakeDeviceForMediaStream)) { | 1597 switches::kUseFakeDeviceForMediaStream)) { |
1592 audio_input_device_manager()->UseFakeDevice(); | 1598 audio_input_device_manager()->UseFakeDevice(); |
1593 } | 1599 } |
1594 | 1600 |
1595 video_capture_manager_ = | 1601 video_capture_manager_ = |
1596 new VideoCaptureManager(media::VideoCaptureDeviceFactory::CreateFactory( | 1602 new VideoCaptureManager(media::VideoCaptureDeviceFactory::CreateFactory( |
1597 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI))); | 1603 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI))); |
| 1604 #if defined(OS_WIN) |
| 1605 // Use an STA Video Capture Thread to try to avoid crashes on enumeration of |
| 1606 // buggy third party Direct Show modules, http://crbug.com/428958. |
| 1607 video_capture_thread_.init_com_with_mta(false); |
| 1608 CHECK(video_capture_thread_.Start()); |
| 1609 video_capture_manager_->Register(this, |
| 1610 video_capture_thread_.message_loop_proxy()); |
| 1611 #else |
1598 video_capture_manager_->Register(this, device_task_runner_); | 1612 video_capture_manager_->Register(this, device_task_runner_); |
| 1613 #endif |
1599 } | 1614 } |
1600 | 1615 |
1601 void MediaStreamManager::Opened(MediaStreamType stream_type, | 1616 void MediaStreamManager::Opened(MediaStreamType stream_type, |
1602 int capture_session_id) { | 1617 int capture_session_id) { |
1603 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1618 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1604 DVLOG(1) << "Opened({stream_type = " << stream_type << "} " | 1619 DVLOG(1) << "Opened({stream_type = " << stream_type << "} " |
1605 << "{capture_session_id = " << capture_session_id << "})"; | 1620 << "{capture_session_id = " << capture_session_id << "})"; |
1606 // Find the request(s) containing this device and mark it as used. | 1621 // Find the request(s) containing this device and mark it as used. |
1607 // It can be used in several requests since the same device can be | 1622 // It can be used in several requests since the same device can be |
1608 // requested from the same web page. | 1623 // requested from the same web page. |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2116 } | 2131 } |
2117 } | 2132 } |
2118 | 2133 |
2119 void MediaStreamManager::SetKeyboardMicOnDeviceThread() { | 2134 void MediaStreamManager::SetKeyboardMicOnDeviceThread() { |
2120 DCHECK(device_task_runner_->BelongsToCurrentThread()); | 2135 DCHECK(device_task_runner_->BelongsToCurrentThread()); |
2121 audio_manager_->SetHasKeyboardMic(); | 2136 audio_manager_->SetHasKeyboardMic(); |
2122 } | 2137 } |
2123 #endif | 2138 #endif |
2124 | 2139 |
2125 } // namespace content | 2140 } // namespace content |
OLD | NEW |