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

Unified Diff: remoting/protocol/ice_connection_to_client.cc

Issue 2254673002: Remove dependency on AudioStub in ConnectionToClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win Created 4 years, 3 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
« no previous file with comments | « remoting/protocol/ice_connection_to_client.h ('k') | remoting/protocol/protocol_mock_objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/ice_connection_to_client.cc
diff --git a/remoting/protocol/ice_connection_to_client.cc b/remoting/protocol/ice_connection_to_client.cc
index 4a7dcf3720a328fd38133f508b525f8c231c48c7..4742f19a38ad2972628016fefe021c8e2a6c873b 100644
--- a/remoting/protocol/ice_connection_to_client.cc
+++ b/remoting/protocol/ice_connection_to_client.cc
@@ -10,7 +10,11 @@
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "net/base/io_buffer.h"
+#include "remoting/codec/audio_encoder.h"
+#include "remoting/codec/audio_encoder_opus.h"
#include "remoting/codec/video_encoder.h"
+#include "remoting/protocol/audio_pump.h"
+#include "remoting/protocol/audio_source.h"
#include "remoting/protocol/audio_writer.h"
#include "remoting/protocol/clipboard_stub.h"
#include "remoting/protocol/host_control_dispatcher.h"
@@ -24,13 +28,31 @@
namespace remoting {
namespace protocol {
+namespace {
+
+std::unique_ptr<AudioEncoder> CreateAudioEncoder(
+ const protocol::SessionConfig& config) {
+ const protocol::ChannelConfig& audio_config = config.audio_config();
+
+ if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) {
+ return base::WrapUnique(new AudioEncoderOpus());
+ }
+
+ NOTREACHED();
+ return nullptr;
+}
+
+} // namespace
+
IceConnectionToClient::IceConnectionToClient(
std::unique_ptr<protocol::Session> session,
scoped_refptr<TransportContext> transport_context,
- scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner)
+ scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner)
: event_handler_(nullptr),
session_(std::move(session)),
video_encode_task_runner_(video_encode_task_runner),
+ audio_task_runner_(audio_task_runner),
transport_(transport_context, this),
control_dispatcher_(new HostControlDispatcher()),
event_dispatcher_(new HostEventDispatcher()),
@@ -79,9 +101,20 @@ std::unique_ptr<VideoStream> IceConnectionToClient::StartVideoStream(
return std::move(pump);
}
-AudioStub* IceConnectionToClient::audio_stub() {
+std::unique_ptr<AudioStream> IceConnectionToClient::StartAudioStream(
+ std::unique_ptr<AudioSource> audio_source) {
DCHECK(thread_checker_.CalledOnValidThread());
- return audio_writer_.get();
+
+ // Audio channel is disabled.
+ if (!audio_writer_)
+ return nullptr;
+
+ std::unique_ptr<AudioEncoder> audio_encoder =
+ CreateAudioEncoder(session_->config());
+
+ return base::WrapUnique(
+ new AudioPump(audio_task_runner_, std::move(audio_source),
+ std::move(audio_encoder), audio_writer_.get()));
}
// Return pointer to ClientStub.
@@ -190,7 +223,7 @@ void IceConnectionToClient::NotifyIfChannelsReady() {
return;
}
event_handler_->OnConnectionChannelsConnected(this);
- event_handler_->CreateVideoStreams(this);
+ event_handler_->CreateMediaStreams(this);
}
void IceConnectionToClient::CloseChannels() {
« no previous file with comments | « remoting/protocol/ice_connection_to_client.h ('k') | remoting/protocol/protocol_mock_objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698