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_DECODER_CONFIG_H_ | 5 #ifndef MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ |
6 #define MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ | 6 #define MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 // Constructs an initialized object. It is acceptable to pass in NULL for | 57 // Constructs an initialized object. It is acceptable to pass in NULL for |
58 // |extra_data|, otherwise the memory is copied. | 58 // |extra_data|, otherwise the memory is copied. |
59 AudioDecoderConfig(AudioCodec codec, SampleFormat sample_format, | 59 AudioDecoderConfig(AudioCodec codec, SampleFormat sample_format, |
60 ChannelLayout channel_layout, int samples_per_second, | 60 ChannelLayout channel_layout, int samples_per_second, |
61 const uint8* extra_data, size_t extra_data_size, | 61 const uint8* extra_data, size_t extra_data_size, |
62 bool is_encrypted); | 62 bool is_encrypted); |
63 | 63 |
64 ~AudioDecoderConfig(); | 64 ~AudioDecoderConfig(); |
65 | 65 |
66 // Resets the internal state of this object. | 66 // Resets the internal state of this object. |codec_delay| is in frames. |
67 void Initialize(AudioCodec codec, SampleFormat sample_format, | 67 void Initialize(AudioCodec codec, SampleFormat sample_format, |
68 ChannelLayout channel_layout, int samples_per_second, | 68 ChannelLayout channel_layout, int samples_per_second, |
69 const uint8* extra_data, size_t extra_data_size, | 69 const uint8* extra_data, size_t extra_data_size, |
70 bool is_encrypted, bool record_stats, | 70 bool is_encrypted, bool record_stats, |
71 base::TimeDelta seek_preroll, | 71 base::TimeDelta seek_preroll, |
72 base::TimeDelta codec_delay); | 72 int codec_delay); |
73 | 73 |
74 // Returns true if this object has appropriate configuration values, false | 74 // Returns true if this object has appropriate configuration values, false |
75 // otherwise. | 75 // otherwise. |
76 bool IsValidConfig() const; | 76 bool IsValidConfig() const; |
77 | 77 |
78 // Returns true if all fields in |config| match this config. | 78 // Returns true if all fields in |config| match this config. |
79 // Note: The contents of |extra_data_| are compared not the raw pointers. | 79 // Note: The contents of |extra_data_| are compared not the raw pointers. |
80 bool Matches(const AudioDecoderConfig& config) const; | 80 bool Matches(const AudioDecoderConfig& config) const; |
81 | 81 |
82 // Returns a human-readable string describing |*this|. For debugging & test | 82 // Returns a human-readable string describing |*this|. For debugging & test |
83 // output only. | 83 // output only. |
84 std::string AsHumanReadableString() const; | 84 std::string AsHumanReadableString() const; |
85 | 85 |
86 AudioCodec codec() const { return codec_; } | 86 AudioCodec codec() const { return codec_; } |
87 int bits_per_channel() const { return bytes_per_channel_ * 8; } | 87 int bits_per_channel() const { return bytes_per_channel_ * 8; } |
88 int bytes_per_channel() const { return bytes_per_channel_; } | 88 int bytes_per_channel() const { return bytes_per_channel_; } |
89 ChannelLayout channel_layout() const { return channel_layout_; } | 89 ChannelLayout channel_layout() const { return channel_layout_; } |
90 int samples_per_second() const { return samples_per_second_; } | 90 int samples_per_second() const { return samples_per_second_; } |
91 SampleFormat sample_format() const { return sample_format_; } | 91 SampleFormat sample_format() const { return sample_format_; } |
92 int bytes_per_frame() const { return bytes_per_frame_; } | 92 int bytes_per_frame() const { return bytes_per_frame_; } |
93 base::TimeDelta seek_preroll() const { return seek_preroll_; } | 93 base::TimeDelta seek_preroll() const { return seek_preroll_; } |
94 base::TimeDelta codec_delay() const { return codec_delay_; } | 94 int codec_delay() const { return codec_delay_; } |
95 | 95 |
96 // Optional byte data required to initialize audio decoders such as Vorbis | 96 // Optional byte data required to initialize audio decoders such as Vorbis |
97 // codebooks. | 97 // codebooks. |
98 const uint8* extra_data() const { | 98 const uint8* extra_data() const { |
99 return extra_data_.empty() ? NULL : &extra_data_[0]; | 99 return extra_data_.empty() ? NULL : &extra_data_[0]; |
100 } | 100 } |
101 size_t extra_data_size() const { return extra_data_.size(); } | 101 size_t extra_data_size() const { return extra_data_.size(); } |
102 | 102 |
103 // Whether the audio stream is potentially encrypted. | 103 // Whether the audio stream is potentially encrypted. |
104 // Note that in a potentially encrypted audio stream, individual buffers | 104 // Note that in a potentially encrypted audio stream, individual buffers |
105 // can be encrypted or not encrypted. | 105 // can be encrypted or not encrypted. |
106 bool is_encrypted() const { return is_encrypted_; } | 106 bool is_encrypted() const { return is_encrypted_; } |
107 | 107 |
108 private: | 108 private: |
109 AudioCodec codec_; | 109 AudioCodec codec_; |
110 SampleFormat sample_format_; | 110 SampleFormat sample_format_; |
111 int bytes_per_channel_; | 111 int bytes_per_channel_; |
112 ChannelLayout channel_layout_; | 112 ChannelLayout channel_layout_; |
113 int samples_per_second_; | 113 int samples_per_second_; |
114 int bytes_per_frame_; | 114 int bytes_per_frame_; |
115 std::vector<uint8> extra_data_; | 115 std::vector<uint8> extra_data_; |
116 bool is_encrypted_; | 116 bool is_encrypted_; |
117 | 117 |
118 // |seek_preroll_| is the duration of the data that the decoder must decode | 118 // |seek_preroll_| is the duration of the data that the decoder must decode |
119 // before the decoded data is valid. | 119 // before the decoded data is valid. |
120 base::TimeDelta seek_preroll_; | 120 base::TimeDelta seek_preroll_; |
121 | 121 |
122 // |codec_delay_| is the overall delay overhead added by the codec while | 122 // |codec_delay_| is the number of frames the decoder should discard before |
123 // encoding. This value should be subtracted from each block's timestamp to | 123 // returning decoded data. This value can include both decoder delay as well |
124 // get the actual timestamp. | 124 // as padding added during encoding. |
125 base::TimeDelta codec_delay_; | 125 int codec_delay_; |
126 | 126 |
127 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler | 127 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler |
128 // generated copy constructor and assignment operator. Since the extra data is | 128 // generated copy constructor and assignment operator. Since the extra data is |
129 // typically small, the performance impact is minimal. | 129 // typically small, the performance impact is minimal. |
130 }; | 130 }; |
131 | 131 |
132 } // namespace media | 132 } // namespace media |
133 | 133 |
134 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ | 134 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ |
OLD | NEW |