Chromium Code Reviews| Index: media/mojo/common/media_type_converters.cc |
| diff --git a/media/mojo/common/media_type_converters.cc b/media/mojo/common/media_type_converters.cc |
| index 37966ab772eeb2e48fe2f4cfea57db7060765fc9..994d9506460896698597407db4705a1440236a6e 100644 |
| --- a/media/mojo/common/media_type_converters.cc |
| +++ b/media/mojo/common/media_type_converters.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/memory/ptr_util.h" |
| #include "base/numerics/safe_conversions.h" |
| +#include "media/audio/audio_parameters.h" |
| #include "media/base/audio_buffer.h" |
| #include "media/base/audio_decoder_config.h" |
| #include "media/base/buffering_state.h" |
| @@ -42,10 +43,38 @@ namespace mojo { |
| static_cast<media::media_enum>(media::interfaces::mojo_enum_value), \ |
| "Mismatched enum: " #media_enum_value " != " #mojo_enum_value) |
| +#define ASSERT_ENUM_EQ_COMPLEX(media_enum, media_prefix, mojo_prefix, value) \ |
| + static_assert(media::media_prefix::value == \ |
| + static_cast<media::media_enum>(media::mojo_prefix::value), \ |
| + "Mismatched enum: " #media_prefix #value \ |
| + " != ::" #mojo_prefix #value) |
| + |
| // BufferingState. |
| ASSERT_ENUM_EQ(BufferingState, BUFFERING_, , HAVE_NOTHING); |
| ASSERT_ENUM_EQ(BufferingState, BUFFERING_, , HAVE_ENOUGH); |
| +// AudioFormat |
| +ASSERT_ENUM_EQ_COMPLEX(AudioParameters::Format, |
| + AudioParameters::Format, |
| + interfaces::AudioFormat, |
| + AUDIO_PCM_LINEAR); |
| +ASSERT_ENUM_EQ_COMPLEX(AudioParameters::Format, |
| + AudioParameters::Format, |
| + interfaces::AudioFormat, |
| + AUDIO_PCM_LOW_LATENCY); |
| +ASSERT_ENUM_EQ_COMPLEX(AudioParameters::Format, |
| + AudioParameters::Format, |
| + interfaces::AudioFormat, |
| + AUDIO_FAKE); |
| +ASSERT_ENUM_EQ_COMPLEX(AudioParameters::Format, |
| + AudioParameters::Format, |
| + interfaces::AudioFormat, |
| + AUDIO_FORMAT_LAST); |
| +ASSERT_ENUM_EQ_COMPLEX(AudioParameters::Format, |
| + AudioParameters::Format, |
| + interfaces::AudioFormat, |
| + AUDIO_FORMAT_LAST); |
| + |
| // AudioCodec. |
| ASSERT_ENUM_EQ_RAW(AudioCodec, kUnknownAudioCodec, AudioCodec::UNKNOWN); |
| ASSERT_ENUM_EQ(AudioCodec, kCodec, , AAC); |
| @@ -346,6 +375,38 @@ TypeConverter<media::EncryptionScheme::Pattern, media::interfaces::PatternPtr>:: |
| } |
| // static |
| +media::interfaces::AudioOutputStreamParametersPtr TypeConverter< |
| + media::interfaces::AudioOutputStreamParametersPtr, |
| + media::AudioParameters>::Convert(const media::AudioParameters& input) { |
| + media::interfaces::AudioOutputStreamParametersPtr output( |
| + media::interfaces::AudioOutputStreamParameters::New()); |
| + |
| + output->format = static_cast<media::interfaces::AudioFormat>(input.format()); |
| + output->channel_layout = |
| + static_cast<media::interfaces::ChannelLayout>(input.channel_layout()); |
| + output->channels = input.channels(); |
| + output->sample_rate = input.sample_rate(); |
| + output->bits_per_sample = input.bits_per_sample(); |
| + output->frames_per_buffer = input.frames_per_buffer(); |
| + output->effects = input.effects(); |
| + return output; |
| +} |
| + |
| +// static |
| +media::AudioParameters |
| +TypeConverter<media::AudioParameters, |
| + media::interfaces::AudioOutputStreamParametersPtr>:: |
| + Convert(const media::interfaces::AudioOutputStreamParametersPtr& input) { |
| + media::AudioParameters output( |
| + static_cast<media::AudioParameters::Format>(input->format), |
| + static_cast<media::ChannelLayout>(input->channel_layout), |
| + input->sample_rate, input->bits_per_sample, input->frames_per_buffer); |
| + output.set_channels(input->channels); |
|
mcasas
2016/04/29 17:14:11
I'm not 100% sure of this but, couldn't we use
med
rchtara
2016/05/02 15:54:10
I replaced set_channels with set_channels_for_disc
|
| + output.set_effects(input->effects); |
| + return output; |
| +} |
| + |
| +// static |
| media::interfaces::EncryptionSchemePtr TypeConverter< |
| media::interfaces::EncryptionSchemePtr, |
| media::EncryptionScheme>::Convert(const media::EncryptionScheme& input) { |
| @@ -379,6 +440,7 @@ media::interfaces::SubsampleEntryPtr TypeConverter< |
| } |
| // static |
| + |
|
mcasas
2016/04/29 17:14:11
Remove added empty line
rchtara
2016/05/02 15:54:10
Done.
|
| media::SubsampleEntry |
| TypeConverter<media::SubsampleEntry, media::interfaces::SubsampleEntryPtr>:: |
| Convert(const media::interfaces::SubsampleEntryPtr& input) { |