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