OLD | NEW |
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 "media/audio/audio_parameters.h" | 5 #include "media/audio/audio_parameters.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/base/limits.h" | 8 #include "media/base/limits.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
11 | 11 |
12 AudioParameters::AudioParameters() | 12 AudioParameters::AudioParameters() |
13 : format_(AUDIO_PCM_LINEAR), | 13 : format_(AUDIO_PCM_LINEAR), |
14 channel_layout_(CHANNEL_LAYOUT_NONE), | 14 channel_layout_(CHANNEL_LAYOUT_NONE), |
15 sample_rate_(0), | 15 sample_rate_(0), |
16 bits_per_sample_(0), | 16 bits_per_sample_(0), |
17 frames_per_buffer_(0), | 17 frames_per_buffer_(0), |
18 channels_(0), | 18 channels_(0), |
19 input_channels_(0) { | 19 input_channels_(0), |
| 20 use_platform_aec_(false) { |
20 } | 21 } |
21 | 22 |
22 AudioParameters::AudioParameters(Format format, ChannelLayout channel_layout, | 23 AudioParameters::AudioParameters(Format format, ChannelLayout channel_layout, |
23 int sample_rate, int bits_per_sample, | 24 int sample_rate, int bits_per_sample, |
24 int frames_per_buffer) | 25 int frames_per_buffer) |
25 : format_(format), | 26 : format_(format), |
26 channel_layout_(channel_layout), | 27 channel_layout_(channel_layout), |
27 sample_rate_(sample_rate), | 28 sample_rate_(sample_rate), |
28 bits_per_sample_(bits_per_sample), | 29 bits_per_sample_(bits_per_sample), |
29 frames_per_buffer_(frames_per_buffer), | 30 frames_per_buffer_(frames_per_buffer), |
30 channels_(ChannelLayoutToChannelCount(channel_layout)), | 31 channels_(ChannelLayoutToChannelCount(channel_layout)), |
31 input_channels_(0) { | 32 input_channels_(0), |
| 33 use_platform_aec_(false) { |
32 } | 34 } |
33 | 35 |
34 AudioParameters::AudioParameters(Format format, ChannelLayout channel_layout, | 36 AudioParameters::AudioParameters(Format format, ChannelLayout channel_layout, |
35 int input_channels, | 37 int input_channels, |
36 int sample_rate, int bits_per_sample, | 38 int sample_rate, int bits_per_sample, |
37 int frames_per_buffer) | 39 int frames_per_buffer) |
38 : format_(format), | 40 : format_(format), |
39 channel_layout_(channel_layout), | 41 channel_layout_(channel_layout), |
40 sample_rate_(sample_rate), | 42 sample_rate_(sample_rate), |
41 bits_per_sample_(bits_per_sample), | 43 bits_per_sample_(bits_per_sample), |
42 frames_per_buffer_(frames_per_buffer), | 44 frames_per_buffer_(frames_per_buffer), |
43 channels_(ChannelLayoutToChannelCount(channel_layout)), | 45 channels_(ChannelLayoutToChannelCount(channel_layout)), |
44 input_channels_(input_channels) { | 46 input_channels_(input_channels), |
| 47 use_platform_aec_(false) { |
45 } | 48 } |
46 | 49 |
47 void AudioParameters::Reset(Format format, ChannelLayout channel_layout, | 50 void AudioParameters::Reset(Format format, ChannelLayout channel_layout, |
48 int channels, int input_channels, | 51 int channels, int input_channels, |
49 int sample_rate, int bits_per_sample, | 52 int sample_rate, int bits_per_sample, |
50 int frames_per_buffer) { | 53 int frames_per_buffer) { |
51 if (channel_layout != CHANNEL_LAYOUT_DISCRETE) | 54 if (channel_layout != CHANNEL_LAYOUT_DISCRETE) |
52 DCHECK_EQ(channels, ChannelLayoutToChannelCount(channel_layout)); | 55 DCHECK_EQ(channels, ChannelLayoutToChannelCount(channel_layout)); |
53 | 56 |
54 format_ = format; | 57 format_ = format; |
55 channel_layout_ = channel_layout; | 58 channel_layout_ = channel_layout; |
56 channels_ = channels; | 59 channels_ = channels; |
57 input_channels_ = input_channels; | 60 input_channels_ = input_channels; |
58 sample_rate_ = sample_rate; | 61 sample_rate_ = sample_rate; |
59 bits_per_sample_ = bits_per_sample; | 62 bits_per_sample_ = bits_per_sample; |
60 frames_per_buffer_ = frames_per_buffer; | 63 frames_per_buffer_ = frames_per_buffer; |
61 } | 64 } |
62 | 65 |
| 66 void AudioParameters::Reset(Format format, ChannelLayout channel_layout, |
| 67 int channels, int input_channels, |
| 68 int sample_rate, int bits_per_sample, |
| 69 int frames_per_buffer, bool use_platform_aec) { |
| 70 use_platform_aec_ = use_platform_aec; |
| 71 Reset(format, channel_layout, channels, input_channels, sample_rate, |
| 72 bits_per_sample, frames_per_buffer); |
| 73 } |
| 74 |
63 bool AudioParameters::IsValid() const { | 75 bool AudioParameters::IsValid() const { |
64 return (format_ >= AUDIO_PCM_LINEAR) && | 76 return (format_ >= AUDIO_PCM_LINEAR) && |
65 (format_ < AUDIO_LAST_FORMAT) && | 77 (format_ < AUDIO_LAST_FORMAT) && |
66 (channels_ > 0) && | 78 (channels_ > 0) && |
67 (channels_ <= media::limits::kMaxChannels) && | 79 (channels_ <= media::limits::kMaxChannels) && |
68 (channel_layout_ > CHANNEL_LAYOUT_UNSUPPORTED) && | 80 (channel_layout_ > CHANNEL_LAYOUT_UNSUPPORTED) && |
69 (channel_layout_ < CHANNEL_LAYOUT_MAX) && | 81 (channel_layout_ < CHANNEL_LAYOUT_MAX) && |
70 (input_channels_ >= 0) && | 82 (input_channels_ >= 0) && |
71 (input_channels_ <= media::limits::kMaxChannels) && | 83 (input_channels_ <= media::limits::kMaxChannels) && |
72 (sample_rate_ >= media::limits::kMinSampleRate) && | 84 (sample_rate_ >= media::limits::kMinSampleRate) && |
(...skipping 21 matching lines...) Expand all Loading... |
94 frames_per_buffer_ * base::Time::kMicrosecondsPerSecond / | 106 frames_per_buffer_ * base::Time::kMicrosecondsPerSecond / |
95 static_cast<float>(sample_rate_)); | 107 static_cast<float>(sample_rate_)); |
96 } | 108 } |
97 | 109 |
98 void AudioParameters::SetDiscreteChannels(int channels) { | 110 void AudioParameters::SetDiscreteChannels(int channels) { |
99 channel_layout_ = CHANNEL_LAYOUT_DISCRETE; | 111 channel_layout_ = CHANNEL_LAYOUT_DISCRETE; |
100 channels_ = channels; | 112 channels_ = channels; |
101 } | 113 } |
102 | 114 |
103 } // namespace media | 115 } // namespace media |
OLD | NEW |