Commit a88118b3 authored by Benjamin Shaya's avatar Benjamin Shaya Committed by Commit Bot

Standalone tool for processing files with Cast Audio pipeline.

Bug: 124534506
Test: cplay
Change-Id: I512e2b6d2f43d56c13d0dcf1dcf5d63778156135
Reviewed-on: https://chromium-review.googlesource.com/c/1479303
Commit-Queue: Benjamin Shaya <bshaya@chromium.org>
Auto-Submit: Benjamin Shaya <bshaya@chromium.org>
Reviewed-by: default avatarKenneth MacKay <kmackay@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634357}
parent ad64b0ee
...@@ -191,6 +191,51 @@ cast_source_set("audio_resampler") { ...@@ -191,6 +191,51 @@ cast_source_set("audio_resampler") {
] ]
} }
cast_source_set("mixer_pipeline") {
sources = [
"audio_output_redirector_input.h",
"filter_group.cc",
"filter_group.h",
"mixer_input.cc",
"mixer_input.h",
"mixer_pipeline.cc",
"mixer_pipeline.h",
"post_processing_pipeline.h",
"post_processing_pipeline_impl.cc",
"post_processing_pipeline_impl.h",
"post_processing_pipeline_parser.cc",
"post_processing_pipeline_parser.h",
]
deps = [
":audio_buildflags",
":audio_helpers",
":audio_resampler",
":cast_audio_json",
":post_processor_factory",
":public",
"//base",
"//chromecast/base",
"//chromecast/media/base",
"//chromecast/media/cma/base",
"//chromecast/media/cma/decoder",
"//chromecast/public",
"//chromecast/public/media",
"//media",
"//media:shared_memory_support",
]
}
cast_source_set("volume_map") {
sources = [
"volume_map.cc",
"volume_map.h",
]
deps = [
":cast_audio_json",
"//base",
]
}
cast_source_set("for_mixer_audio") { cast_source_set("for_mixer_audio") {
sources = [ sources = [
"audio_decoder_for_mixer.cc", "audio_decoder_for_mixer.cc",
...@@ -202,24 +247,11 @@ cast_source_set("for_mixer_audio") { ...@@ -202,24 +247,11 @@ cast_source_set("for_mixer_audio") {
"cast_media_shlib_mixer_audio.cc", "cast_media_shlib_mixer_audio.cc",
"direct_mixer_source.cc", "direct_mixer_source.cc",
"direct_mixer_source.h", "direct_mixer_source.h",
"filter_group.cc",
"filter_group.h",
"media_pipeline_backend_for_mixer.cc", "media_pipeline_backend_for_mixer.cc",
"media_pipeline_backend_for_mixer.h", "media_pipeline_backend_for_mixer.h",
"mixer_input.cc",
"mixer_input.h",
"mixer_pipeline.cc",
"mixer_pipeline.h",
"post_processing_pipeline.h",
"post_processing_pipeline_impl.cc",
"post_processing_pipeline_impl.h",
"post_processing_pipeline_parser.cc",
"post_processing_pipeline_parser.h",
"stream_mixer.cc", "stream_mixer.cc",
"stream_mixer.h", "stream_mixer.h",
"volume_control.cc", "volume_control.cc",
"volume_map.cc",
"volume_map.h",
] ]
deps = [ deps = [
...@@ -227,8 +259,10 @@ cast_source_set("for_mixer_audio") { ...@@ -227,8 +259,10 @@ cast_source_set("for_mixer_audio") {
":audio_helpers", ":audio_helpers",
":audio_resampler", ":audio_resampler",
":cast_audio_json", ":cast_audio_json",
":mixer_pipeline",
":post_processor_factory", ":post_processor_factory",
":public", ":public",
":volume_map",
"//base", "//base",
"//chromecast/base", "//chromecast/base",
"//chromecast/media/audio:libcast_external_audio_pipeline_1.0", "//chromecast/media/audio:libcast_external_audio_pipeline_1.0",
...@@ -278,8 +312,10 @@ test("cast_audio_backend_unittests") { ...@@ -278,8 +312,10 @@ test("cast_audio_backend_unittests") {
":av_sync_dummy", ":av_sync_dummy",
":cast_audio_json", ":cast_audio_json",
":for_mixer_audio", ":for_mixer_audio",
":mixer_pipeline",
":null_video", ":null_video",
":public", ":public",
":volume_map",
"//base", "//base",
"//base/test:run_all_unittests", "//base/test:run_all_unittests",
"//chromecast/media/audio:fake_external_audio_pipeline", "//chromecast/media/audio:fake_external_audio_pipeline",
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/strings/pattern.h" #include "base/strings/pattern.h"
#include "base/values.h" #include "base/values.h"
#include "chromecast/media/cma/backend/audio_fader.h" #include "chromecast/media/cma/backend/audio_fader.h"
#include "chromecast/media/cma/backend/audio_output_redirector_input.h"
#include "chromecast/media/cma/backend/mixer_input.h" #include "chromecast/media/cma/backend/mixer_input.h"
#include "chromecast/media/cma/backend/stream_mixer.h" #include "chromecast/media/cma/backend/stream_mixer.h"
#include "chromecast/public/cast_media_shlib.h" #include "chromecast/public/cast_media_shlib.h"
......
...@@ -25,32 +25,6 @@ namespace chromecast { ...@@ -25,32 +25,6 @@ namespace chromecast {
namespace media { namespace media {
class MixerInput; class MixerInput;
// Interface used by matching MixerInputs to pass audio data to an output
// redirector.
class AudioOutputRedirectorInput {
public:
// Returns the relative order of the output redirector (used if there are
// multiple output redirectors that match a given MixerInput).
virtual int Order() = 0;
// Returns any extra delay that the output redirector will add. Used for A/V
// sync.
virtual int64_t GetDelayMicroseconds() = 0;
// Called to handle audio from a single input stream. Note that all audio
// output redirectors will receive this data, even if they are not first in
// the queue of redirectors; this is to allow smooth fading in/out when
// redirectors are added or removed.
virtual void Redirect(
::media::AudioBus* const buffer,
int num_frames,
MediaPipelineBackend::AudioDecoder::RenderingDelay rendering_delay,
bool redirected) = 0;
protected:
virtual ~AudioOutputRedirectorInput() = default;
};
// Empty interface so we can use a pointer to AudioOutputRedirector as the // Empty interface so we can use a pointer to AudioOutputRedirector as the
// token. // token.
class AudioOutputRedirectorToken {}; class AudioOutputRedirectorToken {};
......
// Copyright 2018 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.
#ifndef CHROMECAST_MEDIA_CMA_BACKEND_AUDIO_OUTPUT_REDIRECTOR_INPUT_H_
#define CHROMECAST_MEDIA_CMA_BACKEND_AUDIO_OUTPUT_REDIRECTOR_INPUT_H_
namespace media {
class AudioBus;
} // namespace media
namespace chromecast {
namespace media {
// Interface used by matching MixerInputs to pass audio data to an output
// redirector.
class AudioOutputRedirectorInput {
public:
// Returns the relative order of the output redirector (used if there are
// multiple output redirectors that match a given MixerInput).
virtual int Order() = 0;
// Returns any extra delay that the output redirector will add. Used for A/V
// sync.
virtual int64_t GetDelayMicroseconds() = 0;
// Called to handle audio from a single input stream. Note that all audio
// output redirectors will receive this data, even if they are not first in
// the queue of redirectors; this is to allow smooth fading in/out when
// redirectors are added or removed.
virtual void Redirect(
::media::AudioBus* const buffer,
int num_frames,
MediaPipelineBackend::AudioDecoder::RenderingDelay rendering_delay,
bool redirected) = 0;
protected:
virtual ~AudioOutputRedirectorInput() = default;
};
} // namespace media
} // namespace chromecast
#endif // CHROMECAST_MEDIA_CMA_BACKEND_AUDIO_OUTPUT_REDIRECTOR_INPUT_H_
# Copyright 2019 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.
executable("cplay") {
sources = [
"cplay.cc",
"wav_header.h",
]
deps = [
"//base",
"//chromecast/media/cma/backend:cast_audio_json",
"//chromecast/media/cma/backend:mixer_pipeline",
"//chromecast/media/cma/backend:public",
"//chromecast/media/cma/backend:volume_map",
"//chromecast/public",
"//chromecast/public/media",
"//media",
]
}
This diff is collapsed.
// Copyright 2019 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.
#ifndef CHROMECAST_MEDIA_CMA_BACKEND_CPLAY_WAV_HEADER_H_
#define CHROMECAST_MEDIA_CMA_BACKEND_CPLAY_WAV_HEADER_H_
#include <stdint.h>
namespace chromecast {
namespace media {
// From http://soundfile.sapp.org/doc/WaveFormat/
struct __attribute__((packed)) WavHeader {
const char riff[4] = {'R', 'I', 'F', 'F'};
uint32_t chunk_size; // size of file - 8
const char wave[4] = {'W', 'A', 'V', 'E'};
const char fmt[4] = {'f', 'm', 't', ' '};
const uint32_t subchunk_size = 16;
const uint16_t audio_format = 1; // PCM
uint16_t num_channels;
uint32_t sample_rate;
uint32_t byte_rate; // sample_rate * num_channels * bytes per sample
uint16_t block_align; // num_channels * bytes per sample
uint16_t bits_per_sample;
const char data[4] = {'d', 'a', 't', 'a'};
uint32_t subchunk_2_size; // bytes in the data
WavHeader();
~WavHeader() = default;
void SetDataSize(int size_bytes) {
chunk_size = 36 + size_bytes;
subchunk_2_size = size_bytes;
}
void SetNumChannels(int num_channels_in) {
num_channels = num_channels_in;
byte_rate = sample_rate * num_channels * bits_per_sample / 8;
block_align = num_channels * bits_per_sample / 8;
}
void SetSampleRate(int sample_rate_in) {
sample_rate = sample_rate_in;
byte_rate = sample_rate * num_channels * bits_per_sample / 8;
}
void SetBitsPerSample(int bits_per_sample_in) {
bits_per_sample = bits_per_sample_in;
byte_rate = sample_rate * num_channels * bits_per_sample / 8;
block_align = num_channels * bits_per_sample / 8;
}
};
WavHeader::WavHeader() = default;
} // namespace media
} // namespace chromecast
#endif // CHROMECAST_MEDIA_CMA_BACKEND_CPLAY_WAV_HEADER_H_
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/logging.h" #include "base/logging.h"
#include "chromecast/media/cma/backend/audio_fader.h" #include "chromecast/media/cma/backend/audio_fader.h"
#include "chromecast/media/cma/backend/audio_output_redirector.h" #include "chromecast/media/cma/backend/audio_output_redirector_input.h"
#include "chromecast/media/cma/backend/filter_group.h" #include "chromecast/media/cma/backend/filter_group.h"
#include "media/base/audio_bus.h" #include "media/base/audio_bus.h"
#include "media/base/audio_timestamp_helper.h" #include "media/base/audio_timestamp_helper.h"
......
...@@ -32,13 +32,14 @@ class VolumeMap { ...@@ -32,13 +32,14 @@ class VolumeMap {
float DbFSToVolume(float db); float DbFSToVolume(float db);
void LoadVolumeMap(std::unique_ptr<base::Value> cast_audio_config);
private: private:
struct LevelToDb { struct LevelToDb {
float level; float level;
float db; float db;
}; };
void LoadVolumeMap(std::unique_ptr<base::Value> cast_audio_config);
void UseDefaultVolumeMap(); void UseDefaultVolumeMap();
// |volume_map_| must be accessed with |lock_|. // |volume_map_| must be accessed with |lock_|.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment