| Index: chromecast/media/audio/audio_manager.cc
|
| diff --git a/chromecast/media/audio/audio_manager.cc b/chromecast/media/audio/audio_manager.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e2bce4715173ed2a7ab6a72e788424d069a651af
|
| --- /dev/null
|
| +++ b/chromecast/media/audio/audio_manager.cc
|
| @@ -0,0 +1,110 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chromecast/media/audio/audio_manager.h"
|
| +
|
| +#include "chromecast/base/task_runner_impl.h"
|
| +#include "chromecast/media/audio/audio_output_stream.h"
|
| +#include "chromecast/public/cast_media_shlib.h"
|
| +#include "chromecast/public/media/media_pipeline_backend.h"
|
| +#include "chromecast/public/media/media_pipeline_device_params.h"
|
| +
|
| +namespace chromecast {
|
| +namespace media {
|
| +
|
| +AudioManager::AudioManager(::media::AudioLogFactory* audio_log_factory)
|
| + : AudioManagerBase(audio_log_factory) {}
|
| +
|
| +AudioManager::~AudioManager() {
|
| + Shutdown();
|
| +}
|
| +
|
| +bool AudioManager::HasAudioOutputDevices() {
|
| + return true;
|
| +}
|
| +
|
| +bool AudioManager::HasAudioInputDevices() {
|
| + return false;
|
| +}
|
| +
|
| +void AudioManager::ShowAudioInputSettings() {
|
| + LOG(WARNING) << "No support for input audio devices";
|
| +}
|
| +
|
| +void AudioManager::GetAudioInputDeviceNames(
|
| + ::media::AudioDeviceNames* device_names) {
|
| + DCHECK(device_names->empty());
|
| + LOG(WARNING) << "No support for input audio devices";
|
| +}
|
| +
|
| +::media::AudioParameters AudioManager::GetInputStreamParameters(
|
| + const std::string& device_id) {
|
| + LOG(WARNING) << "No support for input audio devices";
|
| + // Need to send a valid AudioParameters object even when it will unused.
|
| + return ::media::AudioParameters(
|
| + ::media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
|
| + ::media::CHANNEL_LAYOUT_STEREO, 48000, 16, 1024);
|
| +}
|
| +
|
| +scoped_ptr<MediaPipelineBackend> AudioManager::CreateMediaPipelineBackend() {
|
| + if (!audio_task_runner_)
|
| + audio_task_runner_.reset(new TaskRunnerImpl());
|
| +
|
| + MediaPipelineDeviceParams device_params(
|
| + MediaPipelineDeviceParams::kModeIgnorePts, audio_task_runner_.get());
|
| + return scoped_ptr<MediaPipelineBackend>(
|
| + CastMediaShlib::CreateMediaPipelineBackend(device_params));
|
| +}
|
| +
|
| +::media::AudioOutputStream* AudioManager::MakeLinearOutputStream(
|
| + const ::media::AudioParameters& params) {
|
| + DCHECK_EQ(::media::AudioParameters::AUDIO_PCM_LINEAR, params.format());
|
| + return new AudioOutputStream(params, this);
|
| +}
|
| +
|
| +::media::AudioOutputStream* AudioManager::MakeLowLatencyOutputStream(
|
| + const ::media::AudioParameters& params,
|
| + const std::string& device_id) {
|
| + DCHECK_EQ(::media::AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format());
|
| + return new AudioOutputStream(params, this);
|
| +}
|
| +
|
| +::media::AudioInputStream* AudioManager::MakeLinearInputStream(
|
| + const ::media::AudioParameters& params,
|
| + const std::string& device_id) {
|
| + LOG(WARNING) << "No support for input audio devices";
|
| + return nullptr;
|
| +}
|
| +
|
| +::media::AudioInputStream* AudioManager::MakeLowLatencyInputStream(
|
| + const ::media::AudioParameters& params,
|
| + const std::string& device_id) {
|
| + LOG(WARNING) << "No support for input audio devices";
|
| + return nullptr;
|
| +}
|
| +
|
| +::media::AudioParameters AudioManager::GetPreferredOutputStreamParameters(
|
| + const std::string& output_device_id,
|
| + const ::media::AudioParameters& input_params) {
|
| + ::media::ChannelLayout channel_layout = ::media::CHANNEL_LAYOUT_STEREO;
|
| + int sample_rate = 44100;
|
| + int buffer_size = 2048;
|
| + int bits_per_sample = 16;
|
| + if (input_params.IsValid()) {
|
| + // Do not change:
|
| + // - the channel layout
|
| + // - the number of bits per sample
|
| + // We support stereo only with 16 bits per sample.
|
| + sample_rate = input_params.sample_rate();
|
| + }
|
| +
|
| + ::media::AudioParameters output_params(
|
| + ::media::AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
|
| + sample_rate, bits_per_sample, buffer_size,
|
| + ::media::AudioParameters::NO_EFFECTS);
|
| + return output_params;
|
| +}
|
| +
|
| +} // namespace media
|
| +} // namespace chromecast
|
|
|