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 set_channels_for_discrete(int channels) { | |
|
DaleCurtis
2017/03/20 17:38:58
Should be SetChannelsForDiscrete(), since hacker_s
flim-chromium
2017/03/22 06:20:50
Done.
| |
| 67 DCHECK(channel_layout_ == CHANNEL_LAYOUT_DISCRETE || | |
| 68 channels == ChannelLayoutToChannelCount(channel_layout_)); | |
| 69 channels_ = channels; | |
| 70 bytes_per_frame_= channels_ * bytes_per_channel_; | |
| 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 private: | 98 private: |
| 91 AudioCodec codec_; | 99 AudioCodec codec_; |
| 92 SampleFormat sample_format_; | 100 SampleFormat sample_format_; |
| 93 int bytes_per_channel_; | 101 int bytes_per_channel_; |
| 94 ChannelLayout channel_layout_; | 102 ChannelLayout channel_layout_; |
| 103 int channels_; | |
| 95 int samples_per_second_; | 104 int samples_per_second_; |
| 96 int bytes_per_frame_; | 105 int bytes_per_frame_; |
| 97 std::vector<uint8_t> extra_data_; | 106 std::vector<uint8_t> extra_data_; |
| 98 EncryptionScheme encryption_scheme_; | 107 EncryptionScheme encryption_scheme_; |
| 99 | 108 |
| 100 // |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 |
| 101 // before the decoded data is valid. | 110 // before the decoded data is valid. |
| 102 base::TimeDelta seek_preroll_; | 111 base::TimeDelta seek_preroll_; |
| 103 | 112 |
| 104 // |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 |
| 105 // 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 |
| 106 // as padding added during encoding. | 115 // as padding added during encoding. |
| 107 int codec_delay_; | 116 int codec_delay_; |
| 108 | 117 |
| 109 // 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 |
| 110 // generated copy constructor and assignment operator. Since the extra data is | 119 // generated copy constructor and assignment operator. Since the extra data is |
| 111 // typically small, the performance impact is minimal. | 120 // typically small, the performance impact is minimal. |
| 112 }; | 121 }; |
| 113 | 122 |
| 114 } // namespace media | 123 } // namespace media |
| 115 | 124 |
| 116 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ | 125 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ |
| OLD | NEW |