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

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

Issue 139303016: Feed the render data to MediaStreamAudioProcessor and used AudioBus in render callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Per's comments. Created 6 years, 11 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 (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_audio_capturer.h" 5 #include "content/renderer/media/webrtc_audio_capturer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 // Dispatch the new parameters both to the sink(s) and to the new source, 290 // Dispatch the new parameters both to the sink(s) and to the new source,
291 // also apply the new |constraints|. 291 // also apply the new |constraints|.
292 // The idea is to get rid of any dependency of the microphone parameters 292 // The idea is to get rid of any dependency of the microphone parameters
293 // which would normally be used by default. 293 // which would normally be used by default.
294 // bits_per_sample is always 16 for now. 294 // bits_per_sample is always 16 for now.
295 int buffer_size = GetBufferSize(sample_rate); 295 int buffer_size = GetBufferSize(sample_rate);
296 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 296 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
297 channel_layout, 0, sample_rate, 297 channel_layout, 0, sample_rate,
298 16, buffer_size, effects); 298 16, buffer_size, effects);
299 scoped_refptr<MediaStreamAudioProcessor> new_audio_processor( 299 scoped_refptr<MediaStreamAudioProcessor> new_audio_processor(
300 new MediaStreamAudioProcessor(params, constraints, effects)); 300 new MediaStreamAudioProcessor(params, constraints, effects,
301 audio_device_));
301 { 302 {
302 base::AutoLock auto_lock(lock_); 303 base::AutoLock auto_lock(lock_);
303 audio_processor_ = new_audio_processor; 304 audio_processor_ = new_audio_processor;
304 need_audio_processing_ = NeedsAudioProcessing(constraints, effects); 305 need_audio_processing_ = NeedsAudioProcessing(constraints, effects);
305 306
306 // Notify all tracks about the new format. 307 // Notify all tracks about the new format.
307 tracks_.TagAll(); 308 tracks_.TagAll();
308 } 309 }
309 310
310 if (source.get()) 311 if (source.get())
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 } 544 }
544 545
545 void WebRtcAudioCapturer::GetAudioProcessingParams( 546 void WebRtcAudioCapturer::GetAudioProcessingParams(
546 base::TimeDelta* delay, int* volume, bool* key_pressed) { 547 base::TimeDelta* delay, int* volume, bool* key_pressed) {
547 base::AutoLock auto_lock(lock_); 548 base::AutoLock auto_lock(lock_);
548 *delay = audio_delay_; 549 *delay = audio_delay_;
549 *volume = volume_; 550 *volume = volume_;
550 *key_pressed = key_pressed_; 551 *key_pressed = key_pressed_;
551 } 552 }
552 553
553 void WebRtcAudioCapturer::FeedRenderDataToAudioProcessor(
554 const int16* render_audio,
555 int sample_rate,
556 int number_of_channels,
557 int number_of_frames,
558 base::TimeDelta render_delay) {
559 scoped_refptr<MediaStreamAudioProcessor> audio_processor;
560 {
561 base::AutoLock auto_lock(lock_);
562 if (!running_)
563 return;
564
565 audio_processor = audio_processor_;
566 }
567
568 audio_processor->PushRenderData(render_audio, sample_rate,
569 number_of_channels,
570 number_of_frames,
571 render_delay);
572 }
573
574 void WebRtcAudioCapturer::SetCapturerSourceForTesting( 554 void WebRtcAudioCapturer::SetCapturerSourceForTesting(
575 const scoped_refptr<media::AudioCapturerSource>& source, 555 const scoped_refptr<media::AudioCapturerSource>& source,
576 media::AudioParameters params) { 556 media::AudioParameters params) {
577 // Create a new audio stream as source which uses the new source. 557 // Create a new audio stream as source which uses the new source.
578 SetCapturerSource(source, params.channel_layout(), 558 SetCapturerSource(source, params.channel_layout(),
579 static_cast<float>(params.sample_rate()), 559 static_cast<float>(params.sample_rate()),
580 params.effects(), 560 params.effects(),
581 constraints_); 561 constraints_);
582 } 562 }
583 563
584 } // namespace content 564 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698