OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chromecast/media/cma/base/decoder_config_adapter.h" | 5 #include "chromecast/media/cma/base/decoder_config_adapter.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/base/channel_layout.h" | 8 #include "media/base/channel_layout.h" |
9 | 9 |
10 namespace chromecast { | 10 namespace chromecast { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 return ::media::kCodecVorbis; | 168 return ::media::kCodecVorbis; |
169 case kCodecOpus: | 169 case kCodecOpus: |
170 return ::media::kCodecOpus; | 170 return ::media::kCodecOpus; |
171 case kCodecFLAC: | 171 case kCodecFLAC: |
172 return ::media::kCodecFLAC; | 172 return ::media::kCodecFLAC; |
173 default: | 173 default: |
174 return ::media::kUnknownAudioCodec; | 174 return ::media::kUnknownAudioCodec; |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
| 178 ::media::CipherMode ToMediaCipherMode(CipherMode mode) { |
| 179 switch(mode) { |
| 180 case kCipherModeAesCtr: |
| 181 return ::media::kCipherModeAesCtr; |
| 182 case kCipherModeAesCbc: |
| 183 return ::media::kCipherModeAesCbc; |
| 184 default: |
| 185 return ::media::kCipherModeUnknown; |
| 186 } |
| 187 } |
| 188 |
| 189 CipherMode ToCipherMode(::media::CipherMode mode) { |
| 190 switch(mode) { |
| 191 case ::media::kCipherModeAesCtr: |
| 192 return kCipherModeAesCtr; |
| 193 case ::media::kCipherModeAesCbc: |
| 194 return kCipherModeAesCbc; |
| 195 default: |
| 196 return kCipherModeUnknown; |
| 197 } |
| 198 } |
| 199 |
| 200 EncryptionScheme::PatternSpec ToPatternSpec( |
| 201 const ::media::EncryptionScheme::PatternSpec& pattern) { |
| 202 return EncryptionScheme::PatternSpec( |
| 203 pattern.encrypt_blocks(), pattern.skip_blocks()); |
| 204 } |
| 205 |
| 206 ::media::EncryptionScheme::PatternSpec ToMediaPatternSpec( |
| 207 const EncryptionScheme::PatternSpec& pattern) { |
| 208 return ::media::EncryptionScheme::PatternSpec( |
| 209 pattern.encrypt_blocks, pattern.skip_blocks); |
| 210 } |
| 211 |
| 212 // static |
| 213 EncryptionScheme ToEncryptionScheme( |
| 214 const ::media::EncryptionScheme& scheme) { |
| 215 return EncryptionScheme( |
| 216 scheme.is_encrypted(), |
| 217 ToCipherMode(scheme.mode()), |
| 218 ToPatternSpec(scheme.pattern())); |
| 219 } |
| 220 |
| 221 // static |
| 222 ::media::EncryptionScheme ToMediaEncryptionScheme( |
| 223 const EncryptionScheme& scheme) { |
| 224 return new ::media::EncryptionScheme( |
| 225 scheme.is_encrypted, |
| 226 ToMediaCipherMode(scheme.mode), |
| 227 ToMediaPatternSpec(scheme.pattern)); |
| 228 } |
| 229 |
178 } // namespace | 230 } // namespace |
179 | 231 |
180 // static | 232 // static |
181 AudioConfig DecoderConfigAdapter::ToCastAudioConfig( | 233 AudioConfig DecoderConfigAdapter::ToCastAudioConfig( |
182 StreamId id, | 234 StreamId id, |
183 const ::media::AudioDecoderConfig& config) { | 235 const ::media::AudioDecoderConfig& config) { |
184 AudioConfig audio_config; | 236 AudioConfig audio_config; |
185 if (!config.IsValidConfig()) | 237 if (!config.IsValidConfig()) |
186 return audio_config; | 238 return audio_config; |
187 | 239 |
188 audio_config.id = id; | 240 audio_config.id = id; |
189 audio_config.codec = ToAudioCodec(config.codec()); | 241 audio_config.codec = ToAudioCodec(config.codec()); |
190 audio_config.sample_format = ToSampleFormat(config.sample_format()); | 242 audio_config.sample_format = ToSampleFormat(config.sample_format()); |
191 audio_config.bytes_per_channel = config.bytes_per_channel(); | 243 audio_config.bytes_per_channel = config.bytes_per_channel(); |
192 audio_config.channel_number = | 244 audio_config.channel_number = |
193 ::media::ChannelLayoutToChannelCount(config.channel_layout()), | 245 ::media::ChannelLayoutToChannelCount(config.channel_layout()), |
194 audio_config.samples_per_second = config.samples_per_second(); | 246 audio_config.samples_per_second = config.samples_per_second(); |
195 audio_config.extra_data = config.extra_data(); | 247 audio_config.extra_data = config.extra_data(); |
196 audio_config.is_encrypted = config.is_encrypted(); | 248 audio_config.encryption_scheme = ToEncryptionScheme( |
| 249 config.encryption_scheme()); |
197 return audio_config; | 250 return audio_config; |
198 } | 251 } |
199 | 252 |
200 // static | 253 // static |
201 ::media::AudioDecoderConfig DecoderConfigAdapter::ToMediaAudioDecoderConfig( | 254 ::media::AudioDecoderConfig DecoderConfigAdapter::ToMediaAudioDecoderConfig( |
202 const AudioConfig& config) { | 255 const AudioConfig& config) { |
203 return ::media::AudioDecoderConfig( | 256 return ::media::AudioDecoderConfig( |
204 ToMediaAudioCodec(config.codec), | 257 ToMediaAudioCodec(config.codec), |
205 ToMediaSampleFormat(config.sample_format), | 258 ToMediaSampleFormat(config.sample_format), |
206 ToMediaChannelLayout(config.channel_number), config.samples_per_second, | 259 ToMediaChannelLayout(config.channel_number), config.samples_per_second, |
207 config.extra_data, config.is_encrypted); | 260 config.extra_data, |
| 261 ToMediaEncryptionScheme(config.encryption_scheme)); |
208 } | 262 } |
209 | 263 |
210 // static | 264 // static |
211 VideoConfig DecoderConfigAdapter::ToCastVideoConfig( | 265 VideoConfig DecoderConfigAdapter::ToCastVideoConfig( |
212 StreamId id, | 266 StreamId id, |
213 const ::media::VideoDecoderConfig& config) { | 267 const ::media::VideoDecoderConfig& config) { |
214 VideoConfig video_config; | 268 VideoConfig video_config; |
215 if (!config.IsValidConfig()) { | 269 if (!config.IsValidConfig()) { |
216 return video_config; | 270 return video_config; |
217 } | 271 } |
218 | 272 |
219 video_config.id = id; | 273 video_config.id = id; |
220 video_config.codec = ToVideoCodec(config.codec()); | 274 video_config.codec = ToVideoCodec(config.codec()); |
221 video_config.profile = ToVideoProfile(config.profile()); | 275 video_config.profile = ToVideoProfile(config.profile()); |
222 video_config.extra_data = config.extra_data(); | 276 video_config.extra_data = config.extra_data(); |
223 video_config.is_encrypted = config.is_encrypted(); | 277 video_config.encryption_scheme = ToEncryptionScheme( |
| 278 config.encryption_scheme()); |
224 return video_config; | 279 return video_config; |
225 } | 280 } |
226 | 281 |
227 } // namespace media | 282 } // namespace media |
228 } // namespace chromecast | 283 } // namespace chromecast |
OLD | NEW |