| 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_BASE_AUDIO_PARAMETERS_H_ | 5 #ifndef MEDIA_BASE_AUDIO_PARAMETERS_H_ |
| 6 #define MEDIA_BASE_AUDIO_PARAMETERS_H_ | 6 #define MEDIA_BASE_AUDIO_PARAMETERS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "media/base/audio_bus.h" | 14 #include "media/base/audio_bus.h" |
| 15 #include "media/base/audio_latency.h" |
| 15 #include "media/base/audio_point.h" | 16 #include "media/base/audio_point.h" |
| 16 #include "media/base/channel_layout.h" | 17 #include "media/base/channel_layout.h" |
| 17 #include "media/base/media_export.h" | 18 #include "media/base/media_export.h" |
| 18 | 19 |
| 19 namespace media { | 20 namespace media { |
| 20 | 21 |
| 21 // Use a struct-in-struct approach to ensure that we can calculate the required | 22 // Use a struct-in-struct approach to ensure that we can calculate the required |
| 22 // size as sizeof(Audio{Input,Output}BufferParameters) + #(bytes in audio | 23 // size as sizeof(Audio{Input,Output}BufferParameters) + #(bytes in audio |
| 23 // buffer) without using packing. Also align Audio{Input,Output}BufferParameters | 24 // buffer) without using packing. Also align Audio{Input,Output}BufferParameters |
| 24 // instead of in Audio{Input,Output}Buffer to be able to calculate size like so. | 25 // instead of in Audio{Input,Output}Buffer to be able to calculate size like so. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 int frames_per_buffer() const { return frames_per_buffer_; } | 168 int frames_per_buffer() const { return frames_per_buffer_; } |
| 168 | 169 |
| 169 void set_effects(int effects) { effects_ = effects; } | 170 void set_effects(int effects) { effects_ = effects; } |
| 170 int effects() const { return effects_; } | 171 int effects() const { return effects_; } |
| 171 | 172 |
| 172 void set_mic_positions(const std::vector<Point>& mic_positions) { | 173 void set_mic_positions(const std::vector<Point>& mic_positions) { |
| 173 mic_positions_ = mic_positions; | 174 mic_positions_ = mic_positions; |
| 174 } | 175 } |
| 175 const std::vector<Point>& mic_positions() const { return mic_positions_; } | 176 const std::vector<Point>& mic_positions() const { return mic_positions_; } |
| 176 | 177 |
| 178 void set_latency_tag(AudioLatency::LatencyType latency_tag) { |
| 179 latency_tag_ = latency_tag; |
| 180 } |
| 181 AudioLatency::LatencyType latency_tag() const { return latency_tag_; } |
| 182 |
| 177 AudioParameters(const AudioParameters&); | 183 AudioParameters(const AudioParameters&); |
| 178 AudioParameters& operator=(const AudioParameters&); | 184 AudioParameters& operator=(const AudioParameters&); |
| 179 | 185 |
| 180 // Creates reasonable dummy parameters in case no device is available. | 186 // Creates reasonable dummy parameters in case no device is available. |
| 181 static AudioParameters UnavailableDeviceParams(); | 187 static AudioParameters UnavailableDeviceParams(); |
| 182 | 188 |
| 183 private: | 189 private: |
| 184 Format format_; // Format of the stream. | 190 Format format_; // Format of the stream. |
| 185 ChannelLayout channel_layout_; // Order of surround sound channels. | 191 ChannelLayout channel_layout_; // Order of surround sound channels. |
| 186 int channels_; // Number of channels. Value set based on | 192 int channels_; // Number of channels. Value set based on |
| 187 // |channel_layout|. | 193 // |channel_layout|. |
| 188 int sample_rate_; // Sampling frequency/rate. | 194 int sample_rate_; // Sampling frequency/rate. |
| 189 int bits_per_sample_; // Number of bits per sample. | 195 int bits_per_sample_; // Number of bits per sample. |
| 190 int frames_per_buffer_; // Number of frames in a buffer. | 196 int frames_per_buffer_; // Number of frames in a buffer. |
| 191 int effects_; // Bitmask using PlatformEffectsMask. | 197 int effects_; // Bitmask using PlatformEffectsMask. |
| 192 | 198 |
| 193 // Microphone positions using Cartesian coordinates: | 199 // Microphone positions using Cartesian coordinates: |
| 194 // x: the horizontal dimension, with positive to the right from the camera's | 200 // x: the horizontal dimension, with positive to the right from the camera's |
| 195 // perspective. | 201 // perspective. |
| 196 // y: the depth dimension, with positive forward from the camera's | 202 // y: the depth dimension, with positive forward from the camera's |
| 197 // perspective. | 203 // perspective. |
| 198 // z: the vertical dimension, with positive upwards. | 204 // z: the vertical dimension, with positive upwards. |
| 199 // | 205 // |
| 200 // Usually, the center of the microphone array will be treated as the origin | 206 // Usually, the center of the microphone array will be treated as the origin |
| 201 // (often the position of the camera). | 207 // (often the position of the camera). |
| 202 // | 208 // |
| 203 // An empty vector indicates unknown positions. | 209 // An empty vector indicates unknown positions. |
| 204 std::vector<Point> mic_positions_; | 210 std::vector<Point> mic_positions_; |
| 211 |
| 212 // Optional tag to pass latency info from renderer to browser. |
| 213 AudioLatency::LatencyType latency_tag_; |
| 205 }; | 214 }; |
| 206 | 215 |
| 207 // Comparison is useful when AudioParameters is used with std structures. | 216 // Comparison is useful when AudioParameters is used with std structures. |
| 208 inline bool operator<(const AudioParameters& a, const AudioParameters& b) { | 217 inline bool operator<(const AudioParameters& a, const AudioParameters& b) { |
| 209 if (a.format() != b.format()) | 218 if (a.format() != b.format()) |
| 210 return a.format() < b.format(); | 219 return a.format() < b.format(); |
| 211 if (a.channels() != b.channels()) | 220 if (a.channels() != b.channels()) |
| 212 return a.channels() < b.channels(); | 221 return a.channels() < b.channels(); |
| 213 if (a.sample_rate() != b.sample_rate()) | 222 if (a.sample_rate() != b.sample_rate()) |
| 214 return a.sample_rate() < b.sample_rate(); | 223 return a.sample_rate() < b.sample_rate(); |
| 215 if (a.bits_per_sample() != b.bits_per_sample()) | 224 if (a.bits_per_sample() != b.bits_per_sample()) |
| 216 return a.bits_per_sample() < b.bits_per_sample(); | 225 return a.bits_per_sample() < b.bits_per_sample(); |
| 217 return a.frames_per_buffer() < b.frames_per_buffer(); | 226 return a.frames_per_buffer() < b.frames_per_buffer(); |
| 218 } | 227 } |
| 219 | 228 |
| 220 } // namespace media | 229 } // namespace media |
| 221 | 230 |
| 222 #endif // MEDIA_BASE_AUDIO_PARAMETERS_H_ | 231 #endif // MEDIA_BASE_AUDIO_PARAMETERS_H_ |
| OLD | NEW |