| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "media/base/channel_layout.h" | 9 #include "media/base/channel_layout.h" |
| 10 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // Telephone quality sample rate, mostly for speech-only audio. | 39 // Telephone quality sample rate, mostly for speech-only audio. |
| 40 kTelephoneSampleRate = 8000, | 40 kTelephoneSampleRate = 8000, |
| 41 // CD sampling rate is 44.1 KHz or conveniently 2x2x3x3x5x5x7x7. | 41 // CD sampling rate is 44.1 KHz or conveniently 2x2x3x3x5x5x7x7. |
| 42 kAudioCDSampleRate = 44100, | 42 kAudioCDSampleRate = 44100, |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 AudioParameters(); | 45 AudioParameters(); |
| 46 AudioParameters(Format format, ChannelLayout channel_layout, | 46 AudioParameters(Format format, ChannelLayout channel_layout, |
| 47 int sample_rate, int bits_per_sample, | 47 int sample_rate, int bits_per_sample, |
| 48 int frames_per_buffer); | 48 int frames_per_buffer); |
| 49 AudioParameters(Format format, ChannelLayout channel_layout, |
| 50 int input_channels, |
| 51 int sample_rate, int bits_per_sample, |
| 52 int frames_per_buffer); |
| 49 void Reset(Format format, ChannelLayout channel_layout, | 53 void Reset(Format format, ChannelLayout channel_layout, |
| 54 int input_channels, |
| 50 int sample_rate, int bits_per_sample, | 55 int sample_rate, int bits_per_sample, |
| 51 int frames_per_buffer); | 56 int frames_per_buffer); |
| 52 | 57 |
| 53 // Checks that all values are in the expected range. All limits are specified | 58 // Checks that all values are in the expected range. All limits are specified |
| 54 // in media::Limits. | 59 // in media::Limits. |
| 55 bool IsValid() const; | 60 bool IsValid() const; |
| 56 | 61 |
| 57 // Returns size of audio buffer in bytes. | 62 // Returns size of audio buffer in bytes. |
| 58 int GetBytesPerBuffer() const; | 63 int GetBytesPerBuffer() const; |
| 59 | 64 |
| 60 // Returns the number of bytes representing one second of audio. | 65 // Returns the number of bytes representing one second of audio. |
| 61 int GetBytesPerSecond() const; | 66 int GetBytesPerSecond() const; |
| 62 | 67 |
| 63 // Returns the number of bytes representing a frame of audio. | 68 // Returns the number of bytes representing a frame of audio. |
| 64 int GetBytesPerFrame() const; | 69 int GetBytesPerFrame() const; |
| 65 | 70 |
| 66 Format format() const { return format_; } | 71 Format format() const { return format_; } |
| 67 ChannelLayout channel_layout() const { return channel_layout_; } | 72 ChannelLayout channel_layout() const { return channel_layout_; } |
| 68 int sample_rate() const { return sample_rate_; } | 73 int sample_rate() const { return sample_rate_; } |
| 69 int bits_per_sample() const { return bits_per_sample_; } | 74 int bits_per_sample() const { return bits_per_sample_; } |
| 70 int frames_per_buffer() const { return frames_per_buffer_; } | 75 int frames_per_buffer() const { return frames_per_buffer_; } |
| 71 int channels() const { return channels_; } | 76 int channels() const { return channels_; } |
| 77 int input_channels() const { return input_channels_; } |
| 72 | 78 |
| 73 private: | 79 private: |
| 74 Format format_; // Format of the stream. | 80 Format format_; // Format of the stream. |
| 75 ChannelLayout channel_layout_; // Order of surround sound channels. | 81 ChannelLayout channel_layout_; // Order of surround sound channels. |
| 76 int sample_rate_; // Sampling frequency/rate. | 82 int sample_rate_; // Sampling frequency/rate. |
| 77 int bits_per_sample_; // Number of bits per sample. | 83 int bits_per_sample_; // Number of bits per sample. |
| 78 int frames_per_buffer_; // Number of frames in a buffer. | 84 int frames_per_buffer_; // Number of frames in a buffer. |
| 79 | 85 |
| 80 int channels_; // Number of channels. Value set based on | 86 int channels_; // Number of channels. Value set based on |
| 81 // |channel_layout|. | 87 // |channel_layout|. |
| 88 int input_channels_; // Optional number of input channels. |
| 89 // Normally 0, but can be set to specify |
| 90 // synchronized I/O. |
| 82 }; | 91 }; |
| 83 | 92 |
| 84 // Comparison is useful when AudioParameters is used with std structures. | 93 // Comparison is useful when AudioParameters is used with std structures. |
| 85 inline bool operator<(const AudioParameters& a, const AudioParameters& b) { | 94 inline bool operator<(const AudioParameters& a, const AudioParameters& b) { |
| 86 if (a.format() != b.format()) | 95 if (a.format() != b.format()) |
| 87 return a.format() < b.format(); | 96 return a.format() < b.format(); |
| 88 if (a.channels() != b.channels()) | 97 if (a.channels() != b.channels()) |
| 89 return a.channels() < b.channels(); | 98 return a.channels() < b.channels(); |
| 99 if (a.input_channels() != b.input_channels()) |
| 100 return a.input_channels() < b.input_channels(); |
| 90 if (a.sample_rate() != b.sample_rate()) | 101 if (a.sample_rate() != b.sample_rate()) |
| 91 return a.sample_rate() < b.sample_rate(); | 102 return a.sample_rate() < b.sample_rate(); |
| 92 if (a.bits_per_sample() != b.bits_per_sample()) | 103 if (a.bits_per_sample() != b.bits_per_sample()) |
| 93 return a.bits_per_sample() < b.bits_per_sample(); | 104 return a.bits_per_sample() < b.bits_per_sample(); |
| 94 return a.frames_per_buffer() < b.frames_per_buffer(); | 105 return a.frames_per_buffer() < b.frames_per_buffer(); |
| 95 } | 106 } |
| 96 | 107 |
| 97 } // namespace media | 108 } // namespace media |
| 98 | 109 |
| 99 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ | 110 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ |
| OLD | NEW |