| 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 |
| 11 #include "base/base64.h" | 11 #include "base/base64.h" |
| 12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/task_runner_util.h" | 20 #include "base/task_runner_util.h" |
| 21 #include "base/threading/thread_restrictions.h" |
| 21 #include "base/threading/thread_task_runner_handle.h" | 22 #include "base/threading/thread_task_runner_handle.h" |
| 22 #include "jingle/glue/thread_wrapper.h" | 23 #include "jingle/glue/thread_wrapper.h" |
| 23 #include "remoting/protocol/authenticator.h" | 24 #include "remoting/protocol/authenticator.h" |
| 24 #include "remoting/protocol/port_allocator_factory.h" | 25 #include "remoting/protocol/port_allocator_factory.h" |
| 25 #include "remoting/protocol/sdp_message.h" | 26 #include "remoting/protocol/sdp_message.h" |
| 26 #include "remoting/protocol/stream_message_pipe_adapter.h" | 27 #include "remoting/protocol/stream_message_pipe_adapter.h" |
| 27 #include "remoting/protocol/transport_context.h" | 28 #include "remoting/protocol/transport_context.h" |
| 28 #include "remoting/protocol/webrtc_audio_module.h" | 29 #include "remoting/protocol/webrtc_audio_module.h" |
| 29 #include "remoting/protocol/webrtc_dummy_video_encoder.h" | 30 #include "remoting/protocol/webrtc_dummy_video_encoder.h" |
| 30 #include "third_party/webrtc/api/test/fakeconstraints.h" | 31 #include "third_party/webrtc/api/test/fakeconstraints.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 rtc_config.bundle_policy = | 188 rtc_config.bundle_policy = |
| 188 webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle; | 189 webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle; |
| 189 rtc_config.rtcp_mux_policy = | 190 rtc_config.rtcp_mux_policy = |
| 190 webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire; | 191 webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire; |
| 191 | 192 |
| 192 rtc_config.media_config.video.periodic_alr_bandwidth_probing = true; | 193 rtc_config.media_config.video.periodic_alr_bandwidth_probing = true; |
| 193 | 194 |
| 194 peer_connection_ = peer_connection_factory_->CreatePeerConnection( | 195 peer_connection_ = peer_connection_factory_->CreatePeerConnection( |
| 195 rtc_config, &constraints, std::move(port_allocator), nullptr, this); | 196 rtc_config, &constraints, std::move(port_allocator), nullptr, this); |
| 196 } | 197 } |
| 197 virtual ~PeerConnectionWrapper() { peer_connection_->Close(); } | 198 virtual ~PeerConnectionWrapper() { |
| 199 // PeerConnection creates threads internally, which are stopped when the |
| 200 // connection is closed. Thread.Stop() is a blocking operation. |
| 201 // See crbug.com/660081. |
| 202 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 203 peer_connection_->Close(); |
| 204 } |
| 198 | 205 |
| 199 WebrtcAudioModule* audio_module() { | 206 WebrtcAudioModule* audio_module() { |
| 200 return audio_module_.get(); | 207 return audio_module_.get(); |
| 201 } | 208 } |
| 202 | 209 |
| 203 webrtc::PeerConnectionInterface* peer_connection() { | 210 webrtc::PeerConnectionInterface* peer_connection() { |
| 204 return peer_connection_.get(); | 211 return peer_connection_.get(); |
| 205 } | 212 } |
| 206 | 213 |
| 207 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() { | 214 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() { |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 // the stack and so it must be destroyed later. | 702 // the stack and so it must be destroyed later. |
| 696 base::ThreadTaskRunnerHandle::Get()->DeleteSoon( | 703 base::ThreadTaskRunnerHandle::Get()->DeleteSoon( |
| 697 FROM_HERE, peer_connection_wrapper_.release()); | 704 FROM_HERE, peer_connection_wrapper_.release()); |
| 698 | 705 |
| 699 if (error != OK) | 706 if (error != OK) |
| 700 event_handler_->OnWebrtcTransportError(error); | 707 event_handler_->OnWebrtcTransportError(error); |
| 701 } | 708 } |
| 702 | 709 |
| 703 } // namespace protocol | 710 } // namespace protocol |
| 704 } // namespace remoting | 711 } // namespace remoting |
| OLD | NEW |