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 |
(...skipping 23 matching lines...) Expand all Loading... | |
34 "Audio buffer parameters struct alignment not same as AudioBus"); | 34 "Audio buffer parameters struct alignment not same as AudioBus"); |
35 struct MEDIA_EXPORT ALIGNAS(PARAMETERS_ALIGNMENT) AudioInputBufferParameters { | 35 struct MEDIA_EXPORT ALIGNAS(PARAMETERS_ALIGNMENT) AudioInputBufferParameters { |
36 double volume; | 36 double volume; |
37 uint32_t size; | 37 uint32_t size; |
38 uint32_t hardware_delay_bytes; | 38 uint32_t hardware_delay_bytes; |
39 uint32_t id; | 39 uint32_t id; |
40 bool key_pressed; | 40 bool key_pressed; |
41 }; | 41 }; |
42 struct MEDIA_EXPORT ALIGNAS(PARAMETERS_ALIGNMENT) AudioOutputBufferParameters { | 42 struct MEDIA_EXPORT ALIGNAS(PARAMETERS_ALIGNMENT) AudioOutputBufferParameters { |
43 uint32_t frames_skipped; | 43 uint32_t frames_skipped; |
44 uint32_t frames; | |
45 uint32_t data_size; | |
44 }; | 46 }; |
45 #undef PARAMETERS_ALIGNMENT | 47 #undef PARAMETERS_ALIGNMENT |
46 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
47 #pragma warning(pop) | 49 #pragma warning(pop) |
48 #endif | 50 #endif |
49 | 51 |
50 static_assert(sizeof(AudioInputBufferParameters) % | 52 static_assert(sizeof(AudioInputBufferParameters) % |
51 AudioBus::kChannelAlignment == | 53 AudioBus::kChannelAlignment == |
52 0, | 54 0, |
53 "AudioInputBufferParameters not aligned"); | 55 "AudioInputBufferParameters not aligned"); |
(...skipping 11 matching lines...) Expand all Loading... | |
65 int8_t audio[1]; | 67 int8_t audio[1]; |
66 }; | 68 }; |
67 | 69 |
68 class MEDIA_EXPORT AudioParameters { | 70 class MEDIA_EXPORT AudioParameters { |
69 public: | 71 public: |
70 // TODO(miu): Rename this enum to something that correctly reflects its | 72 // TODO(miu): Rename this enum to something that correctly reflects its |
71 // semantics, such as "TransportScheme." | 73 // semantics, such as "TransportScheme." |
72 enum Format { | 74 enum Format { |
73 AUDIO_PCM_LINEAR = 0, // PCM is 'raw' amplitude samples. | 75 AUDIO_PCM_LINEAR = 0, // PCM is 'raw' amplitude samples. |
74 AUDIO_PCM_LOW_LATENCY, // Linear PCM, low latency requested. | 76 AUDIO_PCM_LOW_LATENCY, // Linear PCM, low latency requested. |
77 AUDIO_RAW_AC3, // Raw compressed AC3 bitstream. | |
78 AUDIO_RAW_EAC3, // Raw compressed E-AC3 bitstream. | |
75 AUDIO_FAKE, // Creates a fake AudioOutputStream object. | 79 AUDIO_FAKE, // Creates a fake AudioOutputStream object. |
76 AUDIO_FORMAT_LAST = AUDIO_FAKE, // Only used for validation of format. | 80 AUDIO_FORMAT_LAST = AUDIO_FAKE, // Only used for validation of format. |
77 }; | 81 }; |
78 | 82 |
79 enum { | 83 enum { |
80 // Telephone quality sample rate, mostly for speech-only audio. | 84 // Telephone quality sample rate, mostly for speech-only audio. |
81 kTelephoneSampleRate = 8000, | 85 kTelephoneSampleRate = 8000, |
82 // CD sampling rate is 44.1 KHz or conveniently 2x2x3x3x5x5x7x7. | 86 // CD sampling rate is 44.1 KHz or conveniently 2x2x3x3x5x5x7x7. |
83 kAudioCDSampleRate = 44100, | 87 kAudioCDSampleRate = 44100, |
84 }; | 88 }; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 // can lead to audio/video sync drift. | 136 // can lead to audio/video sync drift. |
133 double GetMicrosecondsPerFrame() const; | 137 double GetMicrosecondsPerFrame() const; |
134 | 138 |
135 // Returns the duration of this buffer as calculated from frames_per_buffer() | 139 // Returns the duration of this buffer as calculated from frames_per_buffer() |
136 // and sample_rate(). | 140 // and sample_rate(). |
137 base::TimeDelta GetBufferDuration() const; | 141 base::TimeDelta GetBufferDuration() const; |
138 | 142 |
139 // Comparison with other AudioParams. | 143 // Comparison with other AudioParams. |
140 bool Equals(const AudioParameters& other) const; | 144 bool Equals(const AudioParameters& other) const; |
141 | 145 |
146 // Return true if |format_| is raw compressed audio. | |
147 bool IsRawFormat() const { | |
DaleCurtis
2016/11/01 23:05:13
Inline method must be hacker_style().
AndyWu
2016/11/04 18:04:24
Done.
| |
148 return format_ == AUDIO_RAW_AC3 || format_ == AUDIO_RAW_EAC3; | |
149 } | |
150 | |
142 void set_format(Format format) { format_ = format; } | 151 void set_format(Format format) { format_ = format; } |
143 Format format() const { return format_; } | 152 Format format() const { return format_; } |
144 | 153 |
145 // A setter for channel_layout_ is intentionally excluded. | 154 // A setter for channel_layout_ is intentionally excluded. |
146 ChannelLayout channel_layout() const { return channel_layout_; } | 155 ChannelLayout channel_layout() const { return channel_layout_; } |
147 | 156 |
148 // The number of channels is usually computed from channel_layout_. Setting | 157 // The number of channels is usually computed from channel_layout_. Setting |
149 // this explictly is only required with CHANNEL_LAYOUT_DISCRETE. | 158 // this explictly is only required with CHANNEL_LAYOUT_DISCRETE. |
150 void set_channels_for_discrete(int channels) { | 159 void set_channels_for_discrete(int channels) { |
151 DCHECK(channel_layout_ == CHANNEL_LAYOUT_DISCRETE || | 160 DCHECK(channel_layout_ == CHANNEL_LAYOUT_DISCRETE || |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 if (a.sample_rate() != b.sample_rate()) | 232 if (a.sample_rate() != b.sample_rate()) |
224 return a.sample_rate() < b.sample_rate(); | 233 return a.sample_rate() < b.sample_rate(); |
225 if (a.bits_per_sample() != b.bits_per_sample()) | 234 if (a.bits_per_sample() != b.bits_per_sample()) |
226 return a.bits_per_sample() < b.bits_per_sample(); | 235 return a.bits_per_sample() < b.bits_per_sample(); |
227 return a.frames_per_buffer() < b.frames_per_buffer(); | 236 return a.frames_per_buffer() < b.frames_per_buffer(); |
228 } | 237 } |
229 | 238 |
230 } // namespace media | 239 } // namespace media |
231 | 240 |
232 #endif // MEDIA_BASE_AUDIO_PARAMETERS_H_ | 241 #endif // MEDIA_BASE_AUDIO_PARAMETERS_H_ |
OLD | NEW |