diff -r 73a1feb507fb -r bc78a40cd63c mmsharing/mmshengine/tsrc/ut_engine/src/ut_musenglivesession.cpp --- a/mmsharing/mmshengine/tsrc/ut_engine/src/ut_musenglivesession.cpp Tue Aug 31 15:12:07 2010 +0300 +++ b/mmsharing/mmshengine/tsrc/ut_engine/src/ut_musenglivesession.cpp Wed Sep 01 12:31:01 2010 +0100 @@ -24,8 +24,6 @@ #include "mussipprofilehandler.h" #include "musengmceutils.h" #include "mussettings.h" -#include "mussessionproperties.h" -#include "musenglivevideoplayer.h" // SYSTEM INCLUDES #include @@ -40,6 +38,31 @@ #include +_LIT8( KMusAvcBitrateLevel1TestText, "TestTextForAvcBrL1Level" ); +_LIT8( KMusAvcBitrateLevel1bTestText, "TestTextForAvcBrL1bLevel" ); +_LIT8( KMusAvcBitrateLevel1_1TestText, "TestTextForAvcBrL1_1Level" ); +_LIT8( KMusAvcBitrateLevel1_2TestText, "TestTextForAvcBrL1_2Level" ); +_LIT8( KMusAvcBitrateLevel1_3TestText, "TestTextForAvcBrL1_3Level" ); +_LIT8( KMusAvcBitrateLevel2TestText, "TestTextForAvcBrL2Level" ); + +_LIT8( KMusAvcBitrateLevel_1b_ConfigKey, "AvcBrL1b=TestTextForAvcBrL1bLevel;" ); + +_LIT8( KMusAvcBitrateLevel_1_1_ConfigKey, +"AvcBrL1_1=TestTextForAvcBrL1_1Level;"); + +_LIT8( KMusAvcBitrateLevels_1_1_And_1b_ConfigKeys, +"AvcBrL1_1=TestTextForAvcBrL1_1Level;\ +AvcBrL1b=TestTextForAvcBrL1bLevel;" ); + +_LIT8( KMusAvcAllLevelsConcatenation, +"AvcBrL1=TestTextForAvcBrL1Level;\ +AvcBrL1b=TestTextForAvcBrL1bLevel;\ +AvcBrL1_1=TestTextForAvcBrL1_1Level;\ +AvcBrL1_2=TestTextForAvcBrL1_2Level;\ +AvcBrL1_3=TestTextForAvcBrL1_3Level;\ +AvcBrL2=TestTextForAvcBrL2Level;" ); + + //use step in different time period const TInt KZoomBigStepCount = 15; @@ -116,25 +139,20 @@ // ----------------------------------------------------------------------------- // void UT_CMusEngLiveSession::SetupL() - { - iLcSessionObserver = new( ELeave )CLcSessionObserverStub; - iLcUiProvider = new( ELeave )CLcUiProviderStub; - iAudioRoutingObserver = new( ELeave )CMusEngObserverStub; + { + iObserver = new( ELeave ) CMusEngObserverStub; - iLiveSession = CMusEngLiveSession::NewL(); - iLiveSession->SetLcSessionObserver( iLcSessionObserver ); - iLiveSession->SetLcUiProvider( iLcUiProvider ); + iLiveSession = CMusEngLiveSession::NewL( TRect(0, 0, 100, 100), + *iObserver, + *iObserver, + *iObserver ); - iRecordedLiveSession = CMusEngLiveSession::NewL(); - iRecordedLiveSession->SetLcSessionObserver( iLcSessionObserver ); - iRecordedLiveSession->SetLcUiProvider( iLcUiProvider ); - MLcDestinationFileControl* destinationFileControl = - iRecordedLiveSession->LocalVideoPlayer()->LcDestinationFileControl(); - destinationFileControl->SetLcFileNameL( KTestVideoFileName() ); - - User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid, - NMusSessionApi::KRemoteSipAddress, - KTestRecipientSipUri ) ); + iRecordedLiveSession = CMusEngLiveSession::NewL( KTestVideoFileName(), + TRect(0, 0, 100, 100), + *iObserver, + *iObserver, + *iObserver ); + } @@ -146,14 +164,11 @@ { delete iLiveSession; delete iRecordedLiveSession; - delete iLcSessionObserver; - delete iLcUiProvider; - delete iAudioRoutingObserver; - PropertyHelper::Close(); + delete iObserver; + // Delete static data from CenRep stub CRepository::iStaticWriteAvcKeysToStaticData = EFalse; CRepository::DeleteStubAvcConfigKeys(); - CRepository::ResetStubGlobal(); CRepository::iForceFailWithCode = KErrNone; } @@ -161,37 +176,602 @@ // TEST CASES + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // void UT_CMusEngLiveSession::UT_NewLL() { - EUNIT_ASSERT( iLiveSession ) - EUNIT_ASSERT( iRecordedLiveSession ) - EUNIT_ASSERT( iLiveSession->iCameraHandler.iCameraUsage == MusSettingsKeys::EUseCameraSwapping ); - EUNIT_ASSERT( iLiveSession->iMceManagerUid == TUid::Uid( KMusUiUid ) ); + EUNIT_ASSERT( iLiveSession ); + EUNIT_ASSERT( iLiveSession->iRecordedFile == KNullDesC() ); + EUNIT_ASSERT( iRecordedLiveSession ); + EUNIT_ASSERT( iRecordedLiveSession->iRecordedFile == KTestVideoFileName() ); + } + + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_CurrentZoomLL() + { + // Check that checking current zoom is not possible before invite + TRAPD( error, iLiveSession->CurrentZoomL() ); + MUS_TEST_FORWARD_ALLOC_FAILURE( error ); + EUNIT_ASSERT( error == KErrNotReady ); + + // simulate session establishment + ESTABLISH_OUT_SESSION( iLiveSession ); + + CMceCameraSource* camera = + MusEngMceUtils::GetCameraL( *(iLiveSession->iSession) ); + + // Check that originally current and default zoom are the same + EUNIT_ASSERT( iLiveSession->iDefaultZoomFactor == + iLiveSession->CurrentZoomL() ); + + // Zoom to maximum optical value + while ( camera->iZoomFactor < iLiveSession->iCameraInfo.iMaxZoom ) + { + iLiveSession->ZoomInL(); + } + + EUNIT_ASSERT( iLiveSession->iCameraInfo.iMaxZoom == + iLiveSession->CurrentZoomL() ); + + // Zoom using digital zoom + + iLiveSession->ZoomInL(); + + EUNIT_ASSERT( iLiveSession->CurrentZoomL() == + iLiveSession->iCameraInfo.iMaxZoom + + camera->iDigitalZoomFactor ) + + } + + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_CMusEngLiveSession_SetZoomLL() + { + TRAPD( error, iLiveSession->SetZoomL(2) ); + MUS_TEST_FORWARD_ALLOC_FAILURE( error ); + EUNIT_ASSERT( error == KErrNotReady ); + ESTABLISH_OUT_SESSION( iLiveSession ); + CMceCameraSource* camera = + MusEngMceUtils::GetCameraL( *(iLiveSession->iSession) ); + EUNIT_ASSERT( camera->iZoomFactor == 1 ); + EUNIT_ASSERT( camera->iDigitalZoomFactor == 0 ); + TRAPD( err, iLiveSession->SetZoomL(0) ); + EUNIT_ASSERT( err == KErrArgument ); + iLiveSession->SetZoomL(2); + EUNIT_ASSERT( camera->iZoomFactor == 2 ); + TRAPD( err1, iLiveSession->SetZoomL(14) ); + EUNIT_ASSERT( err1 == KErrArgument ); + iLiveSession->SetZoomL( 5 ); + EUNIT_ASSERT( camera->iDigitalZoomFactor == 2 ); + } +void UT_CMusEngLiveSession::UT_MaxZoomLL() + { + // Check that checking maximum zoom is not possible before invite + TRAPD( error, iLiveSession->MaxZoomL() ); + MUS_TEST_FORWARD_ALLOC_FAILURE( error ); + EUNIT_ASSERT( error == KErrNotReady ); + + // simulate session establishment + ESTABLISH_OUT_SESSION( iLiveSession ); + + EUNIT_ASSERT( iLiveSession->MaxZoomL() == + iLiveSession->iCameraInfo.iMaxZoom + + iLiveSession->iCameraInfo.iMaxDigitalZoom ); + } + + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_ZoomInLL() + { + // Check that zooming is not possible before invite + TRAPD( error, iLiveSession->ZoomInL() ); + MUS_TEST_FORWARD_ALLOC_FAILURE( error ); + EUNIT_ASSERT( error == KErrNotReady ); + + // simulate session establishment + ESTABLISH_OUT_SESSION( iLiveSession ); + + CMceCameraSource* camera = + MusEngMceUtils::GetCameraL( *(iLiveSession->iSession) ); + + // Check the default value + EUNIT_ASSERT( iLiveSession->iDefaultZoomFactor == camera->iZoomFactor ); + + // Check that zoom factor can be increased + USER_SLEEP; //insure that small step is used + iLiveSession->ZoomInL(); + EUNIT_ASSERT( camera->iZoomFactor == iLiveSession->iDefaultZoomFactor + + iLiveSession->iSmallZoomStep ); + + //Check the "burst" mode (immediate second ZoomIn), big step should be used + TInt nZoom = camera->iZoomFactor + camera->iDigitalZoomFactor; + iLiveSession->ZoomInL(); + TInt nStep = camera->iZoomFactor + camera->iDigitalZoomFactor - nZoom; + EUNIT_ASSERT( nStep == iLiveSession->iBigZoomStep ); - delete iLiveSession; - iLiveSession = NULL; - CRepository::SetStubGlobal( MusSettingsKeys::KCameraUsage, - MusSettingsKeys::EUseOnlySecondaryCamera ); + // Zoom to maximum optical value + while ( camera->iZoomFactor < iLiveSession->iCameraInfo.iMaxZoom ) + { + iLiveSession->ZoomInL(); + } + + TInt maxOpticalZoomFactor = camera->ZoomFactorL(); + + // Check that digital zoom is used instead of optical + iLiveSession->ZoomInL(); + EUNIT_ASSERT( camera->iZoomFactor == maxOpticalZoomFactor ); + EUNIT_ASSERT( camera->iDigitalZoomFactor > 0 ); + + // Zoom to maximum digital value + while ( camera->iDigitalZoomFactor < + iLiveSession->iCameraInfo.iMaxDigitalZoom ) + { + iLiveSession->ZoomInL(); + } + + TInt maxDigitalZoomFactor = camera->DigitalZoomFactorL(); + + // Check that further zooming is impossible + iLiveSession->ZoomInL(); + EUNIT_ASSERT( camera->iZoomFactor == maxOpticalZoomFactor ); + EUNIT_ASSERT( camera->iDigitalZoomFactor == maxDigitalZoomFactor ); + + } + - iLiveSession = CMusEngLiveSession::NewL(); +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_ZoomOutLL() + { + // Check that zooming is not possible before invite + TRAPD( error, iLiveSession->ZoomOutL() ); + MUS_TEST_FORWARD_ALLOC_FAILURE( error ); + EUNIT_ASSERT( error == KErrNotReady ); + + // simulate session establishment + ESTABLISH_OUT_SESSION( iLiveSession ); + + CMceCameraSource* camera = + MusEngMceUtils::GetCameraL( *(iLiveSession->iSession) ); + + // Check the default value + EUNIT_ASSERT( iLiveSession->iDefaultZoomFactor == camera->iZoomFactor ); + + // Simulate maximum zoom + camera->iZoomFactor = iLiveSession->iCameraInfo.iMaxZoom; + camera->iDigitalZoomFactor = iLiveSession->iCameraInfo.iMaxDigitalZoom; + + // Check that digital zoom factor can be decreased + USER_SLEEP; //insure that small step is used + iLiveSession->ZoomOutL(); + EUNIT_ASSERT( camera->iZoomFactor == iLiveSession->iCameraInfo.iMaxZoom ); + EUNIT_ASSERT( camera->iDigitalZoomFactor == + iLiveSession->iCameraInfo.iMaxDigitalZoom - + iLiveSession->iSmallZoomStep ); + + //Check the "burst" mode (immediate second ZoomOut), big step should be used + TInt nZoom = camera->iZoomFactor + camera->iDigitalZoomFactor; + iLiveSession->ZoomOutL(); + TInt nStep; + nStep = nZoom - (camera->iZoomFactor + camera->iDigitalZoomFactor ); + EUNIT_ASSERT( nStep == iLiveSession->iBigZoomStep ); + + // Simulate maximum zoom again + camera->iZoomFactor = iLiveSession->iCameraInfo.iMaxZoom; + camera->iDigitalZoomFactor = iLiveSession->iCameraInfo.iMaxDigitalZoom; + + // Zoom to minimum digital zoom + while ( camera->iDigitalZoomFactor > 0 ) + { + iLiveSession->ZoomOutL(); + } + + EUNIT_ASSERT( camera->iZoomFactor == iLiveSession->iCameraInfo.iMaxZoom ); + EUNIT_ASSERT( camera->iDigitalZoomFactor == 0 ); + + // Check that optical zoom is decreased instead of digital + USER_SLEEP; //insure that step is the small one + iLiveSession->ZoomOutL(); + EUNIT_ASSERT( camera->iZoomFactor == + iLiveSession->iCameraInfo.iMaxZoom - + iLiveSession->iSmallZoomStep ); + EUNIT_ASSERT( camera->iDigitalZoomFactor == 0 ); + + // Zoom to minimum optical zoom + while ( camera->iZoomFactor > iLiveSession->iCameraInfo.iMinZoom ) + { + iLiveSession->ZoomOutL(); + } + + // Check that further zooming is impossible + iLiveSession->ZoomOutL(); + EUNIT_ASSERT( camera->iZoomFactor == iLiveSession->iCameraInfo.iMinZoom ); + EUNIT_ASSERT( camera->iDigitalZoomFactor == 0 ); + } + + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_ZoomDefaultLL() + { + // Check that zooming is not possible before invite + TRAPD( error, iLiveSession->ZoomDefaultL() ); + MUS_TEST_FORWARD_ALLOC_FAILURE( error ); + EUNIT_ASSERT( error == KErrNotReady ); + + // simulate session establishment + ESTABLISH_OUT_SESSION( iLiveSession ); + + CMceCameraSource* camera = + MusEngMceUtils::GetCameraL( *(iLiveSession->iSession) ); + + // Check the default value + EUNIT_ASSERT( iLiveSession->iDefaultZoomFactor == camera->iZoomFactor ); + + // increase zoom factor so much that optical zoom is in maximum value + // and digital zoom is in use + while ( camera->iDigitalZoomFactor == 0 ) + { + iLiveSession->ZoomInL(); + } + EUNIT_ASSERT( camera->iZoomFactor > iLiveSession->iDefaultZoomFactor ); + EUNIT_ASSERT( camera->iDigitalZoomFactor > 0 ); + + // back to default + iLiveSession->ZoomDefaultL(); + EUNIT_ASSERT( camera->iZoomFactor == iLiveSession->iDefaultZoomFactor ); + EUNIT_ASSERT( camera->iDigitalZoomFactor == 0 ); + } + + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_SetBrightnessLL() + { + // Check that setting brightness is not possible before invite + EUNIT_ASSERT_SPECIFIC_LEAVE( + iLiveSession->SetBrightnessL( KTestSomeBrightness ), + KErrNotReady ) - EUNIT_ASSERT_EQUALS( TInt( iLiveSession->iCameraHandler.iCameraUsage ), - TInt( MusSettingsKeys::EUseOnlySecondaryCamera ) ); + // simulate session establishment + ESTABLISH_OUT_SESSION( iLiveSession ); + + CMceCameraSource* camera = + MusEngMceUtils::GetCameraL( *(iLiveSession->iSession) ); + + camera->iCameraInfo.iOptionsSupported = + camera->iCameraInfo.iOptionsSupported | TCameraInfo::EBrightnessSupported; + + // Check that originally current and default brightness are the same + EUNIT_ASSERT_EQUALS( iLiveSession->iDefaultBrightness, + iLiveSession->CurrentBrightnessL() ) + + // Test setting brightness + iLiveSession->SetBrightnessL( KTestSomeBrightness ); + + EUNIT_ASSERT_EQUALS( KTestSomeBrightness, + iLiveSession->CurrentBrightnessL() ) + } + + + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_CurrentBrightnessLL() + { + // Check that checking current brightness is not possible before invite + EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->CurrentBrightnessL(), + KErrNotReady ) + + // All the other stuff checked in tests of SetBrightnessL + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_MaxBrightnessLL() + { + // MaxBrightness should return a constant + + EUNIT_ASSERT_EQUALS( KTestMaxBrightness, iLiveSession->MaxBrightnessL() ) + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_MinBrightnessLL() + { + // MinBrightness should return a constant + + EUNIT_ASSERT_EQUALS( KTestMinBrightness, iLiveSession->MinBrightnessL() ) + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_IncreaseBrightnessLL() + { + // Check that increasing brightness is not possible before invite + EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->IncreaseBrightnessL(), + KErrNotReady ) + + // simulate session establishment + ESTABLISH_OUT_SESSION( iLiveSession ); + + CMceCameraSource* camera = + MusEngMceUtils::GetCameraL( *(iLiveSession->iSession) ); + + camera->iCameraInfo.iOptionsSupported = + camera->iCameraInfo.iOptionsSupported | TCameraInfo::EBrightnessSupported; + + // Check that originally current and default brightness are the same + EUNIT_ASSERT_EQUALS( iLiveSession->iDefaultBrightness, + iLiveSession->CurrentBrightnessL() ) + + // Check that brightness can be increased... + iLiveSession->IncreaseBrightnessL(); + + EUNIT_ASSERT_EQUALS( iLiveSession->iDefaultBrightness + KTestBrightnessStepSize, + iLiveSession->CurrentBrightnessL() ) + + // ... but only to maximum + + iLiveSession->SetBrightnessL( KTestMaxBrightness ); + + iLiveSession->IncreaseBrightnessL(); + + EUNIT_ASSERT_EQUALS( KTestMaxBrightness, + iLiveSession->CurrentBrightnessL() ) + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_DecreaseBrightnessLL() + { + // Check that decreasing brightness is not possible before invite + EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->DecreaseBrightnessL(), + KErrNotReady ) + + // simulate session establishment + ESTABLISH_OUT_SESSION( iLiveSession ); + + CMceCameraSource* camera = + MusEngMceUtils::GetCameraL( *(iLiveSession->iSession) ); + + camera->iCameraInfo.iOptionsSupported = + camera->iCameraInfo.iOptionsSupported | TCameraInfo::EBrightnessSupported; + + // Check that originally current and default brightness are the same + EUNIT_ASSERT_EQUALS( iLiveSession->iDefaultBrightness, + iLiveSession->CurrentBrightnessL() ) + + // Check that brightness can be decreased... + iLiveSession->DecreaseBrightnessL(); + + EUNIT_ASSERT_EQUALS( iLiveSession->iDefaultBrightness - KTestBrightnessStepSize, + iLiveSession->CurrentBrightnessL() ) + + // ... but only to minimum + + iLiveSession->SetBrightnessL( KTestMinBrightness ); + + iLiveSession->DecreaseBrightnessL(); + + EUNIT_ASSERT_EQUALS( KTestMinBrightness, + iLiveSession->CurrentBrightnessL() ) + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_BrightnessDefaultLL() + { + // Check that setting default brightness is not possible before invite + EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->BrightnessDefaultL(), + KErrNotReady ) + + // simulate session establishment + ESTABLISH_OUT_SESSION( iLiveSession ); + + CMceCameraSource* camera = + MusEngMceUtils::GetCameraL( *(iLiveSession->iSession) ); + + camera->iCameraInfo.iOptionsSupported = + camera->iCameraInfo.iOptionsSupported | TCameraInfo::EBrightnessSupported; - delete iLiveSession; - iLiveSession = NULL; - CRepository::SetStubGlobal( MusSettingsKeys::KCameraUsage, - MusSettingsKeys::EUseOnlyMainCamera ); + // Check that originally current and default brightness are the same + EUNIT_ASSERT_EQUALS( iLiveSession->iDefaultBrightness, + iLiveSession->CurrentBrightnessL() ) + + // set brightness to max + iLiveSession->SetBrightnessL( KTestMaxBrightness ); + EUNIT_ASSERT_NOT_EQUALS( iLiveSession->iDefaultBrightness, + iLiveSession->CurrentBrightnessL() ) + + // set brightness to default and check it + iLiveSession->BrightnessDefaultL(); + + EUNIT_ASSERT_EQUALS( iLiveSession->iDefaultBrightness, + iLiveSession->CurrentBrightnessL() ) + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_BrightnessAutoLL() + { + // Check that setting brightness to auto is not possible before invite + EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->BrightnessAutoL(), + KErrNotReady ); + + // simulate session establishment + ESTABLISH_OUT_SESSION( iLiveSession ); + + CMceCameraSource* camera = + MusEngMceUtils::GetCameraL( *(iLiveSession->iSession) ); + + camera->iCameraInfo.iOptionsSupported = + camera->iCameraInfo.iOptionsSupported | TCameraInfo::EBrightnessSupported; + + // Check that originally brightness is not auto + EUNIT_ASSERT_NOT_EQUALS( CCamera::EBrightnessAuto, + iLiveSession->CurrentBrightnessL() ) + + // check that brightness is set to auto + iLiveSession->BrightnessAutoL(); + EUNIT_ASSERT_EQUALS( CCamera::EBrightnessAuto, + iLiveSession->CurrentBrightnessL() ) + } + - iLiveSession = CMusEngLiveSession::NewL(); +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_RecordL_and_IsRecordingLL() + { + // Check that recording is not possible before invite + EUNIT_ASSERT_SPECIFIC_LEAVE( iRecordedLiveSession->RecordL( ETrue ), + KErrNotReady ) + + // simulate session establishment + ESTABLISH_OUT_SESSION( iLiveSession ); + ESTABLISH_OUT_SESSION( iRecordedLiveSession ); + + // Check that recording is off by default + EUNIT_ASSERT( !iRecordedLiveSession->IsRecording() ); + + // Check that recording can be set on + iRecordedLiveSession->RecordL( ETrue ); + EUNIT_ASSERT( iRecordedLiveSession->IsRecording() ); + + // Check that recording cannot be set on if recording stream does not exist + EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->RecordL( ETrue ), + KErrNotReady ) + + // Check that setting on the recording twice does not harm + iRecordedLiveSession->RecordL( ETrue ); + EUNIT_ASSERT( iRecordedLiveSession->IsRecording() ); + + // Check that recording can be set off again + iRecordedLiveSession->RecordL( EFalse ); + EUNIT_ASSERT( !iRecordedLiveSession->IsRecording() ); + + // Check that setting off the recording twice does not harm + iRecordedLiveSession->RecordL( EFalse ); + EUNIT_ASSERT( !iRecordedLiveSession->IsRecording() ); + } + + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_PlayLL() + { + // Check that resuming is not possible before invite + TRAPD( error, iLiveSession->PlayL() ); + MUS_TEST_FORWARD_ALLOC_FAILURE( error ); + EUNIT_ASSERT( error == KErrNotReady ); + + ESTABLISH_OUT_SESSION( iLiveSession ); + + iLiveSession->PauseL(); - EUNIT_ASSERT_EQUALS( TInt( iLiveSession->iCameraHandler.iCameraUsage ), - TInt( MusSettingsKeys::EUseOnlyMainCamera ) ); + CMceCameraSource* camera = + MusEngMceUtils::GetCameraL( *(iLiveSession->iSession) ); + + iLiveSession->PlayL(); + + EUNIT_ASSERT( camera->IsEnabled() ); + + // Try to enable camera again, request should be ignored + + iLiveSession->PlayL(); + + EUNIT_ASSERT( camera->IsEnabled() ); + } + + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_PauseLL() + { + // Check that pausing is not possible before invite + TRAPD( error, iLiveSession->PauseL() ); + MUS_TEST_FORWARD_ALLOC_FAILURE( error ); + EUNIT_ASSERT( error == KErrNotReady ); + + ESTABLISH_OUT_SESSION( iLiveSession ); + + iLiveSession->PlayL(); + + CMceCameraSource* camera = + MusEngMceUtils::GetCameraL( *(iLiveSession->iSession) ); + + iLiveSession->PauseL(); + + EUNIT_ASSERT( !camera->IsEnabled() ); + + // Try to disable camera again, request should be ignored + + iLiveSession->PauseL(); + + EUNIT_ASSERT( !camera->IsEnabled() ); + + } + + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_IsPlayingLL() + { + // Try without a session + EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->IsPlayingL(), KErrNotReady ); + + // Normal cases + ESTABLISH_OUT_SESSION( iLiveSession ); + + iLiveSession->PlayL(); + EUNIT_ASSERT( iLiveSession->IsPlayingL() ) + + iLiveSession->PauseL(); + EUNIT_ASSERT( !iLiveSession->IsPlayingL() ) + } + // ----------------------------------------------------------------------------- // @@ -199,8 +779,9 @@ // void UT_CMusEngLiveSession::UT_CompleteSessionStructureLL() { + CMceStreamBundle* localBundle = - CMceStreamBundle::NewLC( CMceStreamBundle::ELS ); + CMceStreamBundle::NewLC( CMceStreamBundle::ELS ); // Check that structure cannot be completed before creating the session TRAPD( error, iLiveSession->CompleteSessionStructureL( *localBundle ) ); @@ -225,6 +806,7 @@ EUNIT_ASSERT( iLiveSession->iSession->Streams()[0]->Source() ); EUNIT_ASSERT( iLiveSession->iSession->Streams()[0]->Source()->Type() == KMceCameraSource ); + EUNIT_ASSERT( !iLiveSession->IsPlayingL() ) EUNIT_ASSERT( iLiveSession->iSession->Streams()[0]->Sinks().Count() == 1 ); EUNIT_ASSERT( iLiveSession->iSession->Streams()[0]->Sinks()[0]->Type() == KMceRTPSink ); @@ -262,28 +844,46 @@ EUNIT_ASSERT( file ) - + CleanupStack::PopAndDestroy( localBundle ); + + } + - EUNIT_ASSERT( iLiveSession->iCameraHandler.iCurrentCamera == - TMusEngCameraHandler::EBackCamera ); +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_HandleSessionStateChangedL() + { + // Make Repository empty, config keys must be written + CRepository::SetStubAvcConfigKeysL( KNullDesC8() ); - delete iLiveSession->iSession; - iLiveSession->iSession = NULL; + // Invite + iLiveSession->InviteL( KTestRecipientSipUri ); + iLiveSession->iSession->iState = CMceSession::EEstablished; - iLiveSession->iSession = CMceOutSession::NewL( - *(iLiveSession->iManager), - *profile, - KTestRecipientSipUri8() ); + // Force failure on CenRep + CRepository::iForceFailWithCode = KErrNoMemory; + + // Simulate session state transition notification + iLiveSession->HandleSessionStateChanged( + *iLiveSession->iSession, + 200, KNullDesC8() ); + + EUNIT_ASSERT( iObserver->iSessionFailedCalled ); - iLiveSession->iCameraHandler.iCameraUsage = MusSettingsKeys::EUseOnlySecondaryCamera; - iLiveSession->CompleteSessionStructureL( *localBundle ); + // Normal case, something will be written to CenRep + iRecordedLiveSession->InviteL( KTestRecipientSipUri ); + iRecordedLiveSession->iSession->iState = CMceSession::EEstablished; + iRecordedLiveSession->HandleSessionStateChanged( + *iRecordedLiveSession->iSession, + 200, KNullDesC8() ); - EUNIT_ASSERT( iLiveSession->iCameraHandler.iCurrentCamera == - TMusEngCameraHandler::EFrontCamera ); + HBufC8* info = MultimediaSharingSettings::EncoderConfigInfoLC(); + EUNIT_ASSERT_NOT_EQUALS( *info, KMusAvcBitrateLevel_1b_ConfigKey() ) + CleanupStack::PopAndDestroy( info ); + } - - CleanupStack::PopAndDestroy( localBundle ); - } // ----------------------------------------------------------------------------- // @@ -298,10 +898,10 @@ CMceVideoCodec* codecAvc = CMceAvcCodec::NewLC( KMceSDPNameH264() ); CMceVideoCodec* codecUnknown = CMceH263Codec::NewLC( KNullDesC8() ); - iLiveSession->AdjustVideoCodecL( *codecH263, KMceCameraSource ); - iLiveSession->AdjustVideoCodecL( *codecH2632000, KMceCameraSource ); - iLiveSession->AdjustVideoCodecL( *codecAvc, KMceCameraSource ); - iLiveSession->AdjustVideoCodecL( *codecUnknown, KMceCameraSource ); + iLiveSession->AdjustVideoCodecL( *codecH263 ); + iLiveSession->AdjustVideoCodecL( *codecH2632000 ); + iLiveSession->AdjustVideoCodecL( *codecAvc ); + iLiveSession->AdjustVideoCodecL( *codecUnknown ); // Test that bit rates has been set to H263 & AVC codecs EUNIT_ASSERT( codecH263->iAllowedBitrates == KMceAllowedH263BitrateAll ) @@ -336,8 +936,10 @@ CleanupStack::PopAndDestroy( codecAvc ); CleanupStack::PopAndDestroy( codecH2632000 ); CleanupStack::PopAndDestroy( codecH263 ); + } + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -356,6 +958,7 @@ CleanupStack::PopAndDestroy( codec ); } + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -381,16 +984,16 @@ EUNIT_ASSERT_EQUALS( stream->Codecs().Count(), 3 ) // Check that AVC codecs are removed if they are known to be not supported - delete iLiveSession->iVideoCodecList; - iLiveSession->iVideoCodecList = NULL; - iLiveSession->iVideoCodecList = _L8("SomethingThatIsNotAVC").AllocL(); + iLiveSession->SetSupportedVideoCodecListL( _L( "SomethingThatIsNotAVC" ) ); iLiveSession->DoCodecSelectionL( *stream ); EUNIT_ASSERT_EQUALS( stream->Codecs().Count(), 2 ) EUNIT_ASSERT( stream->Codecs()[0]->SdpName() != KMceSDPNameH264() ) EUNIT_ASSERT( stream->Codecs()[1]->SdpName() != KMceSDPNameH264() ) CleanupStack::PopAndDestroy( stream ); + } + // ----------------------------------------------------------------------------- // Although all states are not meaningfull for LiveSession, all states are @@ -406,7 +1009,7 @@ CleanupStack::PopAndDestroy( videoStream ); // Simulate sending invite - iLiveSession->EstablishLcSessionL(); + iLiveSession->InviteL( KTestRecipientSipUri() ); // Try all the stream states CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0]; @@ -415,58 +1018,59 @@ changedStream->iState = CMceMediaStream::EUninitialized; static_cast(iLiveSession)->StreamStateChanged( *changedStream ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->IsReseted() ); // EInitialized, stream is initialized changedStream->iState = CMceMediaStream::EInitialized; static_cast(iLiveSession)->StreamStateChanged( *changedStream ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->IsReseted() ); // EBuffering, stream is buffering changedStream->iState = CMceMediaStream::EBuffering; static_cast(iLiveSession)->StreamStateChanged( *changedStream ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->IsReseted() ); // EIdle, stream is not receiving RTP changedStream->iState = CMceMediaStream::EIdle; static_cast(iLiveSession)->StreamStateChanged( *changedStream ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->iStreamIdleCalled ); // EStreaming, stream is streaming changedStream->iState = CMceMediaStream::EStreaming; - static_cast(iLiveSession)->StreamStateChanged( *changedStream ); - EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), - TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) - iLcSessionObserver->Reset(); + static_cast(iLiveSession)->StreamStateChanged( + *changedStream ); + EUNIT_ASSERT( iObserver->iStreamStreamingCalled ); + iObserver->Reset(); // EDisabled, stream is explicitly disabled changedStream->iState = CMceMediaStream::EDisabled; static_cast(iLiveSession)->StreamStateChanged( *changedStream ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->IsReseted() ); // ENoResources, stream has no needed resources to stream changedStream->iState = CMceMediaStream::ENoResources; static_cast(iLiveSession)->StreamStateChanged( *changedStream ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->IsReseted() ); // ETranscodingRequired, stream requires non-realtime transcoding changedStream->iState = CMceMediaStream::ETranscodingRequired; static_cast(iLiveSession)->StreamStateChanged( *changedStream ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->IsReseted() ); // ETranscoding, stream is transcoding in non-realtime changedStream->iState = CMceMediaStream::ETranscoding; static_cast(iLiveSession)->StreamStateChanged( *changedStream ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->IsReseted() ); } + // ----------------------------------------------------------------------------- // Although all states are not meaningfull for LiveSession, all states are // tested in order to force the updating of unit tests when behavior is changed @@ -483,7 +1087,7 @@ CleanupStack::PopAndDestroy( videoStream ); // Simulate sending invite - iLiveSession->EstablishLcSessionL(); + iLiveSession->InviteL( KTestRecipientSipUri() ); // Try all the stream states CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0]; @@ -493,59 +1097,59 @@ changedStream->iState = CMceMediaStream::EUninitialized; static_cast(iLiveSession)->StreamStateChanged( *changedStream, *changedSource ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->IsReseted() ); // EInitialized, stream is initialized changedStream->iState = CMceMediaStream::EInitialized; static_cast(iLiveSession)->StreamStateChanged( *changedStream, *changedSource );; - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->IsReseted() ); // EBuffering, stream is buffering changedStream->iState = CMceMediaStream::EBuffering; static_cast(iLiveSession)->StreamStateChanged( *changedStream, *changedSource ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->IsReseted() ); // EIdle, stream is not receiving RTP changedStream->iState = CMceMediaStream::EIdle; static_cast(iLiveSession)->StreamStateChanged( *changedStream, *changedSource ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->iStreamIdleCalled ); // EStreaming, stream is streaming changedStream->iState = CMceMediaStream::EStreaming; static_cast(iLiveSession)->StreamStateChanged( *changedStream, *changedSource ); - EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), - TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) - iLcSessionObserver->Reset(); + EUNIT_ASSERT( iObserver->iStreamStreamingCalled ); + iObserver->Reset(); // EDisabled, stream is explicitly disabled changedStream->iState = CMceMediaStream::EDisabled; static_cast(iLiveSession)->StreamStateChanged( *changedStream, *changedSource ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->IsReseted() ); // ENoResources, stream has no needed resources to stream changedStream->iState = CMceMediaStream::ENoResources; static_cast(iLiveSession)->StreamStateChanged( *changedStream, *changedSource ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->IsReseted() ); // ETranscodingRequired, stream requires non-realtime transcoding changedStream->iState = CMceMediaStream::ETranscodingRequired; static_cast(iLiveSession)->StreamStateChanged( *changedStream, *changedSource ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->IsReseted() ); // ETranscoding, stream is transcoding in non-realtime changedStream->iState = CMceMediaStream::ETranscoding; static_cast(iLiveSession)->StreamStateChanged( *changedStream, *changedSource ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); + EUNIT_ASSERT( iObserver->IsReseted() ); } + // ----------------------------------------------------------------------------- // Although all states are not meaningfull for LiveSession, all states are // tested in order to force the updating of unit tests when behavior is changed @@ -563,9 +1167,7 @@ // Try with session ESTABLISH_OUT_SESSION( iRecordedLiveSession ) - MLcDestinationFileControl* destinationFileControl = - iRecordedLiveSession->LocalVideoPlayer()->LcDestinationFileControl(); - destinationFileControl->LcRecordL( ETrue ); + iRecordedLiveSession->RecordL( ETrue ); // Test state CMceMediaStream::ENoResources @@ -574,9 +1176,8 @@ iLiveSession->StreamStateChanged( *iLiveSession->iSession->Streams()[0], *iLiveSession->iSession->Streams()[0]->Sinks()[0] ); - EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), - TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) - iLcSessionObserver->Reset(); + EUNIT_ASSERT( iObserver->iStreamStreamingCalled ) + iObserver->Reset(); // Try again with recording stream, but indicate change in another stream, // nothing happens @@ -611,11 +1212,8 @@ iRecordedLiveSession->StreamStateChanged( *recordingStream, *recordingStream->Sinks()[0] ); - EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), - TInt( CLcSessionObserverStub::ESessionFailed ) ) - EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, - TInt( MLcSession::EDiskFull ) ) - iLcSessionObserver->Reset(); + EUNIT_ASSERT( iObserver->iDiskFullCalled ) + iObserver->Reset(); // Test default stream state change behavior @@ -626,34 +1224,33 @@ // EUninitialized, stream is created, unexpected change, nothing happens changedStream->iState = CMceMediaStream::EUninitialized; iLiveSession->StreamStateChanged( *changedStream, *changedSink ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) + EUNIT_ASSERT( iObserver->IsReseted() ); // EInitialized, stream is initialized changedStream->iState = CMceMediaStream::EInitialized; iLiveSession->StreamStateChanged( *changedStream, *changedSink ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) + EUNIT_ASSERT( iObserver->IsReseted() ); // EBuffering, stream is buffering changedStream->iState = CMceMediaStream::EBuffering; iLiveSession->StreamStateChanged( *changedStream, *changedSink ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) + EUNIT_ASSERT( iObserver->IsReseted() ); // EIdle, stream is not receiving RTP changedStream->iState = CMceMediaStream::EIdle; iLiveSession->StreamStateChanged( *changedStream, *changedSink ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) + EUNIT_ASSERT( iObserver->iStreamIdleCalled ); // EStreaming, stream is streaming changedStream->iState = CMceMediaStream::EStreaming; iLiveSession->StreamStateChanged( *changedStream, *changedSink ); - EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), - TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) - iLcSessionObserver->Reset(); + EUNIT_ASSERT( iObserver->iStreamStreamingCalled ); + iObserver->Reset(); // EDisabled, stream is explicitly disabled changedStream->iState = CMceMediaStream::EDisabled; iLiveSession->StreamStateChanged( *changedStream, *changedSink ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) + EUNIT_ASSERT( iObserver->IsReseted() ); // ENoResources, stream has no needed resources to stream // This state has non-default meaning, tested before defaults @@ -661,12 +1258,12 @@ // ETranscodingRequired, stream requires non-realtime transcoding changedStream->iState = CMceMediaStream::ETranscodingRequired; iLiveSession->StreamStateChanged( *changedStream, *changedSink ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) + EUNIT_ASSERT( iObserver->IsReseted() ); // ETranscoding, stream is transcoding in non-realtime changedStream->iState = CMceMediaStream::ETranscoding; iLiveSession->StreamStateChanged( *changedStream, *changedSink ); - EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) + EUNIT_ASSERT( iObserver->IsReseted() ); } @@ -675,24 +1272,252 @@ // // ----------------------------------------------------------------------------- // -void UT_CMusEngLiveSession::UT_EstablishLcSessionL() +void UT_CMusEngLiveSession::UT_SetEncodingDeviceLL() + { + CMceAvcCodec* codec = CMceAvcCodec::NewLC( KMceSDPNameH264() ); + + // Generic error in CenRep, leave expected + CRepository::iForceFailWithCode = KErrNotReady; + EUNIT_ASSERT_LEAVE( iLiveSession->SetEncodingDeviceL( *codec ) ) + EUNIT_ASSERT_EQUALS( codec->iEncodingDecodingDevice, TUid::Uid( 0 ) ) + + // No entry in CenRep, default value expected + CRepository::iForceFailWithCode = KErrNotFound; + const TUid KDefaultEncodingDevice( TUid::Uid( 0x20001C13 ) ); + iLiveSession->SetEncodingDeviceL( *codec ); + EUNIT_ASSERT_EQUALS( codec->iEncodingDecodingDevice, + KDefaultEncodingDevice ) + + // Entry in CenRep + const TInt KSomeEncodingDevice( 0x20001C15 ); + CRepository::iStaticEncoderUid = KSomeEncodingDevice; + iLiveSession->SetEncodingDeviceL( *codec ); + EUNIT_ASSERT_EQUALS( codec->iEncodingDecodingDevice, + TUid::Uid( KSomeEncodingDevice ) ) + + CleanupStack::PopAndDestroy( codec ); + } + + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_SetCodecConfigKeyLL() { - iLiveSession->EstablishLcSessionL(); - EUNIT_ASSERT_EQUALS( TInt( CMceSession::EOffering ), - TInt( iLiveSession->iSession->iState ) ) + CMceAvcCodec* codec = CMceAvcCodec::NewLC( KMceSDPNameH264() ); + codec->SetAllowedBitrates( KMceAvcBitrateLevel1b ); + + // Generic error in CenRep, leave expected + CRepository::iForceFailWithCode = KErrNotReady; + EUNIT_ASSERT_LEAVE( iLiveSession->SetCodecConfigKeyL( *codec ) ); + EUNIT_ASSERT( !codec->iConfigKey ) + EUNIT_ASSERT( !iLiveSession->iStoreEncoderConfigInfo ) + CRepository::iForceFailWithCode = KErrNone; + + // No entry in CenRep, nothing happens + iLiveSession->SetCodecConfigKeyL( *codec ); + EUNIT_ASSERT( !codec->iConfigKey ) + EUNIT_ASSERT( !iLiveSession->iStoreEncoderConfigInfo ) + + // Empty entry in CenRep + CRepository::SetStubAvcConfigKeysL( KNullDesC8() ); + iLiveSession->SetCodecConfigKeyL( *codec ); + EUNIT_ASSERT( !codec->iConfigKey ) + EUNIT_ASSERT( iLiveSession->iStoreEncoderConfigInfo ) + iLiveSession->iStoreEncoderConfigInfo = EFalse; // emulate original situation + + // Entry in CenRep + CRepository::SetStubAvcConfigKeysL( KMusAvcBitrateLevel_1b_ConfigKey ); + iLiveSession->SetCodecConfigKeyL( *codec ); + EUNIT_ASSERT( codec->iConfigKey ) + HBufC8* key = codec->ConfigKeyL(); + CleanupStack::PushL( key ); + EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1bTestText() ) + CleanupStack::PopAndDestroy( key ); + EUNIT_ASSERT( !iLiveSession->iStoreEncoderConfigInfo ) + + CleanupStack::PopAndDestroy( codec ); } + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // -void UT_CMusEngLiveSession::UT_LocalVideoPlayerL() +void UT_CMusEngLiveSession::UT_ReadCodecConfigKeyLL() { - EUNIT_ASSERT( iLiveSession->LocalVideoPlayer() == - iLiveSession->iLiveVideoPlayer ) + HBufC8* key( NULL ); + + // Try with H263, leave expected + CMceVideoCodec* codecH263 = CMceH263Codec::NewLC( KMceSDPNameH263() ); + EUNIT_ASSERT_LEAVE( key = iLiveSession->ReadCodecConfigKeyL( *codecH263 ) ) + CleanupStack::PopAndDestroy( codecH263 ); + + // Try without an entry in CenRep, leave expected + CMceVideoCodec* codec = CMceAvcCodec::NewLC( KMceSDPNameH264() ); + codec->SetAllowedBitrates( 0 | KMceAvcBitrateLevel1 ); + EUNIT_ASSERT_LEAVE( key = iLiveSession->ReadCodecConfigKeyL( *codec ) ) + + // Create CenRep entry which does not include wanted bitrate, NULL value + // expected + CRepository::SetStubAvcConfigKeysL( KMusAvcBitrateLevel1bTestText() ); + key = iLiveSession->ReadCodecConfigKeyL( *codec ); + EUNIT_ASSERT( !key ) + + // Create entry with all AVC keys and try with all the values + CRepository::SetStubAvcConfigKeysL( KMusAvcAllLevelsConcatenation() ); + + // KMceAvcBitrateLevel1 + key = iLiveSession->ReadCodecConfigKeyL( *codec ); + EUNIT_ASSERT( key ); + CleanupStack::PushL( key ); + EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1TestText ); + CleanupStack::PopAndDestroy( key ); + + // KMceAvcBitrateLevel1b + codec->SetAllowedBitrates( KMceAvcBitrateLevel1b ); + key = iLiveSession->ReadCodecConfigKeyL( *codec ); + EUNIT_ASSERT( key ); + CleanupStack::PushL( key ); + EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1bTestText ); + CleanupStack::PopAndDestroy( key ); + + // KMceAvcBitrateLevel1_1 + codec->SetAllowedBitrates( KMceAvcBitrateLevel1_1 ); + key = iLiveSession->ReadCodecConfigKeyL( *codec ); + EUNIT_ASSERT( key ); + CleanupStack::PushL( key ); + EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1_1TestText ); + CleanupStack::PopAndDestroy( key ); + + // KMceAvcBitrateLevel1_2 + codec->SetAllowedBitrates( KMceAvcBitrateLevel1_2 ); + key = iLiveSession->ReadCodecConfigKeyL( *codec ); + EUNIT_ASSERT( key ); + CleanupStack::PushL( key ); + EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1_2TestText ); + CleanupStack::PopAndDestroy( key ); + + // KMceAvcBitrateLevel1_3 + codec->SetAllowedBitrates( KMceAvcBitrateLevel1_3 ); + key = iLiveSession->ReadCodecConfigKeyL( *codec ); + EUNIT_ASSERT( key ); + CleanupStack::PushL( key ); + EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1_3TestText ); + CleanupStack::PopAndDestroy( key ); + + // KMceAvcBitrateLevel2 + codec->SetAllowedBitrates( KMceAvcBitrateLevel2 ); + key = iLiveSession->ReadCodecConfigKeyL( *codec ); + EUNIT_ASSERT( key ); + CleanupStack::PushL( key ); + EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel2TestText ); + CleanupStack::PopAndDestroy( key ); + + CleanupStack::PopAndDestroy( codec ); + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_StoreEncoderConfigInfoLL() + { + CRepository::iStaticWriteAvcKeysToStaticData = ETrue; + + // Try with clean CenRep + MultimediaSharingSettings::SetEncoderConfigInfoL( KNullDesC8() ); + + ESTABLISH_OUT_SESSION( iLiveSession ) // calls StoreEncoderConfigInfoL + // If StoreEncoderConfigInfoL leaves with KErrNoMemory, + // MMusEngSessionObserver::SessionFailed will be called. + __ASSERT_ALWAYS( !iObserver->iSessionFailedCalled, + User::Leave( KErrNoMemory ) ); + + HBufC8* keys = MultimediaSharingSettings::EncoderConfigInfoLC(); + EUNIT_ASSERT_EQUALS( *keys, KMusAvcBitrateLevel_1b_ConfigKey() ) + CleanupStack::PopAndDestroy( keys ); + + // Try without a clean CenRep + MultimediaSharingSettings::SetEncoderConfigInfoL( + KMusAvcBitrateLevel_1_1_ConfigKey() ); + + ESTABLISH_OUT_SESSION( iRecordedLiveSession ) + // If StoreEncoderConfigInfoL leaves with KErrNoMemory, + // MMusEngSessionObserver::SessionFailed will be called. + __ASSERT_ALWAYS( !iObserver->iSessionFailedCalled, + User::Leave( KErrNoMemory ) ); + + keys = MultimediaSharingSettings::EncoderConfigInfoLC(); + EUNIT_ASSERT_EQUALS( *keys, + KMusAvcBitrateLevels_1_1_And_1b_ConfigKeys() ) + CleanupStack::PopAndDestroy( keys ); + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void UT_CMusEngLiveSession::UT_InitializeZoomStepSizeL() + { + //Check that zooming steps have defualt values before session establishment + iLiveSession->InitializeZoomStepSize(); + EUNIT_ASSERT( iLiveSession->iSmallZoomStep == KZoomStepMinSize ); + EUNIT_ASSERT( iLiveSession->iBigZoomStep == KZoomStepMinSize ); + + // simulate session establishment + ESTABLISH_OUT_SESSION( iLiveSession ); + + CMceCameraSource* camera = + MusEngMceUtils::GetCameraL( *(iLiveSession->iSession) ); + + //Check that zooming step sizes have default value KZoomStepMinSize + //in case of zooming values range is smaller than KZoomBigStepCount + iLiveSession->iCameraInfo.iMinZoom = 0; + iLiveSession->iCameraInfo.iMaxZoom = 0; + iLiveSession->iCameraInfo.iMaxDigitalZoom = KZoomBigStepCount / 2; + iLiveSession->InitializeZoomStepSize(); + EUNIT_ASSERT( iLiveSession->iSmallZoomStep == KZoomStepMinSize ); + EUNIT_ASSERT( iLiveSession->iBigZoomStep == KZoomStepMinSize ); + + + //Check that zooming step sizes have default value KZoomStepMinSize + //in case of zooming values range is bigger than KZoomBigStepCount, + //but smaller than 2*KZoomBigStepCount (KZoomSmallStepCount) + iLiveSession->iCameraInfo.iMaxDigitalZoom = 2*KZoomBigStepCount - 1; + iLiveSession->InitializeZoomStepSize(); + EUNIT_ASSERT( iLiveSession->iSmallZoomStep == KZoomStepMinSize ); + EUNIT_ASSERT( iLiveSession->iBigZoomStep == KZoomStepMinSize ); + + + //Check zooming steps sizes in case of zooming values range is + //bigger than 2*KZoomBigStepCount and smaller than 2*KZoomSmallStepCount + iLiveSession->iCameraInfo.iMinZoom = - KZoomBigStepCount; + iLiveSession->iCameraInfo.iMaxZoom = KZoomBigStepCount; + iLiveSession->iCameraInfo.iMaxDigitalZoom = KZoomBigStepCount; + //zooming range is (-KZoomBigStepCount, 2*KZoomBigStepCount) + iLiveSession->InitializeZoomStepSize(); + EUNIT_ASSERT( iLiveSession->iSmallZoomStep == KZoomStepMinSize ); + EUNIT_ASSERT( iLiveSession->iBigZoomStep == 3 ); + + + //Check zooming steps sizes in case of zooming values range is + //bigger than 2*KZoomSmallStepCount + iLiveSession->iCameraInfo.iMaxZoom = KZoomSmallStepCount; + iLiveSession->iCameraInfo.iMaxDigitalZoom = KZoomSmallStepCount; + iLiveSession->iCameraInfo.iMinZoom = - KZoomSmallStepCount; + //zooming range is (-KZoomSmallStepCount, 2*KZoomSmallStepCount) + iLiveSession->InitializeZoomStepSize(); + EUNIT_ASSERT( iLiveSession->iSmallZoomStep == 3 ); + EUNIT_ASSERT( iLiveSession->iBigZoomStep == 6 ); + } + + // TEST TABLE + EUNIT_BEGIN_TEST_TABLE( UT_CMusEngLiveSession, "UT_CMusEngLiveSesssion", @@ -706,6 +1531,125 @@ SetupL, UT_NewLL, Teardown) EUNIT_TEST( + "CurrentZoomL - test ", + "CMusEngLiveSession", + "CurrentZoomL", + "FUNCTIONALITY", + SetupL, UT_CurrentZoomLL, Teardown) + +EUNIT_TEST( + "MaxZoomL - test ", + "CMusEngLiveSession", + "MaxZoomL", + "FUNCTIONALITY", + SetupL, UT_MaxZoomLL, Teardown) + +EUNIT_TEST( + "ZoomInL - test ", + "CMusEngLiveSession", + "ZoomInL", + "FUNCTIONALITY", + SetupL, UT_ZoomInLL, Teardown) + +EUNIT_TEST( + "ZoomOutL - test ", + "CMusEngLiveSession", + "ZoomOutL", + "FUNCTIONALITY", + SetupL, UT_ZoomOutLL, Teardown) + +EUNIT_TEST( + "ZoomDefaultL - test ", + "CMusEngLiveSession", + "ZoomDefaultL", + "FUNCTIONALITY", + SetupL, UT_ZoomDefaultLL, Teardown) + +EUNIT_TEST( + "SetBrightnessL - test ", + "CMusEngLiveSession", + "SetBrightnessL", + "FUNCTIONALITY", + SetupL, UT_SetBrightnessLL, Teardown) + +EUNIT_TEST( + "CurrentBrightnessL - test ", + "CMusEngLiveSession", + "CurrentBrightnessL", + "FUNCTIONALITY", + SetupL, UT_CurrentBrightnessLL, Teardown) + +EUNIT_TEST( + "MaxBrightnessL - test ", + "CMusEngLiveSession", + "MaxBrightnessL", + "FUNCTIONALITY", + SetupL, UT_MaxBrightnessLL, Teardown) + +EUNIT_TEST( + "MinBrightnessL - test ", + "CMusEngLiveSession", + "MinBrightnessL", + "FUNCTIONALITY", + SetupL, UT_MinBrightnessLL, Teardown) + +EUNIT_TEST( + "IncreaseBrightnessL - test ", + "CMusEngLiveSession", + "IncreaseBrightnessL", + "FUNCTIONALITY", + SetupL, UT_IncreaseBrightnessLL, Teardown) + +EUNIT_TEST( + "DecreaseBrightnessL - test ", + "CMusEngLiveSession", + "DecreaseBrightnessL", + "FUNCTIONALITY", + SetupL, UT_DecreaseBrightnessLL, Teardown) + +EUNIT_TEST( + "BrightnessDefaultL - test ", + "CMusEngLiveSession", + "BrightnessDefaultL", + "FUNCTIONALITY", + SetupL, UT_BrightnessDefaultLL, Teardown) + +EUNIT_TEST( + "BrightnessAutoL - test ", + "CMusEngLiveSession", + "BrightnessAutoL", + "FUNCTIONALITY", + SetupL, UT_BrightnessAutoLL, Teardown) + +EUNIT_TEST( + "RecordL_and_IsRecordingL - test ", + "CMusEngLiveSession", + "RecordL_and_IsRecordingL", + "FUNCTIONALITY", + SetupL, UT_RecordL_and_IsRecordingLL, Teardown) + +EUNIT_TEST( + "PlayL - test ", + "CMusEngLiveSession", + "PlayL", + "FUNCTIONALITY", + SetupL, UT_PlayLL, Teardown) + +EUNIT_TEST( + "PauseL - test ", + "CMusEngLiveSession", + "PauseL", + "FUNCTIONALITY", + SetupL, UT_PauseLL, Teardown) + +EUNIT_TEST( + "IsPlayingL - test ", + "CMusEngLiveSession", + "IsPlayingL", + "FUNCTIONALITY", + SetupL, UT_IsPlayingLL, Teardown) + +EUNIT_TEST( "CompleteSessionStructureL - test ", "CMusEngLiveSession", "CompleteSessionStructureL", @@ -713,6 +1657,13 @@ SetupL, UT_CompleteSessionStructureLL, Teardown) EUNIT_TEST( + "HandleSessionStateChanged - test ", + "CMusEngLiveSession", + "HandleSessionStateChanged", + "FUNCTIONALITY", + SetupL, UT_HandleSessionStateChangedL, Teardown) + +EUNIT_TEST( "AdjustVideoCodecL - test ", "CMusEngLiveSession", "AdjustVideoCodecL", @@ -752,22 +1703,44 @@ "CMusEngLiveSession", "StreamStateChangedL( sink )", "FUNCTIONALITY", - SetupL, UT_StreamStateChangedWithSinkL, Teardown) + SetupL, UT_StreamStateChangedWithSinkL, Teardown) + +EUNIT_TEST( + "SetEncodingDeviceL - test ", + "CMusEngLiveSession", + "SetEncodingDeviceL", + "FUNCTIONALITY", + SetupL, UT_SetEncodingDeviceLL, Teardown) + +EUNIT_TEST( + "SetCodecConfigKeyL - test ", + "CMusEngLiveSession", + "SetCodecConfigKeyL", + "FUNCTIONALITY", + SetupL, UT_SetCodecConfigKeyLL, Teardown) EUNIT_TEST( - "EstablishLcSessionL - test ", + "ReadCodecConfigKeyL - test ", "CMusEngLiveSession", - "EstablishLcSessionL", + "ReadCodecConfigKeyL", "FUNCTIONALITY", - SetupL, UT_EstablishLcSessionL, Teardown) + SetupL, UT_ReadCodecConfigKeyLL, Teardown) + +EUNIT_TEST( + "StoreEncoderConfigInfoL - test ", + "CMusEngLiveSession", + "StoreEncoderConfigInfoL", + "FUNCTIONALITY", + SetupL, UT_StoreEncoderConfigInfoLL, Teardown) EUNIT_TEST( - "LocalVideoPlayer - test ", + "InitializeZoomStepSize - test ", "CMusEngLiveSession", - "LocalVideoPlayer", + "InitializeZoomStepSize", "FUNCTIONALITY", - SetupL, UT_LocalVideoPlayerL, Teardown) - + SetupL, UT_InitializeZoomStepSizeL, Teardown) + + EUNIT_END_TEST_TABLE // END OF FILE