Chromium Code Reviews| Index: chromecast/media/cma/base/decoder_config_adapter.cc |
| diff --git a/chromecast/media/cma/base/decoder_config_adapter.cc b/chromecast/media/cma/base/decoder_config_adapter.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d70e94f7b227c82e611391042756f30d32805d23 |
| --- /dev/null |
| +++ b/chromecast/media/cma/base/decoder_config_adapter.cc |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chromecast/media/cma/base/decoder_config_adapter.h" |
| + |
| +#include "chromecast/media/cma/public/audio_config.h" |
| +#include "chromecast/media/cma/public/video_config.h" |
| +#include "media/base/audio_decoder_config.h" |
| +#include "media/base/channel_layout.h" |
| +#include "media/base/video_decoder_config.h" |
| + |
| +namespace chromecast { |
| +namespace media { |
| + |
| +AudioConfig DecoderConfigAdapter::ToAudioConfig( |
| + const ::media::AudioDecoderConfig& config) { |
| + if (!config.IsValidConfig()) { |
| + return AudioConfig(); |
| + } |
| + |
| + return AudioConfig( |
| + static_cast<AudioConfig::Codec>(config.codec()), |
|
lcwu1
2015/04/13 23:55:42
It's actually dangerous doing this. I am not sure
erickung1
2015/04/15 22:13:18
Done. Create util function to do the conversion us
|
| + static_cast<AudioConfig::ChannelLayout>(config.channel_layout()), |
| + ::media::ChannelLayoutToChannelCount(config.channel_layout()), |
| + config.bytes_per_channel(), |
| + config.samples_per_second(), |
| + config.extra_data(), |
| + config.extra_data_size(), |
| + config.is_encrypted()); |
| +} |
| + |
| +VideoConfig DecoderConfigAdapter::ToVideoConfig( |
| + const ::media::VideoDecoderConfig& config) { |
| + if (!config.IsValidConfig()) { |
| + return VideoConfig(); |
| + } |
| + |
| + return VideoConfig( |
| + static_cast<VideoConfig::Codec>(config.codec()), |
| + static_cast<VideoConfig::CodecProfile>(config.profile()), |
| + config.extra_data(), |
| + config.extra_data_size(), |
| + config.is_encrypted()); |
| +} |
| + |
| +} // namespace media |
| +} // namespace chromecast |