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_transport.h" | 5 #include "remoting/protocol/webrtc_transport.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 : worker_thread_(worker_thread), | 145 : worker_thread_(worker_thread), |
146 transport_context_(transport_context), | 146 transport_context_(transport_context), |
147 event_handler_(event_handler), | 147 event_handler_(event_handler), |
148 handshake_hmac_(crypto::HMAC::SHA256), | 148 handshake_hmac_(crypto::HMAC::SHA256), |
149 weak_factory_(this) { | 149 weak_factory_(this) { |
150 transport_context_->set_relay_mode(TransportContext::RelayMode::TURN); | 150 transport_context_->set_relay_mode(TransportContext::RelayMode::TURN); |
151 } | 151 } |
152 | 152 |
153 WebrtcTransport::~WebrtcTransport() {} | 153 WebrtcTransport::~WebrtcTransport() {} |
154 | 154 |
| 155 std::unique_ptr<MessagePipe> WebrtcTransport::CreateOutgoingChannel( |
| 156 const std::string& name) { |
| 157 return data_stream_adapter_->CreateOutgoingChannel(name); |
| 158 } |
| 159 |
155 void WebrtcTransport::Start( | 160 void WebrtcTransport::Start( |
156 Authenticator* authenticator, | 161 Authenticator* authenticator, |
157 SendTransportInfoCallback send_transport_info_callback) { | 162 SendTransportInfoCallback send_transport_info_callback) { |
158 DCHECK(thread_checker_.CalledOnValidThread()); | 163 DCHECK(thread_checker_.CalledOnValidThread()); |
159 DCHECK(send_transport_info_callback_.is_null()); | 164 DCHECK(send_transport_info_callback_.is_null()); |
160 | 165 |
161 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); | 166 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); |
162 | 167 |
163 // TODO(sergeyu): Investigate if it's possible to avoid Send(). | 168 // TODO(sergeyu): Investigate if it's possible to avoid Send(). |
164 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); | 169 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); |
(...skipping 20 matching lines...) Expand all Loading... |
185 webrtc::FakeConstraints constraints; | 190 webrtc::FakeConstraints constraints; |
186 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 191 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
187 webrtc::MediaConstraintsInterface::kValueTrue); | 192 webrtc::MediaConstraintsInterface::kValueTrue); |
188 | 193 |
189 std::unique_ptr<cricket::PortAllocator> port_allocator = | 194 std::unique_ptr<cricket::PortAllocator> port_allocator = |
190 transport_context_->port_allocator_factory()->CreatePortAllocator( | 195 transport_context_->port_allocator_factory()->CreatePortAllocator( |
191 transport_context_); | 196 transport_context_); |
192 peer_connection_ = peer_connection_factory_->CreatePeerConnection( | 197 peer_connection_ = peer_connection_factory_->CreatePeerConnection( |
193 rtc_config, &constraints, std::move(port_allocator), nullptr, this); | 198 rtc_config, &constraints, std::move(port_allocator), nullptr, this); |
194 | 199 |
195 data_stream_adapter_.reset(new WebrtcDataStreamAdapter( | 200 data_stream_adapter_.reset(new WebrtcDataStreamAdapter(peer_connection_)); |
196 base::Bind(&WebrtcTransport::Close, base::Unretained(this)))); | |
197 data_stream_adapter_->Initialize(peer_connection_); | |
198 | 201 |
199 event_handler_->OnWebrtcTransportConnecting(); | 202 event_handler_->OnWebrtcTransportConnecting(); |
200 | 203 |
201 if (transport_context_->role() == TransportRole::SERVER) | 204 if (transport_context_->role() == TransportRole::SERVER) |
202 RequestNegotiation(); | 205 RequestNegotiation(); |
203 } | 206 } |
204 | 207 |
205 bool WebrtcTransport::ProcessTransportInfo(XmlElement* transport_info) { | 208 bool WebrtcTransport::ProcessTransportInfo(XmlElement* transport_info) { |
206 DCHECK(thread_checker_.CalledOnValidThread()); | 209 DCHECK(thread_checker_.CalledOnValidThread()); |
207 | 210 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 | 430 |
428 void WebrtcTransport::OnRemoveStream( | 431 void WebrtcTransport::OnRemoveStream( |
429 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) { | 432 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) { |
430 DCHECK(thread_checker_.CalledOnValidThread()); | 433 DCHECK(thread_checker_.CalledOnValidThread()); |
431 event_handler_->OnWebrtcTransportMediaStreamRemoved(stream.get()); | 434 event_handler_->OnWebrtcTransportMediaStreamRemoved(stream.get()); |
432 } | 435 } |
433 | 436 |
434 void WebrtcTransport::OnDataChannel( | 437 void WebrtcTransport::OnDataChannel( |
435 rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) { | 438 rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) { |
436 DCHECK(thread_checker_.CalledOnValidThread()); | 439 DCHECK(thread_checker_.CalledOnValidThread()); |
437 data_stream_adapter_->WrapIncomingDataChannel( | 440 event_handler_->OnWebrtcTransportIncomingDataChannel( |
438 data_channel, | 441 data_channel->label(), |
439 base::Bind(&EventHandler::OnWebrtcTransportIncomingDataChannel, | 442 data_stream_adapter_->WrapIncomingDataChannel(data_channel)); |
440 base::Unretained(event_handler_), data_channel->label())); | |
441 } | 443 } |
442 | 444 |
443 void WebrtcTransport::OnRenegotiationNeeded() { | 445 void WebrtcTransport::OnRenegotiationNeeded() { |
444 DCHECK(thread_checker_.CalledOnValidThread()); | 446 DCHECK(thread_checker_.CalledOnValidThread()); |
445 | 447 |
446 if (transport_context_->role() == TransportRole::SERVER) { | 448 if (transport_context_->role() == TransportRole::SERVER) { |
447 RequestNegotiation(); | 449 RequestNegotiation(); |
448 } else { | 450 } else { |
449 // TODO(sergeyu): Is it necessary to support renegotiation initiated by the | 451 // TODO(sergeyu): Is it necessary to support renegotiation initiated by the |
450 // client? | 452 // client? |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 peer_connection_->Close(); | 579 peer_connection_->Close(); |
578 peer_connection_ = nullptr; | 580 peer_connection_ = nullptr; |
579 peer_connection_factory_ = nullptr; | 581 peer_connection_factory_ = nullptr; |
580 | 582 |
581 if (error != OK) | 583 if (error != OK) |
582 event_handler_->OnWebrtcTransportError(error); | 584 event_handler_->OnWebrtcTransportError(error); |
583 } | 585 } |
584 | 586 |
585 } // namespace protocol | 587 } // namespace protocol |
586 } // namespace remoting | 588 } // namespace remoting |
OLD | NEW |