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

Side by Side Diff: content/renderer/media/webrtc_local_audio_track.cc

Issue 24742007: When an audio track is disabled, still pass the data to webrtc for audio processing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 7 years, 2 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
« no previous file with comments | « no previous file | no next file » | 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/renderer/media/webrtc_local_audio_track.h" 5 #include "content/renderer/media/webrtc_local_audio_track.h"
6 6
7 #include "content/renderer/media/webaudio_capturer_source.h" 7 #include "content/renderer/media/webaudio_capturer_source.h"
8 #include "content/renderer/media/webrtc_audio_capturer.h" 8 #include "content/renderer/media/webrtc_audio_capturer.h"
9 #include "content/renderer/media/webrtc_audio_capturer_sink_owner.h" 9 #include "content/renderer/media/webrtc_audio_capturer_sink_owner.h"
10 #include "content/renderer/media/webrtc_local_audio_source_provider.h" 10 #include "content/renderer/media/webrtc_local_audio_source_provider.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 bool key_pressed) { 149 bool key_pressed) {
150 scoped_refptr<WebRtcAudioCapturer> capturer; 150 scoped_refptr<WebRtcAudioCapturer> capturer;
151 std::vector<int> voe_channels; 151 std::vector<int> voe_channels;
152 int sample_rate = 0; 152 int sample_rate = 0;
153 int number_of_channels = 0; 153 int number_of_channels = 0;
154 int number_of_frames = 0; 154 int number_of_frames = 0;
155 SinkList sinks; 155 SinkList sinks;
156 scoped_refptr<ConfiguredBuffer> current_buffer; 156 scoped_refptr<ConfiguredBuffer> current_buffer;
157 { 157 {
158 base::AutoLock auto_lock(lock_); 158 base::AutoLock auto_lock(lock_);
159 // When the track is disabled, we simply return here.
160 // TODO(xians): Figure out if we should feed zero to sinks instead, in
161 // order to inject VAD data in such case.
162 if (!enabled())
163 return;
164
165 capturer = capturer_; 159 capturer = capturer_;
166 voe_channels = voe_channels_; 160 voe_channels = voe_channels_;
167 current_buffer = buffer_; 161 current_buffer = buffer_;
168 sample_rate = current_buffer->params().sample_rate(); 162 sample_rate = current_buffer->params().sample_rate();
169 number_of_channels = current_buffer->params().channels(); 163 number_of_channels = current_buffer->params().channels();
170 number_of_frames = current_buffer->sink_buffer_size(); 164 number_of_frames = current_buffer->sink_buffer_size();
171 sinks = sinks_; 165 sinks = sinks_;
172 } 166 }
173 167
174 // Push the data to the fifo. 168 // Push the data to the fifo.
175 current_buffer->Push(audio_source); 169 current_buffer->Push(audio_source);
176 // Only turn off the audio processing when the constrain is set to false as 170 // Only turn off the audio processing when the constraint is set to false as
177 // well as there is no correct delay value. 171 // well as there is no correct delay value.
178 bool need_audio_processing = need_audio_processing_ ? 172 bool need_audio_processing = need_audio_processing_ ?
179 need_audio_processing_ : (audio_delay_milliseconds != 0); 173 need_audio_processing_ : (audio_delay_milliseconds != 0);
180 int current_volume = volume; 174 int current_volume = volume;
181 while (current_buffer->Consume()) { 175 while (current_buffer->Consume()) {
182 // Feed the data to the sinks. 176 // Feed the data to the sinks.
177 // TODO (jiayl): we should not pass the real audio data down if the track is
178 // disabled. This is currently done so to feed input to WebRTC typing
179 // detection and should be changed when audio processing is moved from
180 // WebRTC to the track.
183 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it) { 181 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it) {
184 int new_volume = (*it)->CaptureData(voe_channels, 182 int new_volume = (*it)->CaptureData(voe_channels,
185 current_buffer->buffer(), 183 current_buffer->buffer(),
186 sample_rate, 184 sample_rate,
187 number_of_channels, 185 number_of_channels,
188 number_of_frames, 186 number_of_frames,
189 audio_delay_milliseconds, 187 audio_delay_milliseconds,
190 current_volume, 188 current_volume,
191 need_audio_processing, 189 need_audio_processing,
192 key_pressed); 190 key_pressed);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 sinks = sinks_; 338 sinks = sinks_;
341 webaudio_source_ = NULL; 339 webaudio_source_ = NULL;
342 capturer_ = NULL; 340 capturer_ = NULL;
343 } 341 }
344 342
345 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it) 343 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it)
346 (*it)->Reset(); 344 (*it)->Reset();
347 } 345 }
348 346
349 } // namespace content 347 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698