Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/protocol/ice_connection_to_host.h" | 5 #include "remoting/protocol/ice_connection_to_host.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "remoting/base/constants.h" | 12 #include "remoting/base/constants.h" |
| 13 #include "remoting/protocol/audio_reader.h" | 13 #include "remoting/protocol/audio_reader.h" |
| 14 #include "remoting/protocol/audio_stub.h" | 14 #include "remoting/protocol/audio_stub.h" |
| 15 #include "remoting/protocol/auth_util.h" | 15 #include "remoting/protocol/auth_util.h" |
| 16 #include "remoting/protocol/client_control_dispatcher.h" | 16 #include "remoting/protocol/client_control_dispatcher.h" |
| 17 #include "remoting/protocol/client_event_dispatcher.h" | 17 #include "remoting/protocol/client_event_dispatcher.h" |
| 18 #include "remoting/protocol/client_stub.h" | 18 #include "remoting/protocol/client_stub.h" |
| 19 #include "remoting/protocol/client_video_dispatcher.h" | 19 #include "remoting/protocol/client_video_dispatcher.h" |
| 20 #include "remoting/protocol/clipboard_stub.h" | 20 #include "remoting/protocol/clipboard_stub.h" |
| 21 #include "remoting/protocol/errors.h" | 21 #include "remoting/protocol/errors.h" |
| 22 #include "remoting/protocol/ice_transport.h" | 22 #include "remoting/protocol/ice_transport.h" |
| 23 #include "remoting/protocol/transport_context.h" | 23 #include "remoting/protocol/transport_context.h" |
| 24 #include "remoting/protocol/video_stub.h" | 24 #include "remoting/protocol/video_renderer.h" |
| 25 | 25 |
| 26 namespace remoting { | 26 namespace remoting { |
| 27 namespace protocol { | 27 namespace protocol { |
| 28 | 28 |
| 29 IceConnectionToHost::IceConnectionToHost() {} | 29 IceConnectionToHost::IceConnectionToHost() {} |
| 30 IceConnectionToHost::~IceConnectionToHost() {} | 30 IceConnectionToHost::~IceConnectionToHost() {} |
| 31 | 31 |
| 32 void IceConnectionToHost::Connect( | 32 void IceConnectionToHost::Connect( |
| 33 scoped_ptr<Session> session, | 33 scoped_ptr<Session> session, |
| 34 scoped_refptr<TransportContext> transport_context, | 34 scoped_refptr<TransportContext> transport_context, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 } | 66 } |
| 67 | 67 |
| 68 void IceConnectionToHost::set_client_stub(ClientStub* client_stub) { | 68 void IceConnectionToHost::set_client_stub(ClientStub* client_stub) { |
| 69 client_stub_ = client_stub; | 69 client_stub_ = client_stub; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void IceConnectionToHost::set_clipboard_stub(ClipboardStub* clipboard_stub) { | 72 void IceConnectionToHost::set_clipboard_stub(ClipboardStub* clipboard_stub) { |
| 73 clipboard_stub_ = clipboard_stub; | 73 clipboard_stub_ = clipboard_stub; |
| 74 } | 74 } |
| 75 | 75 |
| 76 void IceConnectionToHost::set_video_stub(VideoStub* video_stub) { | 76 void IceConnectionToHost::set_video_renderer(VideoRenderer* video_renderer) { |
| 77 DCHECK(video_stub); | 77 DCHECK(video_renderer); |
| 78 monitored_video_stub_.reset(new MonitoredVideoStub( | 78 video_renderer_ = video_renderer; |
| 79 video_stub, base::TimeDelta::FromSeconds( | |
| 80 MonitoredVideoStub::kConnectivityCheckDelaySeconds), | |
| 81 base::Bind(&IceConnectionToHost::OnVideoChannelStatus, | |
| 82 base::Unretained(this)))); | |
|
Jamie
2016/01/04 22:41:15
I think it would be clearer to keep initialization
Sergey Ulanov
2016/01/04 23:35:22
There are no very significant benefits, but I thin
Jamie
2016/01/04 23:40:49
Maybe a DCHECK that MonitoredVideoStub is null in
Sergey Ulanov
2016/01/05 18:03:03
Done.
| |
| 83 } | 79 } |
| 84 | 80 |
| 85 void IceConnectionToHost::set_audio_stub(AudioStub* audio_stub) { | 81 void IceConnectionToHost::set_audio_stub(AudioStub* audio_stub) { |
| 86 audio_stub_ = audio_stub; | 82 audio_stub_ = audio_stub; |
| 87 } | 83 } |
| 88 | 84 |
| 89 void IceConnectionToHost::OnSessionStateChange(Session::State state) { | 85 void IceConnectionToHost::OnSessionStateChange(Session::State state) { |
| 90 DCHECK(CalledOnValidThread()); | 86 DCHECK(CalledOnValidThread()); |
| 91 DCHECK(event_callback_); | 87 DCHECK(event_callback_); |
| 92 | 88 |
| 93 switch (state) { | 89 switch (state) { |
| 94 case Session::INITIALIZING: | 90 case Session::INITIALIZING: |
| 95 case Session::CONNECTING: | 91 case Session::CONNECTING: |
| 96 case Session::ACCEPTING: | 92 case Session::ACCEPTING: |
| 97 case Session::ACCEPTED: | 93 case Session::ACCEPTED: |
| 98 case Session::AUTHENTICATING: | 94 case Session::AUTHENTICATING: |
| 99 // Don't care about these events. | 95 // Don't care about these events. |
| 100 break; | 96 break; |
| 101 | 97 |
| 102 case Session::AUTHENTICATED: | 98 case Session::AUTHENTICATED: |
| 103 SetState(AUTHENTICATED, OK); | 99 SetState(AUTHENTICATED, OK); |
| 100 | |
| 101 // Setup control channel. | |
| 104 control_dispatcher_.reset(new ClientControlDispatcher()); | 102 control_dispatcher_.reset(new ClientControlDispatcher()); |
| 105 control_dispatcher_->Init(transport_->GetMultiplexedChannelFactory(), | 103 control_dispatcher_->Init(transport_->GetMultiplexedChannelFactory(), |
| 106 this); | 104 this); |
| 107 control_dispatcher_->set_client_stub(client_stub_); | 105 control_dispatcher_->set_client_stub(client_stub_); |
| 108 control_dispatcher_->set_clipboard_stub(clipboard_stub_); | 106 control_dispatcher_->set_clipboard_stub(clipboard_stub_); |
| 109 | 107 |
| 108 // Setup event channel. | |
| 110 event_dispatcher_.reset(new ClientEventDispatcher()); | 109 event_dispatcher_.reset(new ClientEventDispatcher()); |
| 111 event_dispatcher_->Init(transport_->GetMultiplexedChannelFactory(), this); | 110 event_dispatcher_->Init(transport_->GetMultiplexedChannelFactory(), this); |
| 112 | 111 |
| 112 // Configure video pipeline. | |
| 113 video_renderer_->OnSessionConfig(session_->config()); | |
| 114 monitored_video_stub_.reset(new MonitoredVideoStub( | |
| 115 video_renderer_->GetVideoStub(), | |
| 116 base::TimeDelta::FromSeconds( | |
| 117 MonitoredVideoStub::kConnectivityCheckDelaySeconds), | |
| 118 base::Bind(&IceConnectionToHost::OnVideoChannelStatus, | |
| 119 base::Unretained(this)))); | |
| 113 video_dispatcher_.reset( | 120 video_dispatcher_.reset( |
| 114 new ClientVideoDispatcher(monitored_video_stub_.get())); | 121 new ClientVideoDispatcher(monitored_video_stub_.get())); |
| 115 video_dispatcher_->Init(transport_->GetStreamChannelFactory(), this); | 122 video_dispatcher_->Init(transport_->GetStreamChannelFactory(), this); |
| 116 | 123 |
| 124 // Configure audio pipeline if necessary. | |
| 117 if (session_->config().is_audio_enabled()) { | 125 if (session_->config().is_audio_enabled()) { |
| 118 audio_reader_.reset(new AudioReader(audio_stub_)); | 126 audio_reader_.reset(new AudioReader(audio_stub_)); |
| 119 audio_reader_->Init(transport_->GetMultiplexedChannelFactory(), this); | 127 audio_reader_->Init(transport_->GetMultiplexedChannelFactory(), this); |
| 120 } | 128 } |
| 121 break; | 129 break; |
| 122 | 130 |
| 123 case Session::CLOSED: | 131 case Session::CLOSED: |
| 124 CloseChannels(); | 132 CloseChannels(); |
| 125 SetState(CLOSED, OK); | 133 SetState(CLOSED, OK); |
| 126 break; | 134 break; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 | 224 |
| 217 if (state != state_) { | 225 if (state != state_) { |
| 218 state_ = state; | 226 state_ = state; |
| 219 error_ = error; | 227 error_ = error; |
| 220 event_callback_->OnConnectionState(state_, error_); | 228 event_callback_->OnConnectionState(state_, error_); |
| 221 } | 229 } |
| 222 } | 230 } |
| 223 | 231 |
| 224 } // namespace protocol | 232 } // namespace protocol |
| 225 } // namespace remoting | 233 } // namespace remoting |
| OLD | NEW |