| 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) \
|
| + 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);
|
| @@ -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.
|
| + 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) {
|
|
|