OLD | NEW |
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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
12 #include "content/renderer/media/media_stream_audio_processor_options.h" | 12 #include "content/renderer/media/media_stream_audio_processor_options.h" |
13 #include "content/renderer/media/rtc_media_constraints.h" | 13 #include "content/renderer/media/rtc_media_constraints.h" |
| 14 #include "content/renderer/media/webrtc_audio_device_impl.h" |
14 #include "media/audio/audio_parameters.h" | 15 #include "media/audio/audio_parameters.h" |
15 #include "media/base/audio_converter.h" | 16 #include "media/base/audio_converter.h" |
16 #include "media/base/audio_fifo.h" | 17 #include "media/base/audio_fifo.h" |
17 #include "media/base/channel_layout.h" | 18 #include "media/base/channel_layout.h" |
18 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 19 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
19 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface
.h" | 20 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface
.h" |
20 #include "third_party/webrtc/modules/audio_processing/typing_detection.h" | 21 #include "third_party/webrtc/modules/audio_processing/typing_detection.h" |
21 | 22 |
22 namespace content { | 23 namespace content { |
23 | 24 |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 DCHECK_LT(capture_delay_ms, | 468 DCHECK_LT(capture_delay_ms, |
468 std::numeric_limits<base::subtle::Atomic32>::max()); | 469 std::numeric_limits<base::subtle::Atomic32>::max()); |
469 int total_delay_ms = capture_delay_ms + render_delay_ms; | 470 int total_delay_ms = capture_delay_ms + render_delay_ms; |
470 if (total_delay_ms > 300) { | 471 if (total_delay_ms > 300) { |
471 LOG(WARNING) << "Large audio delay, capture delay: " << capture_delay_ms | 472 LOG(WARNING) << "Large audio delay, capture delay: " << capture_delay_ms |
472 << "ms; render delay: " << render_delay_ms << "ms"; | 473 << "ms; render delay: " << render_delay_ms << "ms"; |
473 } | 474 } |
474 | 475 |
475 audio_processing_->set_stream_delay_ms(total_delay_ms); | 476 audio_processing_->set_stream_delay_ms(total_delay_ms); |
476 | 477 |
| 478 DCHECK_LE(volume, WebRtcAudioDeviceImpl::kMaxVolumeLevel); |
477 webrtc::GainControl* agc = audio_processing_->gain_control(); | 479 webrtc::GainControl* agc = audio_processing_->gain_control(); |
478 int err = agc->set_stream_analog_level(volume); | 480 int err = agc->set_stream_analog_level(volume); |
479 DCHECK_EQ(err, 0) << "set_stream_analog_level() error: " << err; | 481 DCHECK_EQ(err, 0) << "set_stream_analog_level() error: " << err; |
480 | 482 |
481 audio_processing_->set_stream_key_pressed(key_pressed); | 483 audio_processing_->set_stream_key_pressed(key_pressed); |
482 | 484 |
483 err = audio_processing_->ProcessStream(audio_frame); | 485 err = audio_processing_->ProcessStream(audio_frame); |
484 DCHECK_EQ(err, 0) << "ProcessStream() error: " << err; | 486 DCHECK_EQ(err, 0) << "ProcessStream() error: " << err; |
485 | 487 |
486 if (typing_detector_ && | 488 if (typing_detector_ && |
(...skipping 23 matching lines...) Expand all Loading... |
510 } | 512 } |
511 | 513 |
512 bool MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled() const { | 514 bool MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled() const { |
513 const std::string group_name = | 515 const std::string group_name = |
514 base::FieldTrialList::FindFullName("MediaStreamAudioTrackProcessing"); | 516 base::FieldTrialList::FindFullName("MediaStreamAudioTrackProcessing"); |
515 return group_name == "Enabled" || CommandLine::ForCurrentProcess()->HasSwitch( | 517 return group_name == "Enabled" || CommandLine::ForCurrentProcess()->HasSwitch( |
516 switches::kEnableAudioTrackProcessing); | 518 switches::kEnableAudioTrackProcessing); |
517 } | 519 } |
518 | 520 |
519 } // namespace content | 521 } // namespace content |
OLD | NEW |