|
1 /* |
|
2 * Copyright (c) 2004 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #ifndef CMCESDPSESSION_H |
|
23 #define CMCESDPSESSION_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <e32base.h> |
|
27 #include <e32cmn.h> |
|
28 #include <e32std.h> |
|
29 #include <in_sock.h> |
|
30 #include <stringpool.h> |
|
31 |
|
32 #include "mcecommediastream.h" |
|
33 #include "mcemediadefs.h" |
|
34 #include "mcesrv.h" |
|
35 #include "mcesip.h" |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class CSdpDocument; |
|
39 class CMceComSession; |
|
40 class CMceComAudioStream; |
|
41 class CSdpMediaField; |
|
42 class CSdpOriginField; |
|
43 class CMceMediaManager; |
|
44 class CMceSdpCodec; |
|
45 class CSIPDialogAssocBase; |
|
46 |
|
47 /** |
|
48 * Class for storing session specific SDP parameters |
|
49 */ |
|
50 class CMceSdpSession : public CBase |
|
51 { |
|
52 |
|
53 public: // enums |
|
54 |
|
55 enum TOfferType |
|
56 { |
|
57 EFirst, |
|
58 EUpdate, |
|
59 ERefresh |
|
60 }; |
|
61 |
|
62 public: // Constructors and destructor |
|
63 |
|
64 /** |
|
65 * Two-phased constructor. |
|
66 */ |
|
67 static CMceSdpSession* NewL( CMceComSession& aSession, |
|
68 CMceMediaManager& aManager ); |
|
69 |
|
70 /** |
|
71 * Two-phased constructor. |
|
72 */ |
|
73 static CMceSdpSession* NewLC( CMceComSession& aSession, |
|
74 CMceMediaManager& aManager ); |
|
75 |
|
76 |
|
77 /** |
|
78 * Destructor. |
|
79 */ |
|
80 ~CMceSdpSession(); |
|
81 |
|
82 public: |
|
83 |
|
84 |
|
85 CMceMediaManager& Manager() const; |
|
86 |
|
87 /** |
|
88 * Createas a SDPDocument based on the streams in iSession. For each stream |
|
89 * a media line is created in the sdp document. Fails if one of the streams |
|
90 * is not supported / failed |
|
91 * @since |
|
92 * @param None. |
|
93 * @return CSdpDocument, containing the offer |
|
94 */ |
|
95 CSdpDocument* CreateOfferL( CMceComSession& aSession, TOfferType aType = EFirst ); |
|
96 |
|
97 /** |
|
98 * Goes through the answer and removes all the not supported codecs from |
|
99 * iSession streams so that for each stream one codec is left. Otherwise |
|
100 * fail. |
|
101 * @since |
|
102 * @param None. |
|
103 * @return KErrNone, if successful, error if answer is not accepted |
|
104 */ |
|
105 TInt DecodeAnswerL( CSdpDocument& aSdpDocument, CMceComSession& aSession ); |
|
106 |
|
107 /** |
|
108 * Decodes the incoming offer. For each media line in the offer, create corresponding |
|
109 * stream in aSession. If one of the streams failes, then fail the whole offer. |
|
110 * NOTE! if KErrNotSupported is returned, offer is rejected and next time CreateAnswerL() |
|
111 * is called it creates a rejected answer. |
|
112 * @return KErrNone, if successful, KErrNotSupported if failed |
|
113 */ |
|
114 TInt DecodeOfferL( CSdpDocument& aSdpDocument, CMceComSession& aSession ); |
|
115 |
|
116 /** |
|
117 * Creates an answer based on the OFFER received and the application's |
|
118 * updated preferences. In successful case SdpDocument will have one selected rtpmap |
|
119 * field for each media line and updated port number. And all session level parameters. |
|
120 * NOTE! if any of the media lines fail, SdpDocument will have rejected media lines. |
|
121 * @since |
|
122 * @param None. |
|
123 * @return KErrNone, if successful, KErrNotSupported if offer was rejected, |
|
124 */ |
|
125 CSdpDocument& CreateAnswerL( CMceComSession& aSession, TBool aInvalid = EFalse ); |
|
126 |
|
127 |
|
128 |
|
129 public: // New functions |
|
130 |
|
131 /** |
|
132 * Set SDP <session name>. Default is -. |
|
133 * Leaves with system wide error code if setting fails. |
|
134 * @since |
|
135 * @param aUserName User name. |
|
136 * @return None. |
|
137 */ |
|
138 void SetSessionNameL( const TDesC8& aUserName ); |
|
139 |
|
140 /** |
|
141 * Get SDP <session name> |
|
142 * @since |
|
143 * @param None. |
|
144 * @return Session name |
|
145 */ |
|
146 const TDesC8& SessionName() const; |
|
147 |
|
148 /** |
|
149 * Set SDP <username>. Default is MediaManager. |
|
150 * Leaves with system wide error code if setting fails. |
|
151 * @since |
|
152 * @param aUserName User name. |
|
153 * @return None. |
|
154 */ |
|
155 void SetUserNameL( const TDesC8& aUserName ); |
|
156 |
|
157 /** |
|
158 * Get SDP <username> |
|
159 * @since |
|
160 * @param None. |
|
161 * @return User name. |
|
162 */ |
|
163 const TDesC8& UserName() const; |
|
164 |
|
165 /** |
|
166 * Stores the remote o= field |
|
167 * @param None. |
|
168 * @return None. |
|
169 */ |
|
170 void StoreRemoteOriginL(); |
|
171 |
|
172 /** |
|
173 * Checks if the SDP is refresh or re-invite |
|
174 * @param aSdpDocument, SDP document |
|
175 * @return None. |
|
176 */ |
|
177 TBool IsSessionRefresh( CSdpDocument* aSdpDocument = NULL ); |
|
178 |
|
179 /** |
|
180 * Cleans session level parameters |
|
181 * @since |
|
182 * @param aSessionVersion Session version. |
|
183 * @return None. |
|
184 */ |
|
185 void CleanSessionParams( CSdpDocument& aDocument ) const; |
|
186 |
|
187 TBool DetachMedia( CMceComSession& aSession ); |
|
188 |
|
189 void StockMediaSessionL(); |
|
190 |
|
191 CMceSdpSession& ForkL(); |
|
192 |
|
193 CMceComSession* Consumes( TUint32 aSessionId ); |
|
194 |
|
195 void ContextSwitch( CMceSdpSession* aForkedSession = NULL ); |
|
196 |
|
197 TBool IsMaster(); |
|
198 |
|
199 void AttachContext( CSIPDialogAssocBase* aContext ); |
|
200 |
|
201 CSIPDialogAssocBase* Context(); |
|
202 |
|
203 TBool ContextSwitchRequested(); |
|
204 |
|
205 |
|
206 public: //update handling |
|
207 |
|
208 /** |
|
209 * Set the current media session |
|
210 * @param aSession the current media session |
|
211 */ |
|
212 void SetMediaSession( CMceComSession* aSession ); |
|
213 |
|
214 /** |
|
215 * Get the current media session |
|
216 * @return the current media session |
|
217 */ |
|
218 CMceComSession* MediaSession(); |
|
219 |
|
220 /** |
|
221 * Store backup session for current media session |
|
222 * @param aSession the backup media session |
|
223 */ |
|
224 void SetBackup( CMceComSession* aSession ); |
|
225 |
|
226 /** |
|
227 * backup session |
|
228 * @param None. |
|
229 * @return server session |
|
230 */ |
|
231 CMceComSession* Backup(); |
|
232 |
|
233 /** |
|
234 * Return indication wheater signalling is required |
|
235 * @return reference to value indication wheater signalling is required |
|
236 */ |
|
237 TInt& SignallingRequired(); |
|
238 |
|
239 /** |
|
240 * Return indication wheater network resource reservation is ready |
|
241 * @return flag indication wheater network resource reservation is ready |
|
242 */ |
|
243 TBool NeedToNegotiate( CMceComSession& aSession ); |
|
244 |
|
245 TBool ReservationNeeded( CMceComSession& aSession ); |
|
246 |
|
247 TMceReturnStatus ReserveL( CMceComSession& aSession ); |
|
248 |
|
249 /** |
|
250 * prepares session refresh |
|
251 * @param aSession the media session |
|
252 */ |
|
253 void PrepareSessionRefreshL( CMceComSession& aSession ); |
|
254 |
|
255 void SdpCleanup( CSdpDocument* aPrevious, CSdpDocument* aReplacement ); |
|
256 |
|
257 |
|
258 private: // for internal use only |
|
259 |
|
260 /** |
|
261 * Encodes session level parameters |
|
262 * @param aSession the media session |
|
263 * @param aDocument the sdp document |
|
264 * @param aType the type of offer |
|
265 * @return None. |
|
266 */ |
|
267 void EncodeSessionParamsL( CMceComSession& aSession, |
|
268 CSdpDocument& aDocument, |
|
269 TOfferType aType = EFirst ); |
|
270 |
|
271 /** |
|
272 * Encodes session level attributes client is willing to insert |
|
273 * @param aSession the media session |
|
274 * @param aDocument the sdp document |
|
275 */ |
|
276 void EncodeClientAttributesL( CMceComSession& aSession, |
|
277 CSdpDocument& aDocument ) const; |
|
278 |
|
279 /** |
|
280 * Decodes session level attributes to be sent to client |
|
281 * @param aDocument the sdp document |
|
282 * @param aSession the media session |
|
283 */ |
|
284 void DecodeClientAttributesL( CSdpDocument& aDocument, |
|
285 CMceComSession& aSession ) const; |
|
286 |
|
287 /** |
|
288 * Gets a random number for version and session id |
|
289 * @since |
|
290 * @param aSessionVersion Session version. |
|
291 * @return None. |
|
292 */ |
|
293 TInt64 GetRandomNumber(); |
|
294 |
|
295 TMceSipWarningCode SetRemoteIpAddressL( CMceComSession& aSession, |
|
296 CSdpDocument& aSdpDocument ); |
|
297 |
|
298 |
|
299 void PrepareForAnswerEncodeL( CSdpMediaField& aMediaLine ); |
|
300 |
|
301 CSdpMediaField* CreateMediaLineLC( CMceComMediaStream& aStream ) const; |
|
302 |
|
303 TBool MediaLineLC( CSdpMediaField*& aMediaLine, |
|
304 CMceSdpCodec*& sdpCodec, |
|
305 CMceComMediaStream* aStream, |
|
306 RPointerArray<CSdpMediaField>& aMediaLines, |
|
307 RPointerArray<CMceComMediaStream>& aStreams ); |
|
308 |
|
309 CMceComMediaStream* MediaSlotInUse( TInt aMediaLine, |
|
310 RPointerArray<CMceComMediaStream>& aStreams ); |
|
311 |
|
312 |
|
313 |
|
314 void DecodeConnectionFieldL( CSdpDocument& aSdpDocument, CMceComSession& aSession ); |
|
315 void EncodeConnectionFieldL( CMceComSession& aSession, CSdpDocument& aSdpDocument ); |
|
316 |
|
317 void MatchingStreamsToMLinesL( |
|
318 CSdpDocument& aSdpDocument, CMceComSession& aSession ); |
|
319 |
|
320 void DecodePullModeUpdateMediaLineL( CSdpDocument& aSdpDocument, |
|
321 CMceComSession& aSession, |
|
322 CSdpMediaField& aMediaLine, |
|
323 TInt aIndex, |
|
324 CMceSdpCodec& aSdpCodec ); |
|
325 |
|
326 /** |
|
327 * Stores the remote a= field |
|
328 * @param None. |
|
329 * @return None. |
|
330 */ |
|
331 void StoreRemoteMediaFieldsL(); |
|
332 |
|
333 /** |
|
334 * Compares media lines |
|
335 * @param aFieldsSrc for media lines being compared |
|
336 * @param aFieldsDst for media lines being compared |
|
337 * @return ETrue if media lines are equal, EFalse otherwise |
|
338 */ |
|
339 TBool CompareMediaLines( |
|
340 RPointerArray<CSdpMediaField>& aFieldsSrc, |
|
341 RPointerArray<CSdpMediaField>& aFieldsDst ) const; |
|
342 |
|
343 private: |
|
344 |
|
345 /** |
|
346 * By default Symbian 2nd phase constructor is private. |
|
347 */ |
|
348 void ConstructL(); |
|
349 |
|
350 /** |
|
351 * C++ default constructor |
|
352 */ |
|
353 CMceSdpSession( CMceComSession& aSession, CMceMediaManager& aManager ); |
|
354 |
|
355 public: // Owned Data |
|
356 |
|
357 CMceComSession* iInitialSession; |
|
358 |
|
359 public: // Data |
|
360 |
|
361 CMceMediaManager& iManager; |
|
362 |
|
363 // User name in SDP origin field |
|
364 HBufC8* iUserName; |
|
365 |
|
366 // Session name in SDP session name field |
|
367 HBufC8* iSessionName; |
|
368 |
|
369 // Session ID in SDP origin field |
|
370 TInt64 iSessionId; |
|
371 |
|
372 // Session version in SDP origin field |
|
373 TInt64 iSessionVersion; |
|
374 |
|
375 // reference to corresponding server stream |
|
376 CMceComSession* iSession; |
|
377 |
|
378 // pointer to backup stream |
|
379 CMceComSession* iBackup; |
|
380 |
|
381 // SDP document, not owned |
|
382 CSdpDocument* iSdpDocument; |
|
383 |
|
384 // the origin field received last from the remote end |
|
385 CSdpOriginField* iRemoteOrigin; |
|
386 |
|
387 // the "a:-" field received last from the remote end |
|
388 RPointerArray<CSdpMediaField> iSdpRemoteMediaFields; |
|
389 |
|
390 TInt iIsSignallingRequired; |
|
391 |
|
392 RStringPool iStringPool; |
|
393 const TStringTable* iStringTable; |
|
394 |
|
395 // OldSchool Flag Outgoing Session |
|
396 TUint iOOldSchool; |
|
397 |
|
398 // OldSchool Flag for Incomming Session |
|
399 TUint iIOldSchool; |
|
400 |
|
401 TUint iOOldSchoolProceeding; |
|
402 |
|
403 TUint iOOldSchoolCompleted; |
|
404 |
|
405 TBool iIsMaster; |
|
406 CSIPDialogAssocBase* iContext; |
|
407 CSIPDialogAssocBase* iRequestedContext; |
|
408 |
|
409 // old local port, used for refresh |
|
410 TUint iOldLocalMediaPort; |
|
411 |
|
412 //definitions for unit testing |
|
413 MCEMM_UT_DEFINITIONS |
|
414 |
|
415 public: //inner classes |
|
416 |
|
417 class TIterator |
|
418 { |
|
419 |
|
420 public: |
|
421 |
|
422 enum TFilter |
|
423 { |
|
424 EFilterNone = 0, |
|
425 EFilterMaster |
|
426 }; |
|
427 |
|
428 public: |
|
429 |
|
430 TIterator( RPointerArray<CMceSdpSession>& aSessions, TFilter aFilter = EFilterNone ); |
|
431 |
|
432 TBool IsEof(); |
|
433 TBool Next( CMceSdpSession*& aCandidate ); |
|
434 |
|
435 void Reset(); |
|
436 TInt Count(); |
|
437 TInt Remove(); |
|
438 TInt Current(); |
|
439 |
|
440 |
|
441 void SetFilter( TFilter aFilter ); |
|
442 |
|
443 private: |
|
444 |
|
445 TFilter iFilter; |
|
446 RPointerArray<CMceSdpSession>& iSessions; |
|
447 TInt iCurrentIndex; |
|
448 |
|
449 }; |
|
450 |
|
451 |
|
452 |
|
453 }; |
|
454 |
|
455 #endif // CMCESDPPARAMETERS_H |
|
456 |
|
457 // End of File |