3 * Copyright 2004--2005, Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef TALK_P2P_BASE_TRANSPORTCHANNELIMPL_H_
29 #define TALK_P2P_BASE_TRANSPORTCHANNELIMPL_H_
32 #include "talk/p2p/base/transport.h"
33 #include "talk/p2p/base/transportchannel.h"
35 namespace buzz { class XmlElement; }
41 // Base class for real implementations of TransportChannel. This includes some
42 // methods called only by Transport, which do not need to be exposed to the
44 class TransportChannelImpl : public TransportChannel {
46 explicit TransportChannelImpl(const std::string& content_name, int component)
47 : TransportChannel(content_name, component) {}
49 // Returns the transport that created this channel.
50 virtual Transport* GetTransport() = 0;
53 virtual IceRole GetIceRole() const = 0;
54 virtual void SetIceRole(IceRole role) = 0;
55 virtual void SetIceTiebreaker(uint64 tiebreaker) = 0;
56 // To toggle G-ICE/ICE.
57 virtual void SetIceProtocolType(IceProtocolType type) = 0;
58 // SetIceCredentials only need to be implemented by the ICE
59 // transport channels. Non-ICE transport channels can just ignore.
60 // The ufrag and pwd should be set before the Connect() is called.
61 virtual void SetIceCredentials(const std::string& ice_ufrag,
62 const std::string& ice_pwd) = 0;
63 // SetRemoteIceCredentials only need to be implemented by the ICE
64 // transport channels. Non-ICE transport channels can just ignore.
65 virtual void SetRemoteIceCredentials(const std::string& ice_ufrag,
66 const std::string& ice_pwd) = 0;
68 // SetRemoteIceMode must be implemented only by the ICE transport channels.
69 virtual void SetRemoteIceMode(IceMode mode) = 0;
71 // Begins the process of attempting to make a connection to the other client.
72 virtual void Connect() = 0;
74 // Resets this channel back to the initial state (i.e., not connecting).
75 virtual void Reset() = 0;
77 // Allows an individual channel to request signaling and be notified when it
78 // is ready. This is useful if the individual named channels have need to
79 // send their own transport-info stanzas.
80 sigslot::signal1<TransportChannelImpl*> SignalRequestSignaling;
81 virtual void OnSignalingReady() = 0;
83 // Handles sending and receiving of candidates. The Transport
84 // receives the candidates and may forward them to the relevant
87 // Note: Since candidates are delivered asynchronously to the
88 // channel, they cannot return an error if the message is invalid.
89 // It is assumed that the Transport will have checked validity
91 sigslot::signal2<TransportChannelImpl*,
92 const Candidate&> SignalCandidateReady;
93 virtual void OnCandidate(const Candidate& candidate) = 0;
96 // Set DTLS local identity. The identity object is not copied, but the caller
97 // retains ownership and must delete it after this TransportChannelImpl is
99 // TODO(bemasc): Fix the ownership semantics of this method.
100 virtual bool SetLocalIdentity(talk_base::SSLIdentity* identity) = 0;
102 // Set DTLS Remote fingerprint. Must be after local identity set.
103 virtual bool SetRemoteFingerprint(const std::string& digest_alg,
105 size_t digest_len) = 0;
107 virtual bool SetSslRole(talk_base::SSLRole role) = 0;
109 // TransportChannel is forwarding this signal from PortAllocatorSession.
110 sigslot::signal1<TransportChannelImpl*> SignalCandidatesAllocationDone;
112 // Invoked when there is conflict in the ICE role between local and remote
114 sigslot::signal1<TransportChannelImpl*> SignalRoleConflict;
117 DISALLOW_EVIL_CONSTRUCTORS(TransportChannelImpl);
120 } // namespace cricket
122 #endif // TALK_P2P_BASE_TRANSPORTCHANNELIMPL_H_