Commit cd16e206 authored by sergeyu's avatar sergeyu Committed by Commit bot

Remove dependency on AudioStub in ConnectionToClient

Replaced audio_stub() in ConnectionToClient interface with
CreateAudioStream(). The new method returns AudioSendStream which
doesn't depend on AudioStub. AudioPump class has been moved to
remoting/protocol and it implements AudioSendStream interface for ICE
protocol.
This change makes it possible to implement audio support in
WebrtcConnectionToClient.

Also removed verbatim audio codec as it wasn't used anywhere.

BUG=638505

Review-Url: https://codereview.chromium.org/2254673002
Cr-Commit-Position: refs/heads/master@{#418002}
parent e4e4e43d
......@@ -8,13 +8,9 @@ source_set("codec") {
"audio_decoder.h",
"audio_decoder_opus.cc",
"audio_decoder_opus.h",
"audio_decoder_verbatim.cc",
"audio_decoder_verbatim.h",
"audio_encoder.h",
"audio_encoder_opus.cc",
"audio_encoder_opus.h",
"audio_encoder_verbatim.cc",
"audio_encoder_verbatim.h",
"scoped_vpx_codec.cc",
"scoped_vpx_codec.h",
"video_decoder.h",
......@@ -56,8 +52,6 @@ source_set("codec") {
"audio_encoder.h",
"audio_encoder_opus.cc",
"audio_encoder_opus.h",
"audio_encoder_verbatim.cc",
"audio_encoder_verbatim.h",
"video_encoder.cc",
"video_encoder.h",
"video_encoder_helper.cc",
......
......@@ -7,18 +7,13 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "remoting/codec/audio_decoder_opus.h"
#include "remoting/codec/audio_decoder_verbatim.h"
#include "remoting/protocol/session_config.h"
namespace remoting {
std::unique_ptr<AudioDecoder> AudioDecoder::CreateAudioDecoder(
const protocol::SessionConfig& config) {
const protocol::ChannelConfig& audio_config = config.audio_config();
if (audio_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) {
return base::WrapUnique(new AudioDecoderVerbatim());
} else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) {
if (config.audio_config().codec == protocol::ChannelConfig::CODEC_OPUS) {
return base::WrapUnique(new AudioDecoderOpus());
}
......
// Copyright (c) 2012 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 "remoting/codec/audio_decoder_verbatim.h"
#include "base/logging.h"
#include "remoting/proto/audio.pb.h"
namespace remoting {
AudioDecoderVerbatim::AudioDecoderVerbatim() {}
AudioDecoderVerbatim::~AudioDecoderVerbatim() {}
std::unique_ptr<AudioPacket> AudioDecoderVerbatim::Decode(
std::unique_ptr<AudioPacket> packet) {
// Return a null scoped_ptr if we get a corrupted packet.
if ((packet->encoding() != AudioPacket::ENCODING_RAW) ||
(packet->data_size() != 1) ||
(packet->sampling_rate() == AudioPacket::SAMPLING_RATE_INVALID) ||
(packet->bytes_per_sample() != AudioPacket::BYTES_PER_SAMPLE_2) ||
(packet->channels() != AudioPacket::CHANNELS_STEREO) ||
(packet->data(0).size() %
(AudioPacket::CHANNELS_STEREO * AudioPacket::BYTES_PER_SAMPLE_2) != 0)) {
LOG(WARNING) << "Verbatim decoder received an invalid packet.";
return nullptr;
}
return packet;
}
} // namespace remoting
// Copyright (c) 2012 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 REMOTING_CODEC_AUDIO_DECODER_VERBATIM_H_
#define REMOTING_CODEC_AUDIO_DECODER_VERBATIM_H_
#include <memory>
#include "base/macros.h"
#include "remoting/codec/audio_decoder.h"
namespace remoting {
class AudioPacket;
// The decoder for raw audio streams.
class AudioDecoderVerbatim : public AudioDecoder {
public:
AudioDecoderVerbatim();
~AudioDecoderVerbatim() override;
std::unique_ptr<AudioPacket> Decode(
std::unique_ptr<AudioPacket> packet) override;
private:
DISALLOW_COPY_AND_ASSIGN(AudioDecoderVerbatim);
};
} // namespace remoting
#endif // REMOTING_CODEC_AUDIO_DECODER_VERBATIM_H_
// Copyright (c) 2012 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 "remoting/codec/audio_encoder_verbatim.h"
#include "base/logging.h"
#include "remoting/proto/audio.pb.h"
namespace remoting {
AudioEncoderVerbatim::AudioEncoderVerbatim() {}
AudioEncoderVerbatim::~AudioEncoderVerbatim() {}
std::unique_ptr<AudioPacket> AudioEncoderVerbatim::Encode(
std::unique_ptr<AudioPacket> packet) {
DCHECK_EQ(AudioPacket::ENCODING_RAW, packet->encoding());
DCHECK_EQ(1, packet->data_size());
DCHECK_NE(AudioPacket::SAMPLING_RATE_INVALID, packet->sampling_rate());
DCHECK_NE(AudioPacket::BYTES_PER_SAMPLE_INVALID, packet->bytes_per_sample());
DCHECK_NE(AudioPacket::CHANNELS_INVALID, packet->channels());
return packet;
}
int AudioEncoderVerbatim::GetBitrate() {
return AudioPacket::SAMPLING_RATE_48000 * AudioPacket::BYTES_PER_SAMPLE_2 *
AudioPacket::CHANNELS_STEREO * 8;
}
} // namespace remoting
// Copyright (c) 2012 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 REMOTING_CODEC_AUDIO_ENCODER_VERBATIM_H_
#define REMOTING_CODEC_AUDIO_ENCODER_VERBATIM_H_
#include "base/macros.h"
#include "remoting/codec/audio_encoder.h"
namespace remoting {
class AudioPacket;
class AudioEncoderVerbatim : public AudioEncoder {
public:
AudioEncoderVerbatim();
~AudioEncoderVerbatim() override;
// AudioEncoder implementation.
std::unique_ptr<AudioPacket> Encode(
std::unique_ptr<AudioPacket> packet) override;
int GetBitrate() override;
private:
DISALLOW_COPY_AND_ASSIGN(AudioEncoderVerbatim);
};
} // namespace remoting
#endif // REMOTING_CODEC_AUDIO_ENCODER_VERBATIM_H_
......@@ -108,8 +108,6 @@ static_library("host") {
"audio_capturer_mac.cc",
"audio_capturer_win.cc",
"audio_capturer_win.h",
"audio_pump.cc",
"audio_pump.h",
"audio_silence_detector.cc",
"audio_silence_detector.h",
"backoff_timer.cc",
......@@ -562,7 +560,6 @@ source_set("unit_tests") {
testonly = true
sources = [
"audio_pump_unittest.cc",
"audio_silence_detector_unittest.cc",
"backoff_timer_unittest.cc",
"chromeos/aura_desktop_capturer_unittest.cc",
......
......@@ -7,29 +7,19 @@
#include <memory>
#include "base/callback.h"
#include "remoting/protocol/audio_source.h"
namespace remoting {
class AudioPacket;
class AudioCapturer {
class AudioCapturer : public protocol::AudioSource {
public:
typedef base::Callback<void(std::unique_ptr<AudioPacket> packet)>
PacketCapturedCallback;
virtual ~AudioCapturer() {}
~AudioCapturer() override {}
// Returns true if audio capturing is supported on this platform. If this
// returns true, then Create() must not return nullptr.
static bool IsSupported();
static std::unique_ptr<AudioCapturer> Create();
// Capturers should sample at a 44.1 or 48 kHz sampling rate, in uncompressed
// PCM stereo format. Capturers may choose the number of frames per packet.
// Returns true on success.
virtual bool Start(const PacketCapturedCallback& callback) = 0;
static bool IsValidSampleRate(int sample_rate);
};
......
......@@ -272,14 +272,13 @@ void ChromotingHost::OnIncomingSession(
} else {
connection.reset(new protocol::IceConnectionToClient(
base::WrapUnique(session), transport_context_,
video_encode_task_runner_));
video_encode_task_runner_, audio_task_runner_));
}
// Create a ClientSession object.
ClientSession* client =
new ClientSession(this, audio_task_runner_, std::move(connection),
desktop_environment_factory_, max_session_duration_,
pairing_registry_, extensions_.get());
ClientSession* client = new ClientSession(
this, std::move(connection), desktop_environment_factory_,
max_session_duration_, pairing_registry_, extensions_.get());
clients_.push_back(client);
}
......
......@@ -127,8 +127,7 @@ class ChromotingHostTest : public testing::Test {
(connection_index == 0) ? owned_connection1_ : owned_connection2_);
protocol::ConnectionToClient* connection_ptr = connection.get();
std::unique_ptr<ClientSession> client(new ClientSession(
host_.get(), task_runner_ /* audio_task_runner */,
std::move(connection), desktop_environment_factory_.get(),
host_.get(), std::move(connection), desktop_environment_factory_.get(),
base::TimeDelta(), nullptr, std::vector<HostExtension*>()));
ClientSession* client_ptr = client.get();
......
......@@ -15,11 +15,7 @@
#include "remoting/base/capabilities.h"
#include "remoting/base/constants.h"
#include "remoting/base/logging.h"
#include "remoting/codec/audio_encoder.h"
#include "remoting/codec/audio_encoder_opus.h"
#include "remoting/codec/audio_encoder_verbatim.h"
#include "remoting/host/audio_capturer.h"
#include "remoting/host/audio_pump.h"
#include "remoting/host/desktop_environment.h"
#include "remoting/host/host_extension_session.h"
#include "remoting/host/input_injector.h"
......@@ -28,6 +24,7 @@
#include "remoting/host/screen_resolution.h"
#include "remoting/proto/control.pb.h"
#include "remoting/proto/event.pb.h"
#include "remoting/protocol/audio_stream.h"
#include "remoting/protocol/client_stub.h"
#include "remoting/protocol/clipboard_thread_proxy.h"
#include "remoting/protocol/pairing_registry.h"
......@@ -43,25 +40,10 @@ namespace {
// Name of command-line flag to disable use of I444 by default.
const char kDisableI444SwitchName[] = "disable-i444";
std::unique_ptr<AudioEncoder> CreateAudioEncoder(
const protocol::SessionConfig& config) {
const protocol::ChannelConfig& audio_config = config.audio_config();
if (audio_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) {
return base::MakeUnique<AudioEncoderVerbatim>();
} else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) {
return base::MakeUnique<AudioEncoderOpus>();
}
NOTREACHED();
return nullptr;
}
} // namespace
ClientSession::ClientSession(
EventHandler* event_handler,
scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
std::unique_ptr<protocol::ConnectionToClient> connection,
DesktopEnvironmentFactory* desktop_environment_factory,
const base::TimeDelta& max_duration,
......@@ -78,7 +60,6 @@ ClientSession::ClientSession(
disable_clipboard_filter_(clipboard_echo_filter_.host_filter()),
client_clipboard_factory_(clipboard_echo_filter_.client_filter()),
max_duration_(max_duration),
audio_task_runner_(audio_task_runner),
pairing_registry_(pairing_registry),
// Note that |lossless_video_color_| defaults to true, but actually only
// controls VP9 video stream color quality.
......@@ -99,7 +80,7 @@ ClientSession::ClientSession(
ClientSession::~ClientSession() {
DCHECK(CalledOnValidThread());
DCHECK(!audio_pump_);
DCHECK(!audio_stream_);
DCHECK(!desktop_environment_);
DCHECK(!input_injector_);
DCHECK(!screen_controls_);
......@@ -173,8 +154,8 @@ void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) {
if (audio_control.has_enable()) {
VLOG(1) << "Received AudioControl (enable="
<< audio_control.enable() << ")";
if (audio_pump_)
audio_pump_->Pause(!audio_control.enable());
if (audio_stream_)
audio_stream_->Pause(!audio_control.enable());
}
}
......@@ -243,7 +224,7 @@ void ClientSession::OnConnectionAuthenticated(
protocol::ConnectionToClient* connection) {
DCHECK(CalledOnValidThread());
DCHECK_EQ(connection_.get(), connection);
DCHECK(!audio_pump_);
DCHECK(!audio_stream_);
DCHECK(!desktop_environment_);
DCHECK(!input_injector_);
DCHECK(!screen_controls_);
......@@ -295,7 +276,7 @@ void ClientSession::OnConnectionAuthenticated(
clipboard_echo_filter_.set_client_stub(connection_->client_stub());
}
void ClientSession::CreateVideoStreams(
void ClientSession::CreateMediaStreams(
protocol::ConnectionToClient* connection) {
DCHECK(CalledOnValidThread());
DCHECK_EQ(connection_.get(), connection);
......@@ -304,6 +285,10 @@ void ClientSession::CreateVideoStreams(
video_stream_ = connection_->StartVideoStream(
desktop_environment_->CreateVideoCapturer());
// Create a AudioStream to pump audio from the capturer to the client.
audio_stream_ = connection_->StartAudioStream(
desktop_environment_->CreateAudioCapturer());
video_stream_->SetObserver(this);
// Apply video-control parameters to the new stream.
......@@ -337,15 +322,6 @@ void ClientSession::OnConnectionChannelsConnected(
new MouseShapePump(desktop_environment_->CreateMouseCursorMonitor(),
connection_->client_stub()));
// Create an AudioPump if audio is enabled, to pump audio samples.
if (connection_->session()->config().is_audio_enabled()) {
std::unique_ptr<AudioEncoder> audio_encoder =
CreateAudioEncoder(connection_->session()->config());
audio_pump_.reset(new AudioPump(
audio_task_runner_, desktop_environment_->CreateAudioCapturer(),
std::move(audio_encoder), connection_->audio_stub()));
}
if (pending_video_layout_message_) {
connection_->client_stub()->SetVideoLayout(*pending_video_layout_message_);
pending_video_layout_message_.reset();
......@@ -375,7 +351,7 @@ void ClientSession::OnConnectionClosed(
// Stop components access the client, audio or video stubs, which are no
// longer valid once ConnectionToClient calls OnConnectionClosed().
audio_pump_.reset();
audio_stream_.reset();
video_stream_.reset();
mouse_shape_pump_.reset();
client_clipboard_factory_.InvalidateWeakPtrs();
......
......@@ -39,7 +39,7 @@ class SingleThreadTaskRunner;
namespace remoting {
class AudioPump;
class AudioStream;
class DesktopEnvironment;
class DesktopEnvironmentFactory;
class InputInjector;
......@@ -93,7 +93,6 @@ class ClientSession : public base::NonThreadSafe,
// |event_handler| and |desktop_environment_factory| must outlive |this|.
// All |HostExtension|s in |extensions| must outlive |this|.
ClientSession(EventHandler* event_handler,
scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
std::unique_ptr<protocol::ConnectionToClient> connection,
DesktopEnvironmentFactory* desktop_environment_factory,
const base::TimeDelta& max_duration,
......@@ -119,7 +118,7 @@ class ClientSession : public base::NonThreadSafe,
protocol::ConnectionToClient* connection) override;
void OnConnectionAuthenticated(
protocol::ConnectionToClient* connection) override;
void CreateVideoStreams(protocol::ConnectionToClient* connection) override;
void CreateMediaStreams(protocol::ConnectionToClient* connection) override;
void OnConnectionChannelsConnected(
protocol::ConnectionToClient* connection) override;
void OnConnectionClosed(protocol::ConnectionToClient* connection,
......@@ -207,11 +206,9 @@ class ClientSession : public base::NonThreadSafe,
// is reached.
base::OneShotTimer max_duration_timer_;
scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
// Objects responsible for sending video, audio and mouse shape.
std::unique_ptr<AudioPump> audio_pump_;
std::unique_ptr<protocol::VideoStream> video_stream_;
std::unique_ptr<protocol::AudioStream> audio_stream_;
std::unique_ptr<MouseShapePump> mouse_shape_pump_;
// The set of all capabilities supported by the client.
......
......@@ -185,11 +185,10 @@ void ClientSessionTest::CreateClientSession() {
connection->set_client_stub(&client_stub_);
connection_ = connection.get();
client_session_.reset(new ClientSession(
&session_event_handler_,
task_runner_, // Audio thread.
std::move(connection), desktop_environment_factory_.get(),
base::TimeDelta(), nullptr, extensions_));
client_session_.reset(
new ClientSession(&session_event_handler_, std::move(connection),
desktop_environment_factory_.get(), base::TimeDelta(),
nullptr, extensions_));
}
void ClientSessionTest::ConnectClientSession() {
......@@ -205,7 +204,7 @@ void ClientSessionTest::ConnectClientSession() {
EXPECT_TRUE(connection_->clipboard_stub());
EXPECT_TRUE(connection_->input_stub());
client_session_->CreateVideoStreams(client_session_->connection());
client_session_->CreateMediaStreams(client_session_->connection());
client_session_->OnConnectionChannelsConnected(client_session_->connection());
}
......
......@@ -23,7 +23,6 @@ message AudioPacket {
ENCODING_INVALID = -1;
ENCODING_RAW = 0; // Uncompressed encoding
ENCODING_OPUS = 1;
ENCODING_SPEEX = 2;
}
optional Encoding encoding = 3 [default = ENCODING_INVALID];
......
......@@ -6,6 +6,8 @@ import("//build/config/features.gni")
static_library("protocol") {
sources = [
"audio_pump.cc",
"audio_pump.h",
"audio_reader.cc",
"audio_reader.h",
"audio_stub.h",
......@@ -268,6 +270,7 @@ source_set("unit_tests") {
testonly = true
sources = [
"audio_pump_unittest.cc",
"authenticator_test_base.cc",
"authenticator_test_base.h",
"capture_scheduler_unittest.cc",
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Copyright 2016 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 "remoting/host/audio_pump.h"
#include "remoting/protocol/audio_pump.h"
#include <utility>
......@@ -13,54 +13,55 @@
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "remoting/codec/audio_encoder.h"
#include "remoting/host/audio_capturer.h"
#include "remoting/proto/audio.pb.h"
#include "remoting/protocol/audio_source.h"
#include "remoting/protocol/audio_stub.h"
namespace remoting {
namespace protocol {
// Limit the data stored in the pending send buffers to 250ms.
const int kMaxBufferedIntervalMs = 250;
class AudioPump::Core {
public:
Core(base::WeakPtr<AudioPump> pump,
std::unique_ptr<AudioCapturer> audio_capturer,
std::unique_ptr<AudioEncoder> audio_encoder);
~Core();
public:
Core(base::WeakPtr<AudioPump> pump,
std::unique_ptr<AudioSource> audio_source,
std::unique_ptr<AudioEncoder> audio_encoder);
~Core();
void Start();
void Pause(bool pause);
void Start();
void Pause(bool pause);
void OnPacketSent(int size);
void OnPacketSent(int size);
private:
void EncodeAudioPacket(std::unique_ptr<AudioPacket> packet);
private:
void EncodeAudioPacket(std::unique_ptr<AudioPacket> packet);
base::ThreadChecker thread_checker_;
base::ThreadChecker thread_checker_;
base::WeakPtr<AudioPump> pump_;
base::WeakPtr<AudioPump> pump_;
scoped_refptr<base::SingleThreadTaskRunner> pump_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> pump_task_runner_;
std::unique_ptr<AudioCapturer> audio_capturer_;
std::unique_ptr<AudioEncoder> audio_encoder_;
std::unique_ptr<AudioSource> audio_source_;
std::unique_ptr<AudioEncoder> audio_encoder_;
bool enabled_;
bool enabled_;
// Number of bytes in the queue that have been encoded but haven't been sent
// yet.
int bytes_pending_;
// Number of bytes in the queue that have been encoded but haven't been sent
// yet.
int bytes_pending_;
DISALLOW_COPY_AND_ASSIGN(Core);
DISALLOW_COPY_AND_ASSIGN(Core);
};
AudioPump::Core::Core(base::WeakPtr<AudioPump> pump,
std::unique_ptr<AudioCapturer> audio_capturer,
std::unique_ptr<AudioSource> audio_source,
std::unique_ptr<AudioEncoder> audio_encoder)
: pump_(pump),
pump_task_runner_(base::ThreadTaskRunnerHandle::Get()),
audio_capturer_(std::move(audio_capturer)),
audio_source_(std::move(audio_source)),
audio_encoder_(std::move(audio_encoder)),
enabled_(true),
bytes_pending_(0) {
......@@ -74,7 +75,7 @@ AudioPump::Core::~Core() {
void AudioPump::Core::Start() {
DCHECK(thread_checker_.CalledOnValidThread());
audio_capturer_->Start(
audio_source_->Start(
base::Bind(&Core::EncodeAudioPacket, base::Unretained(this)));
}
......@@ -87,7 +88,7 @@ void AudioPump::Core::Pause(bool pause) {
void AudioPump::Core::OnPacketSent(int size) {
DCHECK(thread_checker_.CalledOnValidThread());
bytes_pending_-= size;
bytes_pending_ -= size;
DCHECK_GE(bytes_pending_, 0);
}
......@@ -117,15 +118,15 @@ void AudioPump::Core::EncodeAudioPacket(std::unique_ptr<AudioPacket> packet) {
AudioPump::AudioPump(
scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
std::unique_ptr<AudioCapturer> audio_capturer,
std::unique_ptr<AudioSource> audio_source,
std::unique_ptr<AudioEncoder> audio_encoder,
protocol::AudioStub* audio_stub)
AudioStub* audio_stub)
: audio_task_runner_(audio_task_runner),
audio_stub_(audio_stub),
weak_factory_(this) {
DCHECK(audio_stub_);
core_.reset(new Core(weak_factory_.GetWeakPtr(), std::move(audio_capturer),
core_.reset(new Core(weak_factory_.GetWeakPtr(), std::move(audio_source),
std::move(audio_encoder)));
audio_task_runner_->PostTask(
......@@ -161,4 +162,5 @@ void AudioPump::OnPacketSent(int size) {
base::Bind(&Core::OnPacketSent, base::Unretained(core_.get()), size));
}
} // namespace protocol
} // namespace remoting
// Copyright 2015 The Chromium Authors. All rights reserved.
// Copyright 2016 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 REMOTING_HOST_AUDIO_PUMP_H_
#define REMOTING_HOST_AUDIO_PUMP_H_
#ifndef REMOTING_PROTOCOL_AUDIO_PUMP_H_
#define REMOTING_PROTOCOL_AUDIO_PUMP_H_
#include <memory>
......@@ -11,6 +11,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
#include "remoting/protocol/audio_stream.h"
namespace base {
class SingleThreadTaskRunner;
......@@ -18,32 +19,30 @@ class SingleThreadTaskRunner;
namespace remoting {
namespace protocol {
class AudioStub;
} // namespace protocol
class AudioCapturer;
class AudioEncoder;
class AudioPacket;
namespace protocol {
class AudioStub;
class AudioSource;
// AudioPump is responsible for fetching audio data from the AudioCapturer
// and encoding it before passing it to the AudioStub for delivery to the
// client. Audio is captured and encoded on the audio thread and then passed to
// AudioStub on the network thread.
class AudioPump {
class AudioPump : public AudioStream {
public:
// The caller must ensure that the |audio_stub| is not destroyed until the
// pump is destroyed.
AudioPump(scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
std::unique_ptr<AudioCapturer> audio_capturer,
std::unique_ptr<AudioSource> audio_source,
std::unique_ptr<AudioEncoder> audio_encoder,
protocol::AudioStub* audio_stub);
virtual ~AudioPump();
AudioStub* audio_stub);
~AudioPump() override;
// Pauses or resumes audio on a running session. This leaves the audio
// capturer running, and only affects whether or not the captured audio is
// encoded and sent on the wire.
void Pause(bool pause);
// AudioStream interface.
void Pause(bool pause) override;
private:
class Core;
......@@ -57,7 +56,7 @@ class AudioPump {
base::ThreadChecker thread_checker_;
scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
protocol::AudioStub* audio_stub_;
AudioStub* audio_stub_;
std::unique_ptr<Core> core_;
......@@ -66,6 +65,7 @@ class AudioPump {
DISALLOW_COPY_AND_ASSIGN(AudioPump);
};
} // namespace protocol
} // namespace remoting
#endif // REMOTING_HOST_AUDIO_PUMP_H_
#endif // REMOTING_PROTOCOL_AUDIO_PUMP_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/host/audio_pump.h"
#include "remoting/protocol/audio_pump.h"
#include <stddef.h>
......@@ -14,12 +14,13 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "remoting/codec/audio_encoder.h"
#include "remoting/host/audio_capturer.h"
#include "remoting/proto/audio.pb.h"
#include "remoting/protocol/audio_source.h"
#include "remoting/protocol/audio_stub.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace remoting {
namespace protocol {
namespace {
......@@ -32,10 +33,10 @@ std::unique_ptr<AudioPacket> MakeAudioPacket() {
} // namespace
class FakeAudioCapturer : public AudioCapturer {
class FakeAudioSource : public AudioSource {
public:
FakeAudioCapturer() {}
~FakeAudioCapturer() override {}
FakeAudioSource() {}
~FakeAudioSource() override {}
bool Start(const PacketCapturedCallback& callback) override {
callback_ = callback;
......@@ -47,7 +48,7 @@ class FakeAudioCapturer : public AudioCapturer {
private:
PacketCapturedCallback callback_;
DISALLOW_COPY_AND_ASSIGN(FakeAudioCapturer);
DISALLOW_COPY_AND_ASSIGN(FakeAudioSource);
};
class FakeAudioEncoder : public AudioEncoder {
......@@ -59,9 +60,7 @@ class FakeAudioEncoder : public AudioEncoder {
std::unique_ptr<AudioPacket> packet) override {
return packet;
}
int GetBitrate() override {
return 160000;
}
int GetBitrate() override { return 160000; }
private:
DISALLOW_COPY_AND_ASSIGN(FakeAudioEncoder);
......@@ -81,8 +80,8 @@ class AudioPumpTest : public testing::Test, public protocol::AudioStub {
protected: