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/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 } // namespace webrtc | 23 } // namespace webrtc |
24 | 24 |
25 namespace remoting { | 25 namespace remoting { |
26 namespace protocol { | 26 namespace protocol { |
27 | 27 |
28 class TransportContext; | 28 class TransportContext; |
29 | 29 |
30 class WebrtcTransport : public Transport, | 30 class WebrtcTransport : public Transport, |
31 public webrtc::PeerConnectionObserver { | 31 public webrtc::PeerConnectionObserver { |
32 public: | 32 public: |
| 33 class EventHandler { |
| 34 public: |
| 35 // Called when the transport is connected. |
| 36 virtual void OnWebrtcTransportConnected() = 0; |
| 37 |
| 38 // Called when there is an error connecting the session. |
| 39 virtual void OnWebrtcTransportError(ErrorCode error) = 0; |
| 40 }; |
| 41 |
33 WebrtcTransport(rtc::Thread* worker_thread, | 42 WebrtcTransport(rtc::Thread* worker_thread, |
34 scoped_refptr<TransportContext> transport_context); | 43 scoped_refptr<TransportContext> transport_context, |
| 44 EventHandler* event_handler); |
35 ~WebrtcTransport() override; | 45 ~WebrtcTransport() override; |
36 | 46 |
37 webrtc::PeerConnectionInterface* peer_connection() { | 47 webrtc::PeerConnectionInterface* peer_connection() { |
38 return peer_connection_; | 48 return peer_connection_; |
39 } | 49 } |
40 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() { | 50 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() { |
41 return peer_connection_factory_; | 51 return peer_connection_factory_; |
42 } | 52 } |
43 | 53 |
| 54 StreamChannelFactory* GetStreamChannelFactory(); |
| 55 |
44 // Transport interface. | 56 // Transport interface. |
45 void Start(EventHandler* event_handler, | 57 void Start(Authenticator* authenticator, |
46 Authenticator* authenticator) override; | 58 SendTransportInfoCallback send_transport_info_callback) override; |
47 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; | 59 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; |
48 StreamChannelFactory* GetStreamChannelFactory() override; | |
49 StreamChannelFactory* GetMultiplexedChannelFactory() override; | |
50 WebrtcTransport* AsWebrtcTransport() override; | |
51 | 60 |
52 private: | 61 private: |
53 void OnPortAllocatorCreated( | 62 void OnPortAllocatorCreated( |
54 scoped_ptr<cricket::PortAllocator> port_allocator); | 63 scoped_ptr<cricket::PortAllocator> port_allocator); |
55 | 64 |
56 void OnLocalSessionDescriptionCreated( | 65 void OnLocalSessionDescriptionCreated( |
57 scoped_ptr<webrtc::SessionDescriptionInterface> description, | 66 scoped_ptr<webrtc::SessionDescriptionInterface> description, |
58 const std::string& error); | 67 const std::string& error); |
59 void OnLocalDescriptionSet(bool success, const std::string& error); | 68 void OnLocalDescriptionSet(bool success, const std::string& error); |
60 void OnRemoteDescriptionSet(bool send_answer, | 69 void OnRemoteDescriptionSet(bool send_answer, |
(...skipping 16 matching lines...) Expand all Loading... |
77 void RequestNegotiation(); | 86 void RequestNegotiation(); |
78 void SendOffer(); | 87 void SendOffer(); |
79 void EnsurePendingTransportInfoMessage(); | 88 void EnsurePendingTransportInfoMessage(); |
80 void SendTransportInfo(); | 89 void SendTransportInfo(); |
81 void AddPendingCandidatesIfPossible(); | 90 void AddPendingCandidatesIfPossible(); |
82 | 91 |
83 void Close(ErrorCode error); | 92 void Close(ErrorCode error); |
84 | 93 |
85 base::ThreadChecker thread_checker_; | 94 base::ThreadChecker thread_checker_; |
86 | 95 |
| 96 rtc::Thread* worker_thread_; |
87 scoped_refptr<TransportContext> transport_context_; | 97 scoped_refptr<TransportContext> transport_context_; |
88 EventHandler* event_handler_ = nullptr; | 98 EventHandler* event_handler_ = nullptr; |
89 rtc::Thread* worker_thread_; | 99 SendTransportInfoCallback send_transport_info_callback_; |
90 | 100 |
91 scoped_ptr<webrtc::FakeAudioDeviceModule> fake_audio_device_module_; | 101 scoped_ptr<webrtc::FakeAudioDeviceModule> fake_audio_device_module_; |
92 | 102 |
93 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> | 103 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> |
94 peer_connection_factory_; | 104 peer_connection_factory_; |
95 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; | 105 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; |
96 | 106 |
97 bool negotiation_pending_ = false; | 107 bool negotiation_pending_ = false; |
98 | 108 |
99 scoped_ptr<buzz::XmlElement> pending_transport_info_message_; | 109 scoped_ptr<buzz::XmlElement> pending_transport_info_message_; |
100 base::OneShotTimer transport_info_timer_; | 110 base::OneShotTimer transport_info_timer_; |
101 | 111 |
102 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_; | 112 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_; |
103 | 113 |
104 std::list<rtc::scoped_refptr<webrtc::MediaStreamInterface>> | 114 std::list<rtc::scoped_refptr<webrtc::MediaStreamInterface>> |
105 unclaimed_streams_; | 115 unclaimed_streams_; |
106 | 116 |
107 WebrtcDataStreamAdapter data_stream_adapter_; | 117 WebrtcDataStreamAdapter data_stream_adapter_; |
108 | 118 |
109 base::WeakPtrFactory<WebrtcTransport> weak_factory_; | 119 base::WeakPtrFactory<WebrtcTransport> weak_factory_; |
110 | 120 |
111 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport); | 121 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport); |
112 }; | 122 }; |
113 | 123 |
114 class WebrtcTransportFactory : public TransportFactory { | |
115 public: | |
116 WebrtcTransportFactory(rtc::Thread* worker_thread, | |
117 scoped_refptr<TransportContext> transport_context); | |
118 ~WebrtcTransportFactory() override; | |
119 | |
120 // TransportFactory interface. | |
121 scoped_ptr<Transport> CreateTransport() override; | |
122 | |
123 private: | |
124 rtc::Thread* worker_thread_; | |
125 scoped_refptr<TransportContext> transport_context_; | |
126 | |
127 DISALLOW_COPY_AND_ASSIGN(WebrtcTransportFactory); | |
128 }; | |
129 | |
130 } // namespace protocol | 124 } // namespace protocol |
131 } // namespace remoting | 125 } // namespace remoting |
132 | 126 |
133 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ | 127 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ |
OLD | NEW |