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 #include "media/base/audio_decoder_config.h" | 5 #include "media/base/audio_decoder_config.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/base/limits.h" | 8 #include "media/base/limits.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 return ""; | 49 return ""; |
50 } | 50 } |
51 | 51 |
52 AudioDecoderConfig::AudioDecoderConfig() | 52 AudioDecoderConfig::AudioDecoderConfig() |
53 : codec_(kUnknownAudioCodec), | 53 : codec_(kUnknownAudioCodec), |
54 sample_format_(kUnknownSampleFormat), | 54 sample_format_(kUnknownSampleFormat), |
55 bytes_per_channel_(0), | 55 bytes_per_channel_(0), |
56 channel_layout_(CHANNEL_LAYOUT_UNSUPPORTED), | 56 channel_layout_(CHANNEL_LAYOUT_UNSUPPORTED), |
57 samples_per_second_(0), | 57 samples_per_second_(0), |
58 bytes_per_frame_(0), | 58 bytes_per_frame_(0), |
59 is_encrypted_(false), | 59 encryption_scheme_(false), |
ddorwin
2016/03/01 02:17:41
default constructor or EncryptionScheme::unencrypt
dougsteed
2016/03/02 18:07:52
Done.
| |
60 codec_delay_(0) { | 60 codec_delay_(0) {} |
61 } | |
62 | 61 |
63 AudioDecoderConfig::AudioDecoderConfig(AudioCodec codec, | 62 AudioDecoderConfig::AudioDecoderConfig( |
64 SampleFormat sample_format, | 63 AudioCodec codec, |
65 ChannelLayout channel_layout, | 64 SampleFormat sample_format, |
66 int samples_per_second, | 65 ChannelLayout channel_layout, |
67 const std::vector<uint8_t>& extra_data, | 66 int samples_per_second, |
68 bool is_encrypted) { | 67 const std::vector<uint8_t>& extra_data, |
68 const EncryptionScheme& encryption_scheme) { | |
69 Initialize(codec, sample_format, channel_layout, samples_per_second, | 69 Initialize(codec, sample_format, channel_layout, samples_per_second, |
70 extra_data, is_encrypted, base::TimeDelta(), 0); | 70 extra_data, encryption_scheme, base::TimeDelta(), 0); |
71 } | 71 } |
72 | 72 |
73 void AudioDecoderConfig::Initialize(AudioCodec codec, | 73 void AudioDecoderConfig::Initialize(AudioCodec codec, |
74 SampleFormat sample_format, | 74 SampleFormat sample_format, |
75 ChannelLayout channel_layout, | 75 ChannelLayout channel_layout, |
76 int samples_per_second, | 76 int samples_per_second, |
77 const std::vector<uint8_t>& extra_data, | 77 const std::vector<uint8_t>& extra_data, |
78 bool is_encrypted, | 78 const EncryptionScheme& encryption_scheme, |
79 base::TimeDelta seek_preroll, | 79 base::TimeDelta seek_preroll, |
80 int codec_delay) { | 80 int codec_delay) { |
81 codec_ = codec; | 81 codec_ = codec; |
82 channel_layout_ = channel_layout; | 82 channel_layout_ = channel_layout; |
83 samples_per_second_ = samples_per_second; | 83 samples_per_second_ = samples_per_second; |
84 sample_format_ = sample_format; | 84 sample_format_ = sample_format; |
85 bytes_per_channel_ = SampleFormatToBytesPerChannel(sample_format); | 85 bytes_per_channel_ = SampleFormatToBytesPerChannel(sample_format); |
86 extra_data_ = extra_data; | 86 extra_data_ = extra_data; |
87 is_encrypted_ = is_encrypted; | 87 encryption_scheme_ = encryption_scheme; |
88 seek_preroll_ = seek_preroll; | 88 seek_preroll_ = seek_preroll; |
89 codec_delay_ = codec_delay; | 89 codec_delay_ = codec_delay; |
90 | 90 |
91 int channels = ChannelLayoutToChannelCount(channel_layout_); | 91 int channels = ChannelLayoutToChannelCount(channel_layout_); |
92 bytes_per_frame_ = channels * bytes_per_channel_; | 92 bytes_per_frame_ = channels * bytes_per_channel_; |
93 } | 93 } |
94 | 94 |
95 AudioDecoderConfig::~AudioDecoderConfig() {} | 95 AudioDecoderConfig::~AudioDecoderConfig() {} |
96 | 96 |
97 bool AudioDecoderConfig::IsValidConfig() const { | 97 bool AudioDecoderConfig::IsValidConfig() const { |
98 return codec_ != kUnknownAudioCodec && | 98 return codec_ != kUnknownAudioCodec && |
99 channel_layout_ != CHANNEL_LAYOUT_UNSUPPORTED && | 99 channel_layout_ != CHANNEL_LAYOUT_UNSUPPORTED && |
100 bytes_per_channel_ > 0 && | 100 bytes_per_channel_ > 0 && |
101 bytes_per_channel_ <= limits::kMaxBytesPerSample && | 101 bytes_per_channel_ <= limits::kMaxBytesPerSample && |
102 samples_per_second_ > 0 && | 102 samples_per_second_ > 0 && |
103 samples_per_second_ <= limits::kMaxSampleRate && | 103 samples_per_second_ <= limits::kMaxSampleRate && |
104 sample_format_ != kUnknownSampleFormat && | 104 sample_format_ != kUnknownSampleFormat && |
105 seek_preroll_ >= base::TimeDelta() && | 105 seek_preroll_ >= base::TimeDelta() && |
106 codec_delay_ >= 0; | 106 codec_delay_ >= 0; |
107 } | 107 } |
108 | 108 |
109 bool AudioDecoderConfig::Matches(const AudioDecoderConfig& config) const { | 109 bool AudioDecoderConfig::Matches(const AudioDecoderConfig& config) const { |
110 return ((codec() == config.codec()) && | 110 return ((codec() == config.codec()) && |
111 (bytes_per_channel() == config.bytes_per_channel()) && | 111 (bytes_per_channel() == config.bytes_per_channel()) && |
112 (channel_layout() == config.channel_layout()) && | 112 (channel_layout() == config.channel_layout()) && |
113 (samples_per_second() == config.samples_per_second()) && | 113 (samples_per_second() == config.samples_per_second()) && |
114 (extra_data() == config.extra_data()) && | 114 (extra_data() == config.extra_data()) && |
115 (is_encrypted() == config.is_encrypted()) && | 115 (encryption_scheme().Matches(config.encryption_scheme())) && |
116 (sample_format() == config.sample_format()) && | 116 (sample_format() == config.sample_format()) && |
117 (seek_preroll() == config.seek_preroll()) && | 117 (seek_preroll() == config.seek_preroll()) && |
118 (codec_delay() == config.codec_delay())); | 118 (codec_delay() == config.codec_delay())); |
119 } | 119 } |
120 | 120 |
121 std::string AudioDecoderConfig::AsHumanReadableString() const { | 121 std::string AudioDecoderConfig::AsHumanReadableString() const { |
122 std::ostringstream s; | 122 std::ostringstream s; |
123 s << "codec: " << GetCodecName(codec()) | 123 s << "codec: " << GetCodecName(codec()) |
124 << " bytes_per_channel: " << bytes_per_channel() | 124 << " bytes_per_channel: " << bytes_per_channel() |
125 << " channel_layout: " << channel_layout() | 125 << " channel_layout: " << channel_layout() |
126 << " samples_per_second: " << samples_per_second() | 126 << " samples_per_second: " << samples_per_second() |
127 << " sample_format: " << sample_format() | 127 << " sample_format: " << sample_format() |
128 << " bytes_per_frame: " << bytes_per_frame() | 128 << " bytes_per_frame: " << bytes_per_frame() |
129 << " seek_preroll: " << seek_preroll().InMilliseconds() << "ms" | 129 << " seek_preroll: " << seek_preroll().InMilliseconds() << "ms" |
130 << " codec_delay: " << codec_delay() << " has extra data? " | 130 << " codec_delay: " << codec_delay() << " has extra data? " |
131 << (extra_data().empty() ? "false" : "true") << " encrypted? " | 131 << (extra_data().empty() ? "false" : "true") << " encrypted? " |
132 << (is_encrypted() ? "true" : "false"); | 132 << (is_encrypted() ? "true" : "false"); |
133 return s.str(); | 133 return s.str(); |
134 } | 134 } |
135 | 135 |
136 bool AudioDecoderConfig::is_encrypted() const { | |
137 return encryption_scheme_.is_encrypted(); | |
138 } | |
139 | |
136 } // namespace media | 140 } // namespace media |
OLD | NEW |