| 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 <stdint.h> | 8 #include <stdint.h> | 
| 9 #include <string> | 9 #include <string> | 
| 10 | 10 | 
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" | 
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" | 
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" | 
|  | 14 #include "media/audio/point.h" | 
| 14 #include "media/base/audio_bus.h" | 15 #include "media/base/audio_bus.h" | 
| 15 #include "media/base/channel_layout.h" | 16 #include "media/base/channel_layout.h" | 
| 16 #include "media/base/media_export.h" | 17 #include "media/base/media_export.h" | 
| 17 | 18 | 
| 18 namespace media { | 19 namespace media { | 
| 19 | 20 | 
| 20 // Use a struct-in-struct approach to ensure that we can calculate the required | 21 // Use a struct-in-struct approach to ensure that we can calculate the required | 
| 21 // size as sizeof(AudioInputBufferParameters) + #(bytes in audio buffer) without | 22 // size as sizeof(AudioInputBufferParameters) + #(bytes in audio buffer) without | 
| 22 // using packing. Also align AudioInputBufferParameters instead of in | 23 // using packing. Also align AudioInputBufferParameters instead of in | 
| 23 // AudioInputBuffer to be able to calculate size like so. Use a macro for the | 24 // AudioInputBuffer to be able to calculate size like so. Use a macro for the | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 79     HOTWORD = 0x8, | 80     HOTWORD = 0x8, | 
| 80   }; | 81   }; | 
| 81 | 82 | 
| 82   AudioParameters(); | 83   AudioParameters(); | 
| 83   AudioParameters(Format format, | 84   AudioParameters(Format format, | 
| 84                   ChannelLayout channel_layout, | 85                   ChannelLayout channel_layout, | 
| 85                   int sample_rate, | 86                   int sample_rate, | 
| 86                   int bits_per_sample, | 87                   int bits_per_sample, | 
| 87                   int frames_per_buffer); | 88                   int frames_per_buffer); | 
| 88 | 89 | 
|  | 90   ~AudioParameters(); | 
|  | 91 | 
| 89   // Re-initializes all members. | 92   // Re-initializes all members. | 
| 90   void Reset(Format format, | 93   void Reset(Format format, | 
| 91              ChannelLayout channel_layout, | 94              ChannelLayout channel_layout, | 
| 92              int sample_rate, | 95              int sample_rate, | 
| 93              int bits_per_sample, | 96              int bits_per_sample, | 
| 94              int frames_per_buffer); | 97              int frames_per_buffer); | 
| 95 | 98 | 
| 96   // Checks that all values are in the expected range. All limits are specified | 99   // Checks that all values are in the expected range. All limits are specified | 
| 97   // in media::Limits. | 100   // in media::Limits. | 
| 98   bool IsValid() const; | 101   bool IsValid() const; | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 141   int bits_per_sample() const { return bits_per_sample_; } | 144   int bits_per_sample() const { return bits_per_sample_; } | 
| 142 | 145 | 
| 143   void set_frames_per_buffer(int frames_per_buffer) { | 146   void set_frames_per_buffer(int frames_per_buffer) { | 
| 144     frames_per_buffer_ = frames_per_buffer; | 147     frames_per_buffer_ = frames_per_buffer; | 
| 145   } | 148   } | 
| 146   int frames_per_buffer() const { return frames_per_buffer_; } | 149   int frames_per_buffer() const { return frames_per_buffer_; } | 
| 147 | 150 | 
| 148   void set_effects(int effects) { effects_ = effects; } | 151   void set_effects(int effects) { effects_ = effects; } | 
| 149   int effects() const { return effects_; } | 152   int effects() const { return effects_; } | 
| 150 | 153 | 
| 151   AudioParameters(const AudioParameters&) = default; | 154   void set_mic_positions(const std::vector<Point>& mic_positions) { | 
| 152   AudioParameters& operator=(const AudioParameters&) = default; | 155     mic_positions_ = mic_positions; | 
|  | 156   } | 
|  | 157   const std::vector<Point>& mic_positions() const { return mic_positions_; } | 
|  | 158 | 
|  | 159   AudioParameters(const AudioParameters&); | 
|  | 160   AudioParameters& operator=(const AudioParameters&); | 
| 153 | 161 | 
| 154  private: | 162  private: | 
| 155   Format format_;                 // Format of the stream. | 163   Format format_;                 // Format of the stream. | 
| 156   ChannelLayout channel_layout_;  // Order of surround sound channels. | 164   ChannelLayout channel_layout_;  // Order of surround sound channels. | 
| 157   int channels_;                  // Number of channels. Value set based on | 165   int channels_;                  // Number of channels. Value set based on | 
| 158                                   // |channel_layout|. | 166                                   // |channel_layout|. | 
| 159   int sample_rate_;               // Sampling frequency/rate. | 167   int sample_rate_;               // Sampling frequency/rate. | 
| 160   int bits_per_sample_;           // Number of bits per sample. | 168   int bits_per_sample_;           // Number of bits per sample. | 
| 161   int frames_per_buffer_;         // Number of frames in a buffer. | 169   int frames_per_buffer_;         // Number of frames in a buffer. | 
| 162   int effects_;                   // Bitmask using PlatformEffectsMask. | 170   int effects_;                   // Bitmask using PlatformEffectsMask. | 
|  | 171 | 
|  | 172   // Microphone positions using Cartesian coordinates: | 
|  | 173   // x: the horizontal dimension, with positive to the right from the camera's | 
|  | 174   //    perspective. | 
|  | 175   // y: the depth dimension, with positive forward from the camera's | 
|  | 176   //    perspective. | 
|  | 177   // z: the vertical dimension, with positive upwards. | 
|  | 178   // | 
|  | 179   // Usually, the center of the microphone array will be treated as the origin | 
|  | 180   // (often the position of the camera). | 
|  | 181   // | 
|  | 182   // An empty vector indicates unknown positions. | 
|  | 183   std::vector<Point> mic_positions_; | 
| 163 }; | 184 }; | 
| 164 | 185 | 
| 165 // Comparison is useful when AudioParameters is used with std structures. | 186 // Comparison is useful when AudioParameters is used with std structures. | 
| 166 inline bool operator<(const AudioParameters& a, const AudioParameters& b) { | 187 inline bool operator<(const AudioParameters& a, const AudioParameters& b) { | 
| 167   if (a.format() != b.format()) | 188   if (a.format() != b.format()) | 
| 168     return a.format() < b.format(); | 189     return a.format() < b.format(); | 
| 169   if (a.channels() != b.channels()) | 190   if (a.channels() != b.channels()) | 
| 170     return a.channels() < b.channels(); | 191     return a.channels() < b.channels(); | 
| 171   if (a.sample_rate() != b.sample_rate()) | 192   if (a.sample_rate() != b.sample_rate()) | 
| 172     return a.sample_rate() < b.sample_rate(); | 193     return a.sample_rate() < b.sample_rate(); | 
| 173   if (a.bits_per_sample() != b.bits_per_sample()) | 194   if (a.bits_per_sample() != b.bits_per_sample()) | 
| 174     return a.bits_per_sample() < b.bits_per_sample(); | 195     return a.bits_per_sample() < b.bits_per_sample(); | 
| 175   return a.frames_per_buffer() < b.frames_per_buffer(); | 196   return a.frames_per_buffer() < b.frames_per_buffer(); | 
| 176 } | 197 } | 
| 177 | 198 | 
| 178 }  // namespace media | 199 }  // namespace media | 
| 179 | 200 | 
| 180 #endif  // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ | 201 #endif  // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ | 
| OLD | NEW | 
|---|