OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_ | 11 #ifndef WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_ |
12 #define WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_ | 12 #define WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "webrtc/base/constructormagic.h" | 18 #include "webrtc/base/constructormagic.h" |
19 #include "webrtc/p2p/base/candidate.h" | 19 #include "webrtc/p2p/base/candidate.h" |
20 #include "webrtc/p2p/base/candidatepairinterface.h" | 20 #include "webrtc/p2p/base/candidatepairinterface.h" |
| 21 #include "webrtc/p2p/base/packettransport.h" |
21 #include "webrtc/p2p/base/transport.h" | 22 #include "webrtc/p2p/base/transport.h" |
22 #include "webrtc/p2p/base/transportdescription.h" | 23 #include "webrtc/p2p/base/transportdescription.h" |
23 #include "webrtc/base/asyncpacketsocket.h" | 24 #include "webrtc/base/asyncpacketsocket.h" |
24 #include "webrtc/base/basictypes.h" | 25 #include "webrtc/base/basictypes.h" |
25 #include "webrtc/base/dscp.h" | 26 #include "webrtc/base/dscp.h" |
26 #include "webrtc/base/sigslot.h" | 27 #include "webrtc/base/sigslot.h" |
27 #include "webrtc/base/socket.h" | 28 #include "webrtc/base/socket.h" |
28 #include "webrtc/base/sslidentity.h" | 29 #include "webrtc/base/sslidentity.h" |
29 #include "webrtc/base/sslstreamadapter.h" | 30 #include "webrtc/base/sslstreamadapter.h" |
30 | 31 |
(...skipping 13 matching lines...) Expand all Loading... |
44 STATE_INIT, | 45 STATE_INIT, |
45 STATE_CONNECTING, // Will enter this state once a connection is created | 46 STATE_CONNECTING, // Will enter this state once a connection is created |
46 STATE_COMPLETED, | 47 STATE_COMPLETED, |
47 STATE_FAILED | 48 STATE_FAILED |
48 }; | 49 }; |
49 | 50 |
50 // A TransportChannel represents one logical stream of packets that are sent | 51 // A TransportChannel represents one logical stream of packets that are sent |
51 // between the two sides of a session. | 52 // between the two sides of a session. |
52 // TODO(deadbeef): This interface currently represents the unity of an ICE | 53 // TODO(deadbeef): This interface currently represents the unity of an ICE |
53 // transport and a DTLS transport. They need to be separated apart. | 54 // transport and a DTLS transport. They need to be separated apart. |
54 class TransportChannel : public sigslot::has_slots<> { | 55 class TransportChannel : public rtc::PacketTransport { |
55 public: | 56 public: |
56 TransportChannel(const std::string& transport_name, int component) | 57 TransportChannel(const std::string& transport_name, int component) |
57 : transport_name_(transport_name), | 58 : transport_name_(transport_name), |
58 component_(component), | 59 component_(component), |
59 writable_(false), | 60 writable_(false), |
60 receiving_(false) {} | 61 receiving_(false) {} |
61 virtual ~TransportChannel() {} | 62 virtual ~TransportChannel() {} |
62 | 63 |
63 // TODO(guoweis) - Make this pure virtual once all subclasses of | 64 // TODO(guoweis) - Make this pure virtual once all subclasses of |
64 // TransportChannel have this defined. | 65 // TransportChannel have this defined. |
65 virtual TransportChannelState GetState() const { | 66 virtual TransportChannelState GetState() const { |
66 return TransportChannelState::STATE_CONNECTING; | 67 return TransportChannelState::STATE_CONNECTING; |
67 } | 68 } |
68 | 69 |
69 const std::string& transport_name() const { return transport_name_; } | 70 const std::string& transport_name() const override { return transport_name_; } |
70 int component() const { return component_; } | 71 int component() const override { return component_; } |
71 | 72 |
72 // Returns the states of this channel. Each time one of these states changes, | 73 // Returns the states of this channel. Each time one of these states changes, |
73 // a signal is raised. These states are aggregated by the TransportManager. | 74 // a signal is raised. These states are aggregated by the TransportManager. |
74 bool writable() const { return writable_; } | 75 bool writable() const override { return writable_; } |
75 bool receiving() const { return receiving_; } | 76 bool receiving() const { return receiving_; } |
76 DtlsTransportState dtls_state() const { return dtls_state_; } | 77 DtlsTransportState dtls_state() const { return dtls_state_; } |
77 sigslot::signal1<TransportChannel*> SignalWritableState; | |
78 // Emitted when the TransportChannel's ability to send has changed. | |
79 sigslot::signal1<TransportChannel*> SignalReadyToSend; | |
80 sigslot::signal1<TransportChannel*> SignalReceivingState; | 78 sigslot::signal1<TransportChannel*> SignalReceivingState; |
81 // Emitted whenever DTLS-SRTP is setup which will require setting up a new | 79 // Emitted whenever DTLS-SRTP is setup which will require setting up a new |
82 // SRTP context. | 80 // SRTP context. |
83 sigslot::signal2<TransportChannel*, DtlsTransportState> SignalDtlsState; | 81 sigslot::signal2<TransportChannel*, DtlsTransportState> SignalDtlsState; |
84 | 82 |
85 // Attempts to send the given packet. The return value is < 0 on failure. | |
86 // TODO: Remove the default argument once channel code is updated. | |
87 virtual int SendPacket(const char* data, size_t len, | |
88 const rtc::PacketOptions& options, | |
89 int flags = 0) = 0; | |
90 | |
91 // Sets a socket option on this channel. Note that not all options are | |
92 // supported by all transport types. | |
93 virtual int SetOption(rtc::Socket::Option opt, int value) = 0; | |
94 // TODO(pthatcher): Once Chrome's MockTransportChannel implments | |
95 // this, remove the default implementation. | |
96 virtual bool GetOption(rtc::Socket::Option opt, int* value) { return false; } | |
97 | |
98 // Returns the most recent error that occurred on this channel. | |
99 virtual int GetError() = 0; | |
100 | |
101 // Returns the current stats for this connection. | |
102 virtual bool GetStats(ConnectionInfos* infos) = 0; | |
103 | |
104 // Is DTLS active? | 83 // Is DTLS active? |
105 virtual bool IsDtlsActive() const = 0; | 84 virtual bool IsDtlsActive() const = 0; |
106 | 85 |
107 // Default implementation. | 86 // Default implementation. |
108 virtual bool GetSslRole(rtc::SSLRole* role) const = 0; | 87 virtual bool GetSslRole(rtc::SSLRole* role) const = 0; |
109 | 88 |
110 // Sets up the ciphers to use for DTLS-SRTP. TODO(guoweis): Make this pure | 89 // Sets up the ciphers to use for DTLS-SRTP. TODO(guoweis): Make this pure |
111 // virtual once all dependencies have implementation. | 90 // virtual once all dependencies have implementation. |
112 virtual bool SetSrtpCryptoSuites(const std::vector<int>& ciphers); | 91 virtual bool SetSrtpCryptoSuites(const std::vector<int>& ciphers); |
113 | 92 |
(...skipping 18 matching lines...) Expand all Loading... |
132 const = 0; | 111 const = 0; |
133 | 112 |
134 // Allows key material to be extracted for external encryption. | 113 // Allows key material to be extracted for external encryption. |
135 virtual bool ExportKeyingMaterial(const std::string& label, | 114 virtual bool ExportKeyingMaterial(const std::string& label, |
136 const uint8_t* context, | 115 const uint8_t* context, |
137 size_t context_len, | 116 size_t context_len, |
138 bool use_context, | 117 bool use_context, |
139 uint8_t* result, | 118 uint8_t* result, |
140 size_t result_len) = 0; | 119 size_t result_len) = 0; |
141 | 120 |
142 // Signalled each time a packet is received on this channel. | |
143 sigslot::signal5<TransportChannel*, const char*, | |
144 size_t, const rtc::PacketTime&, int> SignalReadPacket; | |
145 | |
146 // Signalled each time a packet is sent on this channel. | |
147 sigslot::signal2<TransportChannel*, const rtc::SentPacket&> SignalSentPacket; | |
148 | |
149 // Deprecated by SignalSelectedCandidatePairChanged | 121 // Deprecated by SignalSelectedCandidatePairChanged |
150 // This signal occurs when there is a change in the way that packets are | 122 // This signal occurs when there is a change in the way that packets are |
151 // being routed, i.e. to a different remote location. The candidate | 123 // being routed, i.e. to a different remote location. The candidate |
152 // indicates where and how we are currently sending media. | 124 // indicates where and how we are currently sending media. |
153 sigslot::signal2<TransportChannel*, const Candidate&> SignalRouteChange; | 125 sigslot::signal2<TransportChannel*, const Candidate&> SignalRouteChange; |
154 | 126 |
155 // Signalled when the current selected candidate pair has changed. | 127 // Signalled when the current selected candidate pair has changed. |
156 // The first parameter is the transport channel that signals the event. | 128 // The first parameter is the transport channel that signals the event. |
157 // The second parameter is the new selected candidate pair. The third | 129 // The second parameter is the new selected candidate pair. The third |
158 // parameter is the last packet id sent on the previous candidate pair. | 130 // parameter is the last packet id sent on the previous candidate pair. |
(...skipping 25 matching lines...) Expand all Loading... |
184 bool writable_; | 156 bool writable_; |
185 bool receiving_; | 157 bool receiving_; |
186 DtlsTransportState dtls_state_ = DTLS_TRANSPORT_NEW; | 158 DtlsTransportState dtls_state_ = DTLS_TRANSPORT_NEW; |
187 | 159 |
188 RTC_DISALLOW_COPY_AND_ASSIGN(TransportChannel); | 160 RTC_DISALLOW_COPY_AND_ASSIGN(TransportChannel); |
189 }; | 161 }; |
190 | 162 |
191 } // namespace cricket | 163 } // namespace cricket |
192 | 164 |
193 #endif // WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_ | 165 #endif // WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_ |
OLD | NEW |