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" |
11 | 11 |
12 namespace media { | 12 namespace media { |
13 | 13 |
14 struct MEDIA_EXPORT AudioInputBufferParameters { | 14 struct MEDIA_EXPORT AudioInputBufferParameters { |
15 double volume; | 15 double volume; |
16 uint32 size; | 16 uint32 size; |
17 }; | 17 }; |
18 | 18 |
19 // Use a struct-in-struct approach to ensure that we can calculate the required | 19 // Use a struct-in-struct approach to ensure that we can calculate the required |
20 // size as sizeof(AudioInputBufferParameters) + #(bytes in audio buffer) without | 20 // size as sizeof(AudioInputBufferParameters) + #(bytes in audio buffer) without |
21 // using packing. | 21 // using packing. |
22 struct MEDIA_EXPORT AudioInputBuffer { | 22 struct MEDIA_EXPORT AudioInputBuffer { |
23 AudioInputBufferParameters params; | 23 AudioInputBufferParameters params; |
24 int8 audio[1]; | 24 int8 audio[1]; |
25 }; | 25 }; |
26 | 26 |
27 class MEDIA_EXPORT AudioParameters { | 27 class MEDIA_EXPORT AudioParameters { |
28 public: | 28 public: |
29 // Compare is useful when AudioParameters is used as a key in std::map. | |
30 class MEDIA_EXPORT Compare { | |
31 public: | |
32 bool operator()(const AudioParameters& a, const AudioParameters& b) const; | |
33 }; | |
34 | |
35 enum Format { | 29 enum Format { |
36 AUDIO_PCM_LINEAR = 0, // PCM is 'raw' amplitude samples. | 30 AUDIO_PCM_LINEAR = 0, // PCM is 'raw' amplitude samples. |
37 AUDIO_PCM_LOW_LATENCY, // Linear PCM, low latency requested. | 31 AUDIO_PCM_LOW_LATENCY, // Linear PCM, low latency requested. |
38 AUDIO_FAKE, // Creates a fake AudioOutputStream object. | 32 AUDIO_FAKE, // Creates a fake AudioOutputStream object. |
39 AUDIO_LAST_FORMAT // Only used for validation of format. | 33 AUDIO_LAST_FORMAT // Only used for validation of format. |
40 }; | 34 }; |
41 | 35 |
42 enum { | 36 enum { |
43 // Telephone quality sample rate, mostly for speech-only audio. | 37 // Telephone quality sample rate, mostly for speech-only audio. |
44 kTelephoneSampleRate = 8000, | 38 kTelephoneSampleRate = 8000, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 Format format_; // Format of the stream. | 72 Format format_; // Format of the stream. |
79 ChannelLayout channel_layout_; // Order of surround sound channels. | 73 ChannelLayout channel_layout_; // Order of surround sound channels. |
80 int sample_rate_; // Sampling frequency/rate. | 74 int sample_rate_; // Sampling frequency/rate. |
81 int bits_per_sample_; // Number of bits per sample. | 75 int bits_per_sample_; // Number of bits per sample. |
82 int frames_per_buffer_; // Number of frames in a buffer. | 76 int frames_per_buffer_; // Number of frames in a buffer. |
83 | 77 |
84 int channels_; // Number of channels. Value set based on | 78 int channels_; // Number of channels. Value set based on |
85 // |channel_layout|. | 79 // |channel_layout|. |
86 }; | 80 }; |
87 | 81 |
| 82 // Comparison is useful when AudioParameters is used with std structures. |
| 83 inline bool operator<(const AudioParameters& a, |
| 84 const AudioParameters& b) { |
| 85 if (a.format() != b.format()) |
| 86 return a.format() < b.format(); |
| 87 if (a.channels() != b.channels()) |
| 88 return a.channels() < b.channels(); |
| 89 if (a.sample_rate() != b.sample_rate()) |
| 90 return a.sample_rate() < b.sample_rate(); |
| 91 if (a.bits_per_sample() != b.bits_per_sample()) |
| 92 return a.bits_per_sample() < b.bits_per_sample(); |
| 93 return a.frames_per_buffer() < b.frames_per_buffer(); |
| 94 } |
| 95 |
88 } // namespace media | 96 } // namespace media |
89 | 97 |
90 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ | 98 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ |
OLD | NEW |