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" |
11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
15 #include "remoting/protocol/port_allocator_factory.h" | 15 #include "remoting/protocol/port_allocator_factory.h" |
16 #include "remoting/protocol/transport.h" | 16 #include "remoting/protocol/transport.h" |
17 #include "remoting/protocol/webrtc_data_stream_adapter.h" | 17 #include "remoting/protocol/webrtc_data_stream_adapter.h" |
18 #include "remoting/signaling/signal_strategy.h" | 18 #include "remoting/signaling/signal_strategy.h" |
19 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h
" | 19 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h
" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
22 class FakeAudioDeviceModule; | 22 class FakeAudioDeviceModule; |
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 class MessageChannelFactory; |
29 | 30 |
30 class WebrtcTransport : public Transport, | 31 class WebrtcTransport : public Transport, |
31 public webrtc::PeerConnectionObserver { | 32 public webrtc::PeerConnectionObserver { |
32 public: | 33 public: |
33 class EventHandler { | 34 class EventHandler { |
34 public: | 35 public: |
35 // Called after |peer_connection| has been created but before handshake. The | 36 // Called after |peer_connection| has been created but before handshake. The |
36 // handler should create data channels and media streams. Renegotiation will | 37 // handler should create data channels and media streams. Renegotiation will |
37 // be required in two cases after this method returns: | 38 // be required in two cases after this method returns: |
38 // 1. When the first data channel is created, if it wasn't created by this | 39 // 1. When the first data channel is created, if it wasn't created by this |
(...skipping 21 matching lines...) Expand all Loading... |
60 | 61 |
61 webrtc::PeerConnectionInterface* peer_connection() { | 62 webrtc::PeerConnectionInterface* peer_connection() { |
62 return peer_connection_; | 63 return peer_connection_; |
63 } | 64 } |
64 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() { | 65 webrtc::PeerConnectionFactoryInterface* peer_connection_factory() { |
65 return peer_connection_factory_; | 66 return peer_connection_factory_; |
66 } | 67 } |
67 | 68 |
68 // Factories for outgoing and incoming data channels. Must be used only after | 69 // Factories for outgoing and incoming data channels. Must be used only after |
69 // the transport is connected. | 70 // the transport is connected. |
70 StreamChannelFactory* outgoing_channel_factory() { | 71 MessageChannelFactory* outgoing_channel_factory() { |
71 return &outgoing_data_stream_adapter_; | 72 return outgoing_channel_factory_.get(); |
72 } | 73 } |
73 StreamChannelFactory* incoming_channel_factory() { | 74 MessageChannelFactory* incoming_channel_factory() { |
74 return &incoming_data_stream_adapter_; | 75 return incoming_channel_factory_.get(); |
75 } | 76 } |
76 | 77 |
77 // Transport interface. | 78 // Transport interface. |
78 void Start(Authenticator* authenticator, | 79 void Start(Authenticator* authenticator, |
79 SendTransportInfoCallback send_transport_info_callback) override; | 80 SendTransportInfoCallback send_transport_info_callback) override; |
80 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; | 81 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; |
81 | 82 |
82 private: | 83 private: |
83 void OnLocalSessionDescriptionCreated( | 84 void OnLocalSessionDescriptionCreated( |
84 scoped_ptr<webrtc::SessionDescriptionInterface> description, | 85 scoped_ptr<webrtc::SessionDescriptionInterface> description, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 bool connected_ = false; | 128 bool connected_ = false; |
128 | 129 |
129 scoped_ptr<buzz::XmlElement> pending_transport_info_message_; | 130 scoped_ptr<buzz::XmlElement> pending_transport_info_message_; |
130 base::OneShotTimer transport_info_timer_; | 131 base::OneShotTimer transport_info_timer_; |
131 | 132 |
132 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_; | 133 ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_; |
133 | 134 |
134 WebrtcDataStreamAdapter outgoing_data_stream_adapter_; | 135 WebrtcDataStreamAdapter outgoing_data_stream_adapter_; |
135 WebrtcDataStreamAdapter incoming_data_stream_adapter_; | 136 WebrtcDataStreamAdapter incoming_data_stream_adapter_; |
136 | 137 |
| 138 // TODO(sergeyu): Remove these and implement MessageChannelFactory in |
| 139 // WebrtcDataStreamAdapter. |
| 140 scoped_ptr<MessageChannelFactory> outgoing_channel_factory_; |
| 141 scoped_ptr<MessageChannelFactory> incoming_channel_factory_; |
| 142 |
137 base::WeakPtrFactory<WebrtcTransport> weak_factory_; | 143 base::WeakPtrFactory<WebrtcTransport> weak_factory_; |
138 | 144 |
139 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport); | 145 DISALLOW_COPY_AND_ASSIGN(WebrtcTransport); |
140 }; | 146 }; |
141 | 147 |
142 } // namespace protocol | 148 } // namespace protocol |
143 } // namespace remoting | 149 } // namespace remoting |
144 | 150 |
145 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ | 151 #endif // REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_ |
OLD | NEW |