Chromium Code Reviews| 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::EncryptionScheme::CipherMode ToMediaCipherMode( | |
| 179 EncryptionScheme::CipherMode mode) { | |
| 180 switch(mode) { | |
|
halliwell
2016/01/13 03:29:41
nit: space after switch. Maybe worth running clan
dougsteed
2016/02/09 22:58:53
Done.
| |
| 181 case EncryptionScheme::kCipherModeNone: | |
| 182 return ::media::EncryptionScheme::kCipherModeNone; | |
| 183 case EncryptionScheme::kCipherModeAesCtr: | |
| 184 return ::media::EncryptionScheme::kCipherModeAesCtr; | |
| 185 case EncryptionScheme::kCipherModeAesCbc: | |
| 186 return ::media::EncryptionScheme::kCipherModeAesCbc; | |
| 187 default: | |
| 188 NOTREACHED(); | |
| 189 return ::media::EncryptionScheme::kCipherModeNone; | |
| 190 } | |
| 191 } | |
| 192 | |
| 193 EncryptionScheme::CipherMode ToCipherMode( | |
| 194 ::media::EncryptionScheme::CipherMode mode) { | |
| 195 switch(mode) { | |
|
halliwell
2016/01/13 03:29:41
ditto
dougsteed
2016/02/09 22:58:53
Done.
| |
| 196 case ::media::EncryptionScheme::kCipherModeNone: | |
| 197 return EncryptionScheme::kCipherModeNone; | |
| 198 case ::media::EncryptionScheme::kCipherModeAesCtr: | |
| 199 return EncryptionScheme::kCipherModeAesCtr; | |
| 200 case ::media::EncryptionScheme::kCipherModeAesCbc: | |
| 201 return EncryptionScheme::kCipherModeAesCbc; | |
| 202 default: | |
| 203 NOTREACHED(); | |
| 204 return EncryptionScheme::kCipherModeNone; | |
| 205 } | |
| 206 } | |
| 207 | |
| 208 EncryptionScheme::PatternSpec ToPatternSpec( | |
| 209 const ::media::EncryptionScheme::PatternSpec& pattern) { | |
| 210 return EncryptionScheme::PatternSpec( | |
| 211 pattern.encrypt_blocks(), pattern.skip_blocks()); | |
| 212 } | |
| 213 | |
| 214 ::media::EncryptionScheme::PatternSpec ToMediaPatternSpec( | |
| 215 const EncryptionScheme::PatternSpec& pattern) { | |
| 216 return ::media::EncryptionScheme::PatternSpec( | |
| 217 pattern.encrypt_blocks, pattern.skip_blocks); | |
| 218 } | |
| 219 | |
| 220 // static | |
|
halliwell
2016/01/13 03:29:41
nit, unnecessary
dougsteed
2016/02/09 22:58:53
Done.
| |
| 221 EncryptionScheme ToEncryptionScheme( | |
| 222 const ::media::EncryptionScheme& scheme) { | |
| 223 return EncryptionScheme( | |
| 224 ToCipherMode(scheme.mode()), | |
| 225 ToPatternSpec(scheme.pattern())); | |
| 226 } | |
| 227 | |
| 228 // static | |
|
halliwell
2016/01/13 03:29:41
ditto
dougsteed
2016/02/09 22:58:53
Done.
| |
| 229 ::media::EncryptionScheme ToMediaEncryptionScheme( | |
| 230 const EncryptionScheme& scheme) { | |
| 231 return ::media::EncryptionScheme( | |
| 232 ToMediaCipherMode(scheme.mode), | |
| 233 ToMediaPatternSpec(scheme.pattern)); | |
| 234 } | |
| 235 | |
| 178 } // namespace | 236 } // namespace |
| 179 | 237 |
| 180 // static | 238 // static |
| 181 AudioConfig DecoderConfigAdapter::ToCastAudioConfig( | 239 AudioConfig DecoderConfigAdapter::ToCastAudioConfig( |
| 182 StreamId id, | 240 StreamId id, |
| 183 const ::media::AudioDecoderConfig& config) { | 241 const ::media::AudioDecoderConfig& config) { |
| 184 AudioConfig audio_config; | 242 AudioConfig audio_config; |
| 185 if (!config.IsValidConfig()) | 243 if (!config.IsValidConfig()) |
| 186 return audio_config; | 244 return audio_config; |
| 187 | 245 |
| 188 audio_config.id = id; | 246 audio_config.id = id; |
| 189 audio_config.codec = ToAudioCodec(config.codec()); | 247 audio_config.codec = ToAudioCodec(config.codec()); |
| 190 audio_config.sample_format = ToSampleFormat(config.sample_format()); | 248 audio_config.sample_format = ToSampleFormat(config.sample_format()); |
| 191 audio_config.bytes_per_channel = config.bytes_per_channel(); | 249 audio_config.bytes_per_channel = config.bytes_per_channel(); |
| 192 audio_config.channel_number = | 250 audio_config.channel_number = |
| 193 ::media::ChannelLayoutToChannelCount(config.channel_layout()), | 251 ::media::ChannelLayoutToChannelCount(config.channel_layout()), |
| 194 audio_config.samples_per_second = config.samples_per_second(); | 252 audio_config.samples_per_second = config.samples_per_second(); |
| 195 audio_config.extra_data = config.extra_data(); | 253 audio_config.extra_data = config.extra_data(); |
| 196 audio_config.is_encrypted = config.is_encrypted(); | 254 audio_config.encryption_scheme = ToEncryptionScheme( |
| 255 config.encryption_scheme()); | |
| 197 return audio_config; | 256 return audio_config; |
| 198 } | 257 } |
| 199 | 258 |
| 200 // static | 259 // static |
| 201 ::media::AudioDecoderConfig DecoderConfigAdapter::ToMediaAudioDecoderConfig( | 260 ::media::AudioDecoderConfig DecoderConfigAdapter::ToMediaAudioDecoderConfig( |
| 202 const AudioConfig& config) { | 261 const AudioConfig& config) { |
| 203 return ::media::AudioDecoderConfig( | 262 return ::media::AudioDecoderConfig( |
| 204 ToMediaAudioCodec(config.codec), | 263 ToMediaAudioCodec(config.codec), |
| 205 ToMediaSampleFormat(config.sample_format), | 264 ToMediaSampleFormat(config.sample_format), |
| 206 ToMediaChannelLayout(config.channel_number), config.samples_per_second, | 265 ToMediaChannelLayout(config.channel_number), config.samples_per_second, |
| 207 config.extra_data, config.is_encrypted); | 266 config.extra_data, |
| 267 ToMediaEncryptionScheme(config.encryption_scheme)); | |
| 208 } | 268 } |
| 209 | 269 |
| 210 // static | 270 // static |
| 211 VideoConfig DecoderConfigAdapter::ToCastVideoConfig( | 271 VideoConfig DecoderConfigAdapter::ToCastVideoConfig( |
| 212 StreamId id, | 272 StreamId id, |
| 213 const ::media::VideoDecoderConfig& config) { | 273 const ::media::VideoDecoderConfig& config) { |
| 214 VideoConfig video_config; | 274 VideoConfig video_config; |
| 215 if (!config.IsValidConfig()) { | 275 if (!config.IsValidConfig()) { |
| 216 return video_config; | 276 return video_config; |
| 217 } | 277 } |
| 218 | 278 |
| 219 video_config.id = id; | 279 video_config.id = id; |
| 220 video_config.codec = ToVideoCodec(config.codec()); | 280 video_config.codec = ToVideoCodec(config.codec()); |
| 221 video_config.profile = ToVideoProfile(config.profile()); | 281 video_config.profile = ToVideoProfile(config.profile()); |
| 222 video_config.extra_data = config.extra_data(); | 282 video_config.extra_data = config.extra_data(); |
| 223 video_config.is_encrypted = config.is_encrypted(); | 283 video_config.encryption_scheme = ToEncryptionScheme( |
| 284 config.encryption_scheme()); | |
| 224 return video_config; | 285 return video_config; |
| 225 } | 286 } |
| 226 | 287 |
| 227 } // namespace media | 288 } // namespace media |
| 228 } // namespace chromecast | 289 } // namespace chromecast |
| OLD | NEW |