| 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_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
| 22 #include "jingle/glue/thread_wrapper.h" | 22 #include "jingle/glue/thread_wrapper.h" |
| 23 #include "remoting/protocol/authenticator.h" | 23 #include "remoting/protocol/authenticator.h" |
| 24 #include "remoting/protocol/port_allocator_factory.h" | 24 #include "remoting/protocol/port_allocator_factory.h" |
| 25 #include "remoting/protocol/stream_message_pipe_adapter.h" | 25 #include "remoting/protocol/stream_message_pipe_adapter.h" |
| 26 #include "remoting/protocol/transport_context.h" | 26 #include "remoting/protocol/transport_context.h" |
| 27 #include "remoting/protocol/webrtc_audio_module.h" |
| 27 #include "remoting/protocol/webrtc_dummy_video_encoder.h" | 28 #include "remoting/protocol/webrtc_dummy_video_encoder.h" |
| 28 #include "third_party/webrtc/api/test/fakeconstraints.h" | 29 #include "third_party/webrtc/api/test/fakeconstraints.h" |
| 29 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 30 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
| 30 #include "third_party/webrtc/modules/audio_device/include/fake_audio_device.h" | |
| 31 | 31 |
| 32 using buzz::QName; | 32 using buzz::QName; |
| 33 using buzz::XmlElement; | 33 using buzz::XmlElement; |
| 34 | 34 |
| 35 namespace remoting { | 35 namespace remoting { |
| 36 namespace protocol { | 36 namespace protocol { |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 // Delay after candidate creation before sending transport-info message to | 40 // Delay after candidate creation before sending transport-info message to |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 class WebrtcTransport::PeerConnectionWrapper | 140 class WebrtcTransport::PeerConnectionWrapper |
| 141 : public webrtc::PeerConnectionObserver { | 141 : public webrtc::PeerConnectionObserver { |
| 142 public: | 142 public: |
| 143 PeerConnectionWrapper( | 143 PeerConnectionWrapper( |
| 144 rtc::Thread* worker_thread, | 144 rtc::Thread* worker_thread, |
| 145 std::unique_ptr<cricket::WebRtcVideoEncoderFactory> encoder_factory, | 145 std::unique_ptr<cricket::WebRtcVideoEncoderFactory> encoder_factory, |
| 146 std::unique_ptr<cricket::PortAllocator> port_allocator, | 146 std::unique_ptr<cricket::PortAllocator> port_allocator, |
| 147 base::WeakPtr<WebrtcTransport> transport) | 147 base::WeakPtr<WebrtcTransport> transport) |
| 148 : transport_(transport) { | 148 : transport_(transport) { |
| 149 scoped_refptr<WebrtcAudioModule> audio_module = |
| 150 new rtc::RefCountedObject<WebrtcAudioModule>(); |
| 151 |
| 149 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( | 152 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( |
| 150 worker_thread, rtc::Thread::Current(), &fake_audio_device_module_, | 153 worker_thread, rtc::Thread::Current(), audio_module.get(), |
| 151 encoder_factory.release(), nullptr); | 154 encoder_factory.release(), nullptr); |
| 152 | 155 |
| 153 webrtc::FakeConstraints constraints; | 156 webrtc::FakeConstraints constraints; |
| 154 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 157 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
| 155 webrtc::MediaConstraintsInterface::kValueTrue); | 158 webrtc::MediaConstraintsInterface::kValueTrue); |
| 156 peer_connection_ = peer_connection_factory_->CreatePeerConnection( | 159 peer_connection_ = peer_connection_factory_->CreatePeerConnection( |
| 157 webrtc::PeerConnectionInterface::RTCConfiguration(), &constraints, | 160 webrtc::PeerConnectionInterface::RTCConfiguration(), &constraints, |
| 158 std::move(port_allocator), nullptr, this); | 161 std::move(port_allocator), nullptr, this); |
| 159 } | 162 } |
| 160 virtual ~PeerConnectionWrapper() { peer_connection_->Close(); } | 163 virtual ~PeerConnectionWrapper() { peer_connection_->Close(); } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 webrtc::PeerConnectionInterface::IceGatheringState new_state) override { | 204 webrtc::PeerConnectionInterface::IceGatheringState new_state) override { |
| 202 if (transport_) | 205 if (transport_) |
| 203 transport_->OnIceGatheringChange(new_state); | 206 transport_->OnIceGatheringChange(new_state); |
| 204 } | 207 } |
| 205 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override { | 208 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override { |
| 206 if (transport_) | 209 if (transport_) |
| 207 transport_->OnIceCandidate(candidate); | 210 transport_->OnIceCandidate(candidate); |
| 208 } | 211 } |
| 209 | 212 |
| 210 private: | 213 private: |
| 211 webrtc::FakeAudioDeviceModule fake_audio_device_module_; | 214 scoped_refptr<WebrtcAudioModule> audio_module_; |
| 212 scoped_refptr<webrtc::PeerConnectionFactoryInterface> | 215 scoped_refptr<webrtc::PeerConnectionFactoryInterface> |
| 213 peer_connection_factory_; | 216 peer_connection_factory_; |
| 214 scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; | 217 scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; |
| 215 | 218 |
| 216 base::WeakPtr<WebrtcTransport> transport_; | 219 base::WeakPtr<WebrtcTransport> transport_; |
| 217 | 220 |
| 218 DISALLOW_COPY_AND_ASSIGN(PeerConnectionWrapper); | 221 DISALLOW_COPY_AND_ASSIGN(PeerConnectionWrapper); |
| 219 }; | 222 }; |
| 220 | 223 |
| 221 WebrtcTransport::WebrtcTransport( | 224 WebrtcTransport::WebrtcTransport( |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 // the stack and so it must be destroyed later. | 663 // the stack and so it must be destroyed later. |
| 661 base::ThreadTaskRunnerHandle::Get()->DeleteSoon( | 664 base::ThreadTaskRunnerHandle::Get()->DeleteSoon( |
| 662 FROM_HERE, peer_connection_wrapper_.release()); | 665 FROM_HERE, peer_connection_wrapper_.release()); |
| 663 | 666 |
| 664 if (error != OK) | 667 if (error != OK) |
| 665 event_handler_->OnWebrtcTransportError(error); | 668 event_handler_->OnWebrtcTransportError(error); |
| 666 } | 669 } |
| 667 | 670 |
| 668 } // namespace protocol | 671 } // namespace protocol |
| 669 } // namespace remoting | 672 } // namespace remoting |
| OLD | NEW |