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

Side by Side Diff: content/renderer/media/webrtc_local_audio_track.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/renderer/media/webrtc_local_audio_track.h" 5 #include "content/renderer/media/webrtc_local_audio_track.h"
6 6
7 #include "content/renderer/media/webrtc_audio_capturer.h" 7 #include "content/renderer/media/webrtc_audio_capturer.h"
8 #include "content/renderer/media/webrtc_audio_capturer_sink_owner.h" 8 #include "content/renderer/media/webrtc_audio_capturer_sink_owner.h"
9 #include "third_party/libjingle/source/talk/media/base/audiorenderer.h" 9 #include "third_party/libjingle/source/talk/media/base/audiorenderer.h"
10 10
(...skipping 30 matching lines...) Expand all
41 // Users might not call Stop() on the track. 41 // Users might not call Stop() on the track.
42 if (capturer_.get()) 42 if (capturer_.get())
43 Stop(); 43 Stop();
44 } 44 }
45 45
46 // Content::WebRtcAudioCapturerSink implementation. 46 // Content::WebRtcAudioCapturerSink implementation.
47 void WebRtcLocalAudioTrack::CaptureData(const int16* audio_data, 47 void WebRtcLocalAudioTrack::CaptureData(const int16* audio_data,
48 int number_of_channels, 48 int number_of_channels,
49 int number_of_frames, 49 int number_of_frames,
50 int audio_delay_milliseconds, 50 int audio_delay_milliseconds,
51 double volume) { 51 double volume,
52 bool key_pressed) {
52 SinkList sinks; 53 SinkList sinks;
53 { 54 {
54 base::AutoLock auto_lock(lock_); 55 base::AutoLock auto_lock(lock_);
55 // When the track is diabled, we simply return here. 56 // When the track is diabled, we simply return here.
56 // TODO(xians): Figure out if we should feed zero to sinks instead, in 57 // TODO(xians): Figure out if we should feed zero to sinks instead, in
57 // order to inject VAD data in such case. 58 // order to inject VAD data in such case.
58 if (!enabled()) 59 if (!enabled())
59 return; 60 return;
60 61
61 sinks = sinks_; 62 sinks = sinks_;
62 } 63 }
63 64
64 // Feed the data to the sinks. 65 // Feed the data to the sinks.
65 for (SinkList::const_iterator it = sinks.begin(); 66 for (SinkList::const_iterator it = sinks.begin();
66 it != sinks.end(); 67 it != sinks.end();
67 ++it) { 68 ++it) {
68 (*it)->CaptureData(audio_data, number_of_channels, number_of_frames, 69 (*it)->CaptureData(audio_data,
69 audio_delay_milliseconds, volume); 70 number_of_channels,
71 number_of_frames,
72 audio_delay_milliseconds,
73 volume,
74 key_pressed);
70 } 75 }
71 } 76 }
72 77
73 void WebRtcLocalAudioTrack::SetCaptureFormat( 78 void WebRtcLocalAudioTrack::SetCaptureFormat(
74 const media::AudioParameters& params) { 79 const media::AudioParameters& params) {
75 base::AutoLock auto_lock(lock_); 80 base::AutoLock auto_lock(lock_);
76 params_ = params; 81 params_ = params;
77 82
78 // Update all the existing sinks with the new format. 83 // Update all the existing sinks with the new format.
79 for (SinkList::const_iterator it = sinks_.begin(); 84 for (SinkList::const_iterator it = sinks_.begin();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void WebRtcLocalAudioTrack::Stop() { 142 void WebRtcLocalAudioTrack::Stop() {
138 DCHECK(thread_checker_.CalledOnValidThread()); 143 DCHECK(thread_checker_.CalledOnValidThread());
139 DVLOG(1) << "WebRtcLocalAudioTrack::Stop()"; 144 DVLOG(1) << "WebRtcLocalAudioTrack::Stop()";
140 if (capturer_.get()) { 145 if (capturer_.get()) {
141 capturer_->RemoveSink(this); 146 capturer_->RemoveSink(this);
142 capturer_ = NULL; 147 capturer_ = NULL;
143 } 148 }
144 } 149 }
145 150
146 } // namespace content 151 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698