| 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..6b785bb833b603edbb9ea0a578ee0439265a4a50 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)));
|
|
|
| + audio_reader_ = AudioReader::Create(session_->config());
|
| + if (audio_reader_.get()) {
|
| + 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)));
|
| @@ -208,15 +219,23 @@ void ConnectionToHost::OnChannelInitialized(bool successful) {
|
| }
|
|
|
| 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() &&
|
| - state_ == CONNECTING) {
|
| - // Start forwarding clipboard and input events.
|
| - clipboard_forwarder_.set_clipboard_stub(control_dispatcher_.get());
|
| - event_forwarder_.set_input_stub(event_dispatcher_.get());
|
| - SetState(CONNECTED, OK);
|
| + if (!control_dispatcher_.get() || !control_dispatcher_->is_connected())
|
| + return;
|
| + if (!event_dispatcher_.get() || !event_dispatcher_->is_connected())
|
| + return;
|
| + if (!video_reader_.get() || !video_reader_->is_connected())
|
| + return;
|
| + if ((!audio_reader_.get() || !audio_reader_->is_connected()) &&
|
| + session_->config().is_audio_enabled()) {
|
| + return;
|
| }
|
| + if (state_ != CONNECTING)
|
| + return;
|
| +
|
| + // Start forwarding clipboard and input events.
|
| + clipboard_forwarder_.set_clipboard_stub(control_dispatcher_.get());
|
| + event_forwarder_.set_input_stub(event_dispatcher_.get());
|
| + SetState(CONNECTED, OK);
|
| }
|
|
|
| void ConnectionToHost::CloseOnError(ErrorCode error) {
|
| @@ -230,6 +249,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) {
|
|
|