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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
| 13 #include "base/threading/thread.h" |
13 #include "content/browser/renderer_host/media/audio_input_device_manager.h" | 14 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
14 #include "content/browser/renderer_host/media/media_stream_requester.h" | 15 #include "content/browser/renderer_host/media/media_stream_requester.h" |
15 #include "content/browser/renderer_host/media/media_stream_ui_controller.h" | 16 #include "content/browser/renderer_host/media/media_stream_ui_controller.h" |
16 #include "content/browser/renderer_host/media/video_capture_manager.h" | 17 #include "content/browser/renderer_host/media/video_capture_manager.h" |
17 #include "content/common/media/media_stream_options.h" | 18 #include "content/common/media/media_stream_options.h" |
18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
19 #include "content/public/browser/content_browser_client.h" | 20 #include "content/public/browser/content_browser_client.h" |
20 #include "content/public/browser/media_observer.h" | 21 #include "content/public/browser/media_observer.h" |
21 #include "content/public/browser/media_request_state.h" | 22 #include "content/public/browser/media_request_state.h" |
22 #include "content/public/common/media_stream_request.h" | 23 #include "content/public/common/media_stream_request.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 return label; | 55 return label; |
55 } | 56 } |
56 | 57 |
57 // Helper to verify if a media stream type is part of options or not. | 58 // Helper to verify if a media stream type is part of options or not. |
58 static bool Requested(const StreamOptions& options, | 59 static bool Requested(const StreamOptions& options, |
59 MediaStreamType stream_type) { | 60 MediaStreamType stream_type) { |
60 return (options.audio_type == stream_type || | 61 return (options.audio_type == stream_type || |
61 options.video_type == stream_type); | 62 options.video_type == stream_type); |
62 } | 63 } |
63 | 64 |
64 #if defined(OS_WIN) | |
65 DeviceThread::DeviceThread(const char* name) : base::Thread(name) { | |
66 } | |
67 | |
68 DeviceThread::~DeviceThread() { | |
69 Stop(); | |
70 } | |
71 | |
72 void DeviceThread::Init() { | |
73 com_initializer_.reset(new base::win::ScopedCOMInitializer( | |
74 base::win::ScopedCOMInitializer::kMTA)); | |
75 } | |
76 | |
77 void DeviceThread::CleanUp() { | |
78 com_initializer_.reset(); | |
79 } | |
80 #endif | |
81 | |
82 // TODO(xians): Merge DeviceRequest with MediaStreamRequest. | 65 // TODO(xians): Merge DeviceRequest with MediaStreamRequest. |
83 class MediaStreamManager::DeviceRequest { | 66 class MediaStreamManager::DeviceRequest { |
84 public: | 67 public: |
85 enum RequestType { | 68 enum RequestType { |
86 DEVICE_ACCESS = 0, | 69 DEVICE_ACCESS = 0, |
87 GENERATE_STREAM, | 70 GENERATE_STREAM, |
88 ENUMERATE_DEVICES, | 71 ENUMERATE_DEVICES, |
89 OPEN_DEVICE | 72 OPEN_DEVICE |
90 }; | 73 }; |
91 | 74 |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 request.render_view_id, | 564 request.render_view_id, |
582 request.options, | 565 request.options, |
583 request.security_origin); | 566 request.security_origin); |
584 } | 567 } |
585 | 568 |
586 void MediaStreamManager::EnsureDeviceManagersStarted() { | 569 void MediaStreamManager::EnsureDeviceManagersStarted() { |
587 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
588 if (device_thread_.get()) | 571 if (device_thread_.get()) |
589 return; | 572 return; |
590 | 573 |
591 device_thread_.reset(new DeviceThread("MediaStreamDeviceThread")); | 574 device_thread_.reset(new base::Thread("MediaStreamDeviceThread")); |
| 575 #if defined(OS_WIN) |
| 576 device_thread_->init_com_with_mta(true); |
| 577 #endif |
592 CHECK(device_thread_->Start()); | 578 CHECK(device_thread_->Start()); |
593 | 579 |
594 audio_input_device_manager_ = | 580 audio_input_device_manager_ = |
595 new media_stream::AudioInputDeviceManager(audio_manager_); | 581 new media_stream::AudioInputDeviceManager(audio_manager_); |
596 audio_input_device_manager_->Register(this, | 582 audio_input_device_manager_->Register(this, |
597 device_thread_->message_loop_proxy()); | 583 device_thread_->message_loop_proxy()); |
598 | 584 |
599 video_capture_manager_ = new media_stream::VideoCaptureManager(); | 585 video_capture_manager_ = new media_stream::VideoCaptureManager(); |
600 video_capture_manager_->Register(this, | 586 video_capture_manager_->Register(this, |
601 device_thread_->message_loop_proxy()); | 587 device_thread_->message_loop_proxy()); |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 it != requests_.end(); ++it) { | 1042 it != requests_.end(); ++it) { |
1057 if (it->second.type == DeviceRequest::ENUMERATE_DEVICES && | 1043 if (it->second.type == DeviceRequest::ENUMERATE_DEVICES && |
1058 Requested(it->second.options, stream_type)) { | 1044 Requested(it->second.options, stream_type)) { |
1059 return true; | 1045 return true; |
1060 } | 1046 } |
1061 } | 1047 } |
1062 return false; | 1048 return false; |
1063 } | 1049 } |
1064 | 1050 |
1065 } // namespace media_stream | 1051 } // namespace media_stream |
OLD | NEW |