|
1 /* |
|
2 * Copyright (c) 2005 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 #ifndef CMCECOMSESSION_H |
|
22 #define CMCECOMSESSION_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <e32std.h> |
|
26 #include <badesca.h> |
|
27 #include <in_sock.h> |
|
28 #include <s32strm.h> |
|
29 |
|
30 #include "mcesession.h" |
|
31 #include "mceclientserver.h" |
|
32 #include "mcecomserializable.h" |
|
33 #include "mcesecuresession.h" |
|
34 |
|
35 class CMceComMediaStream; |
|
36 class TMceComFactory; |
|
37 class TMceComEvent; |
|
38 class MMceMediaSessionObserver; |
|
39 class CMceComStreamBundle; |
|
40 |
|
41 #ifdef MCE_COMMON_SERVER_SIDE |
|
42 #include "mcesecuremediasession.h" |
|
43 #include "mcemediadefs.h" |
|
44 #include "mcesrv.h" |
|
45 |
|
46 class TMceMediaState; |
|
47 class CMceSrvStream; |
|
48 class CMceSdpSession; |
|
49 class CMceMediaManager; |
|
50 class CMceAdoptedSrvStream; |
|
51 class CMceSecureMediaSession; |
|
52 class CSdpDocument; |
|
53 #endif//MCE_COMMON_SERVER_SIDE |
|
54 |
|
55 const TInt KMceMaxSessionModifiers = 10; |
|
56 const TUint32 KMceMaxTypeOfServiceValue = 256; |
|
57 const TUint32 KMceDefaultTypeOfServiceValue = 184; |
|
58 |
|
59 typedef TFixedArray<TUint, KMceMaxSessionModifiers> TMceComSessionModifiers; |
|
60 |
|
61 #define MCE_SET_LOCAL_IP_ADDR( session, addr )\ |
|
62 MCESRV_DEBUG_ADDRVALUE( "local ip", addr );\ |
|
63 (session)->iLocalIpAddress = addr |
|
64 |
|
65 #define MCE_SET_REMOTE_IP_ADDR( session, addr )\ |
|
66 MCESRV_DEBUG_ADDRVALUE( "remote ip", addr );\ |
|
67 (session)->iRemoteIpAddress = addr |
|
68 |
|
69 |
|
70 const TBool KMceDeepMergeNo = EFalse; |
|
71 const TBool KMceDeepMergeYes = ETrue; |
|
72 |
|
73 |
|
74 /** |
|
75 * Server/Client session |
|
76 * |
|
77 * @lib |
|
78 */ |
|
79 class CMceComSession : public CBase, |
|
80 public MMceComSerializable |
|
81 |
|
82 { |
|
83 |
|
84 public://enums |
|
85 |
|
86 enum TType |
|
87 { |
|
88 EInSession, |
|
89 EOutSession |
|
90 }; |
|
91 |
|
92 /** |
|
93 * Constructor |
|
94 * @param aType the type of session |
|
95 * @return The instance |
|
96 */ |
|
97 static CMceComSession* NewL(); |
|
98 |
|
99 /** |
|
100 * Constructor |
|
101 * @param aType the type of session |
|
102 * @return The instance |
|
103 */ |
|
104 static CMceComSession* NewL( TType aType ); |
|
105 |
|
106 /** |
|
107 * Constructor |
|
108 * @param aType the type of session |
|
109 * @return The instance |
|
110 */ |
|
111 static CMceComSession* NewLC( TType aType ); |
|
112 |
|
113 /** |
|
114 * Constructor |
|
115 * @param aSerCtx context for serialization |
|
116 * @return The instance |
|
117 */ |
|
118 static CMceComSession* NewL( MMceComSerializationContext& aSerCtx ); |
|
119 |
|
120 /** |
|
121 * Constructor |
|
122 * @param aSerCtx context for serialization |
|
123 * @return The instance |
|
124 */ |
|
125 static CMceComSession* NewLC( MMceComSerializationContext& aSerCtx ); |
|
126 |
|
127 /** |
|
128 * Destructor. |
|
129 */ |
|
130 ~CMceComSession(); |
|
131 |
|
132 public: // Functions |
|
133 |
|
134 /** |
|
135 * ID |
|
136 * @return ID |
|
137 */ |
|
138 TUint32 Id() const; |
|
139 |
|
140 /** |
|
141 * Adds media stream into session. |
|
142 * @param aMediaStream, media stream to be added. |
|
143 * ownership is transferred. |
|
144 * @return The current state of the session |
|
145 */ |
|
146 void AddStreamL( CMceComMediaStream* aMediaStream ); |
|
147 |
|
148 |
|
149 /** |
|
150 * Returns the streams belonging to the session. |
|
151 * @return streams of the session. |
|
152 */ |
|
153 RPointerArray<CMceComMediaStream>& Streams(); |
|
154 |
|
155 /** |
|
156 * Adds media manager observer |
|
157 * @param aMediaObserver, media manager observer |
|
158 */ |
|
159 void SetObserver( MMceMediaSessionObserver& aMediaObserver ); |
|
160 |
|
161 /** |
|
162 * Adds grouped media streams to the session. Changes SDP |
|
163 * of the session. In order to get complete update, whole |
|
164 * session must be updated causing sending of re-invite. |
|
165 */ |
|
166 void AddBundleL( CMceComStreamBundle* aBundle ); |
|
167 |
|
168 /** |
|
169 * Removes grouped media stream from session. Changes SDP |
|
170 * of the session. In order to get complete update, whole |
|
171 * session must be updated causing sending of re-invite. |
|
172 * @param aBundle bundle to be removed |
|
173 */ |
|
174 void RemoveBundleL( CMceComStreamBundle& aBundle ); |
|
175 |
|
176 /** |
|
177 * Gets the grouped media streams of the session. |
|
178 * @return bundles of the session |
|
179 */ |
|
180 const RPointerArray< CMceComStreamBundle >& Bundles() const; |
|
181 |
|
182 /** |
|
183 * Returns media observer. |
|
184 * @return Media observer |
|
185 */ |
|
186 MMceMediaSessionObserver& MediaObserver(); |
|
187 |
|
188 /** |
|
189 * Sets the originator |
|
190 * @return |
|
191 */ |
|
192 void SetOriginatorL( const TDesC8& aOriginator ); |
|
193 |
|
194 /** |
|
195 * Sets the recipient |
|
196 * @return Media observer |
|
197 */ |
|
198 void SetRecipientL( const TDesC8& aRecipient ); |
|
199 |
|
200 /** |
|
201 * Assigner for session modifier |
|
202 * @param aModifier modifer key |
|
203 * @return assigner for session modifier |
|
204 */ |
|
205 TUint& Modifier( TMceSessionModifier aModifier ); |
|
206 |
|
207 /** |
|
208 * Checks whether RTCP should be used. |
|
209 * return ETrue, if all the streams indicate RTCP usage, |
|
210 * otherwise EFalse. |
|
211 */ |
|
212 TBool UseRtcp() const; |
|
213 |
|
214 public: // serialization |
|
215 |
|
216 /** |
|
217 * Returns serialization id |
|
218 * @return serialization id |
|
219 */ |
|
220 TUint64 SerializationId() const; |
|
221 |
|
222 /** |
|
223 * Internalizes flat data |
|
224 * @param aReadStream read stream |
|
225 */ |
|
226 void InternalizeFlatL( RReadStream& aReadStream ); |
|
227 |
|
228 /** |
|
229 * Externalizes flat data |
|
230 * @param aWriteStream write stream |
|
231 */ |
|
232 void ExternalizeFlatL( RWriteStream& aWriteStream ); |
|
233 |
|
234 /** |
|
235 * Internalizes |
|
236 * @param aSerCtx context for serialization |
|
237 */ |
|
238 void InternalizeL( MMceComSerializationContext& aSerCtx ); |
|
239 |
|
240 /** |
|
241 * Externalizes |
|
242 * @param aSerCtx context for serialization |
|
243 */ |
|
244 void ExternalizeL( MMceComSerializationContext& aSerCtx ); |
|
245 |
|
246 public:// |
|
247 |
|
248 |
|
249 /** |
|
250 * Factory |
|
251 * @return factory |
|
252 */ |
|
253 TMceComFactory BaseFactory(); |
|
254 |
|
255 /** |
|
256 * Factory |
|
257 * @return factory |
|
258 */ |
|
259 static TMceComFactory Factory(); |
|
260 |
|
261 public://event handling && updating && cloning |
|
262 |
|
263 /** |
|
264 * Initializes |
|
265 * @param aParent the parent |
|
266 */ |
|
267 void InitializeL(); |
|
268 |
|
269 /** |
|
270 * Traversal event handler |
|
271 * @param aEvent the event |
|
272 * @return status, if event was consumed or not or object needs update |
|
273 */ |
|
274 virtual void EventReceivedL( TMceComEvent& aEvent ); |
|
275 |
|
276 /** |
|
277 * Updates whole session object with new one |
|
278 * @param aSession new session |
|
279 */ |
|
280 void UpdateL( CMceComSession& aSession ); |
|
281 |
|
282 /** |
|
283 * Clones whole session object |
|
284 */ |
|
285 CMceComSession* CloneL( TBool aPullModeUpdate = EFalse ); |
|
286 |
|
287 /** |
|
288 * Is structure changed during update |
|
289 */ |
|
290 TBool& IsStructureChanged(); |
|
291 |
|
292 void UpdateFlatL( CMceComSession& aSession ); |
|
293 |
|
294 |
|
295 #ifdef MCE_COMMON_SERVER_SIDE |
|
296 |
|
297 static void Delete( CMceComSession*& aThis, CMceMediaManager& aManager ); |
|
298 |
|
299 CMceSdpSession& SdpSession() const; |
|
300 |
|
301 CMceComSession* Backup(); |
|
302 |
|
303 TBool IsBackup(); |
|
304 |
|
305 TBool IsMerged(); |
|
306 |
|
307 void Merge( CMceComSession& aSession, TBool aDeepMerge = KMceDeepMergeNo ); |
|
308 |
|
309 void UnMerge(); |
|
310 |
|
311 void UnMergeL( CMceComSession& aSession ); |
|
312 |
|
313 void AttachSDPSessionL( CMceSdpSession& aSdpSession ); |
|
314 |
|
315 void DetachSDPSession(); |
|
316 |
|
317 TMceMMState SetNegotiationStateL( TMceMediaState* aNewState ); |
|
318 |
|
319 void SetNegotiationState( TMceMediaState* aNewState ); |
|
320 |
|
321 TMceMediaState& NegotiationState() const; |
|
322 |
|
323 void PrepareL( CMceMediaManager& aManager ); |
|
324 |
|
325 void PrepareL(); |
|
326 |
|
327 CMceComSession* CloneAndMergeLC( CMceComSession& aUpdate ); |
|
328 |
|
329 RPointerArray<CMceSrvStream>& MccStreams(); |
|
330 |
|
331 RPointerArray<CMceSrvStream>& AdoptedMccStreams(); |
|
332 |
|
333 void AdoptStreamL( CMceSrvStream& aStream ); |
|
334 |
|
335 CMceSrvStream* RemoveAdoptedStream( CMceSrvStream& aStream ); |
|
336 |
|
337 /** |
|
338 * Create Secure Session |
|
339 */ |
|
340 CMceSecureMediaSession& SecureSessionL(); |
|
341 |
|
342 CMceSecureMediaSession* SecureSession(); |
|
343 |
|
344 void CloneSecureSessionL(CMceComSession& aSession); |
|
345 |
|
346 void DeleteSecureSession(); |
|
347 |
|
348 void SdpCleanup( CSdpDocument* aPrevious, CSdpDocument* aReplacement ); |
|
349 |
|
350 TMceNegotiationAnswerType& AnswerType(); |
|
351 |
|
352 #endif//MCE_COMMON_SERVER_SIDE |
|
353 |
|
354 |
|
355 private: |
|
356 |
|
357 /** |
|
358 * C++ default constructor. |
|
359 */ |
|
360 CMceComSession(); |
|
361 |
|
362 /** |
|
363 * C++ constructor. |
|
364 * @param aType the type of session |
|
365 */ |
|
366 CMceComSession( TType aType ); |
|
367 |
|
368 /** |
|
369 * second-phase constructor |
|
370 */ |
|
371 void ConstructL(); |
|
372 |
|
373 /** |
|
374 * second-phase copy constructor |
|
375 */ |
|
376 void ConstructL( CMceComSession& aSession, |
|
377 TBool aPullModeUpdate = EFalse); |
|
378 |
|
379 /** |
|
380 * Clone streams |
|
381 * @param aSession session |
|
382 */ |
|
383 void CloneStreamsL( CMceComSession& aSession ); |
|
384 |
|
385 /** |
|
386 * Clone bundles |
|
387 * @param aSession session |
|
388 */ |
|
389 void CloneBudlesL( CMceComSession& aSession ); |
|
390 |
|
391 /** |
|
392 * Update streams |
|
393 * @param aSession session |
|
394 */ |
|
395 void UpdateStreamsL( CMceComSession& aSession ); |
|
396 |
|
397 /** |
|
398 * Update bundles |
|
399 * @param aSession session |
|
400 * @param aStreams streams |
|
401 */ |
|
402 void UpdateBundlesL( CMceComSession& aSession, |
|
403 const RPointerArray<CMceComMediaStream>& aStreams ); |
|
404 |
|
405 |
|
406 |
|
407 public: // Owned serialized data |
|
408 |
|
409 |
|
410 /** |
|
411 * type of session |
|
412 */ |
|
413 TUint32 iID; |
|
414 |
|
415 /** |
|
416 * type of session |
|
417 */ |
|
418 TType iType; |
|
419 |
|
420 |
|
421 /** |
|
422 * state of session |
|
423 */ |
|
424 CMceSession::TState iState; |
|
425 |
|
426 /** |
|
427 * recipient |
|
428 */ |
|
429 HBufC8* iRecipient; |
|
430 |
|
431 /** |
|
432 * originator |
|
433 */ |
|
434 HBufC8* iOriginator; |
|
435 |
|
436 /** |
|
437 * is connection active |
|
438 */ |
|
439 TBool iIsConnectionActive; |
|
440 |
|
441 /** |
|
442 * Dialog id |
|
443 */ |
|
444 TUint32 iDialogId; |
|
445 |
|
446 /** |
|
447 * Session modifiers |
|
448 */ |
|
449 TMceComSessionModifiers iSessionModifiers; |
|
450 |
|
451 public: // Owned data |
|
452 |
|
453 /** |
|
454 * Internet access point used |
|
455 */ |
|
456 TUint32 iIapId; |
|
457 |
|
458 /** |
|
459 * Mcc session Id |
|
460 */ |
|
461 TUint32 iMccID; |
|
462 |
|
463 /** |
|
464 * Local host IP-address (IPv4 or IPv6) |
|
465 */ |
|
466 TInetAddr iLocalIpAddress; |
|
467 |
|
468 /** |
|
469 * Remote host IP-address (IPv4 or IPv6) |
|
470 */ |
|
471 TInetAddr iRemoteIpAddress; |
|
472 |
|
473 /** |
|
474 * has structure changed during update |
|
475 */ |
|
476 TBool iStructureChanged; |
|
477 |
|
478 /** |
|
479 * Should use local preconditions |
|
480 */ |
|
481 TBool iUseLocalPreconditions; |
|
482 |
|
483 /** |
|
484 * Should use remote preconditions |
|
485 */ |
|
486 TBool iUseRemotePreconditions; |
|
487 |
|
488 TBool iFcSignallingRequired; |
|
489 |
|
490 TBool iRequireSignalling; |
|
491 // Setting TMccNetService MediaQoS |
|
492 TUint32 iServiceType; |
|
493 |
|
494 TUint iAnswerType; |
|
495 |
|
496 TUint iCodecSelection; |
|
497 |
|
498 /* Remote use require header with precondtion option*/ |
|
499 TBool iRemoteSecPreconditionsRequired ; |
|
500 |
|
501 public: // NOT Owned data |
|
502 |
|
503 /** |
|
504 * Media manager observer |
|
505 */ |
|
506 MMceMediaSessionObserver* iMediaObserver; |
|
507 |
|
508 /** |
|
509 * cloned from |
|
510 */ |
|
511 CMceComSession* iCloneOrigin; |
|
512 |
|
513 |
|
514 public: // Owned invite related data |
|
515 |
|
516 /** |
|
517 * Session timer interval, in milliseconds |
|
518 */ |
|
519 TUint32 iTimeout; |
|
520 |
|
521 /** |
|
522 * Minimun SE received in 422, in milliseconds |
|
523 */ |
|
524 TUint32 iMinSE; |
|
525 |
|
526 /** |
|
527 * Is this UA performing the refresh requests |
|
528 */ |
|
529 TBool iRefresh; |
|
530 |
|
531 /** |
|
532 * sip headers |
|
533 */ |
|
534 CDesC8Array* iSIPHeaders; |
|
535 |
|
536 /** |
|
537 * content type |
|
538 */ |
|
539 HBufC8* iSIPContentType; |
|
540 |
|
541 /** |
|
542 * content headers |
|
543 */ |
|
544 CDesC8Array* iSIPContentHeaders; |
|
545 |
|
546 /** |
|
547 * content |
|
548 * NOT serialized |
|
549 */ |
|
550 HBufC8* iSIPContent; |
|
551 |
|
552 /** |
|
553 * local sdp session lines |
|
554 */ |
|
555 CDesC8Array* iLocalSessionSDPLines; |
|
556 |
|
557 /** |
|
558 * remote sdp session lines |
|
559 */ |
|
560 CDesC8Array* iRemoteSessionSDPLines; |
|
561 |
|
562 /** |
|
563 * Flag to indicate if the secure session is needed |
|
564 * To create secure link in MCC, this has to be set as True. |
|
565 */ |
|
566 TBool iIsSecureSession; |
|
567 |
|
568 TBool iPullModeUpdate; |
|
569 |
|
570 /** |
|
571 * Crypto Suite Set by client |
|
572 */ |
|
573 RArray<TMceCryptoContext> iClientCryptoSuites; |
|
574 |
|
575 /** |
|
576 * secure level by the contact header in offer/Answer which is |
|
577 * with SIPSUri or transport parameter is tls. |
|
578 */ |
|
579 CMceSession::TControlPathSecurityLevel iSipContactAddrSecure; |
|
580 |
|
581 |
|
582 private: // Owned data |
|
583 |
|
584 |
|
585 /** |
|
586 * media streams |
|
587 */ |
|
588 RPointerArray<CMceComMediaStream> iMediaStreams; |
|
589 |
|
590 /** |
|
591 * bundles |
|
592 */ |
|
593 RPointerArray<CMceComStreamBundle> iBundles; |
|
594 |
|
595 #ifdef MCE_COMMON_SERVER_SIDE |
|
596 |
|
597 |
|
598 RPointerArray<CMceSrvStream> iMccStreams; |
|
599 |
|
600 RPointerArray<CMceSrvStream> iMccAdoptedStreams; |
|
601 |
|
602 //current state |
|
603 TMceMediaState* iNegotiationState; |
|
604 |
|
605 CMceSdpSession* iSdpSession; |
|
606 |
|
607 |
|
608 /** |
|
609 * SecureMediaSession |
|
610 */ |
|
611 CMceSecureMediaSession* iSecureMediaSession; |
|
612 |
|
613 |
|
614 //definitions for unit testing |
|
615 MCEMM_UT_DEFINITIONS |
|
616 friend class UT_CMceSipSession; |
|
617 friend class UT_CMceStateOffering; |
|
618 |
|
619 #endif//MCE_COMMON_SERVER_SIDE |
|
620 |
|
621 |
|
622 }; |
|
623 |
|
624 |
|
625 #endif |