Chromium Code Reviews| 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 void SetChannelsForDiscrete(int channels) { | |
|
DaleCurtis
2017/05/24 00:49:58
should be in .cc file. Should also DCHECK that is
flim-chromium
2017/05/25 00:04:25
Done.
| |
| 67 if (channel_layout_ == CHANNEL_LAYOUT_DISCRETE) { | |
| 68 channels_ = channels; | |
| 69 bytes_per_frame_ = channels_ * bytes_per_channel_; | |
| 70 } | |
| 71 } | |
| 72 | |
| 66 AudioCodec codec() const { return codec_; } | 73 AudioCodec codec() const { return codec_; } |
| 67 int bits_per_channel() const { return bytes_per_channel_ * 8; } | 74 int bits_per_channel() const { return bytes_per_channel_ * 8; } |
| 68 int bytes_per_channel() const { return bytes_per_channel_; } | 75 int bytes_per_channel() const { return bytes_per_channel_; } |
| 69 ChannelLayout channel_layout() const { return channel_layout_; } | 76 ChannelLayout channel_layout() const { return channel_layout_; } |
| 77 int channels() const { return channels_; } | |
| 70 int samples_per_second() const { return samples_per_second_; } | 78 int samples_per_second() const { return samples_per_second_; } |
| 71 SampleFormat sample_format() const { return sample_format_; } | 79 SampleFormat sample_format() const { return sample_format_; } |
| 72 int bytes_per_frame() const { return bytes_per_frame_; } | 80 int bytes_per_frame() const { return bytes_per_frame_; } |
| 73 base::TimeDelta seek_preroll() const { return seek_preroll_; } | 81 base::TimeDelta seek_preroll() const { return seek_preroll_; } |
| 74 int codec_delay() const { return codec_delay_; } | 82 int codec_delay() const { return codec_delay_; } |
| 75 | 83 |
| 76 // Optional byte data required to initialize audio decoders such as Vorbis | 84 // Optional byte data required to initialize audio decoders such as Vorbis |
| 77 // codebooks. | 85 // codebooks. |
| 78 const std::vector<uint8_t>& extra_data() const { return extra_data_; } | 86 const std::vector<uint8_t>& extra_data() const { return extra_data_; } |
| 79 | 87 |
| 80 // Whether the audio stream is potentially encrypted. | 88 // Whether the audio stream is potentially encrypted. |
| 81 // Note that in a potentially encrypted audio stream, individual buffers | 89 // Note that in a potentially encrypted audio stream, individual buffers |
| 82 // can be encrypted or not encrypted. | 90 // can be encrypted or not encrypted. |
| 83 bool is_encrypted() const { return encryption_scheme_.is_encrypted(); } | 91 bool is_encrypted() const { return encryption_scheme_.is_encrypted(); } |
| 84 | 92 |
| 85 // Encryption scheme used for encrypted buffers. | 93 // Encryption scheme used for encrypted buffers. |
| 86 const EncryptionScheme& encryption_scheme() const { | 94 const EncryptionScheme& encryption_scheme() const { |
| 87 return encryption_scheme_; | 95 return encryption_scheme_; |
| 88 } | 96 } |
| 89 | 97 |
| 90 // Sets the config to be encrypted or not encrypted manually. This can be | 98 // 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. | 99 // useful for decryptors that decrypts an encrypted stream to a clear stream. |
| 92 void SetIsEncrypted(bool is_encrypted); | 100 void SetIsEncrypted(bool is_encrypted); |
| 93 | 101 |
| 94 private: | 102 private: |
| 95 AudioCodec codec_; | 103 AudioCodec codec_; |
| 96 SampleFormat sample_format_; | 104 SampleFormat sample_format_; |
| 97 int bytes_per_channel_; | 105 int bytes_per_channel_; |
| 98 ChannelLayout channel_layout_; | 106 ChannelLayout channel_layout_; |
| 107 int channels_; | |
| 99 int samples_per_second_; | 108 int samples_per_second_; |
| 100 int bytes_per_frame_; | 109 int bytes_per_frame_; |
| 101 std::vector<uint8_t> extra_data_; | 110 std::vector<uint8_t> extra_data_; |
| 102 EncryptionScheme encryption_scheme_; | 111 EncryptionScheme encryption_scheme_; |
| 103 | 112 |
| 104 // |seek_preroll_| is the duration of the data that the decoder must decode | 113 // |seek_preroll_| is the duration of the data that the decoder must decode |
| 105 // before the decoded data is valid. | 114 // before the decoded data is valid. |
| 106 base::TimeDelta seek_preroll_; | 115 base::TimeDelta seek_preroll_; |
| 107 | 116 |
| 108 // |codec_delay_| is the number of frames the decoder should discard before | 117 // |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 | 118 // returning decoded data. This value can include both decoder delay as well |
| 110 // as padding added during encoding. | 119 // as padding added during encoding. |
| 111 int codec_delay_; | 120 int codec_delay_; |
| 112 | 121 |
| 113 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler | 122 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler |
| 114 // generated copy constructor and assignment operator. Since the extra data is | 123 // generated copy constructor and assignment operator. Since the extra data is |
| 115 // typically small, the performance impact is minimal. | 124 // typically small, the performance impact is minimal. |
| 116 }; | 125 }; |
| 117 | 126 |
| 118 } // namespace media | 127 } // namespace media |
| 119 | 128 |
| 120 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ | 129 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ |
| OLD | NEW |