Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / libjingle / source / talk / p2p / base / transportchannelimpl.h
1 /*
2  * libjingle
3  * Copyright 2004--2005, Google Inc.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
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.
15  *
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.
26  */
27
28 #ifndef TALK_P2P_BASE_TRANSPORTCHANNELIMPL_H_
29 #define TALK_P2P_BASE_TRANSPORTCHANNELIMPL_H_
30
31 #include <string>
32 #include "talk/p2p/base/transport.h"
33 #include "talk/p2p/base/transportchannel.h"
34
35 namespace buzz { class XmlElement; }
36
37 namespace cricket {
38
39 class Candidate;
40
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
43 // client.
44 class TransportChannelImpl : public TransportChannel {
45  public:
46   explicit TransportChannelImpl(const std::string& content_name, int component)
47       : TransportChannel(content_name, component) {}
48
49   // Returns the transport that created this channel.
50   virtual Transport* GetTransport() = 0;
51
52   // For ICE channels.
53   virtual IceRole GetIceRole() const = 0;
54   virtual void SetIceRole(IceRole role) = 0;
55   virtual void SetIceTiebreaker(uint64 tiebreaker) = 0;
56   virtual size_t GetConnectionCount() const = 0;
57   // To toggle G-ICE/ICE.
58   virtual bool GetIceProtocolType(IceProtocolType* type) const = 0;
59   virtual void SetIceProtocolType(IceProtocolType type) = 0;
60   // SetIceCredentials only need to be implemented by the ICE
61   // transport channels. Non-ICE transport channels can just ignore.
62   // The ufrag and pwd should be set before the Connect() is called.
63   virtual void SetIceCredentials(const std::string& ice_ufrag,
64                                  const std::string& ice_pwd)  = 0;
65   // SetRemoteIceCredentials only need to be implemented by the ICE
66   // transport channels. Non-ICE transport channels can just ignore.
67   virtual void SetRemoteIceCredentials(const std::string& ice_ufrag,
68                                        const std::string& ice_pwd) = 0;
69
70   // SetRemoteIceMode must be implemented only by the ICE transport channels.
71   virtual void SetRemoteIceMode(IceMode mode) = 0;
72
73   // Begins the process of attempting to make a connection to the other client.
74   virtual void Connect() = 0;
75
76   // Resets this channel back to the initial state (i.e., not connecting).
77   virtual void Reset() = 0;
78
79   // Allows an individual channel to request signaling and be notified when it
80   // is ready.  This is useful if the individual named channels have need to
81   // send their own transport-info stanzas.
82   sigslot::signal1<TransportChannelImpl*> SignalRequestSignaling;
83   virtual void OnSignalingReady() = 0;
84
85   // Handles sending and receiving of candidates.  The Transport
86   // receives the candidates and may forward them to the relevant
87   // channel.
88   //
89   // Note: Since candidates are delivered asynchronously to the
90   // channel, they cannot return an error if the message is invalid.
91   // It is assumed that the Transport will have checked validity
92   // before forwarding.
93   sigslot::signal2<TransportChannelImpl*,
94                    const Candidate&> SignalCandidateReady;
95   virtual void OnCandidate(const Candidate& candidate) = 0;
96
97   // DTLS methods
98   // Set DTLS local identity.  The identity object is not copied, but the caller
99   // retains ownership and must delete it after this TransportChannelImpl is
100   // destroyed.
101   // TODO(bemasc): Fix the ownership semantics of this method.
102   virtual bool SetLocalIdentity(talk_base::SSLIdentity* identity) = 0;
103
104   // Set DTLS Remote fingerprint. Must be after local identity set.
105   virtual bool SetRemoteFingerprint(const std::string& digest_alg,
106     const uint8* digest,
107     size_t digest_len) = 0;
108
109   virtual bool SetSslRole(talk_base::SSLRole role) = 0;
110
111   // TransportChannel is forwarding this signal from PortAllocatorSession.
112   sigslot::signal1<TransportChannelImpl*> SignalCandidatesAllocationDone;
113
114   // Invoked when there is conflict in the ICE role between local and remote
115   // agents.
116   sigslot::signal1<TransportChannelImpl*> SignalRoleConflict;
117
118   // Emitted whenever the number of connections available to the transport
119   // channel decreases.
120   sigslot::signal1<TransportChannelImpl*> SignalConnectionRemoved;
121
122  private:
123   DISALLOW_EVIL_CONSTRUCTORS(TransportChannelImpl);
124 };
125
126 }  // namespace cricket
127
128 #endif  // TALK_P2P_BASE_TRANSPORTCHANNELIMPL_H_