| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 bool IsValidConfig() const; | 56 bool IsValidConfig() const; |
| 57 | 57 |
| 58 // Returns true if all fields in |config| match this config. | 58 // Returns true if all fields in |config| match this config. |
| 59 // Note: The contents of |extra_data_| are compared not the raw pointers. | 59 // Note: The contents of |extra_data_| are compared not the raw pointers. |
| 60 bool Matches(const AudioDecoderConfig& config) const; | 60 bool Matches(const AudioDecoderConfig& config) const; |
| 61 | 61 |
| 62 // Returns a human-readable string describing |*this|. For debugging & test | 62 // Returns a human-readable string describing |*this|. For debugging & test |
| 63 // output only. | 63 // output only. |
| 64 std::string AsHumanReadableString() const; | 64 std::string AsHumanReadableString() const; |
| 65 | 65 |
| 66 // Sets the number of channels if |channel_layout_| is CHANNEL_LAYOUT_DISCRETE |
| 67 void SetChannelsForDiscrete(int channels); |
| 68 |
| 66 AudioCodec codec() const { return codec_; } | 69 AudioCodec codec() const { return codec_; } |
| 67 int bits_per_channel() const { return bytes_per_channel_ * 8; } | 70 int bits_per_channel() const { return bytes_per_channel_ * 8; } |
| 68 int bytes_per_channel() const { return bytes_per_channel_; } | 71 int bytes_per_channel() const { return bytes_per_channel_; } |
| 69 ChannelLayout channel_layout() const { return channel_layout_; } | 72 ChannelLayout channel_layout() const { return channel_layout_; } |
| 73 int channels() const { return channels_; } |
| 70 int samples_per_second() const { return samples_per_second_; } | 74 int samples_per_second() const { return samples_per_second_; } |
| 71 SampleFormat sample_format() const { return sample_format_; } | 75 SampleFormat sample_format() const { return sample_format_; } |
| 72 int bytes_per_frame() const { return bytes_per_frame_; } | 76 int bytes_per_frame() const { return bytes_per_frame_; } |
| 73 base::TimeDelta seek_preroll() const { return seek_preroll_; } | 77 base::TimeDelta seek_preroll() const { return seek_preroll_; } |
| 74 int codec_delay() const { return codec_delay_; } | 78 int codec_delay() const { return codec_delay_; } |
| 75 | 79 |
| 76 // Optional byte data required to initialize audio decoders such as Vorbis | 80 // Optional byte data required to initialize audio decoders such as Vorbis |
| 77 // codebooks. | 81 // codebooks. |
| 78 const std::vector<uint8_t>& extra_data() const { return extra_data_; } | 82 const std::vector<uint8_t>& extra_data() const { return extra_data_; } |
| 79 | 83 |
| 80 // Whether the audio stream is potentially encrypted. | 84 // Whether the audio stream is potentially encrypted. |
| 81 // Note that in a potentially encrypted audio stream, individual buffers | 85 // Note that in a potentially encrypted audio stream, individual buffers |
| 82 // can be encrypted or not encrypted. | 86 // can be encrypted or not encrypted. |
| 83 bool is_encrypted() const { return encryption_scheme_.is_encrypted(); } | 87 bool is_encrypted() const { return encryption_scheme_.is_encrypted(); } |
| 84 | 88 |
| 85 // Encryption scheme used for encrypted buffers. | 89 // Encryption scheme used for encrypted buffers. |
| 86 const EncryptionScheme& encryption_scheme() const { | 90 const EncryptionScheme& encryption_scheme() const { |
| 87 return encryption_scheme_; | 91 return encryption_scheme_; |
| 88 } | 92 } |
| 89 | 93 |
| 90 // Sets the config to be encrypted or not encrypted manually. This can be | 94 // Sets the config to be encrypted or not encrypted manually. This can be |
| 91 // useful for decryptors that decrypts an encrypted stream to a clear stream. | 95 // useful for decryptors that decrypts an encrypted stream to a clear stream. |
| 92 void SetIsEncrypted(bool is_encrypted); | 96 void SetIsEncrypted(bool is_encrypted); |
| 93 | 97 |
| 94 private: | 98 private: |
| 95 AudioCodec codec_; | 99 AudioCodec codec_; |
| 96 SampleFormat sample_format_; | 100 SampleFormat sample_format_; |
| 97 int bytes_per_channel_; | 101 int bytes_per_channel_; |
| 98 ChannelLayout channel_layout_; | 102 ChannelLayout channel_layout_; |
| 103 int channels_; |
| 99 int samples_per_second_; | 104 int samples_per_second_; |
| 100 int bytes_per_frame_; | 105 int bytes_per_frame_; |
| 101 std::vector<uint8_t> extra_data_; | 106 std::vector<uint8_t> extra_data_; |
| 102 EncryptionScheme encryption_scheme_; | 107 EncryptionScheme encryption_scheme_; |
| 103 | 108 |
| 104 // |seek_preroll_| is the duration of the data that the decoder must decode | 109 // |seek_preroll_| is the duration of the data that the decoder must decode |
| 105 // before the decoded data is valid. | 110 // before the decoded data is valid. |
| 106 base::TimeDelta seek_preroll_; | 111 base::TimeDelta seek_preroll_; |
| 107 | 112 |
| 108 // |codec_delay_| is the number of frames the decoder should discard before | 113 // |codec_delay_| is the number of frames the decoder should discard before |
| 109 // returning decoded data. This value can include both decoder delay as well | 114 // returning decoded data. This value can include both decoder delay as well |
| 110 // as padding added during encoding. | 115 // as padding added during encoding. |
| 111 int codec_delay_; | 116 int codec_delay_; |
| 112 | 117 |
| 113 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler | 118 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler |
| 114 // generated copy constructor and assignment operator. Since the extra data is | 119 // generated copy constructor and assignment operator. Since the extra data is |
| 115 // typically small, the performance impact is minimal. | 120 // typically small, the performance impact is minimal. |
| 116 }; | 121 }; |
| 117 | 122 |
| 118 } // namespace media | 123 } // namespace media |
| 119 | 124 |
| 120 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ | 125 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ |
| OLD | NEW |