henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef WEBRTC_P2P_BASE_TRANSPORTCHANNELIMPL_H_ |
| 12 | #define WEBRTC_P2P_BASE_TRANSPORTCHANNELIMPL_H_ |
| 13 | |
| 14 | #include <string> |
| 15 | #include "webrtc/p2p/base/transport.h" |
| 16 | #include "webrtc/p2p/base/transportchannel.h" |
| 17 | |
| 18 | namespace buzz { class XmlElement; } |
| 19 | |
| 20 | namespace cricket { |
| 21 | |
| 22 | class Candidate; |
| 23 | |
Peter Thatcher | 7cbd188 | 2015-09-17 18:54:52 -0700 | [diff] [blame] | 24 | // TODO(pthatcher): Remove this once it's no longer used in |
| 25 | // remoting/protocol/libjingle_transport_factory.cc |
| 26 | enum IceProtocolType { |
| 27 | ICEPROTO_RFC5245 // Standard RFC 5245 version of ICE. |
| 28 | }; |
| 29 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 30 | // Base class for real implementations of TransportChannel. This includes some |
| 31 | // methods called only by Transport, which do not need to be exposed to the |
| 32 | // client. |
| 33 | class TransportChannelImpl : public TransportChannel { |
| 34 | public: |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame^] | 35 | explicit TransportChannelImpl(const std::string& transport_name, |
| 36 | int component) |
| 37 | : TransportChannel(transport_name, component) {} |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 38 | |
| 39 | // Returns the transport that created this channel. |
| 40 | virtual Transport* GetTransport() = 0; |
| 41 | |
| 42 | // For ICE channels. |
| 43 | virtual IceRole GetIceRole() const = 0; |
| 44 | virtual void SetIceRole(IceRole role) = 0; |
| 45 | virtual void SetIceTiebreaker(uint64 tiebreaker) = 0; |
Peter Thatcher | 7cbd188 | 2015-09-17 18:54:52 -0700 | [diff] [blame] | 46 | // TODO(pthatcher): Remove this once it's no longer called in |
| 47 | // remoting/protocol/libjingle_transport_factory.cc |
| 48 | virtual void SetIceProtocolType(IceProtocolType type) {} |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 49 | // SetIceCredentials only need to be implemented by the ICE |
| 50 | // transport channels. Non-ICE transport channels can just ignore. |
| 51 | // The ufrag and pwd should be set before the Connect() is called. |
| 52 | virtual void SetIceCredentials(const std::string& ice_ufrag, |
| 53 | const std::string& ice_pwd) = 0; |
| 54 | // SetRemoteIceCredentials only need to be implemented by the ICE |
| 55 | // transport channels. Non-ICE transport channels can just ignore. |
| 56 | virtual void SetRemoteIceCredentials(const std::string& ice_ufrag, |
| 57 | const std::string& ice_pwd) = 0; |
| 58 | |
| 59 | // SetRemoteIceMode must be implemented only by the ICE transport channels. |
| 60 | virtual void SetRemoteIceMode(IceMode mode) = 0; |
| 61 | |
honghaiz | 9009962 | 2015-07-13 12:19:33 -0700 | [diff] [blame] | 62 | virtual void SetReceivingTimeout(int timeout_ms) = 0; |
| 63 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 64 | // Begins the process of attempting to make a connection to the other client. |
| 65 | virtual void Connect() = 0; |
| 66 | |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame^] | 67 | // Start gathering candidates if not already started, or if an ICE restart |
| 68 | // occurred. |
| 69 | virtual void MaybeStartGathering() = 0; |
| 70 | |
| 71 | sigslot::signal1<TransportChannelImpl*> SignalGatheringState; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 72 | |
| 73 | // Handles sending and receiving of candidates. The Transport |
| 74 | // receives the candidates and may forward them to the relevant |
| 75 | // channel. |
| 76 | // |
| 77 | // Note: Since candidates are delivered asynchronously to the |
| 78 | // channel, they cannot return an error if the message is invalid. |
| 79 | // It is assumed that the Transport will have checked validity |
| 80 | // before forwarding. |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame^] | 81 | sigslot::signal2<TransportChannelImpl*, const Candidate&> |
| 82 | SignalCandidateGathered; |
| 83 | virtual void AddRemoteCandidate(const Candidate& candidate) = 0; |
| 84 | |
| 85 | virtual IceGatheringState gathering_state() const = 0; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 86 | |
| 87 | // DTLS methods |
Henrik Boström | f3ecdb9 | 2015-09-08 12:11:54 +0200 | [diff] [blame] | 88 | virtual bool SetLocalCertificate( |
| 89 | const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) = 0; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 90 | |
| 91 | // Set DTLS Remote fingerprint. Must be after local identity set. |
| 92 | virtual bool SetRemoteFingerprint(const std::string& digest_alg, |
| 93 | const uint8* digest, |
| 94 | size_t digest_len) = 0; |
| 95 | |
| 96 | virtual bool SetSslRole(rtc::SSLRole role) = 0; |
| 97 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 98 | // Invoked when there is conflict in the ICE role between local and remote |
| 99 | // agents. |
| 100 | sigslot::signal1<TransportChannelImpl*> SignalRoleConflict; |
| 101 | |
| 102 | // Emitted whenever the number of connections available to the transport |
| 103 | // channel decreases. |
| 104 | sigslot::signal1<TransportChannelImpl*> SignalConnectionRemoved; |
| 105 | |
| 106 | private: |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 107 | RTC_DISALLOW_COPY_AND_ASSIGN(TransportChannelImpl); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | } // namespace cricket |
| 111 | |
| 112 | #endif // WEBRTC_P2P_BASE_TRANSPORTCHANNELIMPL_H_ |