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 "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 ~SetSessionDescriptionObserver() override {} | 92 ~SetSessionDescriptionObserver() override {} |
93 | 93 |
94 private: | 94 private: |
95 ResultCallback result_callback_; | 95 ResultCallback result_callback_; |
96 | 96 |
97 DISALLOW_COPY_AND_ASSIGN(SetSessionDescriptionObserver); | 97 DISALLOW_COPY_AND_ASSIGN(SetSessionDescriptionObserver); |
98 }; | 98 }; |
99 | 99 |
100 } // namespace | 100 } // namespace |
101 | 101 |
102 WebrtcTransport::WebrtcTransport(rtc::Thread* worker_thread, | 102 WebrtcTransport::WebrtcTransport( |
103 PortAllocatorFactory* port_allocator_factory, | 103 rtc::Thread* worker_thread, |
104 TransportRole role) | 104 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> |
| 105 port_allocator_factory, |
| 106 TransportRole role) |
105 : port_allocator_factory_(port_allocator_factory), | 107 : port_allocator_factory_(port_allocator_factory), |
106 role_(role), | 108 role_(role), |
107 worker_thread_(worker_thread), | 109 worker_thread_(worker_thread), |
108 weak_factory_(this) {} | 110 weak_factory_(this) {} |
109 | 111 |
110 WebrtcTransport::~WebrtcTransport() {} | 112 WebrtcTransport::~WebrtcTransport() {} |
111 | 113 |
112 void WebrtcTransport::Start(EventHandler* event_handler, | 114 void WebrtcTransport::Start(EventHandler* event_handler, |
113 Authenticator* authenticator) { | 115 Authenticator* authenticator) { |
114 DCHECK(thread_checker_.CalledOnValidThread()); | 116 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 14 matching lines...) Expand all Loading... |
129 | 131 |
130 webrtc::PeerConnectionInterface::IceServer stun_server; | 132 webrtc::PeerConnectionInterface::IceServer stun_server; |
131 stun_server.urls.push_back("stun:stun.l.google.com:19302"); | 133 stun_server.urls.push_back("stun:stun.l.google.com:19302"); |
132 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config; | 134 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config; |
133 rtc_config.servers.push_back(stun_server); | 135 rtc_config.servers.push_back(stun_server); |
134 | 136 |
135 webrtc::FakeConstraints constraints; | 137 webrtc::FakeConstraints constraints; |
136 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 138 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
137 webrtc::MediaConstraintsInterface::kValueTrue); | 139 webrtc::MediaConstraintsInterface::kValueTrue); |
138 | 140 |
139 rtc::scoped_ptr<cricket::PortAllocator> port_allocator( | |
140 port_allocator_factory_->CreatePortAllocator()); | |
141 | |
142 peer_connection_ = peer_connection_factory_->CreatePeerConnection( | 141 peer_connection_ = peer_connection_factory_->CreatePeerConnection( |
143 rtc_config, &constraints, std::move(port_allocator), nullptr, this); | 142 rtc_config, &constraints, port_allocator_factory_, nullptr, this); |
144 | 143 |
145 data_stream_adapter_.Initialize(peer_connection_, | 144 data_stream_adapter_.Initialize(peer_connection_, |
146 role_ == TransportRole::SERVER); | 145 role_ == TransportRole::SERVER); |
147 | 146 |
148 if (role_ == TransportRole::SERVER) | 147 if (role_ == TransportRole::SERVER) |
149 RequestNegotiation(); | 148 RequestNegotiation(); |
150 } | 149 } |
151 | 150 |
152 bool WebrtcTransport::ProcessTransportInfo(XmlElement* transport_info) { | 151 bool WebrtcTransport::ProcessTransportInfo(XmlElement* transport_info) { |
153 DCHECK(thread_checker_.CalledOnValidThread()); | 152 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 return; | 481 return; |
483 } | 482 } |
484 } | 483 } |
485 pending_incoming_candidates_.clear(); | 484 pending_incoming_candidates_.clear(); |
486 } | 485 } |
487 } | 486 } |
488 | 487 |
489 WebrtcTransportFactory::WebrtcTransportFactory( | 488 WebrtcTransportFactory::WebrtcTransportFactory( |
490 rtc::Thread* worker_thread, | 489 rtc::Thread* worker_thread, |
491 SignalStrategy* signal_strategy, | 490 SignalStrategy* signal_strategy, |
492 scoped_ptr<PortAllocatorFactory> port_allocator_factory, | 491 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> |
| 492 port_allocator_factory, |
493 TransportRole role) | 493 TransportRole role) |
494 : worker_thread_(worker_thread), | 494 : worker_thread_(worker_thread), |
495 signal_strategy_(signal_strategy), | 495 signal_strategy_(signal_strategy), |
496 port_allocator_factory_(std::move(port_allocator_factory)), | 496 port_allocator_factory_(port_allocator_factory), |
497 role_(role) {} | 497 role_(role) {} |
498 | 498 |
499 WebrtcTransportFactory::~WebrtcTransportFactory() {} | 499 WebrtcTransportFactory::~WebrtcTransportFactory() {} |
500 | 500 |
501 scoped_ptr<Transport> WebrtcTransportFactory::CreateTransport() { | 501 scoped_ptr<Transport> WebrtcTransportFactory::CreateTransport() { |
502 return make_scoped_ptr(new WebrtcTransport( | 502 return make_scoped_ptr( |
503 worker_thread_, port_allocator_factory_.get(), role_)); | 503 new WebrtcTransport(worker_thread_, port_allocator_factory_, role_)); |
504 } | 504 } |
505 | 505 |
506 } // namespace protocol | 506 } // namespace protocol |
507 } // namespace remoting | 507 } // namespace remoting |
OLD | NEW |