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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/time/time.h" | |
| 11 #include "media/base/channel_layout.h" | 12 #include "media/base/channel_layout.h" |
| 12 #include "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
| 13 #include "media/base/sample_format.h" | 14 #include "media/base/sample_format.h" |
| 14 | 15 |
| 15 namespace media { | 16 namespace media { |
| 16 | 17 |
| 17 enum AudioCodec { | 18 enum AudioCodec { |
| 18 // These values are histogrammed over time; do not change their ordinal | 19 // These values are histogrammed over time; do not change their ordinal |
| 19 // values. When deleting a codec replace it with a dummy value; when adding a | 20 // values. When deleting a codec replace it with a dummy value; when adding a |
| 20 // codec, do so at the bottom before kAudioCodecMax. | 21 // codec, do so at the bottom before kAudioCodecMax. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 ChannelLayout channel_layout, int samples_per_second, | 57 ChannelLayout channel_layout, int samples_per_second, |
| 57 const uint8* extra_data, size_t extra_data_size, | 58 const uint8* extra_data, size_t extra_data_size, |
| 58 bool is_encrypted); | 59 bool is_encrypted); |
| 59 | 60 |
| 60 ~AudioDecoderConfig(); | 61 ~AudioDecoderConfig(); |
| 61 | 62 |
| 62 // Resets the internal state of this object. | 63 // Resets the internal state of this object. |
| 63 void Initialize(AudioCodec codec, SampleFormat sample_format, | 64 void Initialize(AudioCodec codec, SampleFormat sample_format, |
| 64 ChannelLayout channel_layout, int samples_per_second, | 65 ChannelLayout channel_layout, int samples_per_second, |
| 65 const uint8* extra_data, size_t extra_data_size, | 66 const uint8* extra_data, size_t extra_data_size, |
| 66 bool is_encrypted, bool record_stats); | 67 bool is_encrypted, bool record_stats, |
| 68 base::TimeDelta seek_pre_roll, | |
|
acolwell GONE FROM CHROMIUM
2013/09/03 20:14:01
nit: s/seek_pre_roll/seek_preroll/ here and everyw
vignesh
2013/09/03 22:43:03
Done.
| |
| 69 base::TimeDelta codec_delay); | |
| 67 | 70 |
| 68 // Returns true if this object has appropriate configuration values, false | 71 // Returns true if this object has appropriate configuration values, false |
| 69 // otherwise. | 72 // otherwise. |
| 70 bool IsValidConfig() const; | 73 bool IsValidConfig() const; |
| 71 | 74 |
| 72 // Returns true if all fields in |config| match this config. | 75 // Returns true if all fields in |config| match this config. |
| 73 // Note: The contents of |extra_data_| are compared not the raw pointers. | 76 // Note: The contents of |extra_data_| are compared not the raw pointers. |
| 74 bool Matches(const AudioDecoderConfig& config) const; | 77 bool Matches(const AudioDecoderConfig& config) const; |
| 75 | 78 |
| 76 AudioCodec codec() const { return codec_; } | 79 AudioCodec codec() const { return codec_; } |
| 77 int bits_per_channel() const { return bytes_per_channel_ * 8; } | 80 int bits_per_channel() const { return bytes_per_channel_ * 8; } |
| 78 int bytes_per_channel() const { return bytes_per_channel_; } | 81 int bytes_per_channel() const { return bytes_per_channel_; } |
| 79 ChannelLayout channel_layout() const { return channel_layout_; } | 82 ChannelLayout channel_layout() const { return channel_layout_; } |
| 80 int samples_per_second() const { return samples_per_second_; } | 83 int samples_per_second() const { return samples_per_second_; } |
| 81 SampleFormat sample_format() const { return sample_format_; } | 84 SampleFormat sample_format() const { return sample_format_; } |
| 82 int bytes_per_frame() const { return bytes_per_frame_; } | 85 int bytes_per_frame() const { return bytes_per_frame_; } |
| 86 base::TimeDelta seek_pre_roll() const { return seek_pre_roll_; } | |
| 87 base::TimeDelta codec_delay() const { return codec_delay_; } | |
| 83 | 88 |
| 84 // Optional byte data required to initialize audio decoders such as Vorbis | 89 // Optional byte data required to initialize audio decoders such as Vorbis |
| 85 // codebooks. | 90 // codebooks. |
| 86 const uint8* extra_data() const { | 91 const uint8* extra_data() const { |
| 87 return extra_data_.empty() ? NULL : &extra_data_[0]; | 92 return extra_data_.empty() ? NULL : &extra_data_[0]; |
| 88 } | 93 } |
| 89 size_t extra_data_size() const { return extra_data_.size(); } | 94 size_t extra_data_size() const { return extra_data_.size(); } |
| 90 | 95 |
| 91 // Whether the audio stream is potentially encrypted. | 96 // Whether the audio stream is potentially encrypted. |
| 92 // Note that in a potentially encrypted audio stream, individual buffers | 97 // Note that in a potentially encrypted audio stream, individual buffers |
| 93 // can be encrypted or not encrypted. | 98 // can be encrypted or not encrypted. |
| 94 bool is_encrypted() const { return is_encrypted_; } | 99 bool is_encrypted() const { return is_encrypted_; } |
| 95 | 100 |
| 96 private: | 101 private: |
| 97 AudioCodec codec_; | 102 AudioCodec codec_; |
| 98 SampleFormat sample_format_; | 103 SampleFormat sample_format_; |
| 99 int bytes_per_channel_; | 104 int bytes_per_channel_; |
| 100 ChannelLayout channel_layout_; | 105 ChannelLayout channel_layout_; |
| 101 int samples_per_second_; | 106 int samples_per_second_; |
| 102 int bytes_per_frame_; | 107 int bytes_per_frame_; |
| 103 std::vector<uint8> extra_data_; | 108 std::vector<uint8> extra_data_; |
| 104 bool is_encrypted_; | 109 bool is_encrypted_; |
| 105 | 110 |
| 111 // |seek_pre_roll_| is the duration in nanoseconds of the data that the | |
|
acolwell GONE FROM CHROMIUM
2013/09/03 20:14:01
nit: s/nanoseconds//
vignesh
2013/09/03 22:43:03
Done.
| |
| 112 // decoder must decode before the decoded data is valid. | |
| 113 base::TimeDelta seek_pre_roll_; | |
| 114 | |
| 115 // |codec_delay_| is the overall delay overhead in nanoseconds added by the | |
|
acolwell GONE FROM CHROMIUM
2013/09/03 20:14:01
ditto
vignesh
2013/09/03 22:43:03
Done.
| |
| 116 // codec while encoding. This value should be subtracted from each block's | |
| 117 // timestamp to get the actual timestamp. | |
| 118 base::TimeDelta codec_delay_; | |
| 119 | |
| 106 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler | 120 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler |
| 107 // generated copy constructor and assignment operator. Since the extra data is | 121 // generated copy constructor and assignment operator. Since the extra data is |
| 108 // typically small, the performance impact is minimal. | 122 // typically small, the performance impact is minimal. |
| 109 }; | 123 }; |
| 110 | 124 |
| 111 } // namespace media | 125 } // namespace media |
| 112 | 126 |
| 113 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ | 127 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ |
| OLD | NEW |