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 <vector> |
| 9 |
8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "media/base/channel_layout.h" | 11 #include "media/base/channel_layout.h" |
11 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
12 | 13 |
13 namespace media { | 14 namespace media { |
14 | 15 |
15 enum AudioCodec { | 16 enum AudioCodec { |
16 // These values are histogrammed over time; do not change their ordinal | 17 // These values are histogrammed over time; do not change their ordinal |
17 // values. When deleting a codec replace it with a dummy value; when adding a | 18 // values. When deleting a codec replace it with a dummy value; when adding a |
18 // codec, do so at the bottom before kAudioCodecMax. | 19 // codec, do so at the bottom before kAudioCodecMax. |
19 kUnknownAudioCodec = 0, | 20 kUnknownAudioCodec = 0, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 bool is_encrypted); | 72 bool is_encrypted); |
72 | 73 |
73 ~AudioDecoderConfig(); | 74 ~AudioDecoderConfig(); |
74 | 75 |
75 // Resets the internal state of this object. | 76 // Resets the internal state of this object. |
76 void Initialize(AudioCodec codec, SampleFormat sample_format, | 77 void Initialize(AudioCodec codec, SampleFormat sample_format, |
77 ChannelLayout channel_layout, int samples_per_second, | 78 ChannelLayout channel_layout, int samples_per_second, |
78 const uint8* extra_data, size_t extra_data_size, | 79 const uint8* extra_data, size_t extra_data_size, |
79 bool is_encrypted, bool record_stats); | 80 bool is_encrypted, bool record_stats); |
80 | 81 |
81 // Deep copies |audio_config|. | |
82 void CopyFrom(const AudioDecoderConfig& audio_config); | |
83 | |
84 // Returns true if this object has appropriate configuration values, false | 82 // Returns true if this object has appropriate configuration values, false |
85 // otherwise. | 83 // otherwise. |
86 bool IsValidConfig() const; | 84 bool IsValidConfig() const; |
87 | 85 |
88 // Returns true if all fields in |config| match this config. | 86 // Returns true if all fields in |config| match this config. |
89 // Note: The contents of |extra_data_| are compared not the raw pointers. | 87 // Note: The contents of |extra_data_| are compared not the raw pointers. |
90 bool Matches(const AudioDecoderConfig& config) const; | 88 bool Matches(const AudioDecoderConfig& config) const; |
91 | 89 |
92 AudioCodec codec() const { return codec_; } | 90 AudioCodec codec() const { return codec_; } |
93 int bits_per_channel() const { return bits_per_channel_; } | 91 int bits_per_channel() const { return bits_per_channel_; } |
94 ChannelLayout channel_layout() const { return channel_layout_; } | 92 ChannelLayout channel_layout() const { return channel_layout_; } |
95 int samples_per_second() const { return samples_per_second_; } | 93 int samples_per_second() const { return samples_per_second_; } |
96 SampleFormat sample_format() const { return sample_format_; } | 94 SampleFormat sample_format() const { return sample_format_; } |
97 int bytes_per_frame() const { return bytes_per_frame_; } | 95 int bytes_per_frame() const { return bytes_per_frame_; } |
98 | 96 |
99 // Optional byte data required to initialize audio decoders such as Vorbis | 97 // Optional byte data required to initialize audio decoders such as Vorbis |
100 // codebooks. | 98 // codebooks. |
101 uint8* extra_data() const { return extra_data_.get(); } | 99 const uint8* extra_data() const { |
102 size_t extra_data_size() const { return extra_data_size_; } | 100 return extra_data_.empty() ? NULL : &extra_data_[0]; |
| 101 } |
| 102 size_t extra_data_size() const { return extra_data_.size(); } |
103 | 103 |
104 // Whether the audio stream is potentially encrypted. | 104 // Whether the audio stream is potentially encrypted. |
105 // Note that in a potentially encrypted audio stream, individual buffers | 105 // Note that in a potentially encrypted audio stream, individual buffers |
106 // can be encrypted or not encrypted. | 106 // can be encrypted or not encrypted. |
107 bool is_encrypted() const { return is_encrypted_; } | 107 bool is_encrypted() const { return is_encrypted_; } |
108 | 108 |
109 private: | 109 private: |
110 AudioCodec codec_; | 110 AudioCodec codec_; |
111 SampleFormat sample_format_; | 111 SampleFormat sample_format_; |
112 int bits_per_channel_; | 112 int bits_per_channel_; |
113 ChannelLayout channel_layout_; | 113 ChannelLayout channel_layout_; |
114 int samples_per_second_; | 114 int samples_per_second_; |
115 int bytes_per_frame_; | 115 int bytes_per_frame_; |
116 | 116 std::vector<uint8> extra_data_; |
117 scoped_array<uint8> extra_data_; | |
118 size_t extra_data_size_; | |
119 | |
120 bool is_encrypted_; | 117 bool is_encrypted_; |
121 | 118 |
122 DISALLOW_COPY_AND_ASSIGN(AudioDecoderConfig); | 119 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler |
| 120 // generated copy constructor and assignment operator. Since the extra data is |
| 121 // typically small, the performance impact is minimal. |
123 }; | 122 }; |
124 | 123 |
125 } // namespace media | 124 } // namespace media |
126 | 125 |
127 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ | 126 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ |
OLD | NEW |