|
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 #ifndef MUSHENGMCESESSION_H |
|
20 #define MUSHENGMCESESSION_H |
|
21 |
|
22 // USER |
|
23 #include "musengsession.h" |
|
24 #include "musengsessiondurationtimerobserver.h" |
|
25 #include "musunittesting.h" |
|
26 #include "mussipprofileuser.h" |
|
27 |
|
28 // SYSTEM |
|
29 #include <mcesessionobserver.h> |
|
30 #include <mceinsessionobserver.h> |
|
31 #include <mcestreamobserver.h> |
|
32 #include <mcertpobserver.h> |
|
33 #include <mcetransactiondatacontainer.h> |
|
34 |
|
35 class CMceManager; |
|
36 class CMceSession; |
|
37 class CMceVideoStream; |
|
38 class CMceAudioStream; |
|
39 class CMceVideoCodec; |
|
40 class CMceAudioCodec; |
|
41 class CMusEngSessionDurationTimer; |
|
42 class MMusEngSessionObserver; |
|
43 class CMusSipProfileHandler; |
|
44 |
|
45 // CONSTANTS |
|
46 |
|
47 _LIT8( KMusEngAcceptContactHeader, |
|
48 "Accept-Contact: *;+g.3gpp.cs-voice; explicit" ); |
|
49 _LIT8( KMusAcceptHeader, |
|
50 "Accept: application/sdp" ); |
|
51 _LIT8( KMusEngSessionSdpLineXApplication, "a=X-application:com.nokia.rtvs\r\n" ); |
|
52 _LIT8( KMusEngSessionSdpLineApplication , "a=application:com.gsma.rts\r\n" ); |
|
53 _LIT8( KMusEngSessionSdpLineType, "a=type:videolive\r\n" ); |
|
54 _LIT8( KMusEngSessionSdpLineBandwidthLine , "b=AS" ); |
|
55 _LIT8( KMusEngSessionSdpLineBandwidthField , "b=AS:85\r\n" ); |
|
56 _LIT8( KMusPPreferredIdentity, "P-Preferred-Identity" ); |
|
57 _LIT8( KMusPrivacyHeader, "Privacy" ); |
|
58 _LIT8( KMusAnonymousHeader, "\"Anonymous\" <sip:anonymous@anonymous.invalid>" ); |
|
59 |
|
60 const TInt KMusEngMaxVolume = 10; |
|
61 const TInt KMusEngMinVolume = 0; |
|
62 |
|
63 // CLASS DECLARATION |
|
64 |
|
65 /** |
|
66 * Base class for Multimedia Sharing Engine MCE sessions, inherited by |
|
67 * CMusEngLiveSession CMusEngClipSession and CMusEngReceiveSession. |
|
68 * |
|
69 * CMusEngMceSession encapsulates CMCESession and simplifies use of |
|
70 * MCE Sessions to user interface. Also splits observers messy events |
|
71 * to simplified function calls. |
|
72 * |
|
73 * @lib musengine.lib |
|
74 */ |
|
75 class CMusEngMceSession : public CMusEngSession, |
|
76 public MMceSessionObserver, |
|
77 public MMceInSessionObserver, |
|
78 public MMceStreamObserver, |
|
79 public MMceRtpObserver, |
|
80 public MMusEngSessionDurationTimerObserver, |
|
81 public MMusSipProfileUser |
|
82 { |
|
83 |
|
84 public: |
|
85 |
|
86 /* |
|
87 * Defines possible rotations |
|
88 */ |
|
89 enum TDisplayOrientation |
|
90 { |
|
91 EPortrait, // Normal |
|
92 ELandscape // 90 degree's clockwise rotation |
|
93 }; |
|
94 |
|
95 public: |
|
96 |
|
97 /** |
|
98 * Destructor |
|
99 */ |
|
100 ~CMusEngMceSession(); |
|
101 |
|
102 |
|
103 public: // API FUNCTIONS |
|
104 |
|
105 /** |
|
106 * Terminates session. |
|
107 * |
|
108 * @pre Session is established |
|
109 * @post Session is ready to be deleted |
|
110 * @leave KErrNotReady if precondition is not fullfilled |
|
111 */ |
|
112 IMPORT_C void TerminateL(); |
|
113 |
|
114 /** |
|
115 * Get session time return estabilished session time |
|
116 * |
|
117 * @return TTime returns time if connection established else < 0 |
|
118 */ |
|
119 IMPORT_C TTimeIntervalSeconds GetSessionTime() const; |
|
120 |
|
121 /** |
|
122 * Returns current connection state |
|
123 * |
|
124 * @return TBool returns current connection state |
|
125 */ |
|
126 IMPORT_C TBool ConnectionActive() const; |
|
127 |
|
128 /** |
|
129 * Returns presence or absence of audio in session. |
|
130 * |
|
131 * @pre Session is ongoing |
|
132 * @return ETrue if session contains audio. |
|
133 * @leave KErrNotReady if precondition is not fullfilled |
|
134 */ |
|
135 IMPORT_C TBool ContainsAudioL(); |
|
136 |
|
137 /** |
|
138 * Returns state of local playback meaning if playback is muted or not. |
|
139 * |
|
140 * @pre Session is ongoing |
|
141 * @return ETrue if session does not contain audio or contained |
|
142 * audio is muted. |
|
143 * @leave KErrNotReady if precondition is not fullfilled |
|
144 */ |
|
145 IMPORT_C TBool IsMutedL(); |
|
146 |
|
147 /** |
|
148 * Returns current display orientation. |
|
149 * |
|
150 * @pre Session is ongoing |
|
151 * @return Current display orientation |
|
152 * @leave KErrNotReady if precondition is not fullfilled |
|
153 */ |
|
154 IMPORT_C TDisplayOrientation OrientationL(); |
|
155 |
|
156 /** |
|
157 * Sets display orientation. |
|
158 * |
|
159 * @pre Session is ongoing |
|
160 * @return Sets display orientation |
|
161 * @leave KErrNotReady if precondition is not fullfilled |
|
162 */ |
|
163 IMPORT_C void SetOrientationL( TDisplayOrientation aOrientation ); |
|
164 |
|
165 |
|
166 public: // VIRTUAL API |
|
167 |
|
168 // No virtual api |
|
169 |
|
170 |
|
171 public: // from CMusEngSession |
|
172 |
|
173 /** |
|
174 * Increases volume level by one |
|
175 * |
|
176 * @pre Session is ongoing |
|
177 */ |
|
178 IMPORT_C void VolumeUpL(); |
|
179 |
|
180 /** |
|
181 * Decreases volume level by one |
|
182 * |
|
183 * @pre Session is ongoing |
|
184 */ |
|
185 IMPORT_C void VolumeDownL(); |
|
186 |
|
187 /** |
|
188 * Set volume value |
|
189 * @pre Session is ongoing |
|
190 * @param aVal the value of volume |
|
191 */ |
|
192 IMPORT_C void SetVolumeL( TInt aVal ); |
|
193 |
|
194 /** |
|
195 * Permission to draw on screen device. |
|
196 * |
|
197 * @pre Session is ongoing |
|
198 */ |
|
199 IMPORT_C void EnableDisplayL( TBool aEnable ); |
|
200 |
|
201 /** |
|
202 * Implements virtual from CMusEngSession |
|
203 * |
|
204 * @pre Session is ongoing |
|
205 */ |
|
206 IMPORT_C void MuteL(); |
|
207 |
|
208 /** |
|
209 * Implements virtual from CMusEngSession |
|
210 * |
|
211 * @pre Session is ongoing |
|
212 */ |
|
213 IMPORT_C void UnmuteL(); |
|
214 |
|
215 |
|
216 protected: // CONSTRUCTORS |
|
217 |
|
218 /** |
|
219 * Constructor |
|
220 * |
|
221 */ |
|
222 CMusEngMceSession( const TRect& aRect, |
|
223 MMusEngSessionObserver& aSessionObserver ); |
|
224 |
|
225 /** |
|
226 * Second-phase constructor |
|
227 * |
|
228 */ |
|
229 void ConstructL(); |
|
230 |
|
231 |
|
232 protected: // VIRTUAL HELPER FUNCTIONS |
|
233 |
|
234 /** |
|
235 * Function handling MCE session state changes. |
|
236 * To be overridden in sibling classes if needed. |
|
237 */ |
|
238 virtual void HandleSessionStateChanged( CMceSession& aSession, |
|
239 TInt aStatusCode, |
|
240 const TDesC8& aReasonPhrase ); |
|
241 |
|
242 /** |
|
243 * Function handling MCE session termination. |
|
244 */ |
|
245 virtual void HandleTermination( TInt aStatusCode, |
|
246 const TDesC8& aReasonPhrase ); |
|
247 |
|
248 /** |
|
249 * Sets Multimediasharing specific video codec settings. This functions |
|
250 * gets called for every video codec in session. To be overridden in |
|
251 * sibling classes if needed. |
|
252 */ |
|
253 virtual void AdjustVideoCodecL( CMceVideoCodec& aVideoCodec ); |
|
254 |
|
255 /** |
|
256 * Sets Multimediasharing specific audio codec settings like audio MMF |
|
257 * priority and preference. This functions gets called for every audio |
|
258 * codec in session. To be overridden in sibling classes if needed. |
|
259 */ |
|
260 virtual void AdjustAudioCodecL( CMceAudioCodec& aAudioCodec ); |
|
261 |
|
262 /** |
|
263 * Removes multiples of H.263 codec, prefers H263-2000 over H263-1998. |
|
264 * Additionally selects just the one with best quality from selected mode. |
|
265 * @param aVideoStream |
|
266 */ |
|
267 virtual void DoCodecSelectionL( CMceVideoStream& aVideoStream ); |
|
268 |
|
269 |
|
270 protected: // HELPER FUNCTIONS |
|
271 |
|
272 /** |
|
273 * |
|
274 */ |
|
275 void RectChangedL(); |
|
276 |
|
277 /** |
|
278 * Sets session specific SDP lines to a session. |
|
279 */ |
|
280 void SetSessionSdpLinesL( CMceSession& aSession, |
|
281 TBool aForceBandwidthLine = EFalse ); |
|
282 /** |
|
283 * Sets media specific SDP lines to media. |
|
284 */ |
|
285 void SetMediaSdpLinesL( CMceMediaStream& aStream, |
|
286 TBool aForceBandwidthLine = EFalse ); |
|
287 |
|
288 /** |
|
289 * Sets the volume level of all speakers in session structure. |
|
290 * @param aNewVolume New volume level for all speakers |
|
291 */ |
|
292 void SetSpeakerVolumeL( TInt aNewVolume ); |
|
293 |
|
294 /** |
|
295 * Adjusts settings of all streams. Calls AdjustVideoStreamL for every |
|
296 * video stream and AdjustAudioStreamL for every audio stream in session. |
|
297 */ |
|
298 void AdjustStreamsAndCodecsL(); |
|
299 |
|
300 /** |
|
301 * Adjusts stream settings. Calls AdjustVideoCodecL for every video |
|
302 * codec in stream. |
|
303 */ |
|
304 void AdjustVideoStreamL( CMceVideoStream& aVideoStream ); |
|
305 |
|
306 /** |
|
307 * Adjusts stream settings. Calls AdjustAudioCodecL for every audio |
|
308 * codec in stream. |
|
309 */ |
|
310 void AdjustAudioStreamL( CMceAudioStream& aAudioStream ); |
|
311 |
|
312 /* |
|
313 * Calls CMceInSession::RejectL() inside TRAP_IGNORE |
|
314 */ |
|
315 void Reject( CMceInSession& aSession, |
|
316 const TDesC8& aReason = KNullDesC8(), |
|
317 TUint32 aCode = 0 ); |
|
318 |
|
319 |
|
320 protected: // from MMceInSessionObserver |
|
321 |
|
322 /** |
|
323 * Incoming session invitation. The CMceInSession is given to the |
|
324 * application as a callback. This default implementation rejects |
|
325 * session immediately. |
|
326 * @param aSession, pointer to the incoming session. Ownership is |
|
327 * transferred. |
|
328 * @param aContainer, if present, holds details of |
|
329 * transaction causing state change. |
|
330 */ |
|
331 void IncomingSession( CMceInSession* aSession, |
|
332 TMceTransactionDataContainer* aContainer ); |
|
333 |
|
334 |
|
335 /** |
|
336 * Incoming session update. The new updated CMceInSession is given to the |
|
337 * application as a callback. This default implementation rejects |
|
338 * session immediately. |
|
339 * @param aOrigSession, the original session to be updated. This instance |
|
340 * cannot be used anymore, all actions done using aUpdatedSession |
|
341 * instance. |
|
342 * @param aUpdatedSession, pointer to the new updated session. Ownership |
|
343 * is transferred. |
|
344 * @param aContainer, if present, holds details of |
|
345 * update transaction. |
|
346 */ |
|
347 void IncomingUpdate( CMceSession& aOrigSession, |
|
348 CMceInSession* aUpdatedSession, |
|
349 TMceTransactionDataContainer* aContainer ); |
|
350 |
|
351 |
|
352 protected: // from MMceStreamObserver |
|
353 |
|
354 /** |
|
355 * The state of the stream has changed. |
|
356 * |
|
357 * @param aStream, the stream that has changed. |
|
358 */ |
|
359 void StreamStateChanged( CMceMediaStream& aStream ); |
|
360 |
|
361 /** |
|
362 * The state of the source has changed. |
|
363 * |
|
364 * @param aStream, the stream that uses the source. |
|
365 * @param aSource, the source that has changed. |
|
366 */ |
|
367 void StreamStateChanged( CMceMediaStream& aStream, |
|
368 CMceMediaSource& aSource ); |
|
369 |
|
370 /** |
|
371 * The state of the sink has changed. |
|
372 * |
|
373 * @param aStream, the stream that uses the sink. |
|
374 * @param aSink, the sink that has changed. |
|
375 */ |
|
376 void StreamStateChanged( CMceMediaStream& aStream, |
|
377 CMceMediaSink& aSink ); |
|
378 |
|
379 |
|
380 private: // from MMceSessionObserver |
|
381 |
|
382 /** |
|
383 * The state of the session has changed. |
|
384 * |
|
385 * @param aSession, the session that has changed. |
|
386 * @param aContainer, if present, holds details of |
|
387 * transaction causing state change. |
|
388 */ |
|
389 void SessionStateChanged( CMceSession& aSession, |
|
390 TMceTransactionDataContainer* aContainer ); |
|
391 |
|
392 /** |
|
393 * The state of the connection used by the session has changed. |
|
394 * |
|
395 * @param aSession, the session that has changed. |
|
396 * @param aActive, ETrue if connection active, EFalse if |
|
397 * connection inactive. |
|
398 */ |
|
399 void SessionConnectionStateChanged( CMceSession& aSession, |
|
400 TBool aActive ); |
|
401 |
|
402 /** |
|
403 * An error has occurred concerning a specific session. |
|
404 * Note, that each error causes the session state to be ETerminated. |
|
405 * |
|
406 * @param aSession, The session raising the error. |
|
407 * @param aError, Error code |
|
408 */ |
|
409 void Failed( CMceSession& aSession, TInt aError ); |
|
410 |
|
411 /** |
|
412 * An session update has been failed concerning a specific session. |
|
413 * Note, that each error causes the session state to be ETerminated. |
|
414 * |
|
415 * @param aSession, The session raising the error. |
|
416 * @param aContainer, if present, holds details of |
|
417 * transaction causing update. |
|
418 */ |
|
419 void UpdateFailed( CMceSession& aSession, |
|
420 TMceTransactionDataContainer* aContainer ); |
|
421 |
|
422 |
|
423 private: // from MMCERtpObserver |
|
424 |
|
425 /** |
|
426 * Callback function to indicate that an RTCP sender report |
|
427 * has been received. |
|
428 * @param aSession the session that has changed |
|
429 * @param aStream the stream that has changed |
|
430 */ |
|
431 void SRReceived( CMceSession& aSession, CMceMediaStream& aStream); |
|
432 |
|
433 /** |
|
434 * Callback function to indicate that an RTCP receiver report |
|
435 * has been received. |
|
436 * @param aSession the session that has changed |
|
437 * @param aStream the stream that has changed |
|
438 */ |
|
439 void RRReceived( CMceSession& aSession, CMceMediaStream& aStream); |
|
440 |
|
441 /** |
|
442 * Callback function to indicate inactivity timer timeout |
|
443 * has occurred. Timer is disabled after the timeout. |
|
444 * |
|
445 * @param aStream, the session that has changed. |
|
446 * @param aSource, the source that the timeout occurred. |
|
447 */ |
|
448 void InactivityTimeout( CMceMediaStream& aStream, |
|
449 CMceRtpSource& aSource ); |
|
450 |
|
451 /** |
|
452 * Callback function to indicate that spesified CMceRtpSource has |
|
453 * received RTP from a new synchronization source (SSRC). |
|
454 * @param aStream the stream that new SSRC was added to |
|
455 * @param aSource the source that new SSRC was added to |
|
456 * @param aSsrc added SSRC identifier |
|
457 */ |
|
458 void SsrcAdded( CMceMediaStream& aStream, |
|
459 CMceRtpSource& aSource, |
|
460 TUint aSsrc ); |
|
461 |
|
462 /** |
|
463 * Callback function to indicate that spesified CMceRtpSource has |
|
464 * received RTP BYE message from a spesified synchronization |
|
465 * source (SSRC). |
|
466 * @param aStream the stream that SSRC was removed from |
|
467 * @param aSource the source that SSRC was removed from |
|
468 * @param aSsrc removed SSRC identifier |
|
469 */ |
|
470 void SsrcRemoved( CMceMediaStream& aStream, |
|
471 CMceRtpSource& aSource, |
|
472 TUint aSsrc ); |
|
473 |
|
474 private: // from MMusSipProfileUser |
|
475 |
|
476 TBool IsRoamingBetweenAPsAllowed(); |
|
477 |
|
478 private: // HELPER FUNCTIONS |
|
479 |
|
480 /** |
|
481 * Callback |
|
482 */ |
|
483 void UpdateTimerEvent(); |
|
484 |
|
485 /** |
|
486 * Does actual muting or unmuting of local audio playback but does not |
|
487 * mark speaker as explicitly muted so this function can be called also |
|
488 * when muting speaker as a consequence of disabling or enabling |
|
489 * bundled display sink. |
|
490 * |
|
491 */ |
|
492 void DoMuteSpeakerL( TBool aMute ); |
|
493 |
|
494 /** |
|
495 * Checks if some of array items contains specific text. |
|
496 * @param aArray |
|
497 * @param aItem |
|
498 * @return ETrue if array contains aItem |
|
499 */ |
|
500 TBool ContainsText( MDesC8Array* aArray, const TDesC8& aItem ); |
|
501 |
|
502 void DoBitrateBasedRemovalL( CMceVideoStream& aVideoStream, |
|
503 const CMceVideoCodec& aBestBitrateVideoCodec ); |
|
504 |
|
505 void DoCodecModeBasedRemovalL( CMceVideoStream& aVideoStream ); |
|
506 /** |
|
507 * This function currently used to remove the AVC codec support based on |
|
508 * cenrep encoder device uid value. |
|
509 */ |
|
510 void DoCodecConfigurationBasedRemovalL( CMceVideoStream& aVideoStream ); |
|
511 |
|
512 |
|
513 protected: // MEMBERS |
|
514 |
|
515 /** |
|
516 * Callback reference to session observer interface. |
|
517 */ |
|
518 MMusEngSessionObserver& iSessionObserver; |
|
519 |
|
520 /** |
|
521 * Class for connecting to MCE server. |
|
522 * This class provides the connection to the MCE server and |
|
523 * provides functions |
|
524 * for setting observers for asynchronous events. |
|
525 * The user should create only one instance of this class. |
|
526 */ |
|
527 CMceManager* iManager; |
|
528 |
|
529 /** |
|
530 * Base class for MCE sessions, inherited by both CMCEInSession and |
|
531 * CMCEOutSession. * CMCESession represents peer-to-peer connection |
|
532 * made with remote terminal. This connection is also known as dialog |
|
533 * and it is set up using SIP INVITE method. The characteristics of the |
|
534 * session are defined by user of this class by attaching media streams |
|
535 * into the session. After the session has been succesfully established, |
|
536 * it can be later updated and must be finally terminated. If for any |
|
537 * reason instance of this class is deleted while in established state, |
|
538 * session is automatically terminated by MCE server. |
|
539 */ |
|
540 CMceSession* iSession; |
|
541 |
|
542 /** |
|
543 * ETrue if operator specific behavior is expected |
|
544 */ |
|
545 TBool iOperatorVariant; |
|
546 |
|
547 /** |
|
548 * The handler for the SIP profile related to this session |
|
549 */ |
|
550 CMusSipProfileHandler* iSipProfileHandler; |
|
551 |
|
552 private: |
|
553 |
|
554 /** |
|
555 * It is assumed, that user has only one instance of this class. |
|
556 * The same instance is passed between MCE and user, but the data |
|
557 * inside of this container is just updated for each event. |
|
558 */ |
|
559 TMceTransactionDataContainer iTransactionDataContainer; |
|
560 |
|
561 /** |
|
562 * Session time. Acts simultaneously as RTCP inactivity timer. |
|
563 */ |
|
564 TTime iStartTime; |
|
565 |
|
566 CMusEngSessionDurationTimer* iUpdateTimer; |
|
567 |
|
568 /** |
|
569 * Value indicating seconds gone since last received RTCP sender or |
|
570 * receiver report. Value 20 indicates RTCP inactivity timeout. |
|
571 */ |
|
572 TInt iSecondsFromLastRtcpReport; |
|
573 |
|
574 /** |
|
575 * Value indicating if speaker is explicitly muted instead of |
|
576 * muted as part of disabling bundled display sink |
|
577 */ |
|
578 TBool iExplicitlyMuted; |
|
579 |
|
580 |
|
581 MUS_UNITTEST( UT_CMusEngSession ) |
|
582 MUS_UNITTEST( UT_CMusEngMceSession ) |
|
583 MUS_UNITTEST( UT_CMusEngReceiveSession ) |
|
584 }; |
|
585 |
|
586 #endif //MUSHENGMCESESSION_H |