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

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

Issue 2219933003: Use LocalMediaStreamAudioSource for screen-casting use cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 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/media_stream_audio_processor.h" 5 #include "content/renderer/media/media_stream_audio_processor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 DCHECK(main_thread_checker_.CalledOnValidThread()); 442 DCHECK(main_thread_checker_.CalledOnValidThread());
443 if (audio_processing_) 443 if (audio_processing_)
444 StopEchoCancellationDump(audio_processing_.get()); 444 StopEchoCancellationDump(audio_processing_.get());
445 } 445 }
446 446
447 void MediaStreamAudioProcessor::OnIpcClosing() { 447 void MediaStreamAudioProcessor::OnIpcClosing() {
448 DCHECK(main_thread_checker_.CalledOnValidThread()); 448 DCHECK(main_thread_checker_.CalledOnValidThread());
449 aec_dump_message_filter_ = NULL; 449 aec_dump_message_filter_ = NULL;
450 } 450 }
451 451
452 // static
453 bool MediaStreamAudioProcessor::ShouldRouteAudioThroughProcessor(
454 const blink::WebMediaConstraints& constraints,
455 int effects_flags) {
456 // Note: This method should by kept in-sync with any changes to the logic in
457 // MediaStreamAudioProcessor::InitializeAudioProcessingModule().
xjz 2016/08/13 00:43:56 nit: The logic here is in sync with that in MediaS
miu 2016/08/16 04:30:02 Actually, it's perfectly in-sync. If GetGoogAudioM
458
459 const MediaAudioConstraints audio_constraints(constraints, effects_flags);
460
461 if (audio_constraints.GetGoogAudioMirroring())
462 return true;
463
464 #if !defined(OS_IOS)
465 if (audio_constraints.GetEchoCancellationProperty() ||
466 audio_constraints.GetGoogAutoGainControl()) {
467 return true;
468 }
469 #endif
470
471 #if !defined(OS_IOS) && !defined(OS_ANDROID)
472 if (audio_constraints.GetGoogExperimentalEchoCancellation() ||
473 audio_constraints.GetGoogTypingNoiseDetection()) {
474 return true;
475 }
476 #endif
477
478 if (audio_constraints.GetGoogNoiseSuppression() ||
479 audio_constraints.GetGoogExperimentalNoiseSuppression() ||
480 audio_constraints.GetGoogBeamforming() ||
481 audio_constraints.GetGoogHighpassFilter()) {
482 return true;
483 }
484
485 return false;
486 }
487
452 void MediaStreamAudioProcessor::OnPlayoutData(media::AudioBus* audio_bus, 488 void MediaStreamAudioProcessor::OnPlayoutData(media::AudioBus* audio_bus,
453 int sample_rate, 489 int sample_rate,
454 int audio_delay_milliseconds) { 490 int audio_delay_milliseconds) {
455 DCHECK(render_thread_checker_.CalledOnValidThread()); 491 DCHECK(render_thread_checker_.CalledOnValidThread());
456 #if defined(OS_ANDROID) 492 #if defined(OS_ANDROID)
457 DCHECK(audio_processing_->echo_control_mobile()->is_enabled()); 493 DCHECK(audio_processing_->echo_control_mobile()->is_enabled());
458 DCHECK(!audio_processing_->echo_cancellation()->is_enabled()); 494 DCHECK(!audio_processing_->echo_cancellation()->is_enabled());
459 #else 495 #else
460 DCHECK(!audio_processing_->echo_control_mobile()->is_enabled()); 496 DCHECK(!audio_processing_->echo_control_mobile()->is_enabled());
461 DCHECK(audio_processing_->echo_cancellation()->is_enabled()); 497 DCHECK(audio_processing_->echo_cancellation()->is_enabled());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 } 540 }
505 541
506 void MediaStreamAudioProcessor::InitializeAudioProcessingModule( 542 void MediaStreamAudioProcessor::InitializeAudioProcessingModule(
507 const blink::WebMediaConstraints& constraints, 543 const blink::WebMediaConstraints& constraints,
508 const MediaStreamDevice::AudioDeviceParameters& input_params) { 544 const MediaStreamDevice::AudioDeviceParameters& input_params) {
509 DCHECK(main_thread_checker_.CalledOnValidThread()); 545 DCHECK(main_thread_checker_.CalledOnValidThread());
510 DCHECK(!audio_processing_); 546 DCHECK(!audio_processing_);
511 547
512 MediaAudioConstraints audio_constraints(constraints, input_params.effects); 548 MediaAudioConstraints audio_constraints(constraints, input_params.effects);
513 549
514 // Audio mirroring can be enabled even though audio processing is otherwise 550 // Audio mirroring can be enabled even though audio processing is otherwise
o1ka 2016/08/15 15:15:00 ShouldRouteAudioThroughProcessor() always returns
miu 2016/08/16 04:30:02 This comment was confusing; and I've fixed it to c
515 // disabled. 551 // disabled.
516 audio_mirroring_ = audio_constraints.GetGoogAudioMirroring(); 552 audio_mirroring_ = audio_constraints.GetGoogAudioMirroring();
517 553
518 const bool echo_cancellation = 554 const bool echo_cancellation =
519 audio_constraints.GetEchoCancellationProperty(); 555 audio_constraints.GetEchoCancellationProperty();
520 const bool goog_agc = audio_constraints.GetGoogAutoGainControl(); 556 const bool goog_agc = audio_constraints.GetGoogAutoGainControl();
521 557
522 #if defined(OS_ANDROID) 558 #if defined(OS_ANDROID)
523 const bool goog_experimental_aec = false; 559 const bool goog_experimental_aec = false;
524 const bool goog_typing_detection = false; 560 const bool goog_typing_detection = false;
525 #else 561 #else
526 const bool goog_experimental_aec = 562 const bool goog_experimental_aec =
527 audio_constraints.GetGoogExperimentalEchoCancellation(); 563 audio_constraints.GetGoogExperimentalEchoCancellation();
528 const bool goog_typing_detection = 564 const bool goog_typing_detection =
529 audio_constraints.GetGoogTypingNoiseDetection(); 565 audio_constraints.GetGoogTypingNoiseDetection();
530 #endif 566 #endif
531 567
532 const bool goog_ns = audio_constraints.GetGoogNoiseSuppression(); 568 const bool goog_ns = audio_constraints.GetGoogNoiseSuppression();
533 const bool goog_experimental_ns = 569 const bool goog_experimental_ns =
534 audio_constraints.GetGoogExperimentalNoiseSuppression(); 570 audio_constraints.GetGoogExperimentalNoiseSuppression();
535 const bool goog_beamforming = audio_constraints.GetGoogBeamforming(); 571 const bool goog_beamforming = audio_constraints.GetGoogBeamforming();
536 const bool goog_high_pass_filter = audio_constraints.GetGoogHighpassFilter(); 572 const bool goog_high_pass_filter = audio_constraints.GetGoogHighpassFilter();
537 // Return immediately if no goog constraint is enabled. 573 // Return immediately if no goog constraint is enabled.
538 if (!echo_cancellation && !goog_experimental_aec && !goog_ns && 574 if (!echo_cancellation && !goog_experimental_aec && !goog_ns &&
539 !goog_high_pass_filter && !goog_typing_detection && 575 !goog_high_pass_filter && !goog_typing_detection &&
540 !goog_agc && !goog_experimental_ns && !goog_beamforming) { 576 !goog_agc && !goog_experimental_ns && !goog_beamforming) {
577 // Ensure ShouldRouteAudioThroughProcessor() is kept in-sync with all of the
578 // above logic.
579 DCHECK_EQ(audio_mirroring_, ShouldRouteAudioThroughProcessor(
o1ka 2016/08/15 15:15:00 See the comment above: it's confusing when ShouldR
miu 2016/08/16 04:30:02 I made some clarifications on these comments too.
580 constraints, input_params.effects));
541 RecordProcessingState(AUDIO_PROCESSING_DISABLED); 581 RecordProcessingState(AUDIO_PROCESSING_DISABLED);
542 return; 582 return;
583 } else {
584 // Ensure ShouldRouteAudioThroughProcessor() is kept in-sync with all of the
585 // above logic.
586 DCHECK(ShouldRouteAudioThroughProcessor(constraints, input_params.effects));
543 } 587 }
544 588
545 // Experimental options provided at creation. 589 // Experimental options provided at creation.
546 webrtc::Config config; 590 webrtc::Config config;
547 config.Set<webrtc::ExtendedFilter>( 591 config.Set<webrtc::ExtendedFilter>(
548 new webrtc::ExtendedFilter(goog_experimental_aec)); 592 new webrtc::ExtendedFilter(goog_experimental_aec));
549 config.Set<webrtc::ExperimentalNs>( 593 config.Set<webrtc::ExperimentalNs>(
550 new webrtc::ExperimentalNs(goog_experimental_ns)); 594 new webrtc::ExperimentalNs(goog_experimental_ns));
551 config.Set<webrtc::DelayAgnostic>(new webrtc::DelayAgnostic(true)); 595 config.Set<webrtc::DelayAgnostic>(new webrtc::DelayAgnostic(true));
552 if (UseAecRefinedAdaptiveFilter()) { 596 if (UseAecRefinedAdaptiveFilter()) {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 0 : agc->stream_analog_level(); 814 0 : agc->stream_analog_level();
771 } 815 }
772 816
773 void MediaStreamAudioProcessor::UpdateAecStats() { 817 void MediaStreamAudioProcessor::UpdateAecStats() {
774 DCHECK(main_thread_checker_.CalledOnValidThread()); 818 DCHECK(main_thread_checker_.CalledOnValidThread());
775 if (echo_information_) 819 if (echo_information_)
776 echo_information_->UpdateAecStats(audio_processing_->echo_cancellation()); 820 echo_information_->UpdateAecStats(audio_processing_->echo_cancellation());
777 } 821 }
778 822
779 } // namespace content 823 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698