Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: remoting/protocol/webrtc_transport.cc

Issue 1571943002: Simplify PortAllocatorBase and make PortAllocator creation synchronous. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/protocol/webrtc_transport.h ('k') | remoting/test/fake_port_allocator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 weak_factory_(this) {} 115 weak_factory_(this) {}
116 116
117 WebrtcTransport::~WebrtcTransport() {} 117 WebrtcTransport::~WebrtcTransport() {}
118 118
119 void WebrtcTransport::Start( 119 void WebrtcTransport::Start(
120 Authenticator* authenticator, 120 Authenticator* authenticator,
121 SendTransportInfoCallback send_transport_info_callback) { 121 SendTransportInfoCallback send_transport_info_callback) {
122 DCHECK(thread_checker_.CalledOnValidThread()); 122 DCHECK(thread_checker_.CalledOnValidThread());
123 DCHECK(send_transport_info_callback_.is_null()); 123 DCHECK(send_transport_info_callback_.is_null());
124 124
125 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
126
127 // TODO(sergeyu): Investigate if it's possible to avoid Send().
128 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true);
129
125 send_transport_info_callback_ = std::move(send_transport_info_callback); 130 send_transport_info_callback_ = std::move(send_transport_info_callback);
126 131
127 // TODO(sergeyu): Use the |authenticator| to authenticate PeerConnection. 132 // TODO(sergeyu): Use the |authenticator| to authenticate PeerConnection.
128 133
129 transport_context_->CreatePortAllocator(base::Bind(
130 &WebrtcTransport::OnPortAllocatorCreated, weak_factory_.GetWeakPtr()));
131 }
132
133 void WebrtcTransport::OnPortAllocatorCreated(
134 scoped_ptr<cricket::PortAllocator> port_allocator) {
135 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
136
137 // TODO(sergeyu): Investigate if it's possible to avoid Send().
138 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true);
139
140 fake_audio_device_module_.reset(new webrtc::FakeAudioDeviceModule()); 134 fake_audio_device_module_.reset(new webrtc::FakeAudioDeviceModule());
141 135
142 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( 136 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory(
143 worker_thread_, rtc::Thread::Current(), 137 worker_thread_, rtc::Thread::Current(),
144 fake_audio_device_module_.get(), nullptr, nullptr); 138 fake_audio_device_module_.get(), nullptr, nullptr);
145 139
146 webrtc::PeerConnectionInterface::IceServer stun_server; 140 webrtc::PeerConnectionInterface::IceServer stun_server;
147 stun_server.urls.push_back("stun:stun.l.google.com:19302"); 141 stun_server.urls.push_back("stun:stun.l.google.com:19302");
148 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config; 142 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config;
149 rtc_config.servers.push_back(stun_server); 143 rtc_config.servers.push_back(stun_server);
150 144
151 webrtc::FakeConstraints constraints; 145 webrtc::FakeConstraints constraints;
152 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 146 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
153 webrtc::MediaConstraintsInterface::kValueTrue); 147 webrtc::MediaConstraintsInterface::kValueTrue);
154 148
149 scoped_ptr<cricket::PortAllocator> port_allocator =
150 transport_context_->port_allocator_factory()->CreatePortAllocator(
151 transport_context_);
155 peer_connection_ = peer_connection_factory_->CreatePeerConnection( 152 peer_connection_ = peer_connection_factory_->CreatePeerConnection(
156 rtc_config, &constraints, 153 rtc_config, &constraints,
157 rtc::scoped_ptr<cricket::PortAllocator>(port_allocator.release()), 154 rtc::scoped_ptr<cricket::PortAllocator>(port_allocator.release()),
158 nullptr, this); 155 nullptr, this);
159 156
160 outgoing_data_stream_adapter_.Initialize(peer_connection_); 157 outgoing_data_stream_adapter_.Initialize(peer_connection_);
161 incoming_data_stream_adapter_.Initialize(peer_connection_); 158 incoming_data_stream_adapter_.Initialize(peer_connection_);
162 159
163 event_handler_->OnWebrtcTransportConnecting(); 160 event_handler_->OnWebrtcTransportConnecting();
164 161
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 Close(INCOMPATIBLE_PROTOCOL); 482 Close(INCOMPATIBLE_PROTOCOL);
486 return; 483 return;
487 } 484 }
488 } 485 }
489 pending_incoming_candidates_.clear(); 486 pending_incoming_candidates_.clear();
490 } 487 }
491 } 488 }
492 489
493 } // namespace protocol 490 } // namespace protocol
494 } // namespace remoting 491 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/webrtc_transport.h ('k') | remoting/test/fake_port_allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698