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 |
(...skipping 28 matching lines...) Expand all Loading... | |
39 // Used to indicate channel's connection state. | 39 // Used to indicate channel's connection state. |
40 enum TransportChannelState { | 40 enum TransportChannelState { |
41 STATE_INIT, | 41 STATE_INIT, |
42 STATE_CONNECTING, // Will enter this state once a connection is created | 42 STATE_CONNECTING, // Will enter this state once a connection is created |
43 STATE_COMPLETED, | 43 STATE_COMPLETED, |
44 STATE_FAILED | 44 STATE_FAILED |
45 }; | 45 }; |
46 | 46 |
47 // A TransportChannel represents one logical stream of packets that are sent | 47 // A TransportChannel represents one logical stream of packets that are sent |
48 // between the two sides of a session. | 48 // between the two sides of a session. |
49 // TODO(deadbeef): This interface currently represents the unity of an ICE | |
50 // transport and a DTLS transport. They need to be separated apart. | |
49 class TransportChannel : public sigslot::has_slots<> { | 51 class TransportChannel : public sigslot::has_slots<> { |
50 public: | 52 public: |
51 TransportChannel(const std::string& transport_name, int component) | 53 TransportChannel(const std::string& transport_name, int component) |
52 : transport_name_(transport_name), | 54 : transport_name_(transport_name), |
53 component_(component), | 55 component_(component), |
54 writable_(false), | 56 writable_(false), |
55 receiving_(false) {} | 57 receiving_(false) {} |
56 virtual ~TransportChannel() {} | 58 virtual ~TransportChannel() {} |
57 | 59 |
58 // TODO(guoweis) - Make this pure virtual once all subclasses of | 60 // TODO(guoweis) - Make this pure virtual once all subclasses of |
59 // TransportChannel have this defined. | 61 // TransportChannel have this defined. |
60 virtual TransportChannelState GetState() const { | 62 virtual TransportChannelState GetState() const { |
61 return TransportChannelState::STATE_CONNECTING; | 63 return TransportChannelState::STATE_CONNECTING; |
62 } | 64 } |
63 | 65 |
64 // TODO(mallinath) - Remove this API, as it's no longer useful. | 66 // TODO(mallinath) - Remove this API, as it's no longer useful. |
65 // Returns the session id of this channel. | 67 // Returns the session id of this channel. |
66 virtual const std::string SessionId() const { return std::string(); } | 68 virtual const std::string SessionId() const { return std::string(); } |
67 | 69 |
68 const std::string& transport_name() const { return transport_name_; } | 70 const std::string& transport_name() const { return transport_name_; } |
69 int component() const { return component_; } | 71 int component() const { return component_; } |
70 | 72 |
71 // 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, |
72 // a signal is raised. These states are aggregated by the TransportManager. | 74 // a signal is raised. These states are aggregated by the TransportManager. |
73 bool writable() const { return writable_; } | 75 bool writable() const { return writable_; } |
74 bool receiving() const { return receiving_; } | 76 bool receiving() const { return receiving_; } |
77 DtlsTransportState dtls_transport_state() const { | |
78 return dtls_transport_state_; | |
79 } | |
pthatcher1
2015/10/20 20:28:07
I agree with the type name (DtlsTransportState), b
Taylor Brandstetter
2015/10/21 16:28:16
That's what I had originally, then I renamed it ha
| |
75 sigslot::signal1<TransportChannel*> SignalWritableState; | 80 sigslot::signal1<TransportChannel*> SignalWritableState; |
76 // Emitted when the TransportChannel's ability to send has changed. | 81 // Emitted when the TransportChannel's ability to send has changed. |
77 sigslot::signal1<TransportChannel*> SignalReadyToSend; | 82 sigslot::signal1<TransportChannel*> SignalReadyToSend; |
78 sigslot::signal1<TransportChannel*> SignalReceivingState; | 83 sigslot::signal1<TransportChannel*> SignalReceivingState; |
84 // Emitted when the DtlsTransportState has changed. | |
85 sigslot::signal1<TransportChannel*> SignalDtlsTransportState; | |
pthatcher1
2015/10/20 20:28:07
And this SignalDtlsState.
Taylor Brandstetter
2015/10/21 16:28:16
Done.
| |
79 | 86 |
80 // Attempts to send the given packet. The return value is < 0 on failure. | 87 // Attempts to send the given packet. The return value is < 0 on failure. |
81 // TODO: Remove the default argument once channel code is updated. | 88 // TODO: Remove the default argument once channel code is updated. |
82 virtual int SendPacket(const char* data, size_t len, | 89 virtual int SendPacket(const char* data, size_t len, |
83 const rtc::PacketOptions& options, | 90 const rtc::PacketOptions& options, |
84 int flags = 0) = 0; | 91 int flags = 0) = 0; |
85 | 92 |
86 // Sets a socket option on this channel. Note that not all options are | 93 // Sets a socket option on this channel. Note that not all options are |
87 // supported by all transport types. | 94 // supported by all transport types. |
88 virtual int SetOption(rtc::Socket::Option opt, int value) = 0; | 95 virtual int SetOption(rtc::Socket::Option opt, int value) = 0; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 protected: | 158 protected: |
152 // TODO(honghaiz): Remove this once chromium's unit tests no longer call it. | 159 // TODO(honghaiz): Remove this once chromium's unit tests no longer call it. |
153 void set_readable(bool readable) { set_receiving(readable); } | 160 void set_readable(bool readable) { set_receiving(readable); } |
154 | 161 |
155 // Sets the writable state, signaling if necessary. | 162 // Sets the writable state, signaling if necessary. |
156 void set_writable(bool writable); | 163 void set_writable(bool writable); |
157 | 164 |
158 // Sets the receiving state, signaling if necessary. | 165 // Sets the receiving state, signaling if necessary. |
159 void set_receiving(bool receiving); | 166 void set_receiving(bool receiving); |
160 | 167 |
168 // Sets the DTLS state, signaling if necessary. | |
169 void set_dtls_transport_state(DtlsTransportState state); | |
pthatcher1
2015/10/20 20:28:06
And this set_dtls_state.
Taylor Brandstetter
2015/10/21 16:28:16
Done.
| |
170 | |
161 private: | 171 private: |
162 // Used mostly for debugging. | 172 // Used mostly for debugging. |
163 std::string transport_name_; | 173 std::string transport_name_; |
164 int component_; | 174 int component_; |
165 bool writable_; | 175 bool writable_; |
166 bool receiving_; | 176 bool receiving_; |
177 DtlsTransportState dtls_transport_state_ = DTLS_TRANSPORT_NEW; | |
pthatcher1
2015/10/20 20:28:07
And this dtls_state_ :).
Taylor Brandstetter
2015/10/21 16:28:16
Done.
| |
167 | 178 |
168 RTC_DISALLOW_COPY_AND_ASSIGN(TransportChannel); | 179 RTC_DISALLOW_COPY_AND_ASSIGN(TransportChannel); |
169 }; | 180 }; |
170 | 181 |
171 } // namespace cricket | 182 } // namespace cricket |
172 | 183 |
173 #endif // WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_ | 184 #endif // WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_ |
OLD | NEW |