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 // TODO(vrk): This should probably be changed to an immutable object instead of | 12 class MEDIA_EXPORT AudioParameters { |
13 // a struct. See crbug.com/115902. | 13 public: |
14 struct MEDIA_EXPORT AudioParameters { | |
15 // Compare is useful when AudioParameters is used as a key in std::map. | 14 // Compare is useful when AudioParameters is used as a key in std::map. |
16 class MEDIA_EXPORT Compare { | 15 class MEDIA_EXPORT Compare { |
17 public: | 16 public: |
18 bool operator()(const AudioParameters& a, const AudioParameters& b) const; | 17 bool operator()(const AudioParameters& a, const AudioParameters& b) const; |
19 }; | 18 }; |
20 | 19 |
21 enum Format { | 20 enum Format { |
22 AUDIO_PCM_LINEAR = 0, // PCM is 'raw' amplitude samples. | 21 AUDIO_PCM_LINEAR = 0, // PCM is 'raw' amplitude samples. |
23 AUDIO_PCM_LOW_LATENCY, // Linear PCM, low latency requested. | 22 AUDIO_PCM_LOW_LATENCY, // Linear PCM, low latency requested. |
24 AUDIO_MOCK, // Creates a dummy AudioOutputStream object. | 23 AUDIO_MOCK, // Creates a dummy AudioOutputStream object. |
25 AUDIO_LAST_FORMAT // Only used for validation of format.y | 24 AUDIO_LAST_FORMAT // Only used for validation of format.y |
26 }; | 25 }; |
27 | 26 |
28 // Telephone quality sample rate, mostly for speech-only audio. | 27 // Telephone quality sample rate, mostly for speech-only audio. |
29 static const uint32 kTelephoneSampleRate = 8000; | 28 static const uint32 kTelephoneSampleRate = 8000; |
30 // CD sampling rate is 44.1 KHz or conveniently 2x2x3x3x5x5x7x7. | 29 // CD sampling rate is 44.1 KHz or conveniently 2x2x3x3x5x5x7x7. |
31 static const uint32 kAudioCDSampleRate = 44100; | 30 static const uint32 kAudioCDSampleRate = 44100; |
32 // Digital Audio Tape sample rate. | 31 // Digital Audio Tape sample rate. |
33 static const uint32 kAudioDATSampleRate = 48000; | 32 static const uint32 kAudioDATSampleRate = 48000; |
34 | 33 |
35 AudioParameters(); | 34 AudioParameters(); |
36 AudioParameters(Format format, ChannelLayout channel_layout, int sample_rate, | 35 AudioParameters(Format format, ChannelLayout channel_layout, |
37 int bits_per_sample, int samples_per_packet); | 36 int samples_per_second, int bits_per_sample, |
Chris Rogers
2012/03/12 20:07:13
It's incorrect to change the name "sample_rate" to
vrk (LEFT CHROMIUM)
2012/03/16 18:30:41
sample_rate it is, as per offline discussion!
| |
37 int samples_per_packet); | |
38 void Reset(Format format, ChannelLayout channel_layout, | |
39 int samples_per_second, int bits_per_sample, | |
40 int samples_per_packet); | |
38 | 41 |
39 // Checks that all values are in the expected range. All limits are specified | 42 // Checks that all values are in the expected range. All limits are specified |
40 // in media::Limits. | 43 // in media::Limits. |
41 bool IsValid() const; | 44 bool IsValid() const; |
42 | 45 |
43 // Returns size of audio packets in bytes. | 46 // Returns size of audio packets in bytes. |
44 int GetPacketSize() const; | 47 int GetPacketSize() const; |
45 | 48 |
46 // Returns the number of bytes representing one second of audio. | 49 // Returns the number of bytes representing one second of audio. |
47 int GetBytesPerSecond() const; | 50 int GetBytesPerSecond() const; |
48 | 51 |
49 Format format; // Format of the stream. | 52 Format format() const { return format_; } |
tommi (sloooow) - chröme
2012/03/10 10:11:32
Would it be worth it to have a DCHECK(IsValid()) i
vrk (LEFT CHROMIUM)
2012/03/16 18:30:41
It's a good idea that we should be doing checks wi
tommi (sloooow) - chröme
2012/03/16 20:57:39
sounds good.
| |
50 ChannelLayout channel_layout; // Order of surround sound channels. | 53 ChannelLayout channel_layout() const { return channel_layout_; } |
51 int sample_rate; // Sampling frequency/rate. | 54 int samples_per_second() const { return samples_per_second_; } |
tommi (sloooow) - chröme
2012/03/10 10:11:32
absolute nit: sample_rate()?
I realize you'd have
vrk (LEFT CHROMIUM)
2012/03/16 18:30:41
sample_rate it is, as per offline discussion!
Asi
| |
52 int bits_per_sample; // Number of bits per sample. | 55 int bits_per_sample() const { return bits_per_sample_; } |
53 int samples_per_packet; // Size of a packet in frames. | 56 int samples_per_packet() const { return samples_per_packet_; } |
57 int channels() const { return channels_; } | |
54 | 58 |
55 int channels; // Number of channels. Value set based on | 59 private: |
56 // |channel_layout|. | 60 Format format_; // Format of the stream. |
61 ChannelLayout channel_layout_; // Order of surround sound channels. | |
62 int samples_per_second_; // Sampling frequency/rate. | |
63 int bits_per_sample_; // Number of bits per sample. | |
64 int samples_per_packet_; // Size of a packet in frames. | |
65 | |
66 int channels_; // Number of channels. Value set based on | |
67 // |channel_layout|. | |
57 }; | 68 }; |
scherkus (not reviewing)
2012/03/09 21:48:59
FYI now that this is a class I want to double chec
vrk (LEFT CHROMIUM)
2012/03/16 18:30:41
Yup! Thanks for checking!
| |
58 | 69 |
59 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ | 70 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ |
OLD | NEW |