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 8d562775b20d45f179d18523c11f680524aaae5b..99857489b7c4d8ce70b11c305c5e4f4705f35eab 100644 |
| --- a/media/mojo/common/media_type_converters.cc |
| +++ b/media/mojo/common/media_type_converters.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/numerics/safe_conversions.h" |
| #include "media/base/audio_buffer.h" |
| #include "media/base/audio_decoder_config.h" |
| +#include "media/base/audio_parameters.h" |
| #include "media/base/buffering_state.h" |
| #include "media/base/cdm_config.h" |
| #include "media/base/cdm_key_information.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) \ |
|
Mike West
2016/05/04 10:56:16
Nit: Is there any time when |media_enum| isn't ==
rchtara
2016/05/05 15:59:44
Done.
|
| + 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); |
|
Mike West
2016/05/04 10:56:17
This duplicates the item at line 69.
rchtara
2016/05/05 15:59:44
Done.
|
| + |
| // AudioCodec. |
| ASSERT_ENUM_EQ_RAW(AudioCodec, kUnknownAudioCodec, AudioCodec::UNKNOWN); |
| ASSERT_ENUM_EQ(AudioCodec, kCodec, , AAC); |
| @@ -351,6 +380,44 @@ TypeConverter<media::EncryptionScheme::Pattern, media::interfaces::PatternPtr>:: |
| } |
| // static |
| +media::interfaces::AudioParametersPtr TypeConverter< |
| + media::interfaces::AudioParametersPtr, |
| + media::AudioParameters>::Convert(const media::AudioParameters& input) { |
| + DCHECK(!input.mic_positions().size()); |
| + media::interfaces::AudioParametersPtr output( |
| + media::interfaces::AudioParameters::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::AudioParametersPtr>:: |
| + Convert(const media::interfaces::AudioParametersPtr& 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); |
| + // Setting the number of channels explicitly is only required with |
| + // CHANNEL_LAYOUT_DISCRETE. |
|
Mike West
2016/05/04 10:56:17
The comment matches the first part of this `if` co
rchtara
2016/05/05 15:59:44
otherwise it will be computed from channel_layout_
Mike West
2016/05/06 13:24:42
Say that in the comment?
rchtara
2016/05/06 13:47:44
Done.
|
| + if (output.channel_layout() == media::CHANNEL_LAYOUT_DISCRETE || |
| + input->channels == ChannelLayoutToChannelCount(output.channel_layout())) { |
| + output.set_channels_for_discrete(input->channels); |
| + } |
| + output.set_effects(input->effects); |
| + DCHECK(!output.mic_positions().size()); |
| + return output; |
| +} |
| + |
| +// static |
| media::interfaces::EncryptionSchemePtr TypeConverter< |
| media::interfaces::EncryptionSchemePtr, |
| media::EncryptionScheme>::Convert(const media::EncryptionScheme& input) { |