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/logging.h" | |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
15 #include "media/base/audio_codecs.h" | 16 #include "media/base/audio_codecs.h" |
16 #include "media/base/channel_layout.h" | 17 #include "media/base/channel_layout.h" |
17 #include "media/base/encryption_scheme.h" | 18 #include "media/base/encryption_scheme.h" |
18 #include "media/base/media_export.h" | 19 #include "media/base/media_export.h" |
20 #include "media/base/media_util.h" | |
19 #include "media/base/sample_format.h" | 21 #include "media/base/sample_format.h" |
20 | 22 |
21 namespace media { | 23 namespace media { |
22 | 24 |
23 // TODO(dalecurtis): FFmpeg API uses |bytes_per_channel| instead of | 25 // TODO(dalecurtis): FFmpeg API uses |bytes_per_channel| instead of |
24 // |bits_per_channel|, we should switch over since bits are generally confusing | 26 // |bits_per_channel|, we should switch over since bits are generally confusing |
25 // to work with. | 27 // to work with. |
26 class MEDIA_EXPORT AudioDecoderConfig { | 28 class MEDIA_EXPORT AudioDecoderConfig { |
27 public: | 29 public: |
28 // Constructs an uninitialized object. Clients should call Initialize() with | 30 // Constructs an uninitialized object. Clients should call Initialize() with |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 // Whether the audio stream is potentially encrypted. | 82 // Whether the audio stream is potentially encrypted. |
81 // Note that in a potentially encrypted audio stream, individual buffers | 83 // Note that in a potentially encrypted audio stream, individual buffers |
82 // can be encrypted or not encrypted. | 84 // can be encrypted or not encrypted. |
83 bool is_encrypted() const { return encryption_scheme_.is_encrypted(); } | 85 bool is_encrypted() const { return encryption_scheme_.is_encrypted(); } |
84 | 86 |
85 // Encryption scheme used for encrypted buffers. | 87 // Encryption scheme used for encrypted buffers. |
86 const EncryptionScheme& encryption_scheme() const { | 88 const EncryptionScheme& encryption_scheme() const { |
87 return encryption_scheme_; | 89 return encryption_scheme_; |
88 } | 90 } |
89 | 91 |
92 // Sets the config to be encrypted or not encrypted manually. This can be | |
DaleCurtis
2017/02/24 18:03:50
Can't use hacker_style() for such a big method; mo
xhwang
2017/02/24 18:18:15
Done.
| |
93 // useful for decryptors that decrypts an encrypted stream to a clear stream, | |
94 // or for decoder selectors that wants to select decrypting decoders instead | |
95 // of clear decoders. | |
96 void set_is_encrypted(bool is_encrypted) { | |
97 if (!is_encrypted) { | |
98 DCHECK(encryption_scheme_.is_encrypted()) << "Config is already clear."; | |
99 encryption_scheme_ = Unencrypted(); | |
100 } else { | |
101 DCHECK(!encryption_scheme_.is_encrypted()) | |
102 << "Config is already encrypted."; | |
103 // TODO(xhwang): This is only used to guide decoder selection, so set | |
104 // a common encryption scheme that should be supported by all decrypting | |
105 // decoders. We should be able to remove this when we support switching | |
106 // decoders at run time. See http://crbug.com/695595 | |
107 encryption_scheme_ = AesCtrEncryptionScheme(); | |
108 } | |
109 } | |
110 | |
90 private: | 111 private: |
91 AudioCodec codec_; | 112 AudioCodec codec_; |
92 SampleFormat sample_format_; | 113 SampleFormat sample_format_; |
93 int bytes_per_channel_; | 114 int bytes_per_channel_; |
94 ChannelLayout channel_layout_; | 115 ChannelLayout channel_layout_; |
95 int samples_per_second_; | 116 int samples_per_second_; |
96 int bytes_per_frame_; | 117 int bytes_per_frame_; |
97 std::vector<uint8_t> extra_data_; | 118 std::vector<uint8_t> extra_data_; |
98 EncryptionScheme encryption_scheme_; | 119 EncryptionScheme encryption_scheme_; |
99 | 120 |
100 // |seek_preroll_| is the duration of the data that the decoder must decode | 121 // |seek_preroll_| is the duration of the data that the decoder must decode |
101 // before the decoded data is valid. | 122 // before the decoded data is valid. |
102 base::TimeDelta seek_preroll_; | 123 base::TimeDelta seek_preroll_; |
103 | 124 |
104 // |codec_delay_| is the number of frames the decoder should discard before | 125 // |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 | 126 // returning decoded data. This value can include both decoder delay as well |
106 // as padding added during encoding. | 127 // as padding added during encoding. |
107 int codec_delay_; | 128 int codec_delay_; |
108 | 129 |
109 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler | 130 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler |
110 // generated copy constructor and assignment operator. Since the extra data is | 131 // generated copy constructor and assignment operator. Since the extra data is |
111 // typically small, the performance impact is minimal. | 132 // typically small, the performance impact is minimal. |
112 }; | 133 }; |
113 | 134 |
114 } // namespace media | 135 } // namespace media |
115 | 136 |
116 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ | 137 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ |
OLD | NEW |