Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1093)

Unified Diff: media/mojo/common/media_type_converters.cc

Issue 1896883002: Mojo interfaces needed for switching audio rendering stream creation and closing from IPC to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
+ 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
+
Henrik Grunell 2016/04/28 11:44:55 Remove empty line.
rchtara 2016/05/02 15:54:10 Done.
media::SubsampleEntry
TypeConverter<media::SubsampleEntry, media::interfaces::SubsampleEntryPtr>::
Convert(const media::interfaces::SubsampleEntryPtr& input) {

Powered by Google App Engine
This is Rietveld 408576698