| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 case ::media::kCodecHEVC: | 78 case ::media::kCodecHEVC: |
| 79 return kCodecHEVC; | 79 return kCodecHEVC; |
| 80 default: | 80 default: |
| 81 LOG(ERROR) << "Unsupported video codec " << video_codec; | 81 LOG(ERROR) << "Unsupported video codec " << video_codec; |
| 82 } | 82 } |
| 83 return kVideoCodecUnknown; | 83 return kVideoCodecUnknown; |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Converts ::media::VideoCodecProfile to chromecast::media::VideoProfile. | 86 // Converts ::media::VideoCodecProfile to chromecast::media::VideoProfile. |
| 87 VideoProfile ToVideoProfile(const ::media::VideoCodecProfile codec_profile) { | 87 VideoProfile ToVideoProfile(const ::media::VideoCodecProfile codec_profile) { |
| 88 switch(codec_profile) { | 88 switch (codec_profile) { |
| 89 case ::media::H264PROFILE_BASELINE: | 89 case ::media::H264PROFILE_BASELINE: |
| 90 return kH264Baseline; | 90 return kH264Baseline; |
| 91 case ::media::H264PROFILE_MAIN: | 91 case ::media::H264PROFILE_MAIN: |
| 92 return kH264Main; | 92 return kH264Main; |
| 93 case ::media::H264PROFILE_EXTENDED: | 93 case ::media::H264PROFILE_EXTENDED: |
| 94 return kH264Extended; | 94 return kH264Extended; |
| 95 case ::media::H264PROFILE_HIGH: | 95 case ::media::H264PROFILE_HIGH: |
| 96 return kH264High; | 96 return kH264High; |
| 97 case ::media::H264PROFILE_HIGH10PROFILE: | 97 case ::media::H264PROFILE_HIGH10PROFILE: |
| 98 return kH264High10; | 98 return kH264High10; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 return ::media::kCodecFLAC; | 176 return ::media::kCodecFLAC; |
| 177 case kCodecEAC3: | 177 case kCodecEAC3: |
| 178 return ::media::kCodecEAC3; | 178 return ::media::kCodecEAC3; |
| 179 case kCodecAC3: | 179 case kCodecAC3: |
| 180 return ::media::kCodecAC3; | 180 return ::media::kCodecAC3; |
| 181 default: | 181 default: |
| 182 return ::media::kUnknownAudioCodec; | 182 return ::media::kUnknownAudioCodec; |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 ::media::EncryptionScheme::CipherMode ToMediaCipherMode( |
| 187 EncryptionScheme::CipherMode mode) { |
| 188 switch (mode) { |
| 189 case EncryptionScheme::kCipherModeUnencrypted: |
| 190 return ::media::EncryptionScheme::kCipherModeUnencrypted; |
| 191 case EncryptionScheme::kCipherModeAesCtr: |
| 192 return ::media::EncryptionScheme::kCipherModeAesCtr; |
| 193 case EncryptionScheme::kCipherModeAesCbc: |
| 194 return ::media::EncryptionScheme::kCipherModeAesCbc; |
| 195 default: |
| 196 NOTREACHED(); |
| 197 return ::media::EncryptionScheme::kCipherModeUnencrypted; |
| 198 } |
| 199 } |
| 200 |
| 201 EncryptionScheme::CipherMode ToCipherMode( |
| 202 ::media::EncryptionScheme::CipherMode mode) { |
| 203 switch (mode) { |
| 204 case ::media::EncryptionScheme::kCipherModeUnencrypted: |
| 205 return EncryptionScheme::kCipherModeUnencrypted; |
| 206 case ::media::EncryptionScheme::kCipherModeAesCtr: |
| 207 return EncryptionScheme::kCipherModeAesCtr; |
| 208 case ::media::EncryptionScheme::kCipherModeAesCbc: |
| 209 return EncryptionScheme::kCipherModeAesCbc; |
| 210 default: |
| 211 NOTREACHED(); |
| 212 return EncryptionScheme::kCipherModeUnencrypted; |
| 213 } |
| 214 } |
| 215 |
| 216 EncryptionScheme::PatternSpec ToPatternSpec( |
| 217 const ::media::EncryptionScheme::PatternSpec& pattern) { |
| 218 return EncryptionScheme::PatternSpec( |
| 219 pattern.encrypt_blocks(), pattern.skip_blocks()); |
| 220 } |
| 221 |
| 222 ::media::EncryptionScheme::PatternSpec ToMediaPatternSpec( |
| 223 const EncryptionScheme::PatternSpec& pattern) { |
| 224 return ::media::EncryptionScheme::PatternSpec( |
| 225 pattern.encrypt_blocks, pattern.skip_blocks); |
| 226 } |
| 227 |
| 228 EncryptionScheme ToEncryptionScheme( |
| 229 const ::media::EncryptionScheme& scheme) { |
| 230 return EncryptionScheme( |
| 231 ToCipherMode(scheme.mode()), |
| 232 ToPatternSpec(scheme.pattern())); |
| 233 } |
| 234 |
| 235 ::media::EncryptionScheme ToMediaEncryptionScheme( |
| 236 const EncryptionScheme& scheme) { |
| 237 return ::media::EncryptionScheme( |
| 238 ToMediaCipherMode(scheme.mode), |
| 239 ToMediaPatternSpec(scheme.pattern)); |
| 240 } |
| 241 |
| 186 } // namespace | 242 } // namespace |
| 187 | 243 |
| 188 // static | 244 // static |
| 189 AudioConfig DecoderConfigAdapter::ToCastAudioConfig( | 245 AudioConfig DecoderConfigAdapter::ToCastAudioConfig( |
| 190 StreamId id, | 246 StreamId id, |
| 191 const ::media::AudioDecoderConfig& config) { | 247 const ::media::AudioDecoderConfig& config) { |
| 192 AudioConfig audio_config; | 248 AudioConfig audio_config; |
| 193 if (!config.IsValidConfig()) | 249 if (!config.IsValidConfig()) |
| 194 return audio_config; | 250 return audio_config; |
| 195 | 251 |
| 196 audio_config.id = id; | 252 audio_config.id = id; |
| 197 audio_config.codec = ToAudioCodec(config.codec()); | 253 audio_config.codec = ToAudioCodec(config.codec()); |
| 198 audio_config.sample_format = ToSampleFormat(config.sample_format()); | 254 audio_config.sample_format = ToSampleFormat(config.sample_format()); |
| 199 audio_config.bytes_per_channel = config.bytes_per_channel(); | 255 audio_config.bytes_per_channel = config.bytes_per_channel(); |
| 200 audio_config.channel_number = | 256 audio_config.channel_number = |
| 201 ::media::ChannelLayoutToChannelCount(config.channel_layout()), | 257 ::media::ChannelLayoutToChannelCount(config.channel_layout()), |
| 202 audio_config.samples_per_second = config.samples_per_second(); | 258 audio_config.samples_per_second = config.samples_per_second(); |
| 203 audio_config.extra_data = config.extra_data(); | 259 audio_config.extra_data = config.extra_data(); |
| 204 audio_config.is_encrypted = config.is_encrypted(); | 260 audio_config.encryption_scheme = ToEncryptionScheme( |
| 261 config.encryption_scheme()); |
| 205 return audio_config; | 262 return audio_config; |
| 206 } | 263 } |
| 207 | 264 |
| 208 // static | 265 // static |
| 209 ::media::AudioDecoderConfig DecoderConfigAdapter::ToMediaAudioDecoderConfig( | 266 ::media::AudioDecoderConfig DecoderConfigAdapter::ToMediaAudioDecoderConfig( |
| 210 const AudioConfig& config) { | 267 const AudioConfig& config) { |
| 211 return ::media::AudioDecoderConfig( | 268 return ::media::AudioDecoderConfig( |
| 212 ToMediaAudioCodec(config.codec), | 269 ToMediaAudioCodec(config.codec), |
| 213 ToMediaSampleFormat(config.sample_format), | 270 ToMediaSampleFormat(config.sample_format), |
| 214 ToMediaChannelLayout(config.channel_number), config.samples_per_second, | 271 ToMediaChannelLayout(config.channel_number), config.samples_per_second, |
| 215 config.extra_data, config.is_encrypted); | 272 config.extra_data, |
| 273 ToMediaEncryptionScheme(config.encryption_scheme)); |
| 216 } | 274 } |
| 217 | 275 |
| 218 // static | 276 // static |
| 219 VideoConfig DecoderConfigAdapter::ToCastVideoConfig( | 277 VideoConfig DecoderConfigAdapter::ToCastVideoConfig( |
| 220 StreamId id, | 278 StreamId id, |
| 221 const ::media::VideoDecoderConfig& config) { | 279 const ::media::VideoDecoderConfig& config) { |
| 222 VideoConfig video_config; | 280 VideoConfig video_config; |
| 223 if (!config.IsValidConfig()) { | 281 if (!config.IsValidConfig()) { |
| 224 return video_config; | 282 return video_config; |
| 225 } | 283 } |
| 226 | 284 |
| 227 video_config.id = id; | 285 video_config.id = id; |
| 228 video_config.codec = ToVideoCodec(config.codec()); | 286 video_config.codec = ToVideoCodec(config.codec()); |
| 229 video_config.profile = ToVideoProfile(config.profile()); | 287 video_config.profile = ToVideoProfile(config.profile()); |
| 230 video_config.extra_data = config.extra_data(); | 288 video_config.extra_data = config.extra_data(); |
| 231 video_config.is_encrypted = config.is_encrypted(); | 289 video_config.encryption_scheme = ToEncryptionScheme( |
| 290 config.encryption_scheme()); |
| 232 return video_config; | 291 return video_config; |
| 233 } | 292 } |
| 234 | 293 |
| 235 } // namespace media | 294 } // namespace media |
| 236 } // namespace chromecast | 295 } // namespace chromecast |
| OLD | NEW |