66 const TUint KMusEngDedicatedAudioPort = 57344; |
56 const TUint KMusEngDedicatedAudioPort = 57344; |
67 |
57 |
68 #define MUS_CODEC_ARR_CONST_CAST( codecArr ) \ |
58 #define MUS_CODEC_ARR_CONST_CAST( codecArr ) \ |
69 ( const_cast< RPointerArray< CMceVideoCodec >& >( codecArr ) ) |
59 ( const_cast< RPointerArray< CMceVideoCodec >& >( codecArr ) ) |
70 |
60 |
71 // Names of AVC levels in string for config keys stored in CenRep |
|
72 _LIT8( KMusAvcBitrateLevel1, "AvcBrL1=" ); |
|
73 _LIT8( KMusAvcBitrateLevel1b, "AvcBrL1b=" ); |
|
74 _LIT8( KMusAvcBitrateLevel1_1, "AvcBrL1_1=" ); |
|
75 _LIT8( KMusAvcBitrateLevel1_2, "AvcBrL1_2=" ); |
|
76 _LIT8( KMusAvcBitrateLevel1_3, "AvcBrL1_3=" ); |
|
77 _LIT8( KMusAvcBitrateLevel2, "AvcBrL2=" ); |
|
78 |
|
79 _LIT8( KMusEncoderInfoTokenizer, ";" ); |
|
80 |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 CMusEngMceSession::CMusEngMceSession() |
|
87 : iSecondsFromLastRtcpReport ( 0 ), |
|
88 // Although speaker is constructed as muted, it is not explicitly muted |
|
89 iExplicitlyMuted( EFalse ), |
|
90 iBackground( ETrue ) |
|
91 { |
|
92 iMceManagerUid.iUid = KMusUiUid; |
|
93 iBackground = IsBackgroundStartup(); |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 void CMusEngMceSession::ConstructL() |
|
101 { |
|
102 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::ConstructL()" ) |
|
103 |
|
104 iTelephoneUtils = CMusEngTelephoneUtils::NewL( *this ); |
|
105 |
|
106 // Creating new MCE Manager and set all needed observers to this class. |
|
107 iManager = CMceManager::NewL( iMceManagerUid, |
|
108 &iTransactionDataContainer ); |
|
109 iManager->SetSessionObserver( this ); |
|
110 iManager->SetInSessionObserver( this ); |
|
111 iManager->SetMediaObserver( this ); |
|
112 iManager->SetRtpObserver( this ); |
|
113 |
|
114 // Check if operator specific behavior is expected |
|
115 iOperatorVariant = ( MultimediaSharingSettings::OperatorVariantSettingL() == |
|
116 MusSettingsKeys::EOperatorSpecific ); |
|
117 |
|
118 // Update timer initialization |
|
119 iUpdateTimer = CMusEngSessionDurationTimer::NewL( *this ); |
|
120 |
|
121 iSipProfileHandler = CMusSipProfileHandler::NewL( *this ); |
|
122 |
|
123 iRemoteDetails = HBufC::NewL( RProperty::KMaxPropertySize ); |
|
124 iRemoteDetails->Des().Copy( KNullDesC ); |
|
125 |
|
126 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::ConstructL()" ) |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
61 // ----------------------------------------------------------------------------- |
130 // |
62 // |
131 // ----------------------------------------------------------------------------- |
63 // ----------------------------------------------------------------------------- |
132 // |
64 // |
133 CMusEngMceSession::~CMusEngMceSession() |
65 CMusEngMceSession::~CMusEngMceSession() |
134 { |
66 { |
135 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::~CMusEngMceSession()" ) |
67 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::~CMusEngMceSession()" ) |
136 |
|
137 delete iSipProfileHandler; |
68 delete iSipProfileHandler; |
138 delete iSession; |
69 delete iSession; |
139 delete iManager; |
70 delete iManager; |
140 delete iUpdateTimer; |
71 delete iUpdateTimer; |
141 delete iTelephoneUtils; |
|
142 delete iRemoteDetails; |
|
143 |
|
144 RProperty::Set( NMusSessionApi::KCategoryUid, |
|
145 NMusSessionApi::KFastMode, |
|
146 MusSettingsKeys::EFastModeDisabled ); |
|
147 |
|
148 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::~CMusEngMceSession()" ) |
72 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::~CMusEngMceSession()" ) |
149 } |
73 } |
150 |
74 |
151 // ----------------------------------------------------------------------------- |
75 |
152 // From MMusEngDisplayHandler |
76 // ----------------------------------------------------------------------------- |
153 // ----------------------------------------------------------------------------- |
77 // |
154 // |
78 // ----------------------------------------------------------------------------- |
155 TRect CMusEngMceSession::Rect() const |
79 // |
156 { |
80 EXPORT_C void CMusEngMceSession::TerminateL() |
157 MUS_LOG( "mus: [ENGINE] CMusEngMceSession::Rect()" ) |
81 { |
158 return iRect; |
82 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::TerminateL()" ) |
159 } |
83 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
160 |
84 iSession->TerminateL(); |
161 // ----------------------------------------------------------------------------- |
85 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::TerminateL()" ) |
162 // From MMusEngDisplayHandler |
86 } |
163 // ----------------------------------------------------------------------------- |
87 |
164 // |
88 |
165 void CMusEngMceSession::SetRectL( const TRect& aRect ) |
89 // ----------------------------------------------------------------------------- |
166 { |
90 // Returns estabilished session time. If not established return |
167 MUS_LOG( "mus: [ENGINE] CMusEngSession::SetRectL()" ) |
91 // value is < 0 |
168 iRect = aRect; |
92 // ----------------------------------------------------------------------------- |
169 RectChangedL(); |
93 // |
170 } |
94 EXPORT_C TTimeIntervalSeconds CMusEngMceSession::GetSessionTime() const |
171 |
95 { |
172 // ----------------------------------------------------------------------------- |
96 if ( iSession && iSession->State() == CMceSession::EEstablished ) |
173 // From MMusEngDisplayHandler |
97 { |
174 // ----------------------------------------------------------------------------- |
98 TTime time; |
175 // |
99 TTimeIntervalSeconds seconds; |
176 void CMusEngMceSession::SetSecondaryRectL( const TRect& aSecondaryRect ) |
100 time.HomeTime(); |
177 { |
101 |
178 MUS_LOG( "mus: [ENGINE] CMusEngMceSession::SetSecondaryRectL()" ) |
102 time.SecondsFrom( iStartTime, seconds ); |
179 |
103 |
180 // Same rect is set by primary and secondary setters |
104 return seconds; |
181 iRect = aSecondaryRect; |
105 } |
182 RectChangedL(); |
106 |
183 } |
107 return TTimeIntervalSeconds( KErrNotReady ); |
184 |
108 |
185 // ----------------------------------------------------------------------------- |
109 } |
186 // From MMusEngDisplayHandler |
110 |
187 // ----------------------------------------------------------------------------- |
111 |
188 // |
112 // ----------------------------------------------------------------------------- |
189 TRect CMusEngMceSession::SecondaryRect() const |
113 // |
190 { |
114 // ----------------------------------------------------------------------------- |
191 MUS_LOG( "mus: [ENGINE] CMusEngMceSession::SecondaryRect()" ) |
115 // |
192 return iRect; |
116 EXPORT_C TBool CMusEngMceSession::ConnectionActive() const |
193 } |
117 { |
194 |
118 if ( iSession ) |
195 // ----------------------------------------------------------------------------- |
119 { |
196 // From MMusEngDisplayHandler |
120 return iSession->ConnectionActive(); |
197 // ----------------------------------------------------------------------------- |
121 } |
198 // |
122 return EFalse; |
199 MMusEngDisplayHandler::TDisplayOrientation CMusEngMceSession::OrientationL() |
123 } |
|
124 |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 EXPORT_C TBool CMusEngMceSession::ContainsAudioL() |
|
131 { |
|
132 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
|
133 |
|
134 for ( TInt i = 0; i < iSession->Streams().Count(); ++i ) |
|
135 { |
|
136 if ( iSession->Streams()[i]->Type() == KMceAudio ) |
|
137 { |
|
138 return ETrue; |
|
139 } |
|
140 } |
|
141 |
|
142 return EFalse; |
|
143 } |
|
144 |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 EXPORT_C TBool CMusEngMceSession::IsMutedL() |
|
151 { |
|
152 // Precondition checked in ContainsAudioL |
|
153 |
|
154 if ( ContainsAudioL() && !iExplicitlyMuted ) |
|
155 { |
|
156 return EFalse; |
|
157 } |
|
158 |
|
159 return ETrue; |
|
160 } |
|
161 |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 EXPORT_C CMusEngMceSession::TDisplayOrientation |
|
168 CMusEngMceSession::OrientationL() |
200 { |
169 { |
201 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::RotationL()" ) |
170 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::RotationL()" ) |
202 |
171 |
203 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
172 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
204 |
173 |
309 |
323 |
310 // ----------------------------------------------------------------------------- |
324 // ----------------------------------------------------------------------------- |
311 // |
325 // |
312 // ----------------------------------------------------------------------------- |
326 // ----------------------------------------------------------------------------- |
313 // |
327 // |
314 TBool CMusEngMceSession::IsDisplayEnabled() |
328 EXPORT_C TBool CMusEngMceSession::IsDisplayEnabledL() |
315 { |
|
316 TBool enabled( EFalse ); |
|
317 if ( iSession ) |
|
318 { |
|
319 CMceDisplaySink* display = |
|
320 MusEngMceUtils::GetDisplay( *iSession, ETrue ); |
|
321 if ( display ) |
|
322 { |
|
323 enabled = display->IsEnabled(); |
|
324 } |
|
325 } |
|
326 return enabled; |
|
327 } |
|
328 |
|
329 // ----------------------------------------------------------------------------- |
|
330 // From MMusEngDisplayHandler |
|
331 // ----------------------------------------------------------------------------- |
|
332 // |
|
333 TBool CMusEngMceSession::IsDisplayActive() |
|
334 { |
|
335 return ( IsDisplayEnabled() ); |
|
336 } |
|
337 |
|
338 // ----------------------------------------------------------------------------- |
|
339 // From MMusEngAudioRoutingObserver |
|
340 // ----------------------------------------------------------------------------- |
|
341 // |
|
342 void CMusEngMceSession::AudioRoutingChanged() |
|
343 { |
|
344 InformObserverAboutPlayerUpdate( LocalVideoPlayer() ); |
|
345 InformObserverAboutPlayerUpdate( RemoteVideoPlayer() ); |
|
346 } |
|
347 |
|
348 // ----------------------------------------------------------------------------- |
|
349 // From MLcSession |
|
350 // ----------------------------------------------------------------------------- |
|
351 // |
|
352 MLcSession::TLcSessionState CMusEngMceSession::LcSessionState() const |
|
353 { |
|
354 TLcSessionState lcSessionState = MLcSession::EUninitialized; |
|
355 |
|
356 if ( iSession ) |
|
357 { |
|
358 switch( iSession->State() ) |
|
359 { |
|
360 case CMceSession::EIdle: |
|
361 { |
|
362 lcSessionState = MLcSession::EInitialized; |
|
363 break; |
|
364 } |
|
365 case CMceSession::EIncoming: |
|
366 case CMceSession::EProceeding: |
|
367 case CMceSession::EReserving: |
|
368 { |
|
369 lcSessionState = MLcSession::EReceived; |
|
370 break; |
|
371 } |
|
372 |
|
373 case CMceSession::EOffering: |
|
374 case CMceSession::EAnswering: |
|
375 { |
|
376 lcSessionState = MLcSession::EOpening; |
|
377 break; |
|
378 } |
|
379 case CMceSession::EEstablished: |
|
380 { |
|
381 lcSessionState = MLcSession::EOpen; |
|
382 break; |
|
383 } |
|
384 case CMceSession::ECancelling: |
|
385 case CMceSession::ETerminating: |
|
386 { |
|
387 lcSessionState = MLcSession::EClosing; |
|
388 break; |
|
389 } |
|
390 case CMceSession::ETerminated: |
|
391 { |
|
392 lcSessionState = MLcSession::EClosed; |
|
393 break; |
|
394 } |
|
395 default: |
|
396 { |
|
397 lcSessionState = MLcSession::EUninitialized; |
|
398 break; |
|
399 } |
|
400 } |
|
401 } |
|
402 return lcSessionState; |
|
403 } |
|
404 |
|
405 // ----------------------------------------------------------------------------- |
|
406 // From MLcSession |
|
407 // ----------------------------------------------------------------------------- |
|
408 // |
|
409 void CMusEngMceSession::SetLcSessionObserver( MLcSessionObserver* aObserver ) |
|
410 { |
|
411 iLcSessionObserver = aObserver; |
|
412 } |
|
413 |
|
414 // ----------------------------------------------------------------------------- |
|
415 // From MLcSession |
|
416 // ----------------------------------------------------------------------------- |
|
417 // |
|
418 void CMusEngMceSession::SetLcUiProvider( MLcUiProvider* aUiProvider ) |
|
419 { |
|
420 iLcUiProvider = aUiProvider; |
|
421 } |
|
422 |
|
423 // ----------------------------------------------------------------------------- |
|
424 // From MLcSession |
|
425 // ----------------------------------------------------------------------------- |
|
426 // |
|
427 MLcVideoPlayer* CMusEngMceSession::RemoteVideoPlayer() |
|
428 { |
|
429 return NULL; |
|
430 } |
|
431 |
|
432 // ----------------------------------------------------------------------------- |
|
433 // From MLcSession |
|
434 // ----------------------------------------------------------------------------- |
|
435 // |
|
436 MLcVideoPlayer* CMusEngMceSession::LocalVideoPlayer() |
|
437 { |
|
438 return NULL; |
|
439 } |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // From MLcSession |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 const TDesC& CMusEngMceSession::LocalDisplayName() |
|
446 { |
|
447 return KNullDesC; |
|
448 } |
|
449 |
|
450 // ----------------------------------------------------------------------------- |
|
451 // From MLcSession |
|
452 // ----------------------------------------------------------------------------- |
|
453 // |
|
454 const TDesC& CMusEngMceSession::RemoteDisplayName() |
|
455 { |
|
456 return KNullDesC; |
|
457 } |
|
458 |
|
459 // ----------------------------------------------------------------------------- |
|
460 // From MLcSession |
|
461 // ----------------------------------------------------------------------------- |
|
462 // |
|
463 TInt CMusEngMceSession::SetParameter( TInt /*aId*/, TInt /*aValue*/ ) |
|
464 { |
|
465 return KErrNotSupported; |
|
466 } |
|
467 |
|
468 // ----------------------------------------------------------------------------- |
|
469 // From MLcSession |
|
470 // ----------------------------------------------------------------------------- |
|
471 // |
|
472 TInt CMusEngMceSession::ParameterValue( TInt /*aId*/ ) |
|
473 { |
|
474 return KErrNotSupported; |
|
475 } |
|
476 |
|
477 // ----------------------------------------------------------------------------- |
|
478 // From MLcSession |
|
479 // ----------------------------------------------------------------------------- |
|
480 // |
|
481 TBool CMusEngMceSession::IsBackgroundStartup() |
|
482 { |
|
483 TInt fastMode; |
|
484 TInt error = RProperty::Get( NMusSessionApi::KCategoryUid, |
|
485 NMusSessionApi::KFastMode, |
|
486 fastMode ); |
|
487 |
|
488 return ( error == KErrNone && |
|
489 iBackground && |
|
490 fastMode == MusSettingsKeys::EFastModeOn ); |
|
491 } |
|
492 |
|
493 // ----------------------------------------------------------------------------- |
|
494 // From MLcSession |
|
495 // ----------------------------------------------------------------------------- |
|
496 // |
|
497 TInt CMusEngMceSession::SetForegroundStatus( TBool aIsForeground ) |
|
498 { |
|
499 MUS_LOG1( "mus: [ENGINE] -> CMusEngMceSession::SetForegroundStatus() %d", |
|
500 aIsForeground ) |
|
501 |
|
502 if ( aIsForeground ) |
|
503 { |
|
504 // Only clear the bg info, do not ever enable it again |
|
505 iBackground = EFalse; |
|
506 } |
|
507 |
|
508 return KErrNone; |
|
509 } |
|
510 |
|
511 // ----------------------------------------------------------------------------- |
|
512 // From MLcSession |
|
513 // ----------------------------------------------------------------------------- |
|
514 // |
|
515 const TDesC& CMusEngMceSession::RemoteDetails() |
|
516 { |
|
517 // Don't care about error, empty value will be used in that case |
|
518 TPtr ptrDetails( iRemoteDetails->Des() ); |
|
519 RProperty::Get( NMusSessionApi::KCategoryUid, |
|
520 NMusSessionApi::KTelNumber, |
|
521 ptrDetails ); |
|
522 return *iRemoteDetails; |
|
523 } |
|
524 |
|
525 // ----------------------------------------------------------------------------- |
|
526 // From MLcSession |
|
527 // ----------------------------------------------------------------------------- |
|
528 // |
|
529 void CMusEngMceSession::UpdateLcSessionL() |
|
530 { |
329 { |
531 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
330 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
532 |
331 if ( iSession->State() == CMceSession::ETerminated || |
533 //In Mus engine, every update of player has immediate effect. Thus, this method |
332 iSession->State() == CMceSession::EIdle ) |
534 //is empty. |
333 { |
535 } |
334 return EFalse; |
536 |
335 } |
537 // ----------------------------------------------------------------------------- |
336 CMceDisplaySink* display = MusEngMceUtils::GetDisplayL( *iSession ); |
538 // From MLcSession |
337 return display->IsEnabled(); |
539 // ----------------------------------------------------------------------------- |
338 } |
540 // |
339 |
541 TBool CMusEngMceSession::SendDialTone( TChar /*aKey*/) |
340 |
542 { |
341 // ----------------------------------------------------------------------------- |
543 // Handle Key once implemented |
342 // Mutes playback of sended audio streams. Audio data is still streamed. |
544 return ETrue; |
343 // ----------------------------------------------------------------------------- |
545 } |
344 // |
546 |
345 EXPORT_C void CMusEngMceSession::MuteL() |
547 // ----------------------------------------------------------------------------- |
346 { |
548 // From MLcAudioControl |
347 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::Mute()" ) |
549 // ----------------------------------------------------------------------------- |
348 |
550 // |
|
551 TBool CMusEngMceSession::IsLcAudioMutedL() |
|
552 { |
|
553 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
349 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
554 |
350 |
555 TBool containsAudio( EFalse ); |
351 DoMuteSpeakerL( ETrue ); |
556 for ( TInt i = 0; i < iSession->Streams().Count(); ++i ) |
352 |
557 { |
353 // Mark speaker as explicitly muted instead of muted because of disabling |
558 if ( iSession->Streams()[i]->Type() == KMceAudio ) |
354 // bundled display |
559 { |
355 iExplicitlyMuted = ETrue; |
560 containsAudio = ETrue; |
356 |
561 } |
357 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::Mute()" ) |
562 } |
358 } |
563 |
359 |
564 if ( containsAudio && !iExplicitlyMuted ) |
360 |
565 { |
361 // ----------------------------------------------------------------------------- |
566 return EFalse; |
362 // Unmutes playback of sended audio streams. |
567 } |
363 // ----------------------------------------------------------------------------- |
568 |
364 // |
569 return ETrue; |
365 EXPORT_C void CMusEngMceSession::UnmuteL() |
570 } |
366 { |
571 |
367 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::Unmute()" ) |
572 // ----------------------------------------------------------------------------- |
368 |
573 // From MLcAudioControl |
|
574 // ----------------------------------------------------------------------------- |
|
575 // |
|
576 void CMusEngMceSession::MuteLcAudioL( TBool aMute ) |
|
577 { |
|
578 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
369 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
579 |
370 |
580 DoMuteSpeakerL( aMute ); |
371 DoMuteSpeakerL( EFalse ); |
581 iExplicitlyMuted = aMute; |
372 |
582 } |
373 // Mark speaker as explicitly unmuted instead of unmuted because of |
583 |
374 // enabling bundled display |
584 // ----------------------------------------------------------------------------- |
375 iExplicitlyMuted = EFalse; |
585 // From MLcAudioControl |
376 |
586 // ----------------------------------------------------------------------------- |
377 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::Unmute()" ) |
587 // |
378 } |
588 TBool CMusEngMceSession::IsLcMicMutedL() |
379 |
589 { |
380 // ----------------------------------------------------------------------------- |
590 return iTelephoneUtils->IsMicMutedL(); |
381 // |
591 } |
382 // ----------------------------------------------------------------------------- |
592 |
383 // |
593 // ----------------------------------------------------------------------------- |
384 void CMusEngMceSession::RefreshOrientationL() |
594 // From MLcAudioControl |
385 { |
595 // ----------------------------------------------------------------------------- |
386 MUS_LOG( "mus: [ENGINE] <-> CMusEngMceSession::RefreshOrientationL()" ) |
596 // |
387 } |
597 void CMusEngMceSession::MuteLcMicL( TBool aMute ) |
388 |
598 { |
389 // ----------------------------------------------------------------------------- |
599 iTelephoneUtils->MuteMicL( aMute ); |
390 // |
600 } |
391 // ----------------------------------------------------------------------------- |
601 |
392 // |
602 // ----------------------------------------------------------------------------- |
393 CMusEngMceSession::CMusEngMceSession( const TRect& aRect, |
603 // From MLcAudioControl |
394 MMusEngSessionObserver& aSessionObserver ) |
604 // ----------------------------------------------------------------------------- |
395 : CMusEngSession( aRect ), |
605 // |
396 iSessionObserver( aSessionObserver ), |
606 TBool CMusEngMceSession::IsEnablingLcLoudspeakerAllowed() |
397 iSecondsFromLastRtcpReport ( 0 ), |
607 { |
398 // Although speaker is constructed as muted, it is not explicitly muted |
608 return iTelephoneUtils->AudioRoutingCanBeChanged(); |
399 iExplicitlyMuted( EFalse ) |
609 } |
400 { |
610 |
401 } |
611 // ----------------------------------------------------------------------------- |
402 |
612 // From MLcAudioControl |
403 |
613 // ----------------------------------------------------------------------------- |
404 // ----------------------------------------------------------------------------- |
614 // |
405 // |
615 void CMusEngMceSession::EnableLcLoudspeakerL( TBool aEnabled ) |
406 // ----------------------------------------------------------------------------- |
616 { |
407 // |
617 TRAPD( error, iTelephoneUtils->LoudspeakerL( aEnabled ) ) |
408 void CMusEngMceSession::ConstructL() |
618 |
409 { |
619 if ( error != KErrNone ) |
410 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::ConstructL()" ) |
620 { |
411 CMusEngSession::ConstructL(); // Base class ConstructL -first |
621 // This is writed for emulator use |
412 |
622 if ( error != KErrNotSupported ) |
413 // Creating new MCE Manager and set all needed observers to this class. |
623 { |
414 iManager = CMceManager::NewL( TUid::Uid( KMusUiUid ), |
624 MUS_LOG1( "mus: [ENGINE] CMusEngSession::EnableLoudspeakerL() Leave: #%d", |
415 &iTransactionDataContainer ); |
625 error ) |
416 |
626 User::Leave( error ); |
417 iManager->SetSessionObserver( this ); |
627 } |
418 iManager->SetInSessionObserver( this ); |
628 // Not leave in emulator if KErrNotSupported |
419 iManager->SetMediaObserver( this ); |
629 #if (!defined (__WINS__) && !defined(__WINSCW__)) |
420 iManager->SetRtpObserver( this ); |
630 User::Leave( error ); |
421 |
631 #endif |
422 // Check if operator specific behavior is expected |
632 } |
423 iOperatorVariant = ( MultimediaSharingSettings::OperatorVariantSettingL() == |
633 } |
424 MusSettingsKeys::EOperatorSpecific ); |
634 |
425 |
635 // ----------------------------------------------------------------------------- |
426 // Update timer initialization |
636 // From MLcAudioControl |
427 iUpdateTimer = CMusEngSessionDurationTimer::NewL( *this ); |
637 // ----------------------------------------------------------------------------- |
428 |
638 // |
429 iSipProfileHandler = CMusSipProfileHandler::NewL( *this ); |
639 TBool CMusEngMceSession::IsLcLoudspeakerEnabled() |
430 |
640 { |
431 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::ConstructL()" ) |
641 return iTelephoneUtils->IsLoudSpeakerEnabled(); |
432 } |
642 } |
433 |
643 |
|
644 // ----------------------------------------------------------------------------- |
|
645 // From MLcAudioControl |
|
646 // ----------------------------------------------------------------------------- |
|
647 // |
|
648 TInt CMusEngMceSession::LcVolumeL() |
|
649 { |
|
650 return iTelephoneUtils->GetVolumeL(); |
|
651 } |
|
652 |
|
653 // ----------------------------------------------------------------------------- |
|
654 // From MLcAudioControl |
|
655 // ----------------------------------------------------------------------------- |
|
656 // |
|
657 void CMusEngMceSession::SetLcVolumeL( TInt aValue ) |
|
658 { |
|
659 iTelephoneUtils->SetVolumeL( aValue ); |
|
660 } |
|
661 |
|
662 // ----------------------------------------------------------------------------- |
|
663 // From MLcAudioControl |
|
664 // ----------------------------------------------------------------------------- |
|
665 // |
|
666 void CMusEngMceSession::IncreaseLcVolumeL() |
|
667 { |
|
668 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
|
669 |
|
670 TInt currentVolume = iTelephoneUtils->GetVolumeL(); |
|
671 iTelephoneUtils->SetVolumeL( currentVolume + 1 ); |
|
672 SetSpeakerVolumeL( LcVolumeL() ); |
|
673 } |
|
674 |
|
675 // ----------------------------------------------------------------------------- |
|
676 // From MLcAudioControl |
|
677 // ----------------------------------------------------------------------------- |
|
678 // |
|
679 void CMusEngMceSession::DecreaseLcVolumeL() |
|
680 { |
|
681 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
|
682 |
|
683 TInt currentVolume = iTelephoneUtils->GetVolumeL(); |
|
684 iTelephoneUtils->SetVolumeL( currentVolume - 1 ); |
|
685 SetSpeakerVolumeL( LcVolumeL() ); |
|
686 } |
|
687 |
|
688 // ----------------------------------------------------------------------------- |
|
689 // |
|
690 // ----------------------------------------------------------------------------- |
|
691 // |
|
692 MLcSessionObserver* CMusEngMceSession::LcSessionObserver() |
|
693 { |
|
694 return iLcSessionObserver; |
|
695 } |
|
696 |
|
697 // ----------------------------------------------------------------------------- |
|
698 // |
|
699 // ----------------------------------------------------------------------------- |
|
700 // |
|
701 MLcUiProvider* CMusEngMceSession::LcUiProvider() |
|
702 { |
|
703 return iLcUiProvider; |
|
704 } |
|
705 |
|
706 // ----------------------------------------------------------------------------- |
|
707 // Returns estabilished session time. If not established return |
|
708 // value is < 0 |
|
709 // ----------------------------------------------------------------------------- |
|
710 // |
|
711 TTimeIntervalSeconds CMusEngMceSession::GetSessionTime() const |
|
712 { |
|
713 if ( iSession && iSession->State() == CMceSession::EEstablished ) |
|
714 { |
|
715 TTime time; |
|
716 TTimeIntervalSeconds seconds; |
|
717 time.HomeTime(); |
|
718 |
|
719 time.SecondsFrom( iStartTime, seconds ); |
|
720 |
|
721 return seconds; |
|
722 } |
|
723 |
|
724 return TTimeIntervalSeconds( KErrNotReady ); |
|
725 } |
|
726 |
434 |
727 // ----------------------------------------------------------------------------- |
435 // ----------------------------------------------------------------------------- |
728 // |
436 // |
729 // ----------------------------------------------------------------------------- |
437 // ----------------------------------------------------------------------------- |
730 // |
438 // |
741 } |
449 } |
742 |
450 |
743 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::RectChangedL()" ) |
451 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::RectChangedL()" ) |
744 } |
452 } |
745 |
453 |
746 // ----------------------------------------------------------------------------- |
|
747 // |
|
748 // ----------------------------------------------------------------------------- |
|
749 // |
|
750 void CMusEngMceSession::InformObserverAboutSessionStateChange() |
|
751 { |
|
752 if ( iLcSessionObserver ) |
|
753 { |
|
754 iLcSessionObserver->StateChanged( *this ); |
|
755 } |
|
756 } |
|
757 |
|
758 // ----------------------------------------------------------------------------- |
|
759 // |
|
760 // ----------------------------------------------------------------------------- |
|
761 // |
|
762 void CMusEngMceSession::InformObserverAboutSessionUpdate() |
|
763 { |
|
764 if ( iLcSessionObserver ) |
|
765 { |
|
766 iLcSessionObserver->Updated( *this ); |
|
767 } |
|
768 } |
|
769 |
|
770 // ----------------------------------------------------------------------------- |
|
771 // |
|
772 // ----------------------------------------------------------------------------- |
|
773 // |
|
774 void CMusEngMceSession::InformObserverAboutSessionFailure( TInt aReason ) |
|
775 { |
|
776 if ( iLcSessionObserver ) |
|
777 { |
|
778 iLcSessionObserver->Failed( *this, aReason ); |
|
779 } |
|
780 } |
|
781 |
|
782 // ----------------------------------------------------------------------------- |
|
783 // |
|
784 // ----------------------------------------------------------------------------- |
|
785 // |
|
786 void CMusEngMceSession::InformObserverAboutPlayerStateChange( |
|
787 MLcVideoPlayer* aPlayer ) |
|
788 { |
|
789 if ( iLcSessionObserver && aPlayer ) |
|
790 { |
|
791 iLcSessionObserver->StateChanged( *aPlayer ); |
|
792 } |
|
793 |
|
794 } |
|
795 |
|
796 // ----------------------------------------------------------------------------- |
|
797 // |
|
798 // ----------------------------------------------------------------------------- |
|
799 // |
|
800 void CMusEngMceSession::InformUiProviderAboutReceivingStart() |
|
801 { |
|
802 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::InformUiProviderAboutReceivingStart()" ) |
|
803 if ( iBackground && iLcUiProvider ) |
|
804 { |
|
805 MUS_LOG( "mus: [ENGINE] receiving started in BG mode, switching to FG" ) |
|
806 iLcUiProvider->HandleForegroundStatus( ETrue ); |
|
807 } |
|
808 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::InformUiProviderAboutReceivingStart()" ) |
|
809 } |
|
810 |
|
811 // ----------------------------------------------------------------------------- |
|
812 // |
|
813 // ----------------------------------------------------------------------------- |
|
814 // |
|
815 void CMusEngMceSession::InformObserverAboutPlayerUpdate( |
|
816 MLcVideoPlayer* aPlayer ) |
|
817 { |
|
818 if ( iLcSessionObserver && aPlayer ) |
|
819 { |
|
820 iLcSessionObserver->Updated( *aPlayer ); |
|
821 } |
|
822 } |
|
823 |
|
824 // ----------------------------------------------------------------------------- |
|
825 // |
|
826 // ----------------------------------------------------------------------------- |
|
827 // |
|
828 void CMusEngMceSession::InformObserverAboutPlayerFailure( |
|
829 MLcVideoPlayer* aPlayer, |
|
830 TInt aReason ) |
|
831 { |
|
832 if ( iLcSessionObserver && aPlayer ) |
|
833 { |
|
834 iLcSessionObserver->Failed( *aPlayer, aReason ); |
|
835 } |
|
836 } |
|
837 |
|
838 // ----------------------------------------------------------------------------- |
|
839 // |
|
840 // ----------------------------------------------------------------------------- |
|
841 // |
|
842 MLcUiProvider& CMusEngMceSession::LcUiProviderL() |
|
843 { |
|
844 __ASSERT_ALWAYS( iLcUiProvider, User::Leave( KErrNotReady ) ); |
|
845 return *iLcUiProvider; |
|
846 } |
|
847 |
|
848 // ----------------------------------------------------------------------------- |
|
849 // |
|
850 // ----------------------------------------------------------------------------- |
|
851 // |
|
852 void CMusEngMceSession::AddSdpBandwidthAttributesL( CDesC8Array& aSdpLinesArray, |
|
853 TInt aBandwidthAs ) |
|
854 { |
|
855 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::AddSdpBandwidthAttributesL()" ) |
|
856 const TInt KMusNumberMaxLength = 10; |
|
857 HBufC8* bandwidth = HBufC8::NewLC( |
|
858 KMusEngSessionSdpLineTiasLine().Length() + KMusNumberMaxLength ); |
|
859 |
|
860 bandwidth->Des().Copy( KMusEngSessionSdpLineBandwidthLine() ); |
|
861 bandwidth->Des().AppendNum( aBandwidthAs ); |
|
862 bandwidth->Des().Append( KMusEngNewLine() ); |
|
863 aSdpLinesArray.AppendL( *bandwidth ); |
|
864 |
|
865 bandwidth->Des().Copy( KMusEngSessionSdpLineTiasLine() ); |
|
866 bandwidth->Des().AppendNum( aBandwidthAs * KMusTiasMultiplier ); |
|
867 bandwidth->Des().Append( KMusEngNewLine() ); |
|
868 aSdpLinesArray.AppendL( *bandwidth ); |
|
869 |
|
870 CleanupStack::PopAndDestroy( bandwidth ); |
|
871 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::AddSdpBandwidthAttributesL()" ) |
|
872 } |
|
873 |
|
874 // ----------------------------------------------------------------------------- |
|
875 // |
|
876 // ----------------------------------------------------------------------------- |
|
877 // |
|
878 TBool CMusEngMceSession::IsBandwidthAttributeSet( MDesC8Array* aSdpLinesArray ) |
|
879 { |
|
880 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::IsBandwidthAttributeSet()" ) |
|
881 TBool ret = |
|
882 ContainsText( aSdpLinesArray, KMusEngSessionSdpLineTiasLine() ) || |
|
883 ContainsText( aSdpLinesArray, KMusEngSessionSdpLineBandwidthLine() ); |
|
884 MUS_LOG1( "mus: [ENGINE] <- CMusEngMceSession::IsBandwidthAttributeSet(): %d", |
|
885 ret ) |
|
886 return ret; |
|
887 } |
|
888 |
454 |
889 // ----------------------------------------------------------------------------- |
455 // ----------------------------------------------------------------------------- |
890 // Setting session level sdp lines. Bandwith attribute is always used in |
456 // Setting session level sdp lines. Bandwith attribute is always used in |
891 // operator variant mode and at receiver side (using force) when TIAS |
457 // operator variant mode and at receiver side (using force). |
892 // usage is disabled. However, bandwidth attribute is preferred to be used |
458 // However, bandwidth attribute is preferred to be used at media level |
893 // at media level (see SetMediaSdpLinesL method). It is set to session level |
459 // (see SetMediaSdpLinesL method). It is set to session level only if other |
894 // only if other side is using also session level bandwidth. Media level |
460 // side is using also session level bandwidth. Media level preference exists |
895 // preference exists because some other manufacturer's videosharing does not |
461 // because some other manufacturer's videosharing does not understand session |
896 // understand session level bandwidth attribute. |
462 // level bandwidth attribute. |
897 // In non-operator variant mode and when TIAS usage is enabled, both AS and |
|
898 // TIAS are added to session level only if the other side is using session |
|
899 // level bandwidth. |
|
900 // ----------------------------------------------------------------------------- |
463 // ----------------------------------------------------------------------------- |
901 // |
464 // |
902 void CMusEngMceSession::SetSessionSdpLinesL( |
465 void CMusEngMceSession::SetSessionSdpLinesL( |
903 CMceSession& aSession, |
466 CMceSession& aSession, |
904 TBool aForceBandwidthLine ) |
467 TBool aForceBandwidthLine ) |
972 |
514 |
973 MDesC8Array* sessionSdpLines = aStream.Session()->SessionSDPLinesL(); |
515 MDesC8Array* sessionSdpLines = aStream.Session()->SessionSDPLinesL(); |
974 CleanupDeletePushL( sessionSdpLines ); |
516 CleanupDeletePushL( sessionSdpLines ); |
975 TBool bandwidthAtSessionLevel( ContainsText( sessionSdpLines, |
517 TBool bandwidthAtSessionLevel( ContainsText( sessionSdpLines, |
976 KMusEngSessionSdpLineBandwidthLine() ) ); |
518 KMusEngSessionSdpLineBandwidthLine() ) ); |
977 |
|
978 TInt bandwidthAs = 0; |
|
979 TRAPD( error, bandwidthAs = |
|
980 MultimediaSharingSettings::VideoBandwidthSettingL() ); |
|
981 __ASSERT_ALWAYS( error == KErrNone || error == KErrNotFound, |
|
982 User::Leave( error ) ); |
|
983 TBool useTias = ( bandwidthAs > 0 ); |
|
984 TBool tiasOrAsAtSessionLevel = EFalse; |
|
985 TBool tiasOrAsAtMediaLevel = EFalse; |
|
986 if ( useTias ) |
|
987 { |
|
988 tiasOrAsAtSessionLevel = IsBandwidthAttributeSet( sessionSdpLines ); |
|
989 MDesC8Array* mediaSdpLines = aStream.MediaAttributeLinesL(); |
|
990 tiasOrAsAtMediaLevel = IsBandwidthAttributeSet( mediaSdpLines ); |
|
991 delete mediaSdpLines; |
|
992 } |
|
993 |
|
994 CleanupStack::PopAndDestroy( sessionSdpLines ); |
519 CleanupStack::PopAndDestroy( sessionSdpLines ); |
995 |
520 |
996 TBool setTiasAtMediaLevel = ( tiasOrAsAtMediaLevel || |
521 if ( !bandwidthAtSessionLevel && ( iOperatorVariant || aForceBandwidthLine ) ) |
997 ( aForceBandwidthLine && |
522 { |
998 !tiasOrAsAtSessionLevel ) ); |
523 MUS_LOG( "mus: [ENGINE] setting bandwidth to media level" ) |
999 |
524 |
1000 const TInt KMusMediaSdpLinesGranularity = 2; |
525 //Add media attribute to sdp |
1001 CDesC8Array* headers = |
526 const TInt KMusMediaSdpLinesGranularity = 1; |
1002 new ( ELeave ) CDesC8ArrayFlat( KMusMediaSdpLinesGranularity ); |
527 CDesC8Array* headers = |
1003 CleanupStack::PushL( headers ); |
528 new ( ELeave ) CDesC8ArrayFlat( KMusMediaSdpLinesGranularity ); |
1004 |
529 CleanupStack::PushL( headers ); |
1005 if ( !bandwidthAtSessionLevel && ( iOperatorVariant || |
530 headers->AppendL( KMusEngSessionSdpLineBandwidthField() ); |
1006 ( aForceBandwidthLine && !useTias ) ) ) |
531 aStream.SetMediaAttributeLinesL( headers ); |
1007 { |
532 CleanupStack::Pop( headers ); |
1008 MUS_LOG( "mus: [ENGINE] setting bandwidth to media level" ) |
533 } |
1009 headers->AppendL( KMusEngSessionSdpLineBandwidthField() ); |
534 |
1010 } |
|
1011 else if ( !iOperatorVariant && useTias && setTiasAtMediaLevel ) |
|
1012 { |
|
1013 MUS_LOG( "mus: [ENGINE] setting b=AS and b=TIAS to media level" ) |
|
1014 AddSdpBandwidthAttributesL( *headers, bandwidthAs ); |
|
1015 } |
|
1016 |
|
1017 aStream.SetMediaAttributeLinesL( headers ); |
|
1018 CleanupStack::Pop( headers ); |
|
1019 |
|
1020 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::SetMediaSdpLinesL()" ) |
535 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::SetMediaSdpLinesL()" ) |
1021 } |
536 } |
1022 |
537 |
1023 // ----------------------------------------------------------------------------- |
538 // ----------------------------------------------------------------------------- |
1024 // Changes volume of all speaker sinks in the session structure |
539 // Changes volume of all speaker sinks in the session structure |
1365 { |
912 { |
1366 if ( !aActive ) |
913 if ( !aActive ) |
1367 { |
914 { |
1368 MUS_LOG( "mus: [ENGINE] CMusEngMceSession::\ |
915 MUS_LOG( "mus: [ENGINE] CMusEngMceSession::\ |
1369 SessionConnectionStateChanged: Notify observer" ) |
916 SessionConnectionStateChanged: Notify observer" ) |
1370 InformObserverAboutSessionFailure( MLcSession::EConnectionLost ); |
917 iSessionObserver.SessionConnectionLost(); |
1371 } |
918 } |
1372 } |
919 } |
1373 |
920 |
1374 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::\ |
921 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::\ |
1375 SessionConnectionStateChanged()" ) |
922 SessionConnectionStateChanged()" ) |
1376 } |
923 } |
1377 |
924 |
1378 // ----------------------------------------------------------------------------- |
925 |
1379 // |
926 // ----------------------------------------------------------------------------- |
1380 // ----------------------------------------------------------------------------- |
927 // |
1381 // |
928 // ----------------------------------------------------------------------------- |
|
929 // |
|
930 |
|
931 #if ( defined( _DEBUG ) && !defined( UNIT_TESTING ) ) |
1382 void CMusEngMceSession::Failed( CMceSession& aSession, TInt aError ) |
932 void CMusEngMceSession::Failed( CMceSession& aSession, TInt aError ) |
|
933 #else |
|
934 void CMusEngMceSession::Failed( CMceSession& aSession, TInt /*aError*/ ) |
|
935 #endif |
1383 { |
936 { |
1384 MUS_LOG1( "mus: [ENGINE] -> CMusEngMceSession::Failed() error #%d", |
937 MUS_LOG1( "mus: [ENGINE] -> CMusEngMceSession::Failed() error #%d", |
1385 aError ) |
938 aError ) |
1386 |
939 |
1387 if ( iSession && iSession == &aSession ) |
940 if ( iSession && iSession == &aSession ) |
1388 { |
941 { |
1389 MUS_LOG( "mus: [ENGINE] CMusEngMceSession::Failed: Notify observer" ) |
942 MUS_LOG( "mus: [ENGINE] CMusEngMceSession::Failed: Notify observer" ) |
1390 InformObserverAboutSessionFailure( aError ); |
943 iSessionObserver.SessionFailed(); |
1391 } |
944 } |
1392 |
945 |
1393 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::Failed()" ) |
946 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::Failed()" ) |
1394 } |
947 } |
1395 |
948 |
|
949 |
1396 // ----------------------------------------------------------------------------- |
950 // ----------------------------------------------------------------------------- |
1397 // |
951 // |
1398 // ----------------------------------------------------------------------------- |
952 // ----------------------------------------------------------------------------- |
1399 // |
953 // |
1400 void CMusEngMceSession::UpdateFailed( |
954 void CMusEngMceSession::UpdateFailed( |
1401 CMceSession& aSession, |
955 CMceSession& aSession, |
1402 TMceTransactionDataContainer* aContainer ) |
956 TMceTransactionDataContainer* aContainer ) |
1403 { |
957 { |
1404 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::UpdateFailed()" ) |
958 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::UpdateFailed()" ) |
1405 |
959 |
1406 if ( !aContainer ) |
960 if ( !aContainer ) |
1407 { |
961 { |
1408 // Container should never be NULL, but if it is, handle as |
962 // Container should never be NULL, but if it is, handle as |
1409 // internal error |
963 // internal error |
1410 InformObserverAboutSessionFailure( KErrGeneral ); |
964 iSessionObserver.SessionFailed(); |
1411 return; |
965 return; |
1412 } |
966 } |
1413 |
967 |
1414 if ( iSession && iSession == &aSession ) |
968 if ( iSession && iSession == &aSession ) |
1415 { |
969 { |
1416 MUS_LOG( "mus: [ENGINE] CMusEngMceSession::UpdateFailed: \ |
970 MUS_LOG( "mus: [ENGINE] CMusEngMceSession::UpdateFailed: \ |
1417 Notify observer" ) |
971 Notify observer" ) |
1418 InformObserverAboutSessionFailure( KErrGeneral ); |
972 iSessionObserver.SessionFailed(); |
1419 } |
973 } |
1420 |
974 |
1421 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::UpdateFailed()" ) |
975 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::UpdateFailed()" ) |
1422 } |
976 } |
|
977 |
1423 |
978 |
1424 // ----------------------------------------------------------------------------- |
979 // ----------------------------------------------------------------------------- |
1425 // |
980 // |
1426 // ----------------------------------------------------------------------------- |
981 // ----------------------------------------------------------------------------- |
1427 // |
982 // |
1549 if ( iSession && iSession == &aSession ) |
1100 if ( iSession && iSession == &aSession ) |
1550 { |
1101 { |
1551 switch ( aSession.State() ) |
1102 switch ( aSession.State() ) |
1552 { |
1103 { |
1553 case CMceSession::EIdle: |
1104 case CMceSession::EIdle: |
1554 case CMceSession::EIncoming: |
|
1555 { |
1105 { |
1556 MUS_LOG( "mus: [ENGINE] Unexpected asynchronous \ |
1106 MUS_LOG( "mus: [ENGINE] Unexpected asynchronous \ |
1557 state transition, consider session as failed." ) |
1107 state transition, consider session as failed." ) |
1558 InformObserverAboutSessionFailure( KErrGeneral ); |
1108 iSessionObserver.SessionFailed(); |
1559 break; |
1109 break; |
1560 } |
1110 } |
|
1111 case CMceSession::EOffering : |
|
1112 { |
|
1113 break; |
|
1114 } |
|
1115 case CMceSession::EIncoming: |
|
1116 { |
|
1117 MUS_LOG( "mus: [ENGINE] Unexpected asynchronous \ |
|
1118 state transition, consider session as failed." ) |
|
1119 iSessionObserver.SessionFailed(); |
|
1120 break; |
|
1121 } |
|
1122 case CMceSession::EReserving : |
|
1123 { |
|
1124 // UpdateL called to incoming session during |
|
1125 // session establishment |
|
1126 break; |
|
1127 } |
|
1128 case CMceSession::EAnswering : // Answering an incoming call |
|
1129 { |
|
1130 break; |
|
1131 } |
|
1132 case CMceSession::EProceeding : |
|
1133 { |
|
1134 break; |
|
1135 } |
1561 case CMceSession::EEstablished: |
1136 case CMceSession::EEstablished: |
1562 { |
1137 { |
1563 if ( iStoreEncoderConfigInfo ) |
|
1564 { |
|
1565 iStoreEncoderConfigInfo = EFalse; |
|
1566 TRAPD( error, StoreEncoderConfigInfoL() ) |
|
1567 if ( error != KErrNone && error != KErrNotFound ) |
|
1568 { |
|
1569 // Only acceptable error is absence of repository entry, |
|
1570 // otherwise we inform user about failed session. |
|
1571 InformObserverAboutSessionFailure( error ); |
|
1572 return; |
|
1573 } |
|
1574 } |
|
1575 |
|
1576 // Check that session timer is not already running, which is |
1138 // Check that session timer is not already running, which is |
1577 // the case when refreshing the session with session timer |
1139 // the case when refreshing the session with session timer |
1578 if ( !iUpdateTimer->IsActive() ) |
1140 if ( !iUpdateTimer->IsActive() ) |
1579 { |
1141 { |
1580 iStartTime.HomeTime(); // Start counting session duration |
1142 iStartTime.HomeTime(); // Start counting session duration |
1581 iUpdateTimer->Start( KMusEngTimerInterval ); |
1143 iUpdateTimer->Start( KMusEngTimerInterval ); |
1582 InformObserverAboutSessionStateChange(); |
1144 iSessionObserver.SessionEstablished(); |
1583 } |
1145 } |
1584 |
1146 |
1585 break; |
1147 break; |
1586 } |
1148 } |
1587 case CMceSession::EOffering: |
|
1588 case CMceSession::EReserving: |
|
1589 case CMceSession::EAnswering: |
|
1590 case CMceSession::EProceeding: |
|
1591 case CMceSession::ECancelling: |
1149 case CMceSession::ECancelling: |
|
1150 { |
|
1151 // MCE has for some reason started to cancel session |
|
1152 break; |
|
1153 } |
1592 case CMceSession::ETerminating: |
1154 case CMceSession::ETerminating: |
1593 { |
1155 { |
1594 // NOP |
1156 // MCE has for some reason started to terminate session |
1595 break; |
1157 break; |
1596 } |
1158 } |
1597 case CMceSession::ETerminated: |
1159 case CMceSession::ETerminated: |
1598 { |
1160 { |
1599 HandleTermination( aStatusCode, aReasonPhrase ); |
1161 HandleTermination( aStatusCode, aReasonPhrase ); |
1609 } |
1171 } |
1610 |
1172 |
1611 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::HandleSessionStateChanged" ) |
1173 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::HandleSessionStateChanged" ) |
1612 } |
1174 } |
1613 |
1175 |
|
1176 |
1614 // ----------------------------------------------------------------------------- |
1177 // ----------------------------------------------------------------------------- |
1615 // This function should be called only if sibling classes cannot handle |
1178 // This function should be called only if sibling classes cannot handle |
1616 // termination reason by themselves. |
1179 // termination reason by themselves. |
1617 // ----------------------------------------------------------------------------- |
1180 // ----------------------------------------------------------------------------- |
1618 // |
1181 // |
1619 void CMusEngMceSession::HandleTermination( TInt aStatusCode, |
1182 void CMusEngMceSession::HandleTermination( TInt aStatusCode, |
1620 const TDesC8& /*aReasonPhrase*/ ) |
1183 const TDesC8& /*aReasonPhrase*/ ) |
1621 { |
1184 { |
1622 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::HandleTermination()" ) |
1185 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::HandleTermination()" ) |
1623 |
1186 |
1624 iSipProfileHandler->RefreshIapAvailabilities(); |
1187 iSipProfileHandler->RefreshIapAvailabilities(); |
1625 |
1188 |
1626 switch ( aStatusCode ) |
1189 switch ( aStatusCode ) |
1627 { |
1190 { |
1628 case 0: |
1191 case 0: |
1629 { |
1192 { |
1630 // Normal session termination or session by another end. |
1193 // Normal session termination or session by another end. |
1631 InformObserverAboutSessionStateChange(); |
1194 iSessionObserver.SessionTerminated(); |
1632 break; |
1195 break; |
1633 } |
1196 } |
1634 case KMusEngSipReasonCodeOk: |
1197 case KMusEngSipReasonCodeOk: |
1635 { |
1198 { |
1636 // Normal session termination by this end: We have sent BYE |
1199 // Normal session termination by this end: We have sent BYE |
1637 // and now received 200 OK to it. |
1200 // and now received 200 OK to it. |
1638 InformObserverAboutSessionStateChange(); |
1201 iSessionObserver.SessionTerminated(); |
1639 break; |
1202 break; |
1640 } |
1203 } |
1641 default: |
1204 default: |
1642 { |
1205 { |
1643 // Termination reason cannot be determined, handle as internal |
1206 // Termination reason cannot be determined, handle as internal |
1644 // error. |
1207 // error. |
1645 InformObserverAboutSessionFailure( KErrGeneral ); |
1208 iSessionObserver.SessionFailed(); |
1646 break; |
1209 break; |
1647 } |
1210 } |
1648 } |
1211 } |
1649 |
1212 |
1650 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::HandleTermination()" ) |
1213 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::HandleTermination()" ) |
1651 } |
1214 } |
1652 |
1215 |
1653 // ----------------------------------------------------------------------------- |
1216 |
1654 // |
1217 // ----------------------------------------------------------------------------- |
1655 // ----------------------------------------------------------------------------- |
1218 // |
1656 // |
1219 // ----------------------------------------------------------------------------- |
1657 void CMusEngMceSession::AdjustVideoCodecL( CMceVideoCodec& aVideoCodec, |
1220 // |
1658 TMceSourceType aSourceType ) |
1221 void CMusEngMceSession::AdjustVideoCodecL( CMceVideoCodec& aVideoCodec ) |
1659 { |
1222 { |
1660 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::AdjustVideoCodecL()" ) |
1223 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::AdjustVideoCodecL()" ) |
1661 |
1224 |
1662 aVideoCodec.SetMMFPriorityL( KAudioPrioritySwisPlayback ); |
1225 aVideoCodec.SetMMFPriorityL( KAudioPrioritySwisPlayback ); |
1663 aVideoCodec.SetMMFPriorityPreferenceL( KAudioPrefSwisPlayback ); |
1226 aVideoCodec.SetMMFPriorityPreferenceL( KAudioPrefSwisPlayback ); |
1664 |
1227 MUS_LOG( "mus: [ENGINE] Video MMF priority and preference set" ) |
1665 if ( aVideoCodec.SdpName() == KMceSDPNameH264() && |
1228 |
1666 aSourceType == KMceCameraSource ) |
|
1667 { |
|
1668 SetCodecConfigKeyL( aVideoCodec ); |
|
1669 SetEncodingDeviceL( aVideoCodec ); |
|
1670 } |
|
1671 |
|
1672 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::AdjustVideoCodecL()" ) |
1229 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::AdjustVideoCodecL()" ) |
1673 } |
1230 } |
|
1231 |
1674 |
1232 |
1675 // ----------------------------------------------------------------------------- |
1233 // ----------------------------------------------------------------------------- |
1676 // 1. Sets MMF audio priority and preference |
1234 // 1. Sets MMF audio priority and preference |
1677 // ----------------------------------------------------------------------------- |
1235 // ----------------------------------------------------------------------------- |
1678 // |
1236 // |
1886 |
1453 |
1887 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::DoCodecModeBasedRemovalL()" ) |
1454 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::DoCodecModeBasedRemovalL()" ) |
1888 } |
1455 } |
1889 |
1456 |
1890 // ----------------------------------------------------------------------------- |
1457 // ----------------------------------------------------------------------------- |
1891 // |
1458 // |
1892 // ----------------------------------------------------------------------------- |
1459 // ----------------------------------------------------------------------------- |
1893 // |
1460 // |
1894 void CMusEngMceSession::SetEncodingDeviceL( CMceVideoCodec& aVideoCodec ) |
1461 void CMusEngMceSession::DoCodecConfigurationBasedRemovalL( CMceVideoStream& aVideoStream ) |
1895 { |
1462 { |
1896 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::SetEncodingDeviceL()" ) |
1463 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::DoCodecConfigurationBasedRemovalL()" ) |
1897 |
1464 if( MultimediaSharingSettings::IsAvcDisabled()) |
1898 // We try to read encoding device UID. If we do not succeed, we use default |
1465 { |
1899 |
1466 RPointerArray<CMceVideoCodec>& codecs = |
1900 const TUid KDefaultEncodingDevice( TUid::Uid( 0x20001C13 ) ); |
1467 MUS_CODEC_ARR_CONST_CAST( aVideoStream.Codecs() ); |
1901 TUid encodingDevice( KDefaultEncodingDevice ); |
1468 TInt codecIndex = 0; |
1902 TRAPD( error, |
1469 while ( codecIndex < codecs.Count() ) |
1903 encodingDevice = MultimediaSharingSettings::EncodingDeviceL() ) |
1470 { |
1904 __ASSERT_ALWAYS( error == KErrNone || error == KErrNotFound, |
1471 CMceVideoCodec& currentCodec = *codecs[codecIndex++]; |
1905 User::Leave( error ) ); |
1472 if ( !currentCodec.SdpName().CompareF( KMceSDPNameH264 ) ) |
1906 aVideoCodec.SetPreferredEncodingDecodingDeviceL( encodingDevice ); |
1473 { |
1907 |
1474 MUS_LOG( "mus: [ENGINE] - Removing avc from supported codec list" ) |
1908 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::SetEncodingDeviceL()" ) |
1475 aVideoStream.RemoveCodecL( currentCodec ); |
1909 } |
1476 codecs = MUS_CODEC_ARR_CONST_CAST( aVideoStream.Codecs() ); |
1910 |
1477 codecIndex = 0; |
1911 // ----------------------------------------------------------------------------- |
1478 } |
1912 // |
1479 } |
1913 // ----------------------------------------------------------------------------- |
1480 } |
1914 // |
1481 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::DoCodecConfigurationBasedRemovalL()" ) |
1915 void CMusEngMceSession::SetCodecConfigKeyL( CMceVideoCodec& aVideoCodec ) |
1482 } |
1916 { |
1483 |
1917 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::SetCodecConfigKeyL()" ) |
1484 // ----------------------------------------------------------------------------- |
1918 |
1485 // |
1919 HBufC8* configKey( NULL ); |
1486 // ----------------------------------------------------------------------------- |
1920 |
1487 // |
1921 // We try to read config key. If we do not succeed, we prepare to |
1488 void CMusEngMceSession::VolumeChanged( TInt aVolume, TBool aAudioRouteChanged ) |
1922 // write keys to CenRep for the next time. |
1489 { |
1923 TRAPD( error, configKey = ReadCodecConfigKeyL( aVideoCodec ) ) |
1490 MUS_LOG1( "mus: [ENGINE] -> CMusEngMceSession::VolumeChanged(): %d", aVolume ) |
1924 |
1491 if ( iSession ) |
1925 if ( error == KErrNone ) |
1492 { |
1926 { |
1493 CMusEngSession::VolumeChanged( aVolume, aAudioRouteChanged ); |
1927 // There is a repository for config keys |
1494 TRAP_IGNORE( SetSpeakerVolumeL( aVolume ) ); |
1928 if ( configKey ) |
1495 } |
1929 { |
1496 |
1930 // ...and key is found. |
1497 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::VolumeChanged()" ) |
1931 CleanupStack::PushL( configKey ); |
1498 } |
1932 aVideoCodec.SetConfigKeyL( *configKey ); |
|
1933 CleanupStack::PopAndDestroy( configKey ); |
|
1934 } |
|
1935 else |
|
1936 { |
|
1937 // ...but key is not found, so it must be written to CenRep when |
|
1938 // available. |
|
1939 iStoreEncoderConfigInfo = ETrue; |
|
1940 } |
|
1941 } |
|
1942 else if ( error == KErrNotFound ) |
|
1943 { |
|
1944 // There is no repository for config keys so there is no point |
|
1945 // trying to write anything there. Session setup can still continue. |
|
1946 MUS_LOG1( "mus: [ENGINE] No repository for config keys [%d]", error ) |
|
1947 } |
|
1948 else |
|
1949 { |
|
1950 User::Leave( error ); |
|
1951 } |
|
1952 |
|
1953 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::SetCodecConfigKeyL()" ) |
|
1954 } |
|
1955 |
|
1956 // ----------------------------------------------------------------------------- |
|
1957 // |
|
1958 // ----------------------------------------------------------------------------- |
|
1959 // |
|
1960 HBufC8* CMusEngMceSession::ReadCodecConfigKeyL( |
|
1961 const CMceVideoCodec& aVideoCodec ) const |
|
1962 { |
|
1963 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::ReadCodecConfigKeyL()" ) |
|
1964 |
|
1965 HBufC8* key( NULL ); |
|
1966 |
|
1967 HBufC8* encoderInfo = MultimediaSharingSettings::EncoderConfigInfoLC(); |
|
1968 __ASSERT_ALWAYS( encoderInfo, User::Leave( KErrNotFound ) ); |
|
1969 |
|
1970 TPtrC8 keyId( ConfigKeyIdL( aVideoCodec ) ); |
|
1971 |
|
1972 TInt tokenStartPosition( encoderInfo->FindC( keyId ) ); |
|
1973 if ( tokenStartPosition > KErrNotFound ) |
|
1974 { |
|
1975 TInt tokenLength( encoderInfo->Mid( tokenStartPosition ).FindC( |
|
1976 KMusEncoderInfoTokenizer ) ); |
|
1977 if ( tokenLength > KErrNotFound ) |
|
1978 { |
|
1979 // Separate key from token by removing keyId |
|
1980 TInt keyStartPosition = tokenStartPosition + keyId.Length(); |
|
1981 TInt keyLength = tokenLength - keyId.Length(); |
|
1982 TPtrC8 keyPtr = encoderInfo->Mid( keyStartPosition, keyLength ); |
|
1983 key = keyPtr.AllocL(); |
|
1984 } |
|
1985 } |
|
1986 |
|
1987 CleanupStack::PopAndDestroy( encoderInfo ); |
|
1988 |
|
1989 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::ReadCodecConfigKeyL()" ) |
|
1990 |
|
1991 return key; |
|
1992 } |
|
1993 |
|
1994 // ----------------------------------------------------------------------------- |
|
1995 // |
|
1996 // ----------------------------------------------------------------------------- |
|
1997 // |
|
1998 void CMusEngMceSession::StoreEncoderConfigInfoL() const |
|
1999 { |
|
2000 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::StoreEncoderConfigInfoL()" ) |
|
2001 |
|
2002 HBufC8* configInfoInCenRep = MultimediaSharingSettings::EncoderConfigInfoLC(); |
|
2003 __ASSERT_ALWAYS( configInfoInCenRep, User::Leave( KErrNotFound ) ); |
|
2004 |
|
2005 TBuf8<NCentralRepositoryConstants::KMaxBinaryLength> keys; |
|
2006 keys.Append( *configInfoInCenRep ); |
|
2007 |
|
2008 CMceVideoStream* stream = MusEngMceUtils::GetVideoOutStreamL( *iSession ); |
|
2009 const RPointerArray<CMceVideoCodec>& codecs = stream->Codecs(); |
|
2010 |
|
2011 for ( TInt codecIndex = 0; codecIndex < codecs.Count(); ++codecIndex ) |
|
2012 { |
|
2013 if ( codecs[codecIndex]->SdpName().FindF( KMceSDPNameH264 ) >= 0 ) |
|
2014 { |
|
2015 const TPtrC8 keyId = ConfigKeyIdL( *codecs[codecIndex] ); |
|
2016 HBufC8* configKey = codecs[codecIndex]->ConfigKeyL(); |
|
2017 CleanupStack::PushL( configKey ); |
|
2018 |
|
2019 if ( configKey && |
|
2020 keys.FindF( keyId ) == KErrNotFound && |
|
2021 configInfoInCenRep->FindF( keyId ) == KErrNotFound ) |
|
2022 { |
|
2023 |
|
2024 if ( keys.Length() + |
|
2025 keyId.Length() + |
|
2026 configKey->Length() + |
|
2027 KMusEncoderInfoTokenizer().Length() < |
|
2028 NCentralRepositoryConstants::KMaxBinaryLength ) |
|
2029 { |
|
2030 keys.Append( keyId ); |
|
2031 keys.Append( *configKey ); |
|
2032 keys.Append( KMusEncoderInfoTokenizer ); |
|
2033 } |
|
2034 } |
|
2035 |
|
2036 CleanupStack::PopAndDestroy( configKey ); |
|
2037 } |
|
2038 } |
|
2039 |
|
2040 MultimediaSharingSettings::SetEncoderConfigInfoL( keys ); |
|
2041 |
|
2042 CleanupStack::PopAndDestroy( configInfoInCenRep ); |
|
2043 |
|
2044 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::StoreEncoderConfigInfoL()" ) |
|
2045 } |
|
2046 |
|
2047 // ----------------------------------------------------------------------------- |
|
2048 // |
|
2049 // ----------------------------------------------------------------------------- |
|
2050 // |
|
2051 const TPtrC8 CMusEngMceSession::ConfigKeyIdL( |
|
2052 const CMceVideoCodec& aVideoCodec ) const |
|
2053 { |
|
2054 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::ConfigKeyIdL()" ) |
|
2055 |
|
2056 // Currently works only for AVC |
|
2057 __ASSERT_ALWAYS( aVideoCodec.SdpName().FindF( KMceSDPNameH264 ) >= 0, |
|
2058 User::Leave( KErrArgument ) ); |
|
2059 |
|
2060 TPtrC8 configKeyTokenId; |
|
2061 |
|
2062 if ( aVideoCodec.AllowedBitrates() & KMceAvcBitrateLevel1 ) |
|
2063 { |
|
2064 configKeyTokenId.Set( KMusAvcBitrateLevel1() ); |
|
2065 } |
|
2066 else if ( aVideoCodec.AllowedBitrates() & KMceAvcBitrateLevel1b ) |
|
2067 { |
|
2068 configKeyTokenId.Set( KMusAvcBitrateLevel1b() ); |
|
2069 } |
|
2070 else if ( aVideoCodec.AllowedBitrates() & KMceAvcBitrateLevel1_1 ) |
|
2071 { |
|
2072 configKeyTokenId.Set( KMusAvcBitrateLevel1_1() ); |
|
2073 } |
|
2074 else if ( aVideoCodec.AllowedBitrates() & KMceAvcBitrateLevel1_2 ) |
|
2075 { |
|
2076 configKeyTokenId.Set( KMusAvcBitrateLevel1_2() ); |
|
2077 } |
|
2078 else if ( aVideoCodec.AllowedBitrates() & KMceAvcBitrateLevel1_3 ) |
|
2079 { |
|
2080 configKeyTokenId.Set( KMusAvcBitrateLevel1_3() ); |
|
2081 } |
|
2082 else if ( aVideoCodec.AllowedBitrates() & KMceAvcBitrateLevel2 ) |
|
2083 { |
|
2084 configKeyTokenId.Set( KMusAvcBitrateLevel2() ); |
|
2085 } |
|
2086 else |
|
2087 { |
|
2088 User::Leave( KErrNotFound ); |
|
2089 } |
|
2090 |
|
2091 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::ConfigKeyIdL()" ) |
|
2092 |
|
2093 return configKeyTokenId; |
|
2094 } |
|
2095 |
|
2096 // ----------------------------------------------------------------------------- |
|
2097 // Contact address is saved if all following apply: |
|
2098 // - standard variant |
|
2099 // - only one contact entry (mus mgr doesn't provide contact id if multiple |
|
2100 // contact entries for other end is found) |
|
2101 // - no existing sip address info for contact |
|
2102 // - address is valid sip or tel uri |
|
2103 // ----------------------------------------------------------------------------- |
|
2104 // |
|
2105 void CMusEngMceSession::SaveContactL( const TDesC8& /*aAddress*/ ) |
|
2106 { |
|
2107 MUS_LOG( "mus: [ENGINE] -> CMusEngMceSession::SaveContactL" ); |
|
2108 |
|
2109 |
|
2110 MUS_LOG( "mus: [ENGINE] <- CMusEngMceSession::SaveContactL" ); |
|
2111 } |
|
2112 |
|
2113 // ----------------------------------------------------------------------------- |
|
2114 // |
|
2115 // ----------------------------------------------------------------------------- |
|
2116 // |
|
2117 void CMusEngMceSession::StreamStreaming( CMceMediaStream& aStream ) |
|
2118 { |
|
2119 if ( aStream.State() == CMceMediaStream::EStreaming && |
|
2120 aStream.Type() == KMceVideo ) |
|
2121 { |
|
2122 MLcVideoPlayer* videoPlayer = NULL; |
|
2123 if ( aStream.Source() && |
|
2124 aStream.Source()->Type() == KMceRTPSource ) |
|
2125 { |
|
2126 videoPlayer = RemoteVideoPlayer(); |
|
2127 } |
|
2128 else if ( aStream.Sinks().Count() >= 0 && |
|
2129 aStream.Sinks()[0]->Type() == KMceRTPSink ) |
|
2130 { |
|
2131 videoPlayer = LocalVideoPlayer(); |
|
2132 } |
|
2133 else |
|
2134 { |
|
2135 } |
|
2136 InformObserverAboutPlayerStateChange( videoPlayer ); |
|
2137 } |
|
2138 } |
|
2139 |
|
2140 // End of file |
|