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

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

Issue 21183002: Adding key press detection in the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 #include "media/audio/key_press_monitor.h"
17 18
18 #if defined(USE_CRAS) 19 #if defined(USE_CRAS)
19 #include "media/audio/cras/audio_manager_cras.h" 20 #include "media/audio/cras/audio_manager_cras.h"
20 #endif 21 #endif
21 22
22 namespace content { 23 namespace content {
23 24
24 struct AudioInputRendererHost::AudioEntry { 25 struct AudioInputRendererHost::AudioEntry {
25 AudioEntry(); 26 AudioEntry();
26 ~AudioEntry(); 27 ~AudioEntry();
(...skipping 21 matching lines...) Expand all
48 : stream_id(0), 49 : stream_id(0),
49 shared_memory_segment_count(0), 50 shared_memory_segment_count(0),
50 pending_close(false) { 51 pending_close(false) {
51 } 52 }
52 53
53 AudioInputRendererHost::AudioEntry::~AudioEntry() {} 54 AudioInputRendererHost::AudioEntry::~AudioEntry() {}
54 55
55 AudioInputRendererHost::AudioInputRendererHost( 56 AudioInputRendererHost::AudioInputRendererHost(
56 media::AudioManager* audio_manager, 57 media::AudioManager* audio_manager,
57 MediaStreamManager* media_stream_manager, 58 MediaStreamManager* media_stream_manager,
58 AudioMirroringManager* audio_mirroring_manager) 59 AudioMirroringManager* audio_mirroring_manager,
60 media::KeyPressMonitor* key_press_monitor)
59 : audio_manager_(audio_manager), 61 : audio_manager_(audio_manager),
60 media_stream_manager_(media_stream_manager), 62 media_stream_manager_(media_stream_manager),
61 audio_mirroring_manager_(audio_mirroring_manager) { 63 audio_mirroring_manager_(audio_mirroring_manager),
62 } 64 key_press_monitor_(key_press_monitor) {}
Sergey Ulanov 2013/08/08 01:25:48 move } to the next line.
63 65
64 AudioInputRendererHost::~AudioInputRendererHost() { 66 AudioInputRendererHost::~AudioInputRendererHost() {
65 DCHECK(audio_entries_.empty()); 67 DCHECK(audio_entries_.empty());
66 } 68 }
67 69
68 void AudioInputRendererHost::OnChannelClosing() { 70 void AudioInputRendererHost::OnChannelClosing() {
69 BrowserMessageFilter::OnChannelClosing(); 71 BrowserMessageFilter::OnChannelClosing();
70 72
71 // Since the IPC channel is gone, close all requested audio streams. 73 // Since the IPC channel is gone, close all requested audio streams.
72 DeleteEntries(); 74 DeleteEntries();
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 return; 282 return;
281 } 283 }
282 284
283 // If we have successfully created the SyncWriter then assign it to the 285 // If we have successfully created the SyncWriter then assign it to the
284 // entry and construct an AudioInputController. 286 // entry and construct an AudioInputController.
285 entry->writer.reset(writer.release()); 287 entry->writer.reset(writer.release());
286 if (WebContentsCaptureUtil::IsWebContentsDeviceId(device_id)) { 288 if (WebContentsCaptureUtil::IsWebContentsDeviceId(device_id)) {
287 entry->controller = media::AudioInputController::CreateForStream( 289 entry->controller = media::AudioInputController::CreateForStream(
288 audio_manager_->GetMessageLoop(), 290 audio_manager_->GetMessageLoop(),
289 this, 291 this,
290 WebContentsAudioInputStream::Create( 292 WebContentsAudioInputStream::Create(device_id,
291 device_id, audio_params, audio_manager_->GetWorkerLoop(), 293 audio_params,
292 audio_mirroring_manager_), 294 audio_manager_->GetWorkerLoop(),
293 entry->writer.get()); 295 audio_mirroring_manager_),
296 entry->writer.get(),
297 key_press_monitor_);
294 } else { 298 } else {
295 // TODO(henrika): replace CreateLowLatency() with Create() as soon 299 // TODO(henrika): replace CreateLowLatency() with Create() as soon
296 // as satish has ensured that Speech Input also uses the default low- 300 // as satish has ensured that Speech Input also uses the default low-
297 // latency path. See crbug.com/112472 for details. 301 // latency path. See crbug.com/112472 for details.
298 entry->controller = media::AudioInputController::CreateLowLatency( 302 entry->controller =
299 audio_manager_, 303 media::AudioInputController::CreateLowLatency(audio_manager_,
300 this, 304 this,
301 audio_params, 305 audio_params,
302 device_id, 306 device_id,
303 entry->writer.get()); 307 entry->writer.get(),
308 key_press_monitor_);
304 } 309 }
305 310
306 if (!entry->controller.get()) { 311 if (!entry->controller.get()) {
307 SendErrorMessage(stream_id); 312 SendErrorMessage(stream_id);
308 return; 313 return;
309 } 314 }
310 315
311 // Set the initial AGC state for the audio input stream. Note that, the AGC 316 // Set the initial AGC state for the audio input stream. Note that, the AGC
312 // is only supported in AUDIO_PCM_LOW_LATENCY mode. 317 // is only supported in AUDIO_PCM_LOW_LATENCY mode.
313 if (config.params.format() == media::AudioParameters::AUDIO_PCM_LOW_LATENCY) 318 if (config.params.format() == media::AudioParameters::AUDIO_PCM_LOW_LATENCY)
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 // TODO(hclam): Implement a faster look up method. 418 // TODO(hclam): Implement a faster look up method.
414 for (AudioEntryMap::iterator i = audio_entries_.begin(); 419 for (AudioEntryMap::iterator i = audio_entries_.begin();
415 i != audio_entries_.end(); ++i) { 420 i != audio_entries_.end(); ++i) {
416 if (controller == i->second->controller.get()) 421 if (controller == i->second->controller.get())
417 return i->second; 422 return i->second;
418 } 423 }
419 return NULL; 424 return NULL;
420 } 425 }
421 426
422 } // namespace content 427 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698