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 "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 DCHECK(source_params.IsValid()); | 369 DCHECK(source_params.IsValid()); |
370 | 370 |
371 // Create and initialize audio converter for the source data. | 371 // Create and initialize audio converter for the source data. |
372 // When the webrtc AudioProcessing is enabled, the sink format of the | 372 // When the webrtc AudioProcessing is enabled, the sink format of the |
373 // converter will be the same as the post-processed data format, which is | 373 // converter will be the same as the post-processed data format, which is |
374 // 32k mono for desktops and 16k mono for Android. When the AudioProcessing | 374 // 32k mono for desktops and 16k mono for Android. When the AudioProcessing |
375 // is disabled, the sink format will be the same as the source format. | 375 // is disabled, the sink format will be the same as the source format. |
376 const int sink_sample_rate = audio_processing_ ? | 376 const int sink_sample_rate = audio_processing_ ? |
377 kAudioProcessingSampleRate : source_params.sample_rate(); | 377 kAudioProcessingSampleRate : source_params.sample_rate(); |
378 const media::ChannelLayout sink_channel_layout = audio_processing_ ? | 378 const media::ChannelLayout sink_channel_layout = audio_processing_ ? |
379 media::CHANNEL_LAYOUT_MONO : source_params.channel_layout(); | 379 media::GuessChannelLayout(kAudioProcessingNumberOfChannel) : |
| 380 source_params.channel_layout(); |
380 | 381 |
381 // WebRtc AudioProcessing requires 10ms as its packet size. We use this | 382 // WebRtc AudioProcessing requires 10ms as its packet size. We use this |
382 // native size when processing is enabled. While processing is disabled, and | 383 // native size when processing is enabled. While processing is disabled, and |
383 // the source is running with a buffer size smaller than 10ms buffer, we use | 384 // the source is running with a buffer size smaller than 10ms buffer, we use |
384 // same buffer size as the incoming format to avoid extra FIFO for WebAudio. | 385 // same buffer size as the incoming format to avoid extra FIFO for WebAudio. |
385 int sink_buffer_size = sink_sample_rate / 100; | 386 int sink_buffer_size = sink_sample_rate / 100; |
386 if (!audio_processing_ && | 387 if (!audio_processing_ && |
387 source_params.frames_per_buffer() < sink_buffer_size) { | 388 source_params.frames_per_buffer() < sink_buffer_size) { |
388 sink_buffer_size = source_params.frames_per_buffer(); | 389 sink_buffer_size = source_params.frames_per_buffer(); |
389 } | 390 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 } | 489 } |
489 | 490 |
490 bool MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled() const { | 491 bool MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled() const { |
491 const std::string group_name = | 492 const std::string group_name = |
492 base::FieldTrialList::FindFullName("MediaStreamAudioTrackProcessing"); | 493 base::FieldTrialList::FindFullName("MediaStreamAudioTrackProcessing"); |
493 return group_name == "Enabled" || CommandLine::ForCurrentProcess()->HasSwitch( | 494 return group_name == "Enabled" || CommandLine::ForCurrentProcess()->HasSwitch( |
494 switches::kEnableAudioTrackProcessing); | 495 switches::kEnableAudioTrackProcessing); |
495 } | 496 } |
496 | 497 |
497 } // namespace content | 498 } // namespace content |
OLD | NEW |