| 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" |
| 19 #include "webrtc/p2p/base/candidate.h" |
| 20 #include "webrtc/p2p/base/candidatepairinterface.h" |
| 21 #include "webrtc/p2p/base/packettransportinterface.h" |
| 22 #include "webrtc/p2p/base/jseptransport.h" |
| 23 #include "webrtc/p2p/base/transportdescription.h" |
| 18 #include "webrtc/base/asyncpacketsocket.h" | 24 #include "webrtc/base/asyncpacketsocket.h" |
| 19 #include "webrtc/base/basictypes.h" | 25 #include "webrtc/base/basictypes.h" |
| 20 #include "webrtc/base/constructormagic.h" | |
| 21 #include "webrtc/base/dscp.h" | 26 #include "webrtc/base/dscp.h" |
| 22 #include "webrtc/base/sigslot.h" | 27 #include "webrtc/base/sigslot.h" |
| 23 #include "webrtc/base/socket.h" | 28 #include "webrtc/base/socket.h" |
| 24 #include "webrtc/base/sslidentity.h" | 29 #include "webrtc/base/sslidentity.h" |
| 25 #include "webrtc/base/sslstreamadapter.h" | 30 #include "webrtc/base/sslstreamadapter.h" |
| 26 #include "webrtc/p2p/base/candidate.h" | |
| 27 #include "webrtc/p2p/base/candidatepairinterface.h" | |
| 28 #include "webrtc/p2p/base/jseptransport.h" | |
| 29 #include "webrtc/p2p/base/icetransportinternal.h" | |
| 30 #include "webrtc/p2p/base/packettransportinterface.h" | |
| 31 #include "webrtc/p2p/base/transportdescription.h" | |
| 32 | 31 |
| 33 namespace cricket { | 32 namespace cricket { |
| 34 | 33 |
| 35 class Candidate; | 34 class Candidate; |
| 36 | 35 |
| 37 // Flags for SendPacket/SignalReadPacket. | 36 // Flags for SendPacket/SignalReadPacket. |
| 38 enum PacketFlags { | 37 enum PacketFlags { |
| 39 PF_NORMAL = 0x00, // A normal packet. | 38 PF_NORMAL = 0x00, // A normal packet. |
| 40 PF_SRTP_BYPASS = 0x01, // An encrypted SRTP packet; bypass any additional | 39 PF_SRTP_BYPASS = 0x01, // An encrypted SRTP packet; bypass any additional |
| 41 // crypto provided by the transport (e.g. DTLS) | 40 // crypto provided by the transport (e.g. DTLS) |
| 42 }; | 41 }; |
| 43 | 42 |
| 43 // Used to indicate channel's connection state. |
| 44 enum TransportChannelState { |
| 45 STATE_INIT, |
| 46 STATE_CONNECTING, // Will enter this state once a connection is created |
| 47 STATE_COMPLETED, |
| 48 STATE_FAILED |
| 49 }; |
| 50 |
| 44 // A TransportChannel represents one logical stream of packets that are sent | 51 // A TransportChannel represents one logical stream of packets that are sent |
| 45 // between the two sides of a session. | 52 // between the two sides of a session. |
| 46 // TODO(deadbeef): This interface currently represents the unity of an ICE | 53 // TODO(deadbeef): This interface currently represents the unity of an ICE |
| 47 // transport and a DTLS transport. They need to be separated apart. | 54 // transport and a DTLS transport. They need to be separated apart. |
| 48 class TransportChannel : public rtc::PacketTransportInterface { | 55 class TransportChannel : public rtc::PacketTransportInterface { |
| 49 public: | 56 public: |
| 50 TransportChannel(const std::string& transport_name, int component) | 57 TransportChannel(const std::string& transport_name, int component) |
| 51 : transport_name_(transport_name), | 58 : transport_name_(transport_name), |
| 52 component_(component), | 59 component_(component), |
| 53 writable_(false), | 60 writable_(false), |
| 54 receiving_(false) {} | 61 receiving_(false) {} |
| 55 virtual ~TransportChannel() {} | 62 virtual ~TransportChannel() {} |
| 56 | 63 |
| 57 // TODO(guoweis) - Make this pure virtual once all subclasses of | 64 // TODO(guoweis) - Make this pure virtual once all subclasses of |
| 58 // TransportChannel have this defined. | 65 // TransportChannel have this defined. |
| 59 virtual IceTransportState GetState() const { | 66 virtual TransportChannelState GetState() const { |
| 60 return IceTransportState::STATE_CONNECTING; | 67 return TransportChannelState::STATE_CONNECTING; |
| 61 } | 68 } |
| 62 | 69 |
| 63 const std::string& transport_name() const { return transport_name_; } | 70 const std::string& transport_name() const { return transport_name_; } |
| 64 int component() const { return component_; } | 71 int component() const { return component_; } |
| 65 std::string debug_name() const override { | 72 const std::string debug_name() const override { |
| 66 return transport_name() + " " + std::to_string(component()); | 73 return transport_name() + " " + std::to_string(component()); |
| 67 } | 74 } |
| 68 | 75 |
| 69 // Returns the states of this channel. Each time one of these states changes, | 76 // Returns the states of this channel. Each time one of these states changes, |
| 70 // a signal is raised. These states are aggregated by the TransportManager. | 77 // a signal is raised. These states are aggregated by the TransportManager. |
| 71 bool writable() const override { return writable_; } | 78 bool writable() const override { return writable_; } |
| 72 bool receiving() const override { return receiving_; } | 79 bool receiving() const override { return receiving_; } |
| 73 DtlsTransportState dtls_state() const { return dtls_state_; } | 80 DtlsTransportState dtls_state() const { return dtls_state_; } |
| 74 // Emitted whenever DTLS-SRTP is setup which will require setting up a new | 81 // Emitted whenever DTLS-SRTP is setup which will require setting up a new |
| 75 // SRTP context. | 82 // SRTP context. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 bool writable_; | 161 bool writable_; |
| 155 bool receiving_; | 162 bool receiving_; |
| 156 DtlsTransportState dtls_state_ = DTLS_TRANSPORT_NEW; | 163 DtlsTransportState dtls_state_ = DTLS_TRANSPORT_NEW; |
| 157 | 164 |
| 158 RTC_DISALLOW_COPY_AND_ASSIGN(TransportChannel); | 165 RTC_DISALLOW_COPY_AND_ASSIGN(TransportChannel); |
| 159 }; | 166 }; |
| 160 | 167 |
| 161 } // namespace cricket | 168 } // namespace cricket |
| 162 | 169 |
| 163 #endif // WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_ | 170 #endif // WEBRTC_P2P_BASE_TRANSPORTCHANNEL_H_ |
| OLD | NEW |