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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 std::unique_ptr<VideoStream> IceConnectionToClient::StartVideoStream( | 85 std::unique_ptr<VideoStream> IceConnectionToClient::StartVideoStream( |
86 std::unique_ptr<webrtc::DesktopCapturer> desktop_capturer) { | 86 std::unique_ptr<webrtc::DesktopCapturer> desktop_capturer) { |
87 DCHECK(thread_checker_.CalledOnValidThread()); | 87 DCHECK(thread_checker_.CalledOnValidThread()); |
88 | 88 |
89 std::unique_ptr<VideoEncoder> video_encoder = | 89 std::unique_ptr<VideoEncoder> video_encoder = |
90 VideoEncoder::Create(session_->config()); | 90 VideoEncoder::Create(session_->config()); |
91 | 91 |
92 std::unique_ptr<VideoFramePump> pump( | 92 std::unique_ptr<VideoFramePump> pump( |
93 new VideoFramePump(video_encode_task_runner_, std::move(desktop_capturer), | 93 new VideoFramePump(video_encode_task_runner_, std::move(desktop_capturer), |
94 std::move(video_encoder), video_dispatcher_.get())); | 94 std::move(video_encoder), video_dispatcher_.get())); |
| 95 pump->SetEventTimestampsSource(event_dispatcher_->event_timestamps_source()); |
95 video_dispatcher_->set_video_feedback_stub(pump->video_feedback_stub()); | 96 video_dispatcher_->set_video_feedback_stub(pump->video_feedback_stub()); |
96 return std::move(pump); | 97 return std::move(pump); |
97 } | 98 } |
98 | 99 |
99 std::unique_ptr<AudioStream> IceConnectionToClient::StartAudioStream( | 100 std::unique_ptr<AudioStream> IceConnectionToClient::StartAudioStream( |
100 std::unique_ptr<AudioSource> audio_source) { | 101 std::unique_ptr<AudioSource> audio_source) { |
101 DCHECK(thread_checker_.CalledOnValidThread()); | 102 DCHECK(thread_checker_.CalledOnValidThread()); |
102 | 103 |
103 // Audio channel is disabled. | 104 // Audio channel is disabled. |
104 if (!audio_writer_) | 105 if (!audio_writer_) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 case Session::ACCEPTED: | 146 case Session::ACCEPTED: |
146 // Don't care about these events. | 147 // Don't care about these events. |
147 break; | 148 break; |
148 case Session::AUTHENTICATING: | 149 case Session::AUTHENTICATING: |
149 event_handler_->OnConnectionAuthenticating(); | 150 event_handler_->OnConnectionAuthenticating(); |
150 break; | 151 break; |
151 case Session::AUTHENTICATED: | 152 case Session::AUTHENTICATED: |
152 // Initialize channels. | 153 // Initialize channels. |
153 control_dispatcher_->Init(transport_.GetMultiplexedChannelFactory(), | 154 control_dispatcher_->Init(transport_.GetMultiplexedChannelFactory(), |
154 this); | 155 this); |
155 | |
156 event_dispatcher_->Init(transport_.GetMultiplexedChannelFactory(), this); | 156 event_dispatcher_->Init(transport_.GetMultiplexedChannelFactory(), this); |
157 event_dispatcher_->set_on_input_event_callback( | |
158 base::Bind(&IceConnectionToClient::OnInputEventReceived, | |
159 base::Unretained(this))); | |
160 | |
161 video_dispatcher_->Init(transport_.GetChannelFactory(), this); | 157 video_dispatcher_->Init(transport_.GetChannelFactory(), this); |
162 | 158 |
163 audio_writer_ = AudioWriter::Create(session_->config()); | 159 audio_writer_ = AudioWriter::Create(session_->config()); |
164 if (audio_writer_) | 160 if (audio_writer_) |
165 audio_writer_->Init(transport_.GetMultiplexedChannelFactory(), this); | 161 audio_writer_->Init(transport_.GetMultiplexedChannelFactory(), this); |
166 | 162 |
167 // Notify the handler after initializing the channels, so that | 163 // Notify the handler after initializing the channels, so that |
168 // ClientSession can get a client clipboard stub. | 164 // ClientSession can get a client clipboard stub. |
169 event_handler_->OnConnectionAuthenticated(); | 165 event_handler_->OnConnectionAuthenticated(); |
170 break; | 166 break; |
(...skipping 26 matching lines...) Expand all Loading... |
197 | 193 |
198 NotifyIfChannelsReady(); | 194 NotifyIfChannelsReady(); |
199 } | 195 } |
200 | 196 |
201 void IceConnectionToClient::OnChannelClosed( | 197 void IceConnectionToClient::OnChannelClosed( |
202 ChannelDispatcherBase* channel_dispatcher) { | 198 ChannelDispatcherBase* channel_dispatcher) { |
203 // ICE transport doesn't close channels dynamically. | 199 // ICE transport doesn't close channels dynamically. |
204 NOTREACHED(); | 200 NOTREACHED(); |
205 } | 201 } |
206 | 202 |
207 void IceConnectionToClient::OnInputEventReceived(int64_t timestamp) { | |
208 DCHECK(thread_checker_.CalledOnValidThread()); | |
209 event_handler_->OnInputEventReceived(timestamp); | |
210 } | |
211 | |
212 void IceConnectionToClient::NotifyIfChannelsReady() { | 203 void IceConnectionToClient::NotifyIfChannelsReady() { |
213 DCHECK(thread_checker_.CalledOnValidThread()); | 204 DCHECK(thread_checker_.CalledOnValidThread()); |
214 | 205 |
215 if (!control_dispatcher_ || !control_dispatcher_->is_connected()) | 206 if (!control_dispatcher_ || !control_dispatcher_->is_connected()) |
216 return; | 207 return; |
217 if (!event_dispatcher_ || !event_dispatcher_->is_connected()) | 208 if (!event_dispatcher_ || !event_dispatcher_->is_connected()) |
218 return; | 209 return; |
219 if (!video_dispatcher_ || !video_dispatcher_->is_connected()) | 210 if (!video_dispatcher_ || !video_dispatcher_->is_connected()) |
220 return; | 211 return; |
221 if ((!audio_writer_ || !audio_writer_->is_connected()) && | 212 if ((!audio_writer_ || !audio_writer_->is_connected()) && |
222 session_->config().is_audio_enabled()) { | 213 session_->config().is_audio_enabled()) { |
223 return; | 214 return; |
224 } | 215 } |
225 event_handler_->OnConnectionChannelsConnected(); | 216 event_handler_->OnConnectionChannelsConnected(); |
226 event_handler_->CreateMediaStreams(); | 217 event_handler_->CreateMediaStreams(); |
227 } | 218 } |
228 | 219 |
229 void IceConnectionToClient::CloseChannels() { | 220 void IceConnectionToClient::CloseChannels() { |
230 control_dispatcher_.reset(); | 221 control_dispatcher_.reset(); |
231 event_dispatcher_.reset(); | 222 event_dispatcher_.reset(); |
232 video_dispatcher_.reset(); | 223 video_dispatcher_.reset(); |
233 audio_writer_.reset(); | 224 audio_writer_.reset(); |
234 } | 225 } |
235 | 226 |
236 } // namespace protocol | 227 } // namespace protocol |
237 } // namespace remoting | 228 } // namespace remoting |
OLD | NEW |