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..1144360e4f81629f347096eb9605b01594800615 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,39 @@ 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_); |
+ output.set_effects(input->effects_); |
+ return output; |
+} |
+ |
+// static |
media::interfaces::EncryptionSchemePtr TypeConverter< |
media::interfaces::EncryptionSchemePtr, |
media::EncryptionScheme>::Convert(const media::EncryptionScheme& input) { |
@@ -379,6 +441,7 @@ media::interfaces::SubsampleEntryPtr TypeConverter< |
} |
// static |
+ |
media::SubsampleEntry |
TypeConverter<media::SubsampleEntry, media::interfaces::SubsampleEntryPtr>:: |
Convert(const media::interfaces::SubsampleEntryPtr& input) { |