| 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 <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" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
| 14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
| 15 #include "jingle/glue/thread_wrapper.h" | 15 #include "jingle/glue/thread_wrapper.h" |
| 16 #include "remoting/protocol/stream_message_pipe_adapter.h" |
| 16 #include "remoting/protocol/transport_context.h" | 17 #include "remoting/protocol/transport_context.h" |
| 17 #include "third_party/libjingle/source/talk/app/webrtc/test/fakeconstraints.h" | 18 #include "third_party/libjingle/source/talk/app/webrtc/test/fakeconstraints.h" |
| 18 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 19 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
| 19 #include "third_party/webrtc/modules/audio_device/include/fake_audio_device.h" | 20 #include "third_party/webrtc/modules/audio_device/include/fake_audio_device.h" |
| 20 | 21 |
| 21 using buzz::QName; | 22 using buzz::QName; |
| 22 using buzz::XmlElement; | 23 using buzz::XmlElement; |
| 23 | 24 |
| 24 namespace remoting { | 25 namespace remoting { |
| 25 namespace protocol { | 26 namespace protocol { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 SetSessionDescriptionObserver(const ResultCallback& result_callback) | 95 SetSessionDescriptionObserver(const ResultCallback& result_callback) |
| 95 : result_callback_(result_callback) {} | 96 : result_callback_(result_callback) {} |
| 96 ~SetSessionDescriptionObserver() override {} | 97 ~SetSessionDescriptionObserver() override {} |
| 97 | 98 |
| 98 private: | 99 private: |
| 99 ResultCallback result_callback_; | 100 ResultCallback result_callback_; |
| 100 | 101 |
| 101 DISALLOW_COPY_AND_ASSIGN(SetSessionDescriptionObserver); | 102 DISALLOW_COPY_AND_ASSIGN(SetSessionDescriptionObserver); |
| 102 }; | 103 }; |
| 103 | 104 |
| 105 void OnChannelErrorHandler(int error) { |
| 106 // WebrtcDataStreamAdapter never returns an error. |
| 107 NOTREACHED(); |
| 108 } |
| 109 |
| 104 } // namespace | 110 } // namespace |
| 105 | 111 |
| 106 WebrtcTransport::WebrtcTransport( | 112 WebrtcTransport::WebrtcTransport( |
| 107 rtc::Thread* worker_thread, | 113 rtc::Thread* worker_thread, |
| 108 scoped_refptr<TransportContext> transport_context, | 114 scoped_refptr<TransportContext> transport_context, |
| 109 EventHandler* event_handler) | 115 EventHandler* event_handler) |
| 110 : worker_thread_(worker_thread), | 116 : worker_thread_(worker_thread), |
| 111 transport_context_(transport_context), | 117 transport_context_(transport_context), |
| 112 event_handler_(event_handler), | 118 event_handler_(event_handler), |
| 113 outgoing_data_stream_adapter_(true), | 119 outgoing_data_stream_adapter_(true), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 154 |
| 149 scoped_ptr<cricket::PortAllocator> port_allocator = | 155 scoped_ptr<cricket::PortAllocator> port_allocator = |
| 150 transport_context_->port_allocator_factory()->CreatePortAllocator( | 156 transport_context_->port_allocator_factory()->CreatePortAllocator( |
| 151 transport_context_); | 157 transport_context_); |
| 152 peer_connection_ = peer_connection_factory_->CreatePeerConnection( | 158 peer_connection_ = peer_connection_factory_->CreatePeerConnection( |
| 153 rtc_config, &constraints, | 159 rtc_config, &constraints, |
| 154 rtc::scoped_ptr<cricket::PortAllocator>(port_allocator.release()), | 160 rtc::scoped_ptr<cricket::PortAllocator>(port_allocator.release()), |
| 155 nullptr, this); | 161 nullptr, this); |
| 156 | 162 |
| 157 outgoing_data_stream_adapter_.Initialize(peer_connection_); | 163 outgoing_data_stream_adapter_.Initialize(peer_connection_); |
| 164 outgoing_channel_factory_.reset(new StreamMessageChannelFactoryAdapter( |
| 165 &outgoing_data_stream_adapter_, base::Bind(&OnChannelErrorHandler))); |
| 166 |
| 158 incoming_data_stream_adapter_.Initialize(peer_connection_); | 167 incoming_data_stream_adapter_.Initialize(peer_connection_); |
| 168 incoming_channel_factory_.reset(new StreamMessageChannelFactoryAdapter( |
| 169 &incoming_data_stream_adapter_, base::Bind(&OnChannelErrorHandler))); |
| 159 | 170 |
| 160 event_handler_->OnWebrtcTransportConnecting(); | 171 event_handler_->OnWebrtcTransportConnecting(); |
| 161 | 172 |
| 162 if (transport_context_->role() == TransportRole::SERVER) | 173 if (transport_context_->role() == TransportRole::SERVER) |
| 163 RequestNegotiation(); | 174 RequestNegotiation(); |
| 164 } | 175 } |
| 165 | 176 |
| 166 bool WebrtcTransport::ProcessTransportInfo(XmlElement* transport_info) { | 177 bool WebrtcTransport::ProcessTransportInfo(XmlElement* transport_info) { |
| 167 DCHECK(thread_checker_.CalledOnValidThread()); | 178 DCHECK(thread_checker_.CalledOnValidThread()); |
| 168 | 179 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 Close(INCOMPATIBLE_PROTOCOL); | 493 Close(INCOMPATIBLE_PROTOCOL); |
| 483 return; | 494 return; |
| 484 } | 495 } |
| 485 } | 496 } |
| 486 pending_incoming_candidates_.clear(); | 497 pending_incoming_candidates_.clear(); |
| 487 } | 498 } |
| 488 } | 499 } |
| 489 | 500 |
| 490 } // namespace protocol | 501 } // namespace protocol |
| 491 } // namespace remoting | 502 } // namespace remoting |
| OLD | NEW |