|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: NAT FW stream abstraction |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef C_CNATFWSTREAMIMPL_H |
|
22 #define C_CNATFWSTREAMIMPL_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <in_sock.h> |
|
26 #include "natfwconnectivityapidefs.h" |
|
27 #include "mncmconnectionmultiplexerobserver.h" |
|
28 |
|
29 class MNATFWSocketMediaConnWrapper; |
|
30 class CNATFWCredentials; |
|
31 class CNATFWCandidate; |
|
32 class CNcmConnectionMultiplexer; |
|
33 class MNATFWConnectivityObserver; |
|
34 class MNATFWRegistrationController; |
|
35 class CNATFWPluginApi; |
|
36 class CNATFWSession; |
|
37 class CNatFwAsyncCallback; |
|
38 |
|
39 /** |
|
40 * NAT FW stream abstraction. |
|
41 * |
|
42 * Provides NAT-traversal capable communication channel between local and |
|
43 * remote sockets. |
|
44 * |
|
45 * @lib natconfw.dll |
|
46 * @since S60 v3.2 |
|
47 */ |
|
48 NONSHARABLE_CLASS( CNATFWStream ) : public CBase |
|
49 { |
|
50 |
|
51 public: |
|
52 |
|
53 static CNATFWStream* NewL( |
|
54 MNATFWRegistrationController& aController, |
|
55 CNcmConnectionMultiplexer& aMultiplexer, |
|
56 CNatFwAsyncCallback& aAsyncCallback, |
|
57 CNATFWSession& aContext, |
|
58 TUint aProtocol, TInt aQoS ); |
|
59 |
|
60 static CNATFWStream* NewLC( |
|
61 MNATFWRegistrationController& aController, |
|
62 CNcmConnectionMultiplexer& aMultiplexer, |
|
63 CNatFwAsyncCallback& aAsyncCallback, |
|
64 CNATFWSession& aContext, |
|
65 TUint aProtocol, TInt aQoS ); |
|
66 |
|
67 virtual ~CNATFWStream(); |
|
68 |
|
69 /** |
|
70 * Return unique identifier of the stream. |
|
71 * |
|
72 * @since S60 v3.2 |
|
73 * @return Stream identifier |
|
74 */ |
|
75 TUint StreamId() const; |
|
76 |
|
77 /** |
|
78 * Creates a wrapper for the stream. |
|
79 * |
|
80 * @since S60 v3.2 |
|
81 * @return The interface through which the client can configure the wrapper. |
|
82 */ |
|
83 MNATFWSocketMediaConnWrapper& CreateWrapperL(); |
|
84 |
|
85 /** |
|
86 * Sets a new NAT-protocol plugin to be used or updates a stored |
|
87 * protocol plugin. |
|
88 * |
|
89 * @since S60 v3.2 |
|
90 * @param aPlugin The protocol plugin |
|
91 */ |
|
92 void SetProtocolPlugin( CNATFWPluginApi* aPlugin ); |
|
93 |
|
94 /** |
|
95 * Resolves public IP address to be used in the communication between |
|
96 * peers. MNATFWConnectivityObserver::NewLocalCandidateFound |
|
97 * is called when a public IP has been resolved. |
|
98 * |
|
99 * @since S60 v3.2 |
|
100 * @param aAddrFamily KAFUnspec / KAfInet / KAfInet6 |
|
101 */ |
|
102 void FetchCandidateL( TUint aAddrFamily ); |
|
103 |
|
104 /** |
|
105 * ICE spesific function. Fetches IP address candidates for the |
|
106 * communication between peers. Client is responsible for providing |
|
107 * mapping between components of media stream through collection ID |
|
108 * parameter. MNATFWConnectivityObserver::NewLocalCandidateFound |
|
109 * is called whenever a new candidate has been found. |
|
110 * |
|
111 * @since S60 v3.2 |
|
112 * @param aCollectionId The stream collection id |
|
113 * @param aComponentId The component identifier |
|
114 * @param aAddrFamily KAFUnspec / KAfInet / KAfInet6 |
|
115 */ |
|
116 void FetchCandidatesL( TUint aCollectionId, TUint aComponentId, |
|
117 TUint aAddrFamily ); |
|
118 |
|
119 /** |
|
120 * ICE specific function. Set username fragment and corresponding |
|
121 * password for message signing and authentication with the specified |
|
122 * candidate. |
|
123 * |
|
124 * @since S60 v3.2 |
|
125 * @param aCandidate The candidate |
|
126 * @param aCredentials The credentials |
|
127 */ |
|
128 void SetCredentialsL( |
|
129 const CNATFWCandidate& aCandidate, |
|
130 const CNATFWCredentials& aCredentials ); |
|
131 |
|
132 /** |
|
133 * Enables/disables media receiving for the specified local candidate. |
|
134 * |
|
135 * Only those candidates given with MNATFWConnectivityObserver callbacks |
|
136 * can be controlled. NATFW stream can have only one active candidate |
|
137 * at a time. In other words, exactly one local candidate can be used |
|
138 * for media delivery in receiving, sending or both directions. |
|
139 * |
|
140 * Receiving must be disabled prior to closing stream so that all |
|
141 * resources can be freed. |
|
142 * |
|
143 * MNATFWConnectivityObserver::Notify is called with event code |
|
144 * EReceivingActivated/EReceivingDeactivated when state change has |
|
145 * completed. While activated incoming data is delivered to the media |
|
146 * engine. |
|
147 * |
|
148 * Note: If TURN is used media cannot be delivered until remote address |
|
149 * is known. |
|
150 * |
|
151 * @since S60 v3.2 |
|
152 * @param aLocalCandidate The local end point for a media |
|
153 * @param aState The receiving state |
|
154 */ |
|
155 void SetReceivingStateL( const CNATFWCandidate& aLocalCandidate, |
|
156 TNATFWStreamingState aState ); |
|
157 |
|
158 /** |
|
159 * Enables/disables media sending from the specified local candidate. |
|
160 * |
|
161 * Only those candidates given with MNATFWConnectivityObserver callbacks |
|
162 * can be controlled. NATFW stream can have only one active candidate |
|
163 * at a time. In other words, exactly one local candidate can be used |
|
164 * for media delivery in receiving, sending or both directions. |
|
165 * |
|
166 * Sending must be disabled prior to closing stream so that all |
|
167 * resources can be freed. |
|
168 * |
|
169 * MNATFWConnectivityObserver::Notify is called with event code |
|
170 * ESendingActivated/ESendingDeactivated when state change has |
|
171 * completed. While activated outgoing data from media engine is delivered |
|
172 * to the specified remote address. |
|
173 * |
|
174 * @since S60 v3.2 |
|
175 * @param aLocalCandidate The local end point for a media |
|
176 * @param aState The sending state |
|
177 * @param aDestAddr The remote end point for a media |
|
178 */ |
|
179 void SetSendingStateL( const CNATFWCandidate& aLocalCandidate, |
|
180 TNATFWStreamingState aState, const TInetAddr& aDestAddr ); |
|
181 |
|
182 /** |
|
183 * Call initiated by the Multiplexer of stream events. |
|
184 * |
|
185 * @since S60 v3.2 |
|
186 * @param aSessionId The ID identifying session |
|
187 * @param aStreamId The ID identifying stream |
|
188 * @param aType The type of the event |
|
189 * @param aError Error code. |
|
190 */ |
|
191 void Notify( TUint aSessionId, TUint aStreamId, |
|
192 MNcmConnectionMultiplexerObserver::TNotifyType aType, TInt aError ); |
|
193 |
|
194 private: |
|
195 |
|
196 CNATFWStream( |
|
197 MNATFWRegistrationController& aController, |
|
198 CNcmConnectionMultiplexer& aMultiplexer, |
|
199 CNatFwAsyncCallback& aAsyncCallback, |
|
200 CNATFWSession& aContext, |
|
201 TUint aProtocol, |
|
202 TInt aQoS ); |
|
203 |
|
204 void ConstructL(); |
|
205 |
|
206 void DoNotify( TUint aSessionId, TUint aStreamId, |
|
207 MNATFWConnectivityObserver::TNATFWConnectivityEvent aEvent, |
|
208 TInt aError ); |
|
209 |
|
210 private: // data |
|
211 |
|
212 /** |
|
213 * Unique identifier of the stream |
|
214 */ |
|
215 TUint iStreamId; |
|
216 |
|
217 /** |
|
218 * Desired quality of service for the stream |
|
219 */ |
|
220 TInt iQoS; |
|
221 |
|
222 /** |
|
223 * Remote IP of the other peer |
|
224 */ |
|
225 TInetAddr iDestAddr; |
|
226 |
|
227 /** |
|
228 * Transport protocol used with the stream |
|
229 */ |
|
230 TUint iProtocol; |
|
231 |
|
232 /** |
|
233 * NAT FW Registration controller |
|
234 * Not own |
|
235 */ |
|
236 MNATFWRegistrationController& iController; |
|
237 |
|
238 /** |
|
239 * Multiplexer |
|
240 * Not own. |
|
241 */ |
|
242 CNcmConnectionMultiplexer& iMultiplexer; |
|
243 |
|
244 /** |
|
245 * Async callback handler |
|
246 * Not own. |
|
247 */ |
|
248 CNatFwAsyncCallback& iAsyncCallback; |
|
249 |
|
250 /** |
|
251 * NAT-protocol plugin to be used |
|
252 * Not own. |
|
253 */ |
|
254 CNATFWPluginApi* iPlugin; |
|
255 |
|
256 /** |
|
257 * Session where stream belongs to |
|
258 * Not own. |
|
259 */ |
|
260 CNATFWSession& iContext; |
|
261 |
|
262 }; |
|
263 |
|
264 #endif // C_CNATFWSTREAMIMPL_H |