| 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/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/process/process.h" | 10 #include "base/process/process.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/browser/renderer_host/media/web_contents_audio_input_stream.h" | 14 #include "content/browser/renderer_host/media/web_contents_audio_input_stream.h" |
| 15 #include "content/browser/renderer_host/media/web_contents_capture_util.h" | 15 #include "content/browser/renderer_host/media/web_contents_capture_util.h" |
| 16 #include "media/audio/audio_manager_base.h" | 16 #include "media/audio/audio_manager_base.h" |
| 17 | 17 |
| 18 #if defined(USE_CRAS) | |
| 19 #include "media/audio/cras/audio_manager_cras.h" | |
| 20 #endif | |
| 21 | |
| 22 namespace content { | 18 namespace content { |
| 23 | 19 |
| 24 struct AudioInputRendererHost::AudioEntry { | 20 struct AudioInputRendererHost::AudioEntry { |
| 25 AudioEntry(); | 21 AudioEntry(); |
| 26 ~AudioEntry(); | 22 ~AudioEntry(); |
| 27 | 23 |
| 28 // The AudioInputController that manages the audio input stream. | 24 // The AudioInputController that manages the audio input stream. |
| 29 scoped_refptr<media::AudioInputController> controller; | 25 scoped_refptr<media::AudioInputController> controller; |
| 30 | 26 |
| 31 // The audio input stream ID in the render view. | 27 // The audio input stream ID in the render view. |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 if (audio_params.format() != media::AudioParameters::AUDIO_FAKE) { | 230 if (audio_params.format() != media::AudioParameters::AUDIO_FAKE) { |
| 235 const StreamDeviceInfo* info = media_stream_manager_-> | 231 const StreamDeviceInfo* info = media_stream_manager_-> |
| 236 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id); | 232 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id); |
| 237 if (!info) { | 233 if (!info) { |
| 238 SendErrorMessage(stream_id); | 234 SendErrorMessage(stream_id); |
| 239 DLOG(WARNING) << "No permission has been granted to input stream with " | 235 DLOG(WARNING) << "No permission has been granted to input stream with " |
| 240 << "session_id=" << session_id; | 236 << "session_id=" << session_id; |
| 241 return; | 237 return; |
| 242 } | 238 } |
| 243 | 239 |
| 244 if (info->device.type == content::MEDIA_SYSTEM_AUDIO_CAPTURE) { | 240 device_id = info->device.id; |
| 245 #if defined(USE_CRAS) | |
| 246 // Use the special loopback device ID for system audio capture. | |
| 247 device_id = media::AudioManagerCras::kLoopbackDeviceId; | |
| 248 #else | |
| 249 SendErrorMessage(stream_id); | |
| 250 DLOG(WARNING) << "Loopback device is not supported on this platform"; | |
| 251 return; | |
| 252 #endif | |
| 253 } else { | |
| 254 device_id = info->device.id; | |
| 255 } | |
| 256 } | 241 } |
| 257 | 242 |
| 258 // Create a new AudioEntry structure. | 243 // Create a new AudioEntry structure. |
| 259 scoped_ptr<AudioEntry> entry(new AudioEntry()); | 244 scoped_ptr<AudioEntry> entry(new AudioEntry()); |
| 260 | 245 |
| 261 const uint32 segment_size = (sizeof(media::AudioInputBufferParameters) + | 246 const uint32 segment_size = (sizeof(media::AudioInputBufferParameters) + |
| 262 audio_params.GetBytesPerBuffer()); | 247 audio_params.GetBytesPerBuffer()); |
| 263 entry->shared_memory_segment_count = config.shared_memory_count; | 248 entry->shared_memory_segment_count = config.shared_memory_count; |
| 264 | 249 |
| 265 // Create the shared memory and share it with the renderer process | 250 // Create the shared memory and share it with the renderer process |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 // TODO(hclam): Implement a faster look up method. | 398 // TODO(hclam): Implement a faster look up method. |
| 414 for (AudioEntryMap::iterator i = audio_entries_.begin(); | 399 for (AudioEntryMap::iterator i = audio_entries_.begin(); |
| 415 i != audio_entries_.end(); ++i) { | 400 i != audio_entries_.end(); ++i) { |
| 416 if (controller == i->second->controller.get()) | 401 if (controller == i->second->controller.get()) |
| 417 return i->second; | 402 return i->second; |
| 418 } | 403 } |
| 419 return NULL; | 404 return NULL; |
| 420 } | 405 } |
| 421 | 406 |
| 422 } // namespace content | 407 } // namespace content |
| OLD | NEW |