Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(652)

Side by Side Diff: content/browser/renderer_host/media/audio_input_renderer_host.cc

Issue 22408006: Properly set loopback device ID for system audio capture. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Give a valid name to the system audio capture device. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/media/media_capture_devices_dispatcher.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « chrome/browser/media/media_capture_devices_dispatcher.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698