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_client.h" | 5 #include "remoting/protocol/ice_connection_to_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
10 #include "remoting/codec/video_encoder.h" | 10 #include "remoting/codec/video_encoder.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 return nullptr; | 40 return nullptr; |
41 } | 41 } |
42 | 42 |
43 } // namespace | 43 } // namespace |
44 | 44 |
45 IceConnectionToClient::IceConnectionToClient( | 45 IceConnectionToClient::IceConnectionToClient( |
46 scoped_ptr<protocol::Session> session, | 46 scoped_ptr<protocol::Session> session, |
47 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner) | 47 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner) |
48 : event_handler_(nullptr), | 48 : event_handler_(nullptr), |
49 session_(session.Pass()), | 49 session_(session.Pass()), |
50 video_encode_task_runner_(video_encode_task_runner) { | 50 video_encode_task_runner_(video_encode_task_runner), |
| 51 control_dispatcher_(new HostControlDispatcher()), |
| 52 event_dispatcher_(new HostEventDispatcher()), |
| 53 video_dispatcher_(new HostVideoDispatcher()) { |
51 session_->SetEventHandler(this); | 54 session_->SetEventHandler(this); |
52 } | 55 } |
53 | 56 |
54 IceConnectionToClient::~IceConnectionToClient() {} | 57 IceConnectionToClient::~IceConnectionToClient() {} |
55 | 58 |
56 void IceConnectionToClient::SetEventHandler( | 59 void IceConnectionToClient::SetEventHandler( |
57 ConnectionToClient::EventHandler* event_handler) { | 60 ConnectionToClient::EventHandler* event_handler) { |
58 DCHECK(thread_checker_.CalledOnValidThread()); | 61 DCHECK(thread_checker_.CalledOnValidThread()); |
59 event_handler_ = event_handler; | 62 event_handler_ = event_handler; |
60 } | 63 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 case Session::ACCEPTING: | 135 case Session::ACCEPTING: |
133 case Session::ACCEPTED: | 136 case Session::ACCEPTED: |
134 case Session::CONNECTED: | 137 case Session::CONNECTED: |
135 // Don't care about these events. | 138 // Don't care about these events. |
136 break; | 139 break; |
137 case Session::AUTHENTICATING: | 140 case Session::AUTHENTICATING: |
138 event_handler_->OnConnectionAuthenticating(this); | 141 event_handler_->OnConnectionAuthenticating(this); |
139 break; | 142 break; |
140 case Session::AUTHENTICATED: | 143 case Session::AUTHENTICATED: |
141 // Initialize channels. | 144 // Initialize channels. |
142 control_dispatcher_.reset(new HostControlDispatcher()); | |
143 control_dispatcher_->Init(session_.get(), | 145 control_dispatcher_->Init(session_.get(), |
144 session_->config().control_config(), this); | 146 session_->config().control_config(), this); |
145 | 147 |
146 event_dispatcher_.reset(new HostEventDispatcher()); | |
147 event_dispatcher_->Init(session_.get(), session_->config().event_config(), | 148 event_dispatcher_->Init(session_.get(), session_->config().event_config(), |
148 this); | 149 this); |
149 event_dispatcher_->set_on_input_event_callback( | 150 event_dispatcher_->set_on_input_event_callback( |
150 base::Bind(&IceConnectionToClient::OnInputEventReceived, | 151 base::Bind(&IceConnectionToClient::OnInputEventReceived, |
151 base::Unretained(this))); | 152 base::Unretained(this))); |
152 | 153 |
153 video_dispatcher_.reset(new HostVideoDispatcher()); | |
154 video_dispatcher_->Init(session_.get(), session_->config().video_config(), | 154 video_dispatcher_->Init(session_.get(), session_->config().video_config(), |
155 this); | 155 this); |
156 | 156 |
157 audio_writer_ = AudioWriter::Create(session_->config()); | 157 audio_writer_ = AudioWriter::Create(session_->config()); |
158 if (audio_writer_.get()) { | 158 if (audio_writer_.get()) { |
159 audio_writer_->Init(session_.get(), session_->config().audio_config(), | 159 audio_writer_->Init(session_.get(), session_->config().audio_config(), |
160 this); | 160 this); |
161 } | 161 } |
162 | 162 |
163 // Notify the handler after initializing the channels, so that | 163 // Notify the handler after initializing the channels, so that |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 221 |
222 void IceConnectionToClient::CloseChannels() { | 222 void IceConnectionToClient::CloseChannels() { |
223 control_dispatcher_.reset(); | 223 control_dispatcher_.reset(); |
224 event_dispatcher_.reset(); | 224 event_dispatcher_.reset(); |
225 video_dispatcher_.reset(); | 225 video_dispatcher_.reset(); |
226 audio_writer_.reset(); | 226 audio_writer_.reset(); |
227 } | 227 } |
228 | 228 |
229 } // namespace protocol | 229 } // namespace protocol |
230 } // namespace remoting | 230 } // namespace remoting |
OLD | NEW |