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

Side by Side Diff: media/audio/audio_parameters.h

Issue 99033003: Enable platform echo cancellation through the AudioRecord path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 7 years 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 (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 #ifndef MEDIA_AUDIO_AUDIO_PARAMETERS_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_PARAMETERS_H_
6 #define MEDIA_AUDIO_AUDIO_PARAMETERS_H_ 6 #define MEDIA_AUDIO_AUDIO_PARAMETERS_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "media/base/channel_layout.h" 10 #include "media/base/channel_layout.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 int sample_rate, int bits_per_sample, 49 int sample_rate, int bits_per_sample,
50 int frames_per_buffer); 50 int frames_per_buffer);
51 AudioParameters(Format format, ChannelLayout channel_layout, 51 AudioParameters(Format format, ChannelLayout channel_layout,
52 int input_channels, 52 int input_channels,
53 int sample_rate, int bits_per_sample, 53 int sample_rate, int bits_per_sample,
54 int frames_per_buffer); 54 int frames_per_buffer);
55 void Reset(Format format, ChannelLayout channel_layout, 55 void Reset(Format format, ChannelLayout channel_layout,
56 int channels, int input_channels, 56 int channels, int input_channels,
57 int sample_rate, int bits_per_sample, 57 int sample_rate, int bits_per_sample,
58 int frames_per_buffer); 58 int frames_per_buffer);
59 void Reset(Format format, ChannelLayout channel_layout,
tommi (sloooow) - chröme 2013/12/06 12:11:34 Can you add a TODO here to remove the other Reset(
Ami GONE FROM CHROMIUM 2013/12/06 19:22:53 Better yet, can you delete the old form?
ajm 2013/12/10 06:37:16 I don't actually need to use Reset(), as all of th
Ami GONE FROM CHROMIUM 2013/12/10 19:31:43 I think it would be better to make use_platform_ae
ajm 2013/12/10 20:13:05 Sorry, missed that comment. I like your suggestio
ajm 2013/12/11 02:48:04 Moved to setting through constructors in patch set
Ami GONE FROM CHROMIUM 2013/12/11 05:25:08 What prevents you from reading into a temporary in
ajm 2013/12/11 17:46:49 I assume you mean "explicit constructor for AudioP
Ami GONE FROM CHROMIUM 2013/12/11 22:11:38 Perhaps that something is a copy ctor for Platform
ajm 2013/12/12 01:51:27 This would require an assignment operator, right?
Ami GONE FROM CHROMIUM 2013/12/12 02:01:20 You're misinterpreting. "Copy constructor" is a te
Ami GONE FROM CHROMIUM 2013/12/12 02:29:33 I was failing to process that default-assignment-o
ajm 2013/12/12 03:36:03 Done.
60 int channels, int input_channels,
61 int sample_rate, int bits_per_sample,
62 int frames_per_buffer, bool use_platform_aec);
59 63
60 // Checks that all values are in the expected range. All limits are specified 64 // Checks that all values are in the expected range. All limits are specified
61 // in media::Limits. 65 // in media::Limits.
62 bool IsValid() const; 66 bool IsValid() const;
63 67
64 // Returns size of audio buffer in bytes. 68 // Returns size of audio buffer in bytes.
65 int GetBytesPerBuffer() const; 69 int GetBytesPerBuffer() const;
66 70
67 // Returns the number of bytes representing one second of audio. 71 // Returns the number of bytes representing one second of audio.
68 int GetBytesPerSecond() const; 72 int GetBytesPerSecond() const;
69 73
70 // Returns the number of bytes representing a frame of audio. 74 // Returns the number of bytes representing a frame of audio.
71 int GetBytesPerFrame() const; 75 int GetBytesPerFrame() const;
72 76
73 // Returns the duration of this buffer as calculated from frames_per_buffer() 77 // Returns the duration of this buffer as calculated from frames_per_buffer()
74 // and sample_rate(). 78 // and sample_rate().
75 base::TimeDelta GetBufferDuration() const; 79 base::TimeDelta GetBufferDuration() const;
76 80
77 Format format() const { return format_; } 81 Format format() const { return format_; }
78 ChannelLayout channel_layout() const { return channel_layout_; } 82 ChannelLayout channel_layout() const { return channel_layout_; }
79 int sample_rate() const { return sample_rate_; } 83 int sample_rate() const { return sample_rate_; }
80 int bits_per_sample() const { return bits_per_sample_; } 84 int bits_per_sample() const { return bits_per_sample_; }
81 int frames_per_buffer() const { return frames_per_buffer_; } 85 int frames_per_buffer() const { return frames_per_buffer_; }
82 int channels() const { return channels_; } 86 int channels() const { return channels_; }
83 int input_channels() const { return input_channels_; } 87 int input_channels() const { return input_channels_; }
88 bool use_platform_aec() const {
89 return use_platform_aec_;
90 }
84 91
85 // Set to CHANNEL_LAYOUT_DISCRETE with given number of channels. 92 // Set to CHANNEL_LAYOUT_DISCRETE with given number of channels.
86 void SetDiscreteChannels(int channels); 93 void SetDiscreteChannels(int channels);
94 void set_use_platform_aec(bool use) {
Ami GONE FROM CHROMIUM 2013/12/06 19:22:53 Why let this be mutable instead of making it a cto
95 use_platform_aec_ = use;
96 }
87 97
88 // Comparison with other AudioParams. 98 // Comparison with other AudioParams.
89 bool operator==(const AudioParameters& other) const { 99 bool operator==(const AudioParameters& other) const {
90 return format_ == other.format() && 100 return format_ == other.format() &&
91 sample_rate_ == other.sample_rate() && 101 sample_rate_ == other.sample_rate() &&
92 channel_layout_ == other.channel_layout() && 102 channel_layout_ == other.channel_layout() &&
93 channels_ == other.channels() && 103 channels_ == other.channels() &&
94 input_channels_ == other.input_channels() && 104 input_channels_ == other.input_channels() &&
95 bits_per_sample_ == other.bits_per_sample() && 105 bits_per_sample_ == other.bits_per_sample() &&
96 frames_per_buffer_ == other.frames_per_buffer(); 106 frames_per_buffer_ == other.frames_per_buffer() &&
107 use_platform_aec_ == other.use_platform_aec();
97 } 108 }
98 109
99 private: 110 private:
100 Format format_; // Format of the stream. 111 Format format_; // Format of the stream.
101 ChannelLayout channel_layout_; // Order of surround sound channels. 112 ChannelLayout channel_layout_; // Order of surround sound channels.
102 int sample_rate_; // Sampling frequency/rate. 113 int sample_rate_; // Sampling frequency/rate.
103 int bits_per_sample_; // Number of bits per sample. 114 int bits_per_sample_; // Number of bits per sample.
104 int frames_per_buffer_; // Number of frames in a buffer. 115 int frames_per_buffer_; // Number of frames in a buffer.
105 116
106 int channels_; // Number of channels. Value set based on 117 int channels_; // Number of channels. Value set based on
107 // |channel_layout|. 118 // |channel_layout|.
108 int input_channels_; // Optional number of input channels. 119 int input_channels_; // Optional number of input channels.
109 // Normally 0, but can be set to specify 120 // Normally 0, but can be set to specify
110 // synchronized I/O. 121 // synchronized I/O.
122 bool use_platform_aec_; // Platform AEC is available, or should be
123 // enabled, depending on context.
111 }; 124 };
112 125
113 // Comparison is useful when AudioParameters is used with std structures. 126 // Comparison is useful when AudioParameters is used with std structures.
114 inline bool operator<(const AudioParameters& a, const AudioParameters& b) { 127 inline bool operator<(const AudioParameters& a, const AudioParameters& b) {
115 if (a.format() != b.format()) 128 if (a.format() != b.format())
116 return a.format() < b.format(); 129 return a.format() < b.format();
117 if (a.channels() != b.channels()) 130 if (a.channels() != b.channels())
118 return a.channels() < b.channels(); 131 return a.channels() < b.channels();
119 if (a.input_channels() != b.input_channels()) 132 if (a.input_channels() != b.input_channels())
120 return a.input_channels() < b.input_channels(); 133 return a.input_channels() < b.input_channels();
121 if (a.sample_rate() != b.sample_rate()) 134 if (a.sample_rate() != b.sample_rate())
122 return a.sample_rate() < b.sample_rate(); 135 return a.sample_rate() < b.sample_rate();
123 if (a.bits_per_sample() != b.bits_per_sample()) 136 if (a.bits_per_sample() != b.bits_per_sample())
124 return a.bits_per_sample() < b.bits_per_sample(); 137 return a.bits_per_sample() < b.bits_per_sample();
125 return a.frames_per_buffer() < b.frames_per_buffer(); 138 if (a.frames_per_buffer() != b.frames_per_buffer())
139 return a.frames_per_buffer() < b.frames_per_buffer();
140 return a.use_platform_aec() < b.use_platform_aec();
126 } 141 }
127 142
128 } // namespace media 143 } // namespace media
129 144
130 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ 145 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698