Chromium Code Reviews| 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 #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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "media/audio/point.h" | |
| 12 #include "media/base/channel_layout.h" | 13 #include "media/base/channel_layout.h" |
| 13 #include "media/base/media_export.h" | 14 #include "media/base/media_export.h" |
| 14 | 15 |
| 15 namespace media { | 16 namespace media { |
| 16 | 17 |
| 17 struct MEDIA_EXPORT AudioInputBufferParameters { | 18 struct MEDIA_EXPORT AudioInputBufferParameters { |
| 18 double volume; | 19 double volume; |
| 19 uint32 size; | 20 uint32 size; |
| 20 bool key_pressed; | 21 bool key_pressed; |
| 21 }; | 22 }; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 50 // effects should be enabled. | 51 // effects should be enabled. |
| 51 enum PlatformEffectsMask { | 52 enum PlatformEffectsMask { |
| 52 NO_EFFECTS = 0x0, | 53 NO_EFFECTS = 0x0, |
| 53 ECHO_CANCELLER = 0x1, | 54 ECHO_CANCELLER = 0x1, |
| 54 DUCKING = 0x2, // Enables ducking if the OS supports it. | 55 DUCKING = 0x2, // Enables ducking if the OS supports it. |
| 55 KEYBOARD_MIC = 0x4, | 56 KEYBOARD_MIC = 0x4, |
| 56 HOTWORD = 0x8, | 57 HOTWORD = 0x8, |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 AudioParameters(); | 60 AudioParameters(); |
| 60 AudioParameters(Format format, ChannelLayout channel_layout, | 61 AudioParameters( |
| 61 int sample_rate, int bits_per_sample, | 62 Format format, |
| 62 int frames_per_buffer); | 63 ChannelLayout channel_layout, |
| 63 AudioParameters(Format format, ChannelLayout channel_layout, | 64 int sample_rate, |
| 64 int sample_rate, int bits_per_sample, | 65 int bits_per_sample, |
| 65 int frames_per_buffer, int effects); | 66 int frames_per_buffer, |
| 66 AudioParameters(Format format, ChannelLayout channel_layout, | 67 const std::vector<Point>& mic_positions = std::vector<Point>(), |
| 67 int channels, int sample_rate, int bits_per_sample, | 68 int effects = NO_EFFECTS); |
| 68 int frames_per_buffer, int effects); | 69 AudioParameters( |
| 70 Format format, | |
| 71 int channels, | |
| 72 ChannelLayout channel_layout, | |
| 73 int sample_rate, | |
| 74 int bits_per_sample, | |
| 75 int frames_per_buffer, | |
| 76 const std::vector<Point>& mic_positions = std::vector<Point>(), | |
| 77 int effects = NO_EFFECTS); | |
| 78 | |
| 79 ~AudioParameters(); | |
| 69 | 80 |
| 70 void Reset(Format format, ChannelLayout channel_layout, | 81 void Reset(Format format, ChannelLayout channel_layout, |
| 71 int channels, int sample_rate, int bits_per_sample, | 82 int channels, int sample_rate, int bits_per_sample, |
| 72 int frames_per_buffer); | 83 int frames_per_buffer); |
| 73 | 84 |
| 74 // Checks that all values are in the expected range. All limits are specified | 85 // Checks that all values are in the expected range. All limits are specified |
| 75 // in media::Limits. | 86 // in media::Limits. |
| 76 bool IsValid() const; | 87 bool IsValid() const; |
| 77 | 88 |
| 78 // Returns a human-readable string describing |*this|. For debugging & test | 89 // Returns a human-readable string describing |*this|. For debugging & test |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 95 // Comparison with other AudioParams. | 106 // Comparison with other AudioParams. |
| 96 bool Equals(const AudioParameters& other) const; | 107 bool Equals(const AudioParameters& other) const; |
| 97 | 108 |
| 98 Format format() const { return format_; } | 109 Format format() const { return format_; } |
| 99 ChannelLayout channel_layout() const { return channel_layout_; } | 110 ChannelLayout channel_layout() const { return channel_layout_; } |
| 100 int sample_rate() const { return sample_rate_; } | 111 int sample_rate() const { return sample_rate_; } |
| 101 int bits_per_sample() const { return bits_per_sample_; } | 112 int bits_per_sample() const { return bits_per_sample_; } |
| 102 int frames_per_buffer() const { return frames_per_buffer_; } | 113 int frames_per_buffer() const { return frames_per_buffer_; } |
| 103 int channels() const { return channels_; } | 114 int channels() const { return channels_; } |
| 104 int effects() const { return effects_; } | 115 int effects() const { return effects_; } |
| 116 const std::vector<Point>& mic_positions() const { return mic_positions_; } | |
| 105 | 117 |
| 106 private: | 118 private: |
| 107 // These members are mutable to support entire struct assignment. They should | 119 // These members are mutable to support entire struct assignment. They should |
| 108 // not be mutated individually. | 120 // not be mutated individually. |
| 109 Format format_; // Format of the stream. | 121 Format format_; // Format of the stream. |
| 110 ChannelLayout channel_layout_; // Order of surround sound channels. | 122 ChannelLayout channel_layout_; // Order of surround sound channels. |
| 111 int sample_rate_; // Sampling frequency/rate. | 123 int sample_rate_; // Sampling frequency/rate. |
| 112 int bits_per_sample_; // Number of bits per sample. | 124 int bits_per_sample_; // Number of bits per sample. |
| 113 int frames_per_buffer_; // Number of frames in a buffer. | 125 int frames_per_buffer_; // Number of frames in a buffer. |
| 114 | 126 |
| 115 int channels_; // Number of channels. Value set based on | 127 int channels_; // Number of channels. Value set based on |
| 116 // |channel_layout|. | 128 // |channel_layout|. |
| 129 | |
| 130 // Microphone positions using Cartesian coordinates: | |
| 131 // x: the horizontal dimension, with positive to the right from the camera's | |
| 132 // perspective. | |
| 133 // y: the depth dimension, with positive forward from the camera's | |
| 134 // perspective. | |
| 135 // z: the vertical dimension, with positive upwards. | |
| 136 // | |
| 137 // Usually, the center of the microphone array will be treated as the origin | |
| 138 // (often the position of the camera). | |
| 139 // | |
| 140 // An empty vector indicates unknown positions. | |
| 141 std::vector<Point> mic_positions_; | |
|
mcasas
2015/09/02 03:05:37
const?
ajm
2015/09/02 06:41:48
The members aren't const to allow copy assignment
| |
| 142 | |
| 117 int effects_; // Bitmask using PlatformEffectsMask. | 143 int effects_; // Bitmask using PlatformEffectsMask. |
|
mcasas
2015/09/02 03:05:37
const?
And perhaps l.121-l.127 as well?
Is strang
mcasas
2015/09/02 03:05:37
const?
And perhaps l.121-l.127 as well?
Is strang
ajm
2015/09/02 06:41:48
As above.
| |
| 118 }; | 144 }; |
| 119 | 145 |
| 120 // Comparison is useful when AudioParameters is used with std structures. | 146 // Comparison is useful when AudioParameters is used with std structures. |
| 121 inline bool operator<(const AudioParameters& a, const AudioParameters& b) { | 147 inline bool operator<(const AudioParameters& a, const AudioParameters& b) { |
| 122 if (a.format() != b.format()) | 148 if (a.format() != b.format()) |
| 123 return a.format() < b.format(); | 149 return a.format() < b.format(); |
| 124 if (a.channels() != b.channels()) | 150 if (a.channels() != b.channels()) |
| 125 return a.channels() < b.channels(); | 151 return a.channels() < b.channels(); |
| 126 if (a.sample_rate() != b.sample_rate()) | 152 if (a.sample_rate() != b.sample_rate()) |
| 127 return a.sample_rate() < b.sample_rate(); | 153 return a.sample_rate() < b.sample_rate(); |
| 128 if (a.bits_per_sample() != b.bits_per_sample()) | 154 if (a.bits_per_sample() != b.bits_per_sample()) |
| 129 return a.bits_per_sample() < b.bits_per_sample(); | 155 return a.bits_per_sample() < b.bits_per_sample(); |
| 130 return a.frames_per_buffer() < b.frames_per_buffer(); | 156 return a.frames_per_buffer() < b.frames_per_buffer(); |
| 131 } | 157 } |
| 132 | 158 |
| 133 } // namespace media | 159 } // namespace media |
| 134 | 160 |
| 135 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ | 161 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ |
| OLD | NEW |