| 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 #ifndef REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ | 5 #ifndef REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ |
| 6 #define REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ | 6 #define REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
| 13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 14 #include "remoting/protocol/transport.h" | 14 #include "remoting/protocol/transport.h" |
| 15 #include "remoting/protocol/webrtc_data_stream_adapter.h" | 15 #include "remoting/protocol/webrtc_data_stream_adapter.h" |
| 16 #include "remoting/signaling/signal_strategy.h" | 16 #include "remoting/signaling/signal_strategy.h" |
| 17 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h
" | 17 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h
" |
| 18 | 18 |
| 19 namespace webrtc { | 19 namespace webrtc { |
| 20 class FakeAudioDeviceModule; | 20 class FakeAudioDeviceModule; |
| 21 } // namespace webrtc | 21 } // namespace webrtc |
| 22 | 22 |
| 23 namespace remoting { | 23 namespace remoting { |
| 24 namespace protocol { | 24 namespace protocol { |
| 25 | 25 |
| 26 class TransportContext; |
| 27 |
| 26 class WebrtcTransport : public Transport, | 28 class WebrtcTransport : public Transport, |
| 27 public webrtc::PeerConnectionObserver { | 29 public webrtc::PeerConnectionObserver { |
| 28 public: | 30 public: |
| 29 WebrtcTransport(rtc::Thread* worker_thread, | 31 WebrtcTransport(rtc::Thread* worker_thread, |
| 30 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> | 32 scoped_refptr<TransportContext> transport_context); |
| 31 port_allocator_factory, | |
| 32 TransportRole role); | |
| 33 ~WebrtcTransport() override; | 33 ~WebrtcTransport() override; |
| 34 | 34 |
| 35 webrtc::PeerConnectionInterface* peer_connection() { | 35 webrtc::PeerConnectionInterface* peer_connection() { |
| 36 return peer_connection_; | 36 return peer_connection_; |
| 37 } | 37 } |
| 38 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() { | 38 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() { |
| 39 return peer_connection_factory_; | 39 return peer_connection_factory_; |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Transport interface. | 42 // Transport interface. |
| 43 void Start(EventHandler* event_handler, | 43 void Start(EventHandler* event_handler, |
| 44 Authenticator* authenticator) override; | 44 Authenticator* authenticator) override; |
| 45 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; | 45 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; |
| 46 StreamChannelFactory* GetStreamChannelFactory() override; | 46 StreamChannelFactory* GetStreamChannelFactory() override; |
| 47 StreamChannelFactory* GetMultiplexedChannelFactory() override; | 47 StreamChannelFactory* GetMultiplexedChannelFactory() override; |
| 48 WebrtcTransport* AsWebrtcTransport() override; | 48 WebrtcTransport* AsWebrtcTransport() override; |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 void OnPortAllocatorCreated( |
| 52 scoped_ptr<cricket::PortAllocator> port_allocator); |
| 53 |
| 51 void OnLocalSessionDescriptionCreated( | 54 void OnLocalSessionDescriptionCreated( |
| 52 scoped_ptr<webrtc::SessionDescriptionInterface> description, | 55 scoped_ptr<webrtc::SessionDescriptionInterface> description, |
| 53 const std::string& error); | 56 const std::string& error); |
| 54 void OnLocalDescriptionSet(bool success, const std::string& error); | 57 void OnLocalDescriptionSet(bool success, const std::string& error); |
| 55 void OnRemoteDescriptionSet(bool send_answer, | 58 void OnRemoteDescriptionSet(bool send_answer, |
| 56 bool success, | 59 bool success, |
| 57 const std::string& error); | 60 const std::string& error); |
| 58 | 61 |
| 59 // webrtc::PeerConnectionObserver interface. | 62 // webrtc::PeerConnectionObserver interface. |
| 60 void OnSignalingChange( | 63 void OnSignalingChange( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 72 void RequestNegotiation(); | 75 void RequestNegotiation(); |
| 73 void SendOffer(); | 76 void SendOffer(); |
| 74 void EnsurePendingTransportInfoMessage(); | 77 void EnsurePendingTransportInfoMessage(); |
| 75 void SendTransportInfo(); | 78 void SendTransportInfo(); |
| 76 void AddPendingCandidatesIfPossible(); | 79 void AddPendingCandidatesIfPossible(); |
| 77 | 80 |
| 78 void Close(ErrorCode error); | 81 void Close(ErrorCode error); |
| 79 | 82 |
| 80 base::ThreadChecker thread_checker_; | 83 base::ThreadChecker thread_checker_; |
| 81 | 84 |
| 82 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> | 85 scoped_refptr<TransportContext> transport_context_; |
| 83 port_allocator_factory_; | |
| 84 TransportRole role_; | |
| 85 EventHandler* event_handler_ = nullptr; | 86 EventHandler* event_handler_ = nullptr; |
| 86 rtc::Thread* worker_thread_; | 87 rtc::Thread* worker_thread_; |
| 87 | 88 |
| 88 scoped_ptr<webrtc::FakeAudioDeviceModule> fake_audio_device_module_; | 89 scoped_ptr<webrtc::FakeAudioDeviceModule> fake_audio_device_module_; |
| 89 | 90 |
| 90 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> | 91 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> |
| 91 peer_connection_factory_; | 92 peer_connection_factory_; |
| 92 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; | 93 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; |
| 93 | 94 |
| 94 bool negotiation_pending_ = false; | 95 bool negotiation_pending_ = false; |
| 95 | 96 |
| 96 scoped_ptr<buzz::XmlElement> pending_transport_info_message_; | 97 scoped_ptr<buzz::XmlElement> pending_transport_info_message_; |
| 97 base::OneShotTimer transport_info_timer_; | 98 base::OneShotTimer transport_info_timer_; |
| 98 | 99 |
| 99 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_; | 100 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_; |
| 100 | 101 |
| 101 std::list<rtc::scoped_refptr<webrtc::MediaStreamInterface>> | 102 std::list<rtc::scoped_refptr<webrtc::MediaStreamInterface>> |
| 102 unclaimed_streams_; | 103 unclaimed_streams_; |
| 103 | 104 |
| 104 WebrtcDataStreamAdapter data_stream_adapter_; | 105 WebrtcDataStreamAdapter data_stream_adapter_; |
| 105 | 106 |
| 106 base::WeakPtrFactory<WebrtcTransport> weak_factory_; | 107 base::WeakPtrFactory<WebrtcTransport> weak_factory_; |
| 107 | 108 |
| 108 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport); | 109 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport); |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 class WebrtcTransportFactory : public TransportFactory { | 112 class WebrtcTransportFactory : public TransportFactory { |
| 112 public: | 113 public: |
| 113 WebrtcTransportFactory( | 114 WebrtcTransportFactory(rtc::Thread* worker_thread, |
| 114 rtc::Thread* worker_thread, | 115 scoped_refptr<TransportContext> transport_context); |
| 115 SignalStrategy* signal_strategy, | |
| 116 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> | |
| 117 port_allocator_factory, | |
| 118 TransportRole role); | |
| 119 ~WebrtcTransportFactory() override; | 116 ~WebrtcTransportFactory() override; |
| 120 | 117 |
| 121 // TransportFactory interface. | 118 // TransportFactory interface. |
| 122 scoped_ptr<Transport> CreateTransport() override; | 119 scoped_ptr<Transport> CreateTransport() override; |
| 123 | 120 |
| 124 private: | 121 private: |
| 125 rtc::Thread* worker_thread_; | 122 rtc::Thread* worker_thread_; |
| 126 SignalStrategy* signal_strategy_; | 123 scoped_refptr<TransportContext> transport_context_; |
| 127 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> | |
| 128 port_allocator_factory_; | |
| 129 TransportRole role_; | |
| 130 | 124 |
| 131 DISALLOW_COPY_AND_ASSIGN(WebrtcTransportFactory); | 125 DISALLOW_COPY_AND_ASSIGN(WebrtcTransportFactory); |
| 132 }; | 126 }; |
| 133 | 127 |
| 134 } // namespace protocol | 128 } // namespace protocol |
| 135 } // namespace remoting | 129 } // namespace remoting |
| 136 | 130 |
| 137 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ | 131 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ |
| OLD | NEW |