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" |
11 #include "jingle/glue/thread_wrapper.h" | 11 #include "jingle/glue/thread_wrapper.h" |
12 #include "remoting/protocol/chromium_port_allocator.h" | |
12 #include "third_party/libjingle/source/talk/app/webrtc/test/fakeconstraints.h" | 13 #include "third_party/libjingle/source/talk/app/webrtc/test/fakeconstraints.h" |
13 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 14 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
14 #include "third_party/webrtc/modules/audio_device/include/fake_audio_device.h" | 15 #include "third_party/webrtc/modules/audio_device/include/fake_audio_device.h" |
15 | 16 |
16 using buzz::QName; | 17 using buzz::QName; |
17 using buzz::XmlElement; | 18 using buzz::XmlElement; |
18 | 19 |
19 namespace remoting { | 20 namespace remoting { |
20 namespace protocol { | 21 namespace protocol { |
21 | 22 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 | 102 |
102 private: | 103 private: |
103 ResultCallback result_callback_; | 104 ResultCallback result_callback_; |
104 | 105 |
105 DISALLOW_COPY_AND_ASSIGN(SetSessionDescriptionObserver); | 106 DISALLOW_COPY_AND_ASSIGN(SetSessionDescriptionObserver); |
106 }; | 107 }; |
107 | 108 |
108 } // namespace | 109 } // namespace |
109 | 110 |
110 WebrtcTransport::WebrtcTransport( | 111 WebrtcTransport::WebrtcTransport( |
111 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> | 112 const NetworkSettings& network_settings, |
Sergey Ulanov
2015/12/04 18:54:07
Pass PortAllocator instead of PortAllocatorFactory
| |
112 port_allocator_factory, | |
113 TransportRole role, | 113 TransportRole role, |
114 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner) | 114 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner) |
115 : port_allocator_factory_(port_allocator_factory), | 115 : network_settings_(network_settings), |
116 role_(role), | 116 role_(role), |
117 worker_task_runner_(worker_task_runner), | 117 worker_task_runner_(worker_task_runner), |
118 weak_factory_(this) {} | 118 weak_factory_(this) {} |
119 | 119 |
120 WebrtcTransport::~WebrtcTransport() {} | 120 WebrtcTransport::~WebrtcTransport() {} |
121 | 121 |
122 void WebrtcTransport::Start(EventHandler* event_handler, | 122 void WebrtcTransport::Start(EventHandler* event_handler, |
123 Authenticator* authenticator) { | 123 Authenticator* authenticator) { |
124 DCHECK(thread_checker_.CalledOnValidThread()); | 124 DCHECK(thread_checker_.CalledOnValidThread()); |
125 | 125 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 | 243 |
244 webrtc::PeerConnectionInterface::IceServer stun_server; | 244 webrtc::PeerConnectionInterface::IceServer stun_server; |
245 stun_server.urls.push_back("stun:stun.l.google.com:19302"); | 245 stun_server.urls.push_back("stun:stun.l.google.com:19302"); |
246 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config; | 246 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config; |
247 rtc_config.servers.push_back(stun_server); | 247 rtc_config.servers.push_back(stun_server); |
248 | 248 |
249 webrtc::FakeConstraints constraints; | 249 webrtc::FakeConstraints constraints; |
250 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 250 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
251 webrtc::MediaConstraintsInterface::kValueTrue); | 251 webrtc::MediaConstraintsInterface::kValueTrue); |
252 | 252 |
253 rtc::scoped_ptr<ChromiumPortAllocator> port_allocator( | |
254 ChromiumPortAllocator::Create(nullptr, network_settings_).release()); | |
Sergey Ulanov
2015/12/04 18:54:07
This is not right. This class shouldn't depend on
| |
255 | |
253 peer_connection_ = peer_connection_factory_->CreatePeerConnection( | 256 peer_connection_ = peer_connection_factory_->CreatePeerConnection( |
254 rtc_config, &constraints, port_allocator_factory_, nullptr, this); | 257 rtc_config, &constraints, std::move(port_allocator), nullptr, this); |
255 | 258 |
256 data_stream_adapter_.Initialize(peer_connection_, | 259 data_stream_adapter_.Initialize(peer_connection_, |
257 role_ == TransportRole::SERVER); | 260 role_ == TransportRole::SERVER); |
258 | 261 |
259 if (role_ == TransportRole::CLIENT) { | 262 if (role_ == TransportRole::CLIENT) { |
260 webrtc::FakeConstraints offer_config; | 263 webrtc::FakeConstraints offer_config; |
261 offer_config.AddMandatory( | 264 offer_config.AddMandatory( |
262 webrtc::MediaConstraintsInterface::kOfferToReceiveVideo, | 265 webrtc::MediaConstraintsInterface::kOfferToReceiveVideo, |
263 webrtc::MediaConstraintsInterface::kValueTrue); | 266 webrtc::MediaConstraintsInterface::kValueTrue); |
264 offer_config.AddMandatory( | 267 offer_config.AddMandatory( |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 Close(INCOMPATIBLE_PROTOCOL); | 469 Close(INCOMPATIBLE_PROTOCOL); |
467 return; | 470 return; |
468 } | 471 } |
469 } | 472 } |
470 pending_incoming_candidates_.clear(); | 473 pending_incoming_candidates_.clear(); |
471 } | 474 } |
472 } | 475 } |
473 | 476 |
474 WebrtcTransportFactory::WebrtcTransportFactory( | 477 WebrtcTransportFactory::WebrtcTransportFactory( |
475 SignalStrategy* signal_strategy, | 478 SignalStrategy* signal_strategy, |
476 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> | 479 const NetworkSettings& network_settings, |
477 port_allocator_factory, | |
478 TransportRole role) | 480 TransportRole role) |
479 : signal_strategy_(signal_strategy), | 481 : signal_strategy_(signal_strategy), |
480 port_allocator_factory_(port_allocator_factory), | 482 network_settings_(network_settings), |
481 role_(role), | 483 role_(role), |
482 worker_thread_("ChromotingWebrtcWorkerThread") { | 484 worker_thread_("ChromotingWebrtcWorkerThread") { |
483 worker_thread_.StartWithOptions( | 485 worker_thread_.StartWithOptions( |
484 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 486 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
485 } | 487 } |
486 | 488 |
487 WebrtcTransportFactory::~WebrtcTransportFactory() {} | 489 WebrtcTransportFactory::~WebrtcTransportFactory() {} |
488 | 490 |
489 scoped_ptr<Transport> WebrtcTransportFactory::CreateTransport() { | 491 scoped_ptr<Transport> WebrtcTransportFactory::CreateTransport() { |
490 return make_scoped_ptr(new WebrtcTransport(port_allocator_factory_, role_, | 492 return make_scoped_ptr(new WebrtcTransport(network_settings_, role_, |
491 worker_thread_.task_runner())); | 493 worker_thread_.task_runner())); |
492 } | 494 } |
493 | 495 |
494 } // namespace protocol | 496 } // namespace protocol |
495 } // namespace remoting | 497 } // namespace remoting |
OLD | NEW |