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/webrtc_connection_to_client.h" | 5 #include "remoting/protocol/webrtc_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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 | 66 |
67 void WebrtcConnectionToClient::Disconnect(ErrorCode error) { | 67 void WebrtcConnectionToClient::Disconnect(ErrorCode error) { |
68 DCHECK(thread_checker_.CalledOnValidThread()); | 68 DCHECK(thread_checker_.CalledOnValidThread()); |
69 | 69 |
70 // This should trigger OnConnectionClosed() event and this object | 70 // This should trigger OnConnectionClosed() event and this object |
71 // may be destroyed as the result. | 71 // may be destroyed as the result. |
72 session_->Close(error); | 72 session_->Close(error); |
73 } | 73 } |
74 | 74 |
75 void WebrtcConnectionToClient::OnInputEventReceived(int64_t timestamp) { | |
76 DCHECK(thread_checker_.CalledOnValidThread()); | |
77 event_handler_->OnInputEventReceived(this, timestamp); | |
78 } | |
79 | |
80 std::unique_ptr<VideoStream> WebrtcConnectionToClient::StartVideoStream( | 75 std::unique_ptr<VideoStream> WebrtcConnectionToClient::StartVideoStream( |
81 std::unique_ptr<webrtc::DesktopCapturer> desktop_capturer) { | 76 std::unique_ptr<webrtc::DesktopCapturer> desktop_capturer) { |
82 // TODO(isheriff): make this codec independent | 77 // TODO(isheriff): make this codec independent |
83 std::unique_ptr<VideoEncoder> video_encoder = | 78 std::unique_ptr<VideoEncoder> video_encoder = |
84 WebrtcVideoEncoderVpx::CreateForVP8(); | 79 WebrtcVideoEncoderVpx::CreateForVP8(); |
85 std::unique_ptr<WebrtcVideoStream> stream(new WebrtcVideoStream()); | 80 std::unique_ptr<WebrtcVideoStream> stream(new WebrtcVideoStream()); |
86 if (!stream->Start(std::move(desktop_capturer), transport_.get(), | 81 if (!stream->Start(std::move(desktop_capturer), transport_.get(), |
87 video_encode_task_runner_, std::move(video_encoder))) { | 82 video_encode_task_runner_, std::move(video_encoder))) { |
88 return nullptr; | 83 return nullptr; |
89 } | 84 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 void WebrtcConnectionToClient::OnWebrtcTransportError(ErrorCode error) { | 166 void WebrtcConnectionToClient::OnWebrtcTransportError(ErrorCode error) { |
172 DCHECK(thread_checker_.CalledOnValidThread()); | 167 DCHECK(thread_checker_.CalledOnValidThread()); |
173 Disconnect(error); | 168 Disconnect(error); |
174 } | 169 } |
175 | 170 |
176 void WebrtcConnectionToClient::OnWebrtcTransportIncomingDataChannel( | 171 void WebrtcConnectionToClient::OnWebrtcTransportIncomingDataChannel( |
177 const std::string& name, | 172 const std::string& name, |
178 std::unique_ptr<MessagePipe> pipe) { | 173 std::unique_ptr<MessagePipe> pipe) { |
179 if (name == event_dispatcher_->channel_name() && | 174 if (name == event_dispatcher_->channel_name() && |
180 !event_dispatcher_->is_connected()) { | 175 !event_dispatcher_->is_connected()) { |
181 event_dispatcher_->set_on_input_event_callback(base::Bind( | 176 event_dispatcher_->set_on_input_event_callback( |
182 &ConnectionToClient::OnInputEventReceived, base::Unretained(this))); | 177 base::Bind(&WebrtcConnectionToClient::OnInputEventReceived, |
| 178 base::Unretained(this))); |
183 event_dispatcher_->Init(std::move(pipe), this); | 179 event_dispatcher_->Init(std::move(pipe), this); |
184 } | 180 } |
185 } | 181 } |
186 | 182 |
187 void WebrtcConnectionToClient::OnWebrtcTransportMediaStreamAdded( | 183 void WebrtcConnectionToClient::OnWebrtcTransportMediaStreamAdded( |
188 scoped_refptr<webrtc::MediaStreamInterface> stream) { | 184 scoped_refptr<webrtc::MediaStreamInterface> stream) { |
189 LOG(WARNING) << "The client created an unexpected media stream."; | 185 LOG(WARNING) << "The client created an unexpected media stream."; |
190 } | 186 } |
191 | 187 |
192 void WebrtcConnectionToClient::OnWebrtcTransportMediaStreamRemoved( | 188 void WebrtcConnectionToClient::OnWebrtcTransportMediaStreamRemoved( |
(...skipping 11 matching lines...) Expand all Loading... |
204 | 200 |
205 void WebrtcConnectionToClient::OnChannelClosed( | 201 void WebrtcConnectionToClient::OnChannelClosed( |
206 ChannelDispatcherBase* channel_dispatcher) { | 202 ChannelDispatcherBase* channel_dispatcher) { |
207 DCHECK(thread_checker_.CalledOnValidThread()); | 203 DCHECK(thread_checker_.CalledOnValidThread()); |
208 | 204 |
209 LOG(ERROR) << "Channel " << channel_dispatcher->channel_name() | 205 LOG(ERROR) << "Channel " << channel_dispatcher->channel_name() |
210 << " was closed unexpectedly."; | 206 << " was closed unexpectedly."; |
211 Disconnect(INCOMPATIBLE_PROTOCOL); | 207 Disconnect(INCOMPATIBLE_PROTOCOL); |
212 } | 208 } |
213 | 209 |
| 210 void WebrtcConnectionToClient::OnInputEventReceived(int64_t timestamp) { |
| 211 DCHECK(thread_checker_.CalledOnValidThread()); |
| 212 event_handler_->OnInputEventReceived(this, timestamp); |
| 213 } |
| 214 |
214 } // namespace protocol | 215 } // namespace protocol |
215 } // namespace remoting | 216 } // namespace remoting |
OLD | NEW |