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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "media/base/channel_layout.h" | 13 #include "media/base/channel_layout.h" |
14 #include "media/base/encryption_scheme.h" | |
14 #include "media/base/media_export.h" | 15 #include "media/base/media_export.h" |
15 #include "media/base/sample_format.h" | 16 #include "media/base/sample_format.h" |
16 | 17 |
17 namespace media { | 18 namespace media { |
18 | 19 |
19 enum AudioCodec { | 20 enum AudioCodec { |
20 // These values are histogrammed over time; do not change their ordinal | 21 // These values are histogrammed over time; do not change their ordinal |
21 // values. When deleting a codec replace it with a dummy value; when adding a | 22 // values. When deleting a codec replace it with a dummy value; when adding a |
22 // codec, do so at the bottom before kAudioCodecMax, and update the value of | 23 // codec, do so at the bottom before kAudioCodecMax, and update the value of |
23 // kAudioCodecMax to equal the new codec. | 24 // kAudioCodecMax to equal the new codec. |
(...skipping 30 matching lines...) Expand all Loading... | |
54 // Constructs an uninitialized object. Clients should call Initialize() with | 55 // Constructs an uninitialized object. Clients should call Initialize() with |
55 // appropriate values before using. | 56 // appropriate values before using. |
56 AudioDecoderConfig(); | 57 AudioDecoderConfig(); |
57 | 58 |
58 // Constructs an initialized object. | 59 // Constructs an initialized object. |
59 AudioDecoderConfig(AudioCodec codec, | 60 AudioDecoderConfig(AudioCodec codec, |
60 SampleFormat sample_format, | 61 SampleFormat sample_format, |
61 ChannelLayout channel_layout, | 62 ChannelLayout channel_layout, |
62 int samples_per_second, | 63 int samples_per_second, |
63 const std::vector<uint8_t>& extra_data, | 64 const std::vector<uint8_t>& extra_data, |
64 bool is_encrypted); | 65 const EncryptionScheme& encryption_scheme); |
65 | 66 |
66 ~AudioDecoderConfig(); | 67 ~AudioDecoderConfig(); |
67 | 68 |
68 // Resets the internal state of this object. |codec_delay| is in frames. | 69 // Resets the internal state of this object. |codec_delay| is in frames. |
69 void Initialize(AudioCodec codec, | 70 void Initialize(AudioCodec codec, |
70 SampleFormat sample_format, | 71 SampleFormat sample_format, |
71 ChannelLayout channel_layout, | 72 ChannelLayout channel_layout, |
72 int samples_per_second, | 73 int samples_per_second, |
73 const std::vector<uint8>& extra_data, | 74 const std::vector<uint8>& extra_data, |
74 bool is_encrypted, | 75 const EncryptionScheme& encryption_scheme, |
75 base::TimeDelta seek_preroll, | 76 base::TimeDelta seek_preroll, |
76 int codec_delay); | 77 int codec_delay); |
77 | 78 |
78 // Returns true if this object has appropriate configuration values, false | 79 // Returns true if this object has appropriate configuration values, false |
79 // otherwise. | 80 // otherwise. |
80 bool IsValidConfig() const; | 81 bool IsValidConfig() const; |
81 | 82 |
82 // Returns true if all fields in |config| match this config. | 83 // Returns true if all fields in |config| match this config. |
83 // Note: The contents of |extra_data_| are compared not the raw pointers. | 84 // Note: The contents of |extra_data_| are compared not the raw pointers. |
84 bool Matches(const AudioDecoderConfig& config) const; | 85 bool Matches(const AudioDecoderConfig& config) const; |
(...skipping 14 matching lines...) Expand all Loading... | |
99 base::TimeDelta seek_preroll() const { return seek_preroll_; } | 100 base::TimeDelta seek_preroll() const { return seek_preroll_; } |
100 int codec_delay() const { return codec_delay_; } | 101 int codec_delay() const { return codec_delay_; } |
101 | 102 |
102 // Optional byte data required to initialize audio decoders such as Vorbis | 103 // Optional byte data required to initialize audio decoders such as Vorbis |
103 // codebooks. | 104 // codebooks. |
104 const std::vector<uint8_t>& extra_data() const { return extra_data_; } | 105 const std::vector<uint8_t>& extra_data() const { return extra_data_; } |
105 | 106 |
106 // Whether the audio stream is potentially encrypted. | 107 // Whether the audio stream is potentially encrypted. |
107 // Note that in a potentially encrypted audio stream, individual buffers | 108 // Note that in a potentially encrypted audio stream, individual buffers |
108 // can be encrypted or not encrypted. | 109 // can be encrypted or not encrypted. |
109 bool is_encrypted() const { return is_encrypted_; } | 110 bool is_encrypted() const { return encryption_scheme_.is_encrypted(); } |
ddorwin
2015/12/10 18:36:00
As mentioned earlier, I think this might be hiding
ddorwin
2015/12/10 18:36:00
Again, unclear if this is a "simple accessor."
dougsteed
2015/12/14 21:19:01
I don't know all the usages of this class, and I d
| |
111 | |
112 // Encryption scheme used for encrypted buffers. | |
113 const EncryptionScheme& encryption_scheme() const { | |
114 return encryption_scheme_; | |
115 } | |
110 | 116 |
111 private: | 117 private: |
112 AudioCodec codec_; | 118 AudioCodec codec_; |
113 SampleFormat sample_format_; | 119 SampleFormat sample_format_; |
114 int bytes_per_channel_; | 120 int bytes_per_channel_; |
115 ChannelLayout channel_layout_; | 121 ChannelLayout channel_layout_; |
116 int samples_per_second_; | 122 int samples_per_second_; |
117 int bytes_per_frame_; | 123 int bytes_per_frame_; |
118 std::vector<uint8_t> extra_data_; | 124 std::vector<uint8_t> extra_data_; |
119 bool is_encrypted_; | 125 EncryptionScheme encryption_scheme_; |
120 | 126 |
121 // |seek_preroll_| is the duration of the data that the decoder must decode | 127 // |seek_preroll_| is the duration of the data that the decoder must decode |
122 // before the decoded data is valid. | 128 // before the decoded data is valid. |
123 base::TimeDelta seek_preroll_; | 129 base::TimeDelta seek_preroll_; |
124 | 130 |
125 // |codec_delay_| is the number of frames the decoder should discard before | 131 // |codec_delay_| is the number of frames the decoder should discard before |
126 // returning decoded data. This value can include both decoder delay as well | 132 // returning decoded data. This value can include both decoder delay as well |
127 // as padding added during encoding. | 133 // as padding added during encoding. |
128 int codec_delay_; | 134 int codec_delay_; |
129 | 135 |
130 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler | 136 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler |
131 // generated copy constructor and assignment operator. Since the extra data is | 137 // generated copy constructor and assignment operator. Since the extra data is |
132 // typically small, the performance impact is minimal. | 138 // typically small, the performance impact is minimal. |
133 }; | 139 }; |
134 | 140 |
135 } // namespace media | 141 } // namespace media |
136 | 142 |
137 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ | 143 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ |
OLD | NEW |