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

Side by Side Diff: trunk/src/content/renderer/media/webrtc_audio_device_impl.cc

Issue 22871007: Revert 217768 "Adding key press detection in the browser process." (Closed) Base URL: svn://svn.chromium.org/chrome/
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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/renderer/media/webrtc_audio_device_impl.h" 5 #include "content/renderer/media/webrtc_audio_device_impl.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/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 return ret; 53 return ret;
54 } 54 }
55 int WebRtcAudioDeviceImpl::CaptureData(const std::vector<int>& channels, 55 int WebRtcAudioDeviceImpl::CaptureData(const std::vector<int>& channels,
56 const int16* audio_data, 56 const int16* audio_data,
57 int sample_rate, 57 int sample_rate,
58 int number_of_channels, 58 int number_of_channels,
59 int number_of_frames, 59 int number_of_frames,
60 int audio_delay_milliseconds, 60 int audio_delay_milliseconds,
61 int current_volume, 61 int current_volume,
62 bool need_audio_processing, 62 bool need_audio_processing) {
63 bool key_pressed) {
64 int total_delay_ms = 0; 63 int total_delay_ms = 0;
65 { 64 {
66 base::AutoLock auto_lock(lock_); 65 base::AutoLock auto_lock(lock_);
67 if (!recording_) 66 if (!recording_)
68 return 0; 67 return 0;
69 68
70 // Store the reported audio delay locally. 69 // Store the reported audio delay locally.
71 input_delay_ms_ = audio_delay_milliseconds; 70 input_delay_ms_ = audio_delay_milliseconds;
72 total_delay_ms = input_delay_ms_ + output_delay_ms_; 71 total_delay_ms = input_delay_ms_ + output_delay_ms_;
73 DVLOG(2) << "total delay: " << input_delay_ms_ + output_delay_ms_; 72 DVLOG(2) << "total delay: " << input_delay_ms_ + output_delay_ms_;
74 } 73 }
75 74
76 // Write audio samples in blocks of 10 milliseconds to the registered 75 // Write audio samples in blocks of 10 milliseconds to the registered
77 // webrtc::AudioTransport sink. Keep writing until our internal byte 76 // webrtc::AudioTransport sink. Keep writing until our internal byte
78 // buffer is empty. 77 // buffer is empty.
78 // TODO(niklase): Wire up the key press detection.
79 const int16* audio_buffer = audio_data; 79 const int16* audio_buffer = audio_data;
80 const int samples_per_10_msec = (sample_rate / 100); 80 const int samples_per_10_msec = (sample_rate / 100);
81 int accumulated_audio_samples = 0; 81 int accumulated_audio_samples = 0;
82 bool key_pressed = false;
82 uint32_t new_volume = 0; 83 uint32_t new_volume = 0;
83 while (accumulated_audio_samples < number_of_frames) { 84 while (accumulated_audio_samples < number_of_frames) {
84 // Deliver 10ms of recorded 16-bit linear PCM audio. 85 // Deliver 10ms of recorded 16-bit linear PCM audio.
85 int new_mic_level = audio_transport_callback_->OnDataAvailable( 86 int new_mic_level = audio_transport_callback_->OnDataAvailable(
86 &channels[0], 87 &channels[0],
87 channels.size(), 88 channels.size(),
88 audio_buffer, 89 audio_buffer,
89 sample_rate, 90 sample_rate,
90 number_of_channels, 91 number_of_channels,
91 samples_per_10_msec, 92 samples_per_10_msec,
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 for (CapturerList::const_iterator iter = capturers_.begin(); 480 for (CapturerList::const_iterator iter = capturers_.begin();
480 iter != capturers_.end(); ++iter) { 481 iter != capturers_.end(); ++iter) {
481 if (!(*iter)->device_id().empty()) 482 if (!(*iter)->device_id().empty())
482 return *iter; 483 return *iter;
483 } 484 }
484 485
485 return NULL; 486 return NULL;
486 } 487 }
487 488
488 } // namespace content 489 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698