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

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, 7 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 8d562775b20d45f179d18523c11f680524aaae5b..7064acdc67b64906ad3496d4d49f48944e33d27d 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,30 @@ 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, mojo_prefix, value) \
+ static_assert(media::media_enum::value == \
+ static_cast<media::media_enum>(media::mojo_prefix::value), \
+ "Mismatched enum: " #media_enum #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,
+ interfaces::AudioFormat,
+ AUDIO_PCM_LINEAR);
+ASSERT_ENUM_EQ_COMPLEX(AudioParameters::Format,
+ interfaces::AudioFormat,
+ AUDIO_PCM_LOW_LATENCY);
+ASSERT_ENUM_EQ_COMPLEX(AudioParameters::Format,
+ interfaces::AudioFormat,
+ AUDIO_FAKE);
+ASSERT_ENUM_EQ_COMPLEX(AudioParameters::Format,
+ interfaces::AudioFormat,
+ AUDIO_FORMAT_LAST);
+
// AudioCodec.
ASSERT_ENUM_EQ_RAW(AudioCodec, kUnknownAudioCodec, AudioCodec::UNKNOWN);
ASSERT_ENUM_EQ(AudioCodec, kCodec, , AAC);
@@ -351,6 +372,45 @@ 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 otherwise it will be computed from channel_layout_
+ // in the AudioParameters constructor.
+ 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) {

Powered by Google App Engine
This is Rietveld 408576698