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 | |
| 24 | // Base class for real implementations of TransportChannel. This includes some |
| 25 | // methods called only by Transport, which do not need to be exposed to the |
| 26 | // client. |
| 27 | class TransportChannelImpl : public TransportChannel { |
| 28 | public: |
| 29 | explicit TransportChannelImpl(const std::string& content_name, int component) |
| 30 | : TransportChannel(content_name, component) {} |
| 31 | |
| 32 | // Returns the transport that created this channel. |
| 33 | virtual Transport* GetTransport() = 0; |
| 34 | |
| 35 | // For ICE channels. |
| 36 | virtual IceRole GetIceRole() const = 0; |
| 37 | virtual void SetIceRole(IceRole role) = 0; |
| 38 | virtual void SetIceTiebreaker(uint64 tiebreaker) = 0; |
| 39 | virtual size_t GetConnectionCount() const = 0; |
| 40 | // To toggle G-ICE/ICE. |
| 41 | virtual bool GetIceProtocolType(IceProtocolType* type) const = 0; |
| 42 | virtual void SetIceProtocolType(IceProtocolType type) = 0; |
| 43 | // SetIceCredentials only need to be implemented by the ICE |
| 44 | // transport channels. Non-ICE transport channels can just ignore. |
| 45 | // The ufrag and pwd should be set before the Connect() is called. |
| 46 | virtual void SetIceCredentials(const std::string& ice_ufrag, |
| 47 | const std::string& ice_pwd) = 0; |
| 48 | // SetRemoteIceCredentials only need to be implemented by the ICE |
| 49 | // transport channels. Non-ICE transport channels can just ignore. |
| 50 | virtual void SetRemoteIceCredentials(const std::string& ice_ufrag, |
| 51 | const std::string& ice_pwd) = 0; |
| 52 | |
| 53 | // SetRemoteIceMode must be implemented only by the ICE transport channels. |
| 54 | virtual void SetRemoteIceMode(IceMode mode) = 0; |
| 55 | |
| 56 | // Begins the process of attempting to make a connection to the other client. |
| 57 | virtual void Connect() = 0; |
| 58 | |
| 59 | // Resets this channel back to the initial state (i.e., not connecting). |
| 60 | virtual void Reset() = 0; |
| 61 | |
| 62 | // Allows an individual channel to request signaling and be notified when it |
| 63 | // is ready. This is useful if the individual named channels have need to |
| 64 | // send their own transport-info stanzas. |
| 65 | sigslot::signal1<TransportChannelImpl*> SignalRequestSignaling; |
| 66 | virtual void OnSignalingReady() = 0; |
| 67 | |
| 68 | // Handles sending and receiving of candidates. The Transport |
| 69 | // receives the candidates and may forward them to the relevant |
| 70 | // channel. |
| 71 | // |
| 72 | // Note: Since candidates are delivered asynchronously to the |
| 73 | // channel, they cannot return an error if the message is invalid. |
| 74 | // It is assumed that the Transport will have checked validity |
| 75 | // before forwarding. |
| 76 | sigslot::signal2<TransportChannelImpl*, |
| 77 | const Candidate&> SignalCandidateReady; |
| 78 | virtual void OnCandidate(const Candidate& candidate) = 0; |
| 79 | |
| 80 | // DTLS methods |
| 81 | // Set DTLS local identity. The identity object is not copied, but the caller |
| 82 | // retains ownership and must delete it after this TransportChannelImpl is |
| 83 | // destroyed. |
| 84 | // TODO(bemasc): Fix the ownership semantics of this method. |
| 85 | virtual bool SetLocalIdentity(rtc::SSLIdentity* identity) = 0; |
| 86 | |
| 87 | // Set DTLS Remote fingerprint. Must be after local identity set. |
| 88 | virtual bool SetRemoteFingerprint(const std::string& digest_alg, |
| 89 | const uint8* digest, |
| 90 | size_t digest_len) = 0; |
| 91 | |
| 92 | virtual bool SetSslRole(rtc::SSLRole role) = 0; |
| 93 | |
| 94 | // TransportChannel is forwarding this signal from PortAllocatorSession. |
| 95 | sigslot::signal1<TransportChannelImpl*> SignalCandidatesAllocationDone; |
| 96 | |
| 97 | // Invoked when there is conflict in the ICE role between local and remote |
| 98 | // agents. |
| 99 | sigslot::signal1<TransportChannelImpl*> SignalRoleConflict; |
| 100 | |
| 101 | // Emitted whenever the number of connections available to the transport |
| 102 | // channel decreases. |
| 103 | sigslot::signal1<TransportChannelImpl*> SignalConnectionRemoved; |
| 104 | |
| 105 | private: |
| 106 | DISALLOW_EVIL_CONSTRUCTORS(TransportChannelImpl); |
| 107 | }; |
| 108 | |
| 109 | } // namespace cricket |
| 110 | |
| 111 | #endif // WEBRTC_P2P_BASE_TRANSPORTCHANNELIMPL_H_ |