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_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/process.h" | 9 #include "base/process.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
11 #include "content/browser/renderer_host/media/audio_input_device_manager.h" | 11 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
12 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" | 12 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" |
13 #include "content/browser/renderer_host/media/media_stream_manager.h" | 13 #include "content/browser/renderer_host/media/media_stream_manager.h" |
14 #include "content/common/media/audio_messages.h" | 14 #include "content/common/media/audio_messages.h" |
| 15 #include "content/public/common/media_stream_request.h" |
15 | 16 |
16 using content::BrowserMessageFilter; | 17 using content::BrowserMessageFilter; |
17 using content::BrowserThread; | 18 using content::BrowserThread; |
18 | 19 |
19 AudioInputRendererHost::AudioEntry::AudioEntry() | 20 AudioInputRendererHost::AudioEntry::AudioEntry() |
20 : stream_id(0), | 21 : stream_id(0), |
21 pending_close(false) { | 22 pending_close(false) { |
22 } | 23 } |
23 | 24 |
24 AudioInputRendererHost::AudioEntry::~AudioEntry() {} | 25 AudioInputRendererHost::AudioEntry::~AudioEntry() {} |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 174 } |
174 void AudioInputRendererHost::OnStartDevice(int stream_id, int session_id) { | 175 void AudioInputRendererHost::OnStartDevice(int stream_id, int session_id) { |
175 VLOG(1) << "AudioInputRendererHost::OnStartDevice(stream_id=" | 176 VLOG(1) << "AudioInputRendererHost::OnStartDevice(stream_id=" |
176 << stream_id << ", session_id = " << session_id << ")"; | 177 << stream_id << ", session_id = " << session_id << ")"; |
177 | 178 |
178 // Add the session entry to the map. | 179 // Add the session entry to the map. |
179 session_entries_[session_id] = stream_id; | 180 session_entries_[session_id] = stream_id; |
180 | 181 |
181 // Start the device with the session_id. If the device is started | 182 // Start the device with the session_id. If the device is started |
182 // successfully, OnDeviceStarted() callback will be triggered. | 183 // successfully, OnDeviceStarted() callback will be triggered. |
183 media_stream_manager_->audio_input_device_manager()->Start(session_id, this); | 184 media_stream_manager_->GetAudioInputDeviceManager( |
| 185 content::MEDIA_USER_AUDIO_CAPTURE)->Start(session_id, this); |
| 186 // TODO(miu): Confirm use of AudioInputHostMsg_* only applies to the user |
| 187 // audio capture devices, and does not have anything to do with |
| 188 // MediaStreamHostMsg_*. |
184 } | 189 } |
185 | 190 |
186 void AudioInputRendererHost::OnCreateStream( | 191 void AudioInputRendererHost::OnCreateStream( |
187 int stream_id, const media::AudioParameters& params, | 192 int stream_id, const media::AudioParameters& params, |
188 const std::string& device_id, bool automatic_gain_control) { | 193 const std::string& device_id, bool automatic_gain_control) { |
189 VLOG(1) << "AudioInputRendererHost::OnCreateStream(stream_id=" | 194 VLOG(1) << "AudioInputRendererHost::OnCreateStream(stream_id=" |
190 << stream_id << ")"; | 195 << stream_id << ")"; |
191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
192 DCHECK(LookupById(stream_id) == NULL); | 197 DCHECK(LookupById(stream_id) == NULL); |
193 | 198 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 stream_id, media::AudioInputIPCDelegate::kStopped)); | 335 stream_id, media::AudioInputIPCDelegate::kStopped)); |
331 } | 336 } |
332 | 337 |
333 // Delete the session entry. | 338 // Delete the session entry. |
334 session_entries_.erase(it); | 339 session_entries_.erase(it); |
335 } | 340 } |
336 | 341 |
337 void AudioInputRendererHost::StopAndDeleteDevice(int session_id) { | 342 void AudioInputRendererHost::StopAndDeleteDevice(int session_id) { |
338 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 343 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
339 | 344 |
340 media_stream_manager_->audio_input_device_manager()->Stop(session_id); | 345 media_stream_manager_->GetAudioInputDeviceManager( |
| 346 content::MEDIA_USER_AUDIO_CAPTURE)->Stop(session_id); |
341 | 347 |
342 // Delete the session entry. | 348 // Delete the session entry. |
343 session_entries_.erase(session_id); | 349 session_entries_.erase(session_id); |
344 } | 350 } |
345 | 351 |
346 void AudioInputRendererHost::CloseAndDeleteStream(AudioEntry* entry) { | 352 void AudioInputRendererHost::CloseAndDeleteStream(AudioEntry* entry) { |
347 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
348 | 354 |
349 if (!entry->pending_close) { | 355 if (!entry->pending_close) { |
350 entry->controller->Close(base::Bind(&AudioInputRendererHost::DeleteEntry, | 356 entry->controller->Close(base::Bind(&AudioInputRendererHost::DeleteEntry, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 406 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
401 | 407 |
402 for (SessionEntryMap::iterator it = session_entries_.begin(); | 408 for (SessionEntryMap::iterator it = session_entries_.begin(); |
403 it != session_entries_.end(); ++it) { | 409 it != session_entries_.end(); ++it) { |
404 if (stream_id == it->second) { | 410 if (stream_id == it->second) { |
405 return it->first; | 411 return it->first; |
406 } | 412 } |
407 } | 413 } |
408 return 0; | 414 return 0; |
409 } | 415 } |
OLD | NEW |