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/audio_input_device_manager.h" | 5 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "content/browser/renderer_host/media/audio_input_device_manager_event_h
andler.h" | 9 #include "content/browser/renderer_host/media/audio_input_device_manager_event_h
andler.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
11 #include "media/audio/audio_manager_base.h" | 11 #include "media/audio/audio_manager_base.h" |
12 | 12 |
13 using content::BrowserThread; | 13 using content::BrowserThread; |
14 | 14 |
15 namespace media_stream { | 15 namespace media_stream { |
16 | 16 |
17 const int AudioInputDeviceManager::kFakeOpenSessionId = 1; | 17 const int AudioInputDeviceManager::kFakeOpenSessionId = 1; |
18 const int AudioInputDeviceManager::kInvalidSessionId = 0; | 18 const int AudioInputDeviceManager::kInvalidSessionId = 0; |
19 const char AudioInputDeviceManager::kInvalidDeviceId[] = ""; | 19 const char AudioInputDeviceManager::kInvalidDeviceId[] = ""; |
20 | 20 |
21 // Starting id for the first capture session. | 21 // Starting id for the first capture session. |
22 const int kFirstSessionId = AudioInputDeviceManager::kFakeOpenSessionId + 1; | 22 const int kFirstSessionId = AudioInputDeviceManager::kFakeOpenSessionId + 1; |
23 | 23 |
24 AudioInputDeviceManager::AudioInputDeviceManager(AudioManager* audio_manager) | 24 AudioInputDeviceManager::AudioInputDeviceManager( |
| 25 media::AudioManager* audio_manager) |
25 : listener_(NULL), | 26 : listener_(NULL), |
26 next_capture_session_id_(kFirstSessionId), | 27 next_capture_session_id_(kFirstSessionId), |
27 audio_manager_(audio_manager) { | 28 audio_manager_(audio_manager) { |
28 } | 29 } |
29 | 30 |
30 AudioInputDeviceManager::~AudioInputDeviceManager() { | 31 AudioInputDeviceManager::~AudioInputDeviceManager() { |
31 } | 32 } |
32 | 33 |
33 void AudioInputDeviceManager::Register(MediaStreamProviderListener* listener) { | 34 void AudioInputDeviceManager::Register(MediaStreamProviderListener* listener) { |
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 int session_id, AudioInputDeviceManagerEventHandler* event_handler) { | 121 int session_id, AudioInputDeviceManagerEventHandler* event_handler) { |
121 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 122 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
122 DCHECK(event_handler); | 123 DCHECK(event_handler); |
123 | 124 |
124 // Solution for not using MediaStreamManager. This is needed when Start() is | 125 // Solution for not using MediaStreamManager. This is needed when Start() is |
125 // called without using Open(), we post default device for test purpose. | 126 // called without using Open(), we post default device for test purpose. |
126 // And we do not store the info for the kFakeOpenSessionId but return | 127 // And we do not store the info for the kFakeOpenSessionId but return |
127 // the callback immediately. | 128 // the callback immediately. |
128 if (session_id == kFakeOpenSessionId) { | 129 if (session_id == kFakeOpenSessionId) { |
129 event_handler->OnDeviceStarted(session_id, | 130 event_handler->OnDeviceStarted(session_id, |
130 AudioManagerBase::kDefaultDeviceId); | 131 media::AudioManagerBase::kDefaultDeviceId); |
131 return; | 132 return; |
132 } | 133 } |
133 | 134 |
134 // Checks if the device has been opened or not. | 135 // Checks if the device has been opened or not. |
135 std::string device_id = (devices_.find(session_id) == devices_.end()) ? | 136 std::string device_id = (devices_.find(session_id) == devices_.end()) ? |
136 kInvalidDeviceId : devices_[session_id].unique_id; | 137 kInvalidDeviceId : devices_[session_id].unique_id; |
137 | 138 |
138 // Adds the event handler to the session if the session has not been started, | 139 // Adds the event handler to the session if the session has not been started, |
139 // otherwise post a |kInvalidDeviceId| to indicate that Start() fails. | 140 // otherwise post a |kInvalidDeviceId| to indicate that Start() fails. |
140 if (event_handlers_.find(session_id) == event_handlers_.end()) | 141 if (event_handlers_.find(session_id) == event_handlers_.end()) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 175 } |
175 | 176 |
176 void AudioInputDeviceManager::ClosedOnIOThread(int session_id) { | 177 void AudioInputDeviceManager::ClosedOnIOThread(int session_id) { |
177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
178 if (listener_) | 179 if (listener_) |
179 listener_->Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, | 180 listener_->Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, |
180 session_id); | 181 session_id); |
181 } | 182 } |
182 | 183 |
183 } // namespace media_stream | 184 } // namespace media_stream |
OLD | NEW |