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_state() const { return dtls_state_; } |
75 sigslot::signal1<TransportChannel*> SignalWritableState; | 78 sigslot::signal1<TransportChannel*> SignalWritableState; |
76 // Emitted when the TransportChannel's ability to send has changed. | 79 // Emitted when the TransportChannel's ability to send has changed. |
77 sigslot::signal1<TransportChannel*> SignalReadyToSend; | 80 sigslot::signal1<TransportChannel*> SignalReadyToSend; |
78 sigslot::signal1<TransportChannel*> SignalReceivingState; | 81 sigslot::signal1<TransportChannel*> SignalReceivingState; |
| 82 // Emitted when the DtlsTransportState has changed. |
| 83 sigslot::signal1<TransportChannel*> SignalDtlsState; |
79 | 84 |
80 // Attempts to send the given packet. The return value is < 0 on failure. | 85 // Attempts to send the given packet. The return value is < 0 on failure. |
81 // TODO: Remove the default argument once channel code is updated. | 86 // TODO: Remove the default argument once channel code is updated. |
82 virtual int SendPacket(const char* data, size_t len, | 87 virtual int SendPacket(const char* data, size_t len, |
83 const rtc::PacketOptions& options, | 88 const rtc::PacketOptions& options, |
84 int flags = 0) = 0; | 89 int flags = 0) = 0; |
85 | 90 |
86 // Sets a socket option on this channel. Note that not all options are | 91 // Sets a socket option on this channel. Note that not all options are |
87 // supported by all transport types. | 92 // supported by all transport types. |
88 virtual int SetOption(rtc::Socket::Option opt, int value) = 0; | 93 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: | 156 protected: |
152 // TODO(honghaiz): Remove this once chromium's unit tests no longer call it. | 157 // TODO(honghaiz): Remove this once chromium's unit tests no longer call it. |
153 void set_readable(bool readable) { set_receiving(readable); } | 158 void set_readable(bool readable) { set_receiving(readable); } |
154 | 159 |
155 // Sets the writable state, signaling if necessary. | 160 // Sets the writable state, signaling if necessary. |
156 void set_writable(bool writable); | 161 void set_writable(bool writable); |
157 | 162 |
158 // Sets the receiving state, signaling if necessary. | 163 // Sets the receiving state, signaling if necessary. |
159 void set_receiving(bool receiving); | 164 void set_receiving(bool receiving); |
160 | 165 |
| 166 // Sets the DTLS state, signaling if necessary. |
| 167 void set_dtls_state(DtlsTransportState state); |
| 168 |
161 private: | 169 private: |
162 // Used mostly for debugging. | 170 // Used mostly for debugging. |
163 std::string transport_name_; | 171 std::string transport_name_; |
164 int component_; | 172 int component_; |
165 bool writable_; | 173 bool writable_; |
166 bool receiving_; | 174 bool receiving_; |
| 175 DtlsTransportState dtls_state_ = DTLS_TRANSPORT_NEW; |
167 | 176 |
168 RTC_DISALLOW_COPY_AND_ASSIGN(TransportChannel); | 177 RTC_DISALLOW_COPY_AND_ASSIGN(TransportChannel); |
169 }; | 178 }; |
170 | 179 |
171 } // namespace cricket | 180 } // namespace cricket |
172 | 181 |
173 #endif // WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_ | 182 #endif // WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_ |
OLD | NEW |