Index: remoting/protocol/connection_to_host.cc |
diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc |
index 296439bf0d6ef6d3285bd5c278ab3cdb24f8df83..c4ff9515bc22f2e24483a01a8cd8b236dc02f2ed 100644 |
--- a/remoting/protocol/connection_to_host.cc |
+++ b/remoting/protocol/connection_to_host.cc |
@@ -10,6 +10,8 @@ |
#include "remoting/base/constants.h" |
#include "remoting/jingle_glue/javascript_signal_strategy.h" |
#include "remoting/jingle_glue/xmpp_signal_strategy.h" |
+#include "remoting/protocol/audio_reader.h" |
+#include "remoting/protocol/audio_stub.h" |
#include "remoting/protocol/auth_util.h" |
#include "remoting/protocol/authenticator.h" |
#include "remoting/protocol/client_control_dispatcher.h" |
@@ -33,6 +35,7 @@ ConnectionToHost::ConnectionToHost( |
client_stub_(NULL), |
clipboard_stub_(NULL), |
video_stub_(NULL), |
+ audio_stub_(NULL), |
state_(CONNECTING), |
error_(OK) { |
} |
@@ -62,11 +65,13 @@ void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy, |
HostEventCallback* event_callback, |
ClientStub* client_stub, |
ClipboardStub* clipboard_stub, |
- VideoStub* video_stub) { |
+ VideoStub* video_stub, |
+ AudioStub* audio_stub) { |
event_callback_ = event_callback; |
client_stub_ = client_stub; |
clipboard_stub_ = clipboard_stub; |
video_stub_ = video_stub; |
+ audio_stub_ = audio_stub; |
authenticator_ = authenticator.Pass(); |
// Save jid of the host. The actual connection is created later after |
@@ -162,6 +167,12 @@ void ConnectionToHost::OnSessionStateChange( |
video_reader_->Init(session_.get(), video_stub_, base::Bind( |
&ConnectionToHost::OnChannelInitialized, base::Unretained(this))); |
+ if (AudioEnabled()) { |
+ audio_reader_ = AudioReader::Create(session_->config()); |
+ audio_reader_->Init(session_.get(), audio_stub_, base::Bind( |
+ &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); |
+ } |
+ |
control_dispatcher_.reset(new ClientControlDispatcher()); |
control_dispatcher_->Init(session_.get(), base::Bind( |
&ConnectionToHost::OnChannelInitialized, base::Unretained(this))); |
@@ -211,6 +222,8 @@ void ConnectionToHost::NotifyIfChannelsReady() { |
if (control_dispatcher_.get() && control_dispatcher_->is_connected() && |
event_dispatcher_.get() && event_dispatcher_->is_connected() && |
video_reader_.get() && video_reader_->is_connected() && |
+ (!AudioEnabled() || |
+ (audio_reader_.get() && audio_reader_->is_connected())) && |
state_ == CONNECTING) { |
// Start forwarding clipboard and input events. |
clipboard_forwarder_.set_clipboard_stub(control_dispatcher_.get()); |
@@ -230,6 +243,7 @@ void ConnectionToHost::CloseChannels() { |
clipboard_forwarder_.set_clipboard_stub(NULL); |
event_forwarder_.set_input_stub(NULL); |
video_reader_.reset(); |
+ audio_reader_.reset(); |
} |
void ConnectionToHost::SetState(State state, ErrorCode error) { |
@@ -244,5 +258,10 @@ void ConnectionToHost::SetState(State state, ErrorCode error) { |
} |
} |
+bool ConnectionToHost::AudioEnabled() { |
+ return (session_->config().audio_config().transport != |
+ ChannelConfig::TRANSPORT_NONE); |
+} |
+ |
} // namespace protocol |
} // namespace remoting |