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/audio_codecs.h" | 15 #include "media/base/audio_codecs.h" |
16 #include "media/base/channel_layout.h" | 16 #include "media/base/channel_layout.h" |
17 #include "media/base/encryption_scheme.h" | |
17 #include "media/base/media_export.h" | 18 #include "media/base/media_export.h" |
18 #include "media/base/sample_format.h" | 19 #include "media/base/sample_format.h" |
19 | 20 |
20 namespace media { | 21 namespace media { |
21 | 22 |
22 // TODO(dalecurtis): FFmpeg API uses |bytes_per_channel| instead of | 23 // TODO(dalecurtis): FFmpeg API uses |bytes_per_channel| instead of |
23 // |bits_per_channel|, we should switch over since bits are generally confusing | 24 // |bits_per_channel|, we should switch over since bits are generally confusing |
24 // to work with. | 25 // to work with. |
25 class MEDIA_EXPORT AudioDecoderConfig { | 26 class MEDIA_EXPORT AudioDecoderConfig { |
26 public: | 27 public: |
27 // Constructs an uninitialized object. Clients should call Initialize() with | 28 // Constructs an uninitialized object. Clients should call Initialize() with |
28 // appropriate values before using. | 29 // appropriate values before using. |
29 AudioDecoderConfig(); | 30 AudioDecoderConfig(); |
30 | 31 |
31 // Constructs an initialized object. | 32 // Constructs an initialized object. |
32 AudioDecoderConfig(AudioCodec codec, | 33 AudioDecoderConfig(AudioCodec codec, |
33 SampleFormat sample_format, | 34 SampleFormat sample_format, |
34 ChannelLayout channel_layout, | 35 ChannelLayout channel_layout, |
35 int samples_per_second, | 36 int samples_per_second, |
36 const std::vector<uint8_t>& extra_data, | 37 const std::vector<uint8_t>& extra_data, |
37 bool is_encrypted); | 38 const EncryptionScheme& encryption_scheme); |
38 | 39 |
39 AudioDecoderConfig(const AudioDecoderConfig& other); | 40 AudioDecoderConfig(const AudioDecoderConfig& other); |
40 | 41 |
41 ~AudioDecoderConfig(); | 42 ~AudioDecoderConfig(); |
42 | 43 |
43 // Resets the internal state of this object. |codec_delay| is in frames. | 44 // Resets the internal state of this object. |codec_delay| is in frames. |
44 void Initialize(AudioCodec codec, | 45 void Initialize(AudioCodec codec, |
45 SampleFormat sample_format, | 46 SampleFormat sample_format, |
46 ChannelLayout channel_layout, | 47 ChannelLayout channel_layout, |
47 int samples_per_second, | 48 int samples_per_second, |
48 const std::vector<uint8_t>& extra_data, | 49 const std::vector<uint8_t>& extra_data, |
49 bool is_encrypted, | 50 const EncryptionScheme& encryption_scheme, |
50 base::TimeDelta seek_preroll, | 51 base::TimeDelta seek_preroll, |
51 int codec_delay); | 52 int codec_delay); |
52 | 53 |
53 // Returns true if this object has appropriate configuration values, false | 54 // Returns true if this object has appropriate configuration values, false |
54 // otherwise. | 55 // otherwise. |
55 bool IsValidConfig() const; | 56 bool IsValidConfig() const; |
56 | 57 |
57 // Returns true if all fields in |config| match this config. | 58 // Returns true if all fields in |config| match this config. |
58 // 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. |
59 bool Matches(const AudioDecoderConfig& config) const; | 60 bool Matches(const AudioDecoderConfig& config) const; |
(...skipping 12 matching lines...) Expand all Loading... | |
72 base::TimeDelta seek_preroll() const { return seek_preroll_; } | 73 base::TimeDelta seek_preroll() const { return seek_preroll_; } |
73 int codec_delay() const { return codec_delay_; } | 74 int codec_delay() const { return codec_delay_; } |
74 | 75 |
75 // Optional byte data required to initialize audio decoders such as Vorbis | 76 // Optional byte data required to initialize audio decoders such as Vorbis |
76 // codebooks. | 77 // codebooks. |
77 const std::vector<uint8_t>& extra_data() const { return extra_data_; } | 78 const std::vector<uint8_t>& extra_data() const { return extra_data_; } |
78 | 79 |
79 // Whether the audio stream is potentially encrypted. | 80 // Whether the audio stream is potentially encrypted. |
80 // Note that in a potentially encrypted audio stream, individual buffers | 81 // Note that in a potentially encrypted audio stream, individual buffers |
81 // can be encrypted or not encrypted. | 82 // can be encrypted or not encrypted. |
82 bool is_encrypted() const { return is_encrypted_; } | 83 bool is_encrypted() const; |
ddorwin
2016/03/02 23:24:05
From PS13: I guess we should look for places where
dougsteed
2016/03/03 04:45:00
OK, I'll scan through all instances with that in m
ddorwin
2016/03/03 18:38:04
Thanks.
Those should three be fine since we only
dougsteed
2016/03/04 19:07:29
In many cases the test uses a boolean to decide wh
| |
84 | |
85 // Encryption scheme used for encrypted buffers. | |
86 const EncryptionScheme& encryption_scheme() const { | |
87 return encryption_scheme_; | |
88 } | |
83 | 89 |
84 private: | 90 private: |
85 AudioCodec codec_; | 91 AudioCodec codec_; |
86 SampleFormat sample_format_; | 92 SampleFormat sample_format_; |
87 int bytes_per_channel_; | 93 int bytes_per_channel_; |
88 ChannelLayout channel_layout_; | 94 ChannelLayout channel_layout_; |
89 int samples_per_second_; | 95 int samples_per_second_; |
90 int bytes_per_frame_; | 96 int bytes_per_frame_; |
91 std::vector<uint8_t> extra_data_; | 97 std::vector<uint8_t> extra_data_; |
92 bool is_encrypted_; | 98 EncryptionScheme encryption_scheme_; |
93 | 99 |
94 // |seek_preroll_| is the duration of the data that the decoder must decode | 100 // |seek_preroll_| is the duration of the data that the decoder must decode |
95 // before the decoded data is valid. | 101 // before the decoded data is valid. |
96 base::TimeDelta seek_preroll_; | 102 base::TimeDelta seek_preroll_; |
97 | 103 |
98 // |codec_delay_| is the number of frames the decoder should discard before | 104 // |codec_delay_| is the number of frames the decoder should discard before |
99 // returning decoded data. This value can include both decoder delay as well | 105 // returning decoded data. This value can include both decoder delay as well |
100 // as padding added during encoding. | 106 // as padding added during encoding. |
101 int codec_delay_; | 107 int codec_delay_; |
102 | 108 |
103 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler | 109 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler |
104 // generated copy constructor and assignment operator. Since the extra data is | 110 // generated copy constructor and assignment operator. Since the extra data is |
105 // typically small, the performance impact is minimal. | 111 // typically small, the performance impact is minimal. |
106 }; | 112 }; |
107 | 113 |
108 } // namespace media | 114 } // namespace media |
109 | 115 |
110 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ | 116 #endif // MEDIA_BASE_AUDIO_DECODER_CONFIG_H_ |
OLD | NEW |