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> |
kwiberg | 4485ffb | 2016-04-26 08:14:39 -0700 | [diff] [blame] | 15 | |
zhihuang | d06adf6 | 2017-01-12 15:58:31 -0800 | [diff] [blame] | 16 | #include "webrtc/p2p/base/icetransportinternal.h" |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 17 | #include "webrtc/p2p/base/transportchannel.h" |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame] | 18 | #include "webrtc/rtc_base/constructormagic.h" |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 19 | |
Honghai Zhang | d93f50c | 2016-10-05 11:47:22 -0700 | [diff] [blame] | 20 | namespace webrtc { |
| 21 | class MetricsObserverInterface; |
| 22 | } |
| 23 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 24 | namespace cricket { |
| 25 | |
| 26 | class Candidate; |
| 27 | |
| 28 | // Base class for real implementations of TransportChannel. This includes some |
| 29 | // methods called only by Transport, which do not need to be exposed to the |
| 30 | // client. |
| 31 | class TransportChannelImpl : public TransportChannel { |
| 32 | public: |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 33 | explicit TransportChannelImpl(const std::string& transport_name, |
| 34 | int component) |
| 35 | : TransportChannel(transport_name, component) {} |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 36 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 37 | // For ICE channels. |
| 38 | virtual IceRole GetIceRole() const = 0; |
| 39 | virtual void SetIceRole(IceRole role) = 0; |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 40 | virtual void SetIceTiebreaker(uint64_t tiebreaker) = 0; |
Peter Thatcher | 7cbd188 | 2015-09-17 18:54:52 -0700 | [diff] [blame] | 41 | // TODO(pthatcher): Remove this once it's no longer called in |
| 42 | // remoting/protocol/libjingle_transport_factory.cc |
| 43 | virtual void SetIceProtocolType(IceProtocolType type) {} |
Honghai Zhang | 4cedf2b | 2016-08-31 08:18:11 -0700 | [diff] [blame] | 44 | // TODO(honghaiz): Remove this once the call in chromoting is removed. |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 45 | virtual void SetIceCredentials(const std::string& ice_ufrag, |
Honghai Zhang | 4cedf2b | 2016-08-31 08:18:11 -0700 | [diff] [blame] | 46 | const std::string& ice_pwd) { |
| 47 | SetIceParameters(IceParameters(ice_ufrag, ice_pwd, false)); |
| 48 | } |
| 49 | // TODO(honghaiz): Remove this once the call in chromoting is removed. |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 50 | virtual void SetRemoteIceCredentials(const std::string& ice_ufrag, |
Honghai Zhang | 4cedf2b | 2016-08-31 08:18:11 -0700 | [diff] [blame] | 51 | const std::string& ice_pwd) { |
| 52 | SetRemoteIceParameters(IceParameters(ice_ufrag, ice_pwd, false)); |
| 53 | } |
| 54 | |
| 55 | // SetIceParameters only needs to be implemented by the ICE transport |
| 56 | // channels. Non-ICE transport channels should pass them down to the inner |
| 57 | // ICE transport channel. The ufrag and pwd in |ice_params| must be set |
| 58 | // before candidate gathering can start. |
| 59 | virtual void SetIceParameters(const IceParameters& ice_params) = 0; |
| 60 | // SetRemoteIceParameters only needs to be implemented by the ICE transport |
| 61 | // channels. Non-ICE transport channels should pass them down to the inner |
| 62 | // ICE transport channel. |
| 63 | virtual void SetRemoteIceParameters(const IceParameters& ice_params) = 0; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 64 | |
| 65 | // SetRemoteIceMode must be implemented only by the ICE transport channels. |
| 66 | virtual void SetRemoteIceMode(IceMode mode) = 0; |
| 67 | |
honghaiz | 1f429e3 | 2015-09-28 07:57:34 -0700 | [diff] [blame] | 68 | virtual void SetIceConfig(const IceConfig& config) = 0; |
honghaiz | 9009962 | 2015-07-13 12:19:33 -0700 | [diff] [blame] | 69 | |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 70 | // Start gathering candidates if not already started, or if an ICE restart |
| 71 | // occurred. |
| 72 | virtual void MaybeStartGathering() = 0; |
| 73 | |
Honghai Zhang | d93f50c | 2016-10-05 11:47:22 -0700 | [diff] [blame] | 74 | virtual void SetMetricsObserver( |
| 75 | webrtc::MetricsObserverInterface* observer) = 0; |
| 76 | |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 77 | sigslot::signal1<TransportChannelImpl*> SignalGatheringState; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 78 | |
| 79 | // Handles sending and receiving of candidates. The Transport |
| 80 | // receives the candidates and may forward them to the relevant |
| 81 | // channel. |
| 82 | // |
| 83 | // Note: Since candidates are delivered asynchronously to the |
| 84 | // channel, they cannot return an error if the message is invalid. |
| 85 | // It is assumed that the Transport will have checked validity |
| 86 | // before forwarding. |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 87 | sigslot::signal2<TransportChannelImpl*, const Candidate&> |
| 88 | SignalCandidateGathered; |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 89 | sigslot::signal2<TransportChannelImpl*, const Candidates&> |
| 90 | SignalCandidatesRemoved; |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 91 | virtual void AddRemoteCandidate(const Candidate& candidate) = 0; |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 92 | virtual void RemoveRemoteCandidate(const Candidate& candidate) = 0; |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 93 | |
| 94 | virtual IceGatheringState gathering_state() const = 0; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 95 | |
| 96 | // DTLS methods |
Henrik Boström | f3ecdb9 | 2015-09-08 12:11:54 +0200 | [diff] [blame] | 97 | virtual bool SetLocalCertificate( |
| 98 | const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) = 0; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 99 | |
| 100 | // Set DTLS Remote fingerprint. Must be after local identity set. |
| 101 | virtual bool SetRemoteFingerprint(const std::string& digest_alg, |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 102 | const uint8_t* digest, |
| 103 | size_t digest_len) = 0; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 104 | |
| 105 | virtual bool SetSslRole(rtc::SSLRole role) = 0; |
| 106 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 107 | // Invoked when there is conflict in the ICE role between local and remote |
| 108 | // agents. |
| 109 | sigslot::signal1<TransportChannelImpl*> SignalRoleConflict; |
| 110 | |
Honghai Zhang | 1590c39 | 2016-05-24 13:15:02 -0700 | [diff] [blame] | 111 | // Emitted whenever the transport channel state changed. |
| 112 | sigslot::signal1<TransportChannelImpl*> SignalStateChanged; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 113 | |
zhihuang | d82eee0 | 2016-08-26 11:25:05 -0700 | [diff] [blame] | 114 | // Emitted whenever the Dtls handshake failed on some transport channel. |
| 115 | sigslot::signal1<rtc::SSLHandshakeError> SignalDtlsHandshakeError; |
| 116 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 117 | private: |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 118 | RTC_DISALLOW_COPY_AND_ASSIGN(TransportChannelImpl); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | } // namespace cricket |
| 122 | |
| 123 | #endif // WEBRTC_P2P_BASE_TRANSPORTCHANNELIMPL_H_ |