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::CIPHER_MODE_UNENCRYPTED: | |
190 return ::media::EncryptionScheme::CIPHER_MODE_UNENCRYPTED; | |
191 case EncryptionScheme::CIPHER_MODE_AES_CTR: | |
192 return ::media::EncryptionScheme::CIPHER_MODE_AES_CTR; | |
193 case EncryptionScheme::CIPHER_MODE_AES_CBC: | |
194 return ::media::EncryptionScheme::CIPHER_MODE_AES_CBC; | |
195 default: | |
196 NOTREACHED(); | |
197 return ::media::EncryptionScheme::CIPHER_MODE_UNENCRYPTED; | |
198 } | |
199 } | |
200 | |
201 EncryptionScheme::CipherMode ToCipherMode( | |
202 ::media::EncryptionScheme::CipherMode mode) { | |
203 switch (mode) { | |
204 case ::media::EncryptionScheme::CIPHER_MODE_UNENCRYPTED: | |
205 return EncryptionScheme::CIPHER_MODE_UNENCRYPTED; | |
206 case ::media::EncryptionScheme::CIPHER_MODE_AES_CTR: | |
207 return EncryptionScheme::CIPHER_MODE_AES_CTR; | |
208 case ::media::EncryptionScheme::CIPHER_MODE_AES_CBC: | |
209 return EncryptionScheme::CIPHER_MODE_AES_CBC; | |
210 default: | |
211 NOTREACHED(); | |
212 return EncryptionScheme::CIPHER_MODE_UNENCRYPTED; | |
213 } | |
214 } | |
215 | |
216 EncryptionScheme::Pattern ToPatternSpec( | |
217 const ::media::EncryptionScheme::Pattern& pattern) { | |
218 return EncryptionScheme::Pattern( | |
219 pattern.encrypt_blocks(), pattern.skip_blocks()); | |
220 } | |
221 | |
222 ::media::EncryptionScheme::Pattern ToMediaPatternSpec( | |
223 const EncryptionScheme::Pattern& pattern) { | |
224 return ::media::EncryptionScheme::Pattern( | |
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 | |
242 } // namespace | 186 } // namespace |
243 | 187 |
244 // static | 188 // static |
245 AudioConfig DecoderConfigAdapter::ToCastAudioConfig( | 189 AudioConfig DecoderConfigAdapter::ToCastAudioConfig( |
246 StreamId id, | 190 StreamId id, |
247 const ::media::AudioDecoderConfig& config) { | 191 const ::media::AudioDecoderConfig& config) { |
248 AudioConfig audio_config; | 192 AudioConfig audio_config; |
249 if (!config.IsValidConfig()) | 193 if (!config.IsValidConfig()) |
250 return audio_config; | 194 return audio_config; |
251 | 195 |
252 audio_config.id = id; | 196 audio_config.id = id; |
253 audio_config.codec = ToAudioCodec(config.codec()); | 197 audio_config.codec = ToAudioCodec(config.codec()); |
254 audio_config.sample_format = ToSampleFormat(config.sample_format()); | 198 audio_config.sample_format = ToSampleFormat(config.sample_format()); |
255 audio_config.bytes_per_channel = config.bytes_per_channel(); | 199 audio_config.bytes_per_channel = config.bytes_per_channel(); |
256 audio_config.channel_number = | 200 audio_config.channel_number = |
257 ::media::ChannelLayoutToChannelCount(config.channel_layout()), | 201 ::media::ChannelLayoutToChannelCount(config.channel_layout()), |
258 audio_config.samples_per_second = config.samples_per_second(); | 202 audio_config.samples_per_second = config.samples_per_second(); |
259 audio_config.extra_data = config.extra_data(); | 203 audio_config.extra_data = config.extra_data(); |
260 audio_config.encryption_scheme = ToEncryptionScheme( | 204 audio_config.is_encrypted = config.is_encrypted(); |
261 config.encryption_scheme()); | |
262 return audio_config; | 205 return audio_config; |
263 } | 206 } |
264 | 207 |
265 // static | 208 // static |
266 ::media::AudioDecoderConfig DecoderConfigAdapter::ToMediaAudioDecoderConfig( | 209 ::media::AudioDecoderConfig DecoderConfigAdapter::ToMediaAudioDecoderConfig( |
267 const AudioConfig& config) { | 210 const AudioConfig& config) { |
268 return ::media::AudioDecoderConfig( | 211 return ::media::AudioDecoderConfig( |
269 ToMediaAudioCodec(config.codec), | 212 ToMediaAudioCodec(config.codec), |
270 ToMediaSampleFormat(config.sample_format), | 213 ToMediaSampleFormat(config.sample_format), |
271 ToMediaChannelLayout(config.channel_number), config.samples_per_second, | 214 ToMediaChannelLayout(config.channel_number), config.samples_per_second, |
272 config.extra_data, | 215 config.extra_data, config.is_encrypted); |
273 ToMediaEncryptionScheme(config.encryption_scheme)); | |
274 } | 216 } |
275 | 217 |
276 // static | 218 // static |
277 VideoConfig DecoderConfigAdapter::ToCastVideoConfig( | 219 VideoConfig DecoderConfigAdapter::ToCastVideoConfig( |
278 StreamId id, | 220 StreamId id, |
279 const ::media::VideoDecoderConfig& config) { | 221 const ::media::VideoDecoderConfig& config) { |
280 VideoConfig video_config; | 222 VideoConfig video_config; |
281 if (!config.IsValidConfig()) { | 223 if (!config.IsValidConfig()) { |
282 return video_config; | 224 return video_config; |
283 } | 225 } |
284 | 226 |
285 video_config.id = id; | 227 video_config.id = id; |
286 video_config.codec = ToVideoCodec(config.codec()); | 228 video_config.codec = ToVideoCodec(config.codec()); |
287 video_config.profile = ToVideoProfile(config.profile()); | 229 video_config.profile = ToVideoProfile(config.profile()); |
288 video_config.extra_data = config.extra_data(); | 230 video_config.extra_data = config.extra_data(); |
289 video_config.encryption_scheme = ToEncryptionScheme( | 231 video_config.is_encrypted = config.is_encrypted(); |
290 config.encryption_scheme()); | |
291 return video_config; | 232 return video_config; |
292 } | 233 } |
293 | 234 |
294 } // namespace media | 235 } // namespace media |
295 } // namespace chromecast | 236 } // namespace chromecast |
OLD | NEW |