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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, | 49 AudioParameters(Format format, ChannelLayout channel_layout, |
50 int input_channels, | 50 int input_channels, |
51 int sample_rate, int bits_per_sample, | 51 int sample_rate, int bits_per_sample, |
52 int frames_per_buffer); | 52 int frames_per_buffer); |
53 void Reset(Format format, ChannelLayout channel_layout, | 53 void Reset(Format format, ChannelLayout channel_layout, |
54 int channels, int input_channels, | 54 int input_channels, |
55 int sample_rate, int bits_per_sample, | 55 int sample_rate, int bits_per_sample, |
56 int frames_per_buffer); | 56 int frames_per_buffer); |
57 | 57 |
58 // 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 |
59 // in media::Limits. | 59 // in media::Limits. |
60 bool IsValid() const; | 60 bool IsValid() const; |
61 | 61 |
62 // Returns size of audio buffer in bytes. | 62 // Returns size of audio buffer in bytes. |
63 int GetBytesPerBuffer() const; | 63 int GetBytesPerBuffer() const; |
64 | 64 |
65 // Returns the number of bytes representing one second of audio. | 65 // Returns the number of bytes representing one second of audio. |
66 int GetBytesPerSecond() const; | 66 int GetBytesPerSecond() const; |
67 | 67 |
68 // Returns the number of bytes representing a frame of audio. | 68 // Returns the number of bytes representing a frame of audio. |
69 int GetBytesPerFrame() const; | 69 int GetBytesPerFrame() const; |
70 | 70 |
71 Format format() const { return format_; } | 71 Format format() const { return format_; } |
72 ChannelLayout channel_layout() const { return channel_layout_; } | 72 ChannelLayout channel_layout() const { return channel_layout_; } |
73 int sample_rate() const { return sample_rate_; } | 73 int sample_rate() const { return sample_rate_; } |
74 int bits_per_sample() const { return bits_per_sample_; } | 74 int bits_per_sample() const { return bits_per_sample_; } |
75 int frames_per_buffer() const { return frames_per_buffer_; } | 75 int frames_per_buffer() const { return frames_per_buffer_; } |
76 int channels() const { return channels_; } | 76 int channels() const { return channels_; } |
77 int input_channels() const { return input_channels_; } | 77 int input_channels() const { return input_channels_; } |
78 | 78 |
79 // Set to CHANNEL_LAYOUT_DISCRETE with given number of channels. | |
80 void SetDiscreteChannels(int channels); | |
81 | |
82 private: | 79 private: |
83 Format format_; // Format of the stream. | 80 Format format_; // Format of the stream. |
84 ChannelLayout channel_layout_; // Order of surround sound channels. | 81 ChannelLayout channel_layout_; // Order of surround sound channels. |
85 int sample_rate_; // Sampling frequency/rate. | 82 int sample_rate_; // Sampling frequency/rate. |
86 int bits_per_sample_; // Number of bits per sample. | 83 int bits_per_sample_; // Number of bits per sample. |
87 int frames_per_buffer_; // Number of frames in a buffer. | 84 int frames_per_buffer_; // Number of frames in a buffer. |
88 | 85 |
89 int channels_; // Number of channels. Value set based on | 86 int channels_; // Number of channels. Value set based on |
90 // |channel_layout|. | 87 // |channel_layout|. |
91 int input_channels_; // Optional number of input channels. | 88 int input_channels_; // Optional number of input channels. |
(...skipping 12 matching lines...) Expand all Loading... |
104 if (a.sample_rate() != b.sample_rate()) | 101 if (a.sample_rate() != b.sample_rate()) |
105 return a.sample_rate() < b.sample_rate(); | 102 return a.sample_rate() < b.sample_rate(); |
106 if (a.bits_per_sample() != b.bits_per_sample()) | 103 if (a.bits_per_sample() != b.bits_per_sample()) |
107 return a.bits_per_sample() < b.bits_per_sample(); | 104 return a.bits_per_sample() < b.bits_per_sample(); |
108 return a.frames_per_buffer() < b.frames_per_buffer(); | 105 return a.frames_per_buffer() < b.frames_per_buffer(); |
109 } | 106 } |
110 | 107 |
111 } // namespace media | 108 } // namespace media |
112 | 109 |
113 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ | 110 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ |
OLD | NEW |