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/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" |
| 11 #include "jingle/glue/thread_wrapper.h" | 11 #include "jingle/glue/thread_wrapper.h" |
| 12 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
| 13 #include "remoting/codec/video_encoder.h" | 13 #include "remoting/codec/video_encoder.h" |
| 14 #include "remoting/codec/webrtc_video_encoder_vpx.h" | 14 #include "remoting/codec/webrtc_video_encoder_vpx.h" |
| 15 #include "remoting/protocol/audio_writer.h" | 15 #include "remoting/protocol/audio_writer.h" |
| 16 #include "remoting/protocol/clipboard_stub.h" | 16 #include "remoting/protocol/clipboard_stub.h" |
| 17 #include "remoting/protocol/host_control_dispatcher.h" | 17 #include "remoting/protocol/host_control_dispatcher.h" |
| 18 #include "remoting/protocol/host_event_dispatcher.h" | 18 #include "remoting/protocol/host_event_dispatcher.h" |
| 19 #include "remoting/protocol/host_stub.h" | 19 #include "remoting/protocol/host_stub.h" |
| 20 #include "remoting/protocol/input_stub.h" | 20 #include "remoting/protocol/input_stub.h" |
| 21 #include "remoting/protocol/message_pipe.h" | |
| 21 #include "remoting/protocol/transport_context.h" | 22 #include "remoting/protocol/transport_context.h" |
| 22 #include "remoting/protocol/webrtc_transport.h" | 23 #include "remoting/protocol/webrtc_transport.h" |
| 23 #include "remoting/protocol/webrtc_video_stream.h" | 24 #include "remoting/protocol/webrtc_video_stream.h" |
| 24 #include "third_party/webrtc/api/mediastreaminterface.h" | 25 #include "third_party/webrtc/api/mediastreaminterface.h" |
| 25 #include "third_party/webrtc/api/peerconnectioninterface.h" | 26 #include "third_party/webrtc/api/peerconnectioninterface.h" |
| 26 #include "third_party/webrtc/api/test/fakeconstraints.h" | 27 #include "third_party/webrtc/api/test/fakeconstraints.h" |
| 27 | 28 |
| 28 namespace remoting { | 29 namespace remoting { |
| 29 namespace protocol { | 30 namespace protocol { |
| 30 | 31 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 transport_->Close(state == Session::CLOSED ? OK : session_->error()); | 148 transport_->Close(state == Session::CLOSED ? OK : session_->error()); |
| 148 control_dispatcher_.reset(); | 149 control_dispatcher_.reset(); |
| 149 event_dispatcher_.reset(); | 150 event_dispatcher_.reset(); |
| 150 event_handler_->OnConnectionClosed( | 151 event_handler_->OnConnectionClosed( |
| 151 this, state == Session::CLOSED ? OK : session_->error()); | 152 this, state == Session::CLOSED ? OK : session_->error()); |
| 152 break; | 153 break; |
| 153 } | 154 } |
| 154 } | 155 } |
| 155 | 156 |
| 156 void WebrtcConnectionToClient::OnWebrtcTransportConnecting() { | 157 void WebrtcConnectionToClient::OnWebrtcTransportConnecting() { |
| 157 control_dispatcher_->Init(transport_->outgoing_channel_factory(), this); | 158 control_dispatcher_->Init(transport_->outgoing_channel_factory(), this); |
|
Jamie
2016/07/19 18:24:47
Could this be initialized in OnWebrtcTransportInco
Sergey Ulanov
2016/07/19 23:38:43
Control channel is created by the host, while even
Jamie
2016/07/20 00:31:39
It's beyond the scope of this CL, but would it be
Sergey Ulanov
2016/07/20 01:18:22
I think we want to support creation of channels in
| |
| 158 | |
| 159 event_dispatcher_->Init(transport_->incoming_channel_factory(), this); | |
| 160 event_dispatcher_->set_on_input_event_callback(base::Bind( | |
| 161 &ConnectionToClient::OnInputEventReceived, base::Unretained(this))); | |
| 162 } | 159 } |
| 163 | 160 |
| 164 void WebrtcConnectionToClient::OnWebrtcTransportConnected() { | 161 void WebrtcConnectionToClient::OnWebrtcTransportConnected() { |
| 165 DCHECK(thread_checker_.CalledOnValidThread()); | 162 DCHECK(thread_checker_.CalledOnValidThread()); |
| 166 } | 163 } |
| 167 | 164 |
| 168 void WebrtcConnectionToClient::OnWebrtcTransportError(ErrorCode error) { | 165 void WebrtcConnectionToClient::OnWebrtcTransportError(ErrorCode error) { |
| 169 DCHECK(thread_checker_.CalledOnValidThread()); | 166 DCHECK(thread_checker_.CalledOnValidThread()); |
| 170 Disconnect(error); | 167 Disconnect(error); |
| 171 } | 168 } |
| 172 | 169 |
| 170 void WebrtcConnectionToClient::OnWebrtcTransportIncomingDataChannel( | |
| 171 const std::string& name, | |
| 172 std::unique_ptr<MessagePipe> pipe) { | |
| 173 if (name == event_dispatcher_->channel_name() && | |
| 174 !event_dispatcher_->is_connected()) { | |
| 175 event_dispatcher_->set_on_input_event_callback(base::Bind( | |
| 176 &ConnectionToClient::OnInputEventReceived, base::Unretained(this))); | |
| 177 event_dispatcher_->Init(std::move(pipe), this); | |
| 178 } | |
| 179 } | |
| 180 | |
| 173 void WebrtcConnectionToClient::OnWebrtcTransportMediaStreamAdded( | 181 void WebrtcConnectionToClient::OnWebrtcTransportMediaStreamAdded( |
| 174 scoped_refptr<webrtc::MediaStreamInterface> stream) { | 182 scoped_refptr<webrtc::MediaStreamInterface> stream) { |
| 175 LOG(WARNING) << "The client created an unexpected media stream."; | 183 LOG(WARNING) << "The client created an unexpected media stream."; |
| 176 } | 184 } |
| 177 | 185 |
| 178 void WebrtcConnectionToClient::OnWebrtcTransportMediaStreamRemoved( | 186 void WebrtcConnectionToClient::OnWebrtcTransportMediaStreamRemoved( |
| 179 scoped_refptr<webrtc::MediaStreamInterface> stream) {} | 187 scoped_refptr<webrtc::MediaStreamInterface> stream) {} |
| 180 | 188 |
| 181 void WebrtcConnectionToClient::OnChannelInitialized( | 189 void WebrtcConnectionToClient::OnChannelInitialized( |
| 182 ChannelDispatcherBase* channel_dispatcher) { | 190 ChannelDispatcherBase* channel_dispatcher) { |
| 183 DCHECK(thread_checker_.CalledOnValidThread()); | 191 DCHECK(thread_checker_.CalledOnValidThread()); |
| 184 | 192 |
| 185 if (control_dispatcher_ && control_dispatcher_->is_connected() && | 193 if (control_dispatcher_ && control_dispatcher_->is_connected() && |
| 186 event_dispatcher_ && event_dispatcher_->is_connected()) { | 194 event_dispatcher_ && event_dispatcher_->is_connected()) { |
| 187 event_handler_->OnConnectionChannelsConnected(this); | 195 event_handler_->OnConnectionChannelsConnected(this); |
| 188 } | 196 } |
| 189 } | 197 } |
| 190 | 198 |
| 199 void WebrtcConnectionToClient::OnChannelClosed( | |
| 200 ChannelDispatcherBase* channel_dispatcher) { | |
| 201 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 202 | |
| 203 LOG(ERROR) << "Channel " << channel_dispatcher->channel_name() | |
| 204 << " was closed unexpectedly."; | |
| 205 Disconnect(INCOMPATIBLE_PROTOCOL); | |
| 206 } | |
| 207 | |
| 191 } // namespace protocol | 208 } // namespace protocol |
| 192 } // namespace remoting | 209 } // namespace remoting |
| OLD | NEW |