sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include "tsu_3gplibrary_composer_api.h" sl@0: sl@0: _LIT8(KDummyData, "DummyData"); sl@0: _LIT8(KFtypAtom, "ftyp"); sl@0: _LIT8(K3g2Brand, "3g2a"); // 3g2a sl@0: _LIT8(K3gpBrand, "3gp"); // 3gp4, 3gp6 sl@0: _LIT8(KMp4Brand, "mp42"); // mp42 sl@0: sl@0: _LIT(KLargeVideoFile, "c:\\3gplibrary\\cube-xvid-640x480-10fps-10s.3gp"); sl@0: const TInt KLargeFileWriteBufferSize = 16384; // 16K sl@0: const TInt KLargeFileWriteBufferMaxCount = 15; sl@0: const TInt64 K3GigaBytes = 0xC0000000; sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeBase - this should not be used directly sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeBase::C3GPLibComposeBase() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeBase::doTestStepPreambleL() sl@0: { sl@0: // ensure there's always a Active Scheduler for the Composer sl@0: if (!CActiveScheduler::Current()) sl@0: { sl@0: iScheduler = new (ELeave) CActiveScheduler; sl@0: CActiveScheduler::Install(iScheduler); sl@0: } sl@0: sl@0: SetTestStepResult(EPass); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeBase::doTestStepPostambleL() sl@0: { sl@0: if (iScheduler) sl@0: { sl@0: CActiveScheduler::Install(NULL); sl@0: delete iScheduler; sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeBase::doTestStepL() sl@0: { sl@0: if (TestStepResult() != EPass) sl@0: { sl@0: return TestStepResult(); sl@0: } sl@0: SetTestStepError(KErrNone); sl@0: sl@0: C3GPCompose* composer = doTestStepCreateComposerL(); sl@0: CleanupStack::PushL(composer); sl@0: sl@0: doTestStepComposeOpenL(*composer); sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: // set it to EFail, if both calls below does not leave, then it will be reset sl@0: // back to EPass sl@0: SetTestStepResult(EFail); sl@0: doTestStepComposeWriteVideoAudioL(*composer); sl@0: doTestStepComposeSetUserDataL(*composer); sl@0: SetTestStepResult(EPass); sl@0: } sl@0: sl@0: TInt err = composer->Complete(); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: User::Leave(err); sl@0: } sl@0: CleanupStack::PopAndDestroy(composer); sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: C3GPCompose* C3GPLibComposeBase::doTestStepCreateComposerL() sl@0: { sl@0: return C3GPCompose::NewL(); sl@0: } sl@0: sl@0: void C3GPLibComposeBase::doTestStepComposeWriteVideoAudioL(C3GPCompose& /* aComposer */) sl@0: { sl@0: } sl@0: sl@0: void C3GPLibComposeBase::doTestStepComposeSetUserDataL(C3GPCompose& /* aComposer */) sl@0: { sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeFilename sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeFilename::C3GPLibComposeFilename() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeFilename::doTestStepPreambleL() sl@0: { sl@0: // ensure all basic setup is completed first sl@0: C3GPLibComposeBase::doTestStepPreambleL(); sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: TPtrC fileNamePtr; sl@0: if (GetStringFromConfig(ConfigSection(), _L("filename"), fileNamePtr)) sl@0: { sl@0: // save a copy of the filename specified for the test sl@0: iFilename.CreateL(fileNamePtr); sl@0: } sl@0: else sl@0: { sl@0: // cannot find filename! sl@0: ERR_PRINTF1(_L("Filename not specified. Test cannot proceed.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeFilename::doTestStepPostambleL() sl@0: { sl@0: iFilename.Close(); sl@0: sl@0: // clean up all composer test base setups sl@0: C3GPLibComposeBase::doTestStepPostambleL(); sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibComposeFilename::doTestStepComposeOpenL(C3GPCompose& aComposer) sl@0: { sl@0: T3GPAudioPropertiesMpeg4Audio audio(100, KDummyData); sl@0: T3GPVideoPropertiesAvc video(100, TSize(100, 100), KDummyData); sl@0: sl@0: TInt err = aComposer.Open(E3GP3GP, &video, &audio, iFilename); sl@0: if (err != KErrNone) sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF2(_L("C3GPCompose::Open failed with error = %d"), err); sl@0: } sl@0: SetTestStepError(err); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("C3GPCompose::Open completes with no error")); sl@0: SetTestStepResult(EPass); sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeWithoutOpen sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeWithoutOpen::C3GPLibComposeWithoutOpen() sl@0: { sl@0: } sl@0: sl@0: void C3GPLibComposeWithoutOpen::doTestStepComposeOpenL(C3GPCompose& /* aComposer */) sl@0: { sl@0: // This test needs the composer NOT initialised. Do nothing here sl@0: } sl@0: sl@0: void C3GPLibComposeWithoutOpen::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer) sl@0: { sl@0: if (TestStepResult() != EPass) sl@0: { sl@0: return; sl@0: } sl@0: sl@0: TInt err = aComposer.WriteVideoFrame(KDummyData, 100, ETrue); sl@0: if (err != KErrNotReady) sl@0: { sl@0: ERR_PRINTF2(_L("C3GPCompose::WriteVideoFrame failed with error = %d instead of KErrNotReady"), err); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: T3GPFrameDependencies dependencies; sl@0: err = aComposer.WriteVideoFrame(KDummyData, 100, ETrue, dependencies); sl@0: if (err != KErrNotReady) sl@0: { sl@0: ERR_PRINTF2(_L("C3GPCompose::WriteVideoFrame failed with error = %d instead of KErrNotReady"), err); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: } sl@0: sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: err = aComposer.WriteAudioFrames(KDummyData, 100); sl@0: if (err != KErrNotReady) sl@0: { sl@0: ERR_PRINTF2(_L("C3GPCompose::WriteAudioFrames failed with error = %d instead of KErrNotReady"), err); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void C3GPLibComposeWithoutOpen::doTestStepComposeSetUserDataL(C3GPCompose& aComposer) sl@0: { sl@0: if (TestStepResult() != EPass) sl@0: { sl@0: return; sl@0: } sl@0: sl@0: TInt err = aComposer.SetUserData(E3GPUdtaMoov, KDummyData); sl@0: if (err != KErrNotReady) sl@0: { sl@0: ERR_PRINTF2(_L("C3GPCompose::SetUserData failed with error = %d instead of KErrNotReady"), err); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: err = aComposer.SetUserData(E3GPUdtaVideoTrak, KDummyData); sl@0: if (err != KErrNotReady) sl@0: { sl@0: ERR_PRINTF2(_L("C3GPCompose::SetUserData failed with error = %d instead of KErrNotReady"), err); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: } sl@0: sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: err = aComposer.SetUserData(E3GPUdtaAudioTrak, KDummyData); sl@0: if (err != KErrNotReady) sl@0: { sl@0: ERR_PRINTF2(_L("C3GPCompose::SetUserData failed with error = %d instead of KErrNotReady"), err); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeFile sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeFile::C3GPLibComposeFile() : sl@0: iInputFileFormat(E3GP3GP), sl@0: iVideoType(E3GPNoVideo), sl@0: iAudioType(E3GPNoAudio) sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeFile::doTestStepPreambleL() sl@0: { sl@0: // ensure the base class setup is completed first sl@0: C3GPLibComposeBase::doTestStepPreambleL(); sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: TInt temp; sl@0: if (GetIntFromConfig(ConfigSection(), _L("inputFormat"), temp)) sl@0: { sl@0: iInputFileFormat = (T3GPFileFormatType)temp; sl@0: sl@0: if (GetIntFromConfig(ConfigSection(), _L("video"), temp)) sl@0: { sl@0: iVideoType = (T3GPVideoType)temp; sl@0: } sl@0: sl@0: if (GetIntFromConfig(ConfigSection(), _L("audio"), temp)) sl@0: { sl@0: iAudioType = (T3GPAudioType)temp; sl@0: } sl@0: sl@0: if (iVideoType == E3GPNoVideo && iAudioType == E3GPNoAudio) sl@0: { sl@0: // At least audio or video should be specified sl@0: ERR_PRINTF1(_L("Specify at least video or audio")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: else sl@0: { sl@0: #ifdef __WINSCW__ sl@0: _LIT(KTestFolderName, "testFolderNameEmu"); sl@0: #else sl@0: _LIT(KTestFolderName, "testFolderNameHw"); sl@0: #endif sl@0: sl@0: TPtrC testFolderName; sl@0: if (GetStringFromConfig(_L("general"), KTestFolderName, testFolderName)) sl@0: { sl@0: TInt err = iFs.Connect(); sl@0: if (err == KErrNone) sl@0: { sl@0: iFs.MkDirAll(testFolderName); sl@0: sl@0: TFileName fileName; sl@0: // Create a temp file for the composer to write data into sl@0: err = iFile.Temp(iFs, testFolderName, fileName, EFileShareExclusive); sl@0: if (err == KErrNone) sl@0: { sl@0: iFileName.CreateL(fileName); sl@0: } sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF1(_L("Fail to create temp file for testing.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF1(_L("Fail to provide test directory.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: // file format has to be specified sl@0: ERR_PRINTF1(_L("Specify file format of the file to be composed")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeFile::doTestStepPostambleL() sl@0: { sl@0: // clean up of temp file sl@0: iFile.Close(); sl@0: iFs.Delete(iFileName); sl@0: iFs.Close(); sl@0: sl@0: iFileName.Close(); sl@0: sl@0: // clean up all composer test base setups sl@0: C3GPLibComposeBase::doTestStepPostambleL(); sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibComposeFile::doTestStepComposeOpenL(C3GPCompose& aComposer) sl@0: { sl@0: T3GPVideoPropertiesBase* video = SetupVideoPropertiesL(); sl@0: CleanupStack::PushL(video); sl@0: sl@0: T3GPAudioPropertiesBase* audio = SetupAudioPropertiesL(); sl@0: CleanupStack::PushL(audio); sl@0: sl@0: TInt err = aComposer.Open(iInputFileFormat, video, audio, iFile); sl@0: if (err == KErrNone) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF2(_L("C3GPLibComposeFile::doTestStepComposeOpenL => C3GPComposer::Open returns = %d"), err); sl@0: } sl@0: SetTestStepError(err); sl@0: SetTestStepResult(EInconclusive); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2); // audio, video sl@0: } sl@0: sl@0: void C3GPLibComposeFile::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer) sl@0: { sl@0: // add a dummy video frame. The content is of no importance for this test case, sl@0: // only the file format is of interest sl@0: TInt err = KErrNone; sl@0: sl@0: if (iVideoType != E3GPNoVideo) sl@0: { sl@0: err = aComposer.WriteVideoFrame(KDummyData, 10, ETrue); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Fail to write video frame, err = %d"), err); sl@0: } sl@0: } sl@0: sl@0: if (err == KErrNone && iAudioType != E3GPNoAudio) sl@0: { sl@0: // add a dummy audio frame. The content is of no importance for this test case, sl@0: // only the file format is of interest sl@0: err = aComposer.WriteAudioFrames(KDummyData, 10); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Fail to write audio frame, err = %d"), err); sl@0: } sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EInconclusive); sl@0: } sl@0: } sl@0: sl@0: T3GPVideoPropertiesBase* C3GPLibComposeFile::SetupVideoPropertiesL() sl@0: { sl@0: if (iVideoType == E3GPNoVideo) sl@0: { sl@0: return NULL; sl@0: } sl@0: sl@0: // create a dummy video property for setting the composer sl@0: T3GPVideoPropertiesBase* video = NULL; sl@0: switch(iVideoType) sl@0: { sl@0: case E3GPMpeg4Video: sl@0: video = SetupMpeg4VideoL(); sl@0: break; sl@0: sl@0: case E3GPAvcProfileBaseline: sl@0: case E3GPAvcProfileMain: sl@0: case E3GPAvcProfileExtended: sl@0: case E3GPAvcProfileHigh: sl@0: video = SetupAvcVideoL(); sl@0: break; sl@0: sl@0: case E3GPH263Profile0: sl@0: case E3GPH263Profile3: sl@0: video = SetupH263VideoL(); sl@0: break; sl@0: sl@0: default: sl@0: User::Leave(KErrUnknown); sl@0: } sl@0: sl@0: return video; sl@0: } sl@0: sl@0: T3GPVideoPropertiesBase* C3GPLibComposeFile::SetupAvcVideoL() sl@0: { sl@0: T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesAvc(1000, TSize(100, 100), KDummyData); sl@0: return video; sl@0: } sl@0: sl@0: T3GPVideoPropertiesBase* C3GPLibComposeFile::SetupH263VideoL() sl@0: { sl@0: T3GPVideoPropertiesH263::TProfile profile = T3GPVideoPropertiesH263::EProfile0; sl@0: if (iVideoType == E3GPH263Profile3) sl@0: { sl@0: profile = T3GPVideoPropertiesH263::EProfile3; sl@0: } sl@0: T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesH263(1000, TSize(100, 100), 10, profile); sl@0: return video; sl@0: } sl@0: sl@0: T3GPVideoPropertiesBase* C3GPLibComposeFile::SetupMpeg4VideoL() sl@0: { sl@0: T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesMpeg4Video(1000, TSize(100, 100), 4000, 400, KDummyData); sl@0: return video; sl@0: } sl@0: sl@0: T3GPAudioPropertiesBase* C3GPLibComposeFile::SetupAudioPropertiesL() sl@0: { sl@0: if (iAudioType == E3GPNoAudio) sl@0: { sl@0: return NULL; sl@0: } sl@0: sl@0: // create a dummy audio property for setting the composer sl@0: T3GPAudioPropertiesBase* audio = NULL; sl@0: switch(iAudioType) sl@0: { sl@0: case E3GPMpeg4Video: sl@0: audio = SetupMpeg4AudioL(); sl@0: break; sl@0: sl@0: case E3GPQcelp13K: sl@0: audio = SetupQcelpAudioL(); sl@0: break; sl@0: sl@0: case E3GPAmrNB: sl@0: case E3GPAmrWB: sl@0: audio = SetupAmrAudioL(); sl@0: break; sl@0: sl@0: default: sl@0: User::Leave(KErrUnknown); sl@0: break; sl@0: } sl@0: sl@0: return audio; sl@0: } sl@0: sl@0: T3GPAudioPropertiesBase* C3GPLibComposeFile::SetupQcelpAudioL() sl@0: { sl@0: // for this test's purpose, just use the default QCELP sample entry storage mode sl@0: T3GPAudioPropertiesBase* audio = new (ELeave) T3GPAudioPropertiesQcelp(1000, 10); sl@0: return audio; sl@0: } sl@0: sl@0: T3GPAudioPropertiesBase* C3GPLibComposeFile::SetupAmrAudioL() sl@0: { sl@0: T3GPAudioPropertiesAmr::TSpeechCodec codec = T3GPAudioPropertiesAmr::EAmrWB; sl@0: if (iAudioType == E3GPAmrNB) sl@0: { sl@0: codec = T3GPAudioPropertiesAmr::EAmrNB; sl@0: } sl@0: T3GPAudioPropertiesBase* audio = new (ELeave) T3GPAudioPropertiesAmr(1000, 10, 150, codec); sl@0: return audio; sl@0: } sl@0: sl@0: T3GPAudioPropertiesBase* C3GPLibComposeFile::SetupMpeg4AudioL() sl@0: { sl@0: T3GPAudioPropertiesBase* audio = new (ELeave)T3GPAudioPropertiesMpeg4Audio(1000, KDummyData); sl@0: return audio; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeFileWithFileFormatCheck sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeFileWithFileFormatCheck::C3GPLibComposeFileWithFileFormatCheck() : sl@0: iOutputFileFormat(E3GP3GP) sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeFileWithFileFormatCheck::doTestStepPreambleL() sl@0: { sl@0: // ensure base class setup is completed first sl@0: C3GPLibComposeFile::doTestStepPreambleL(); sl@0: sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: TInt temp; sl@0: if (!GetIntFromConfig(ConfigSection(), _L("outputFormat"), temp)) sl@0: { sl@0: ERR_PRINTF1(_L("outputFormat not specified")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: else sl@0: { sl@0: iOutputFileFormat = (T3GPFileFormatType)temp; sl@0: } sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeFileWithFileFormatCheck::doTestStepL() sl@0: { sl@0: if (TestStepResult() != EPass) sl@0: { sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: // this triggers: sl@0: // 1. Create a composer sl@0: // 2. Open the composer - C3GPLibComposeFileFormatCheck::doTestStepComposeOpenL sl@0: // 3. Write Video & Audio Data - C3GPLibComposeFileFormatCheck::doTestStepComposeWriteVideoAudioL sl@0: // 4. Write User Data - C3GPLibComposeFileFormatCheck::doTestStepComposeSetUserDataL sl@0: // 5. Complete the composer sl@0: TVerdict verdict = C3GPLibComposeFile::doTestStepL(); sl@0: if (verdict == EPass) sl@0: { sl@0: // once the file is composed, it can be verified if the file composed is the same as the sl@0: // expected file format sl@0: verdict = VerifyFileFormatL(iFile); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L(" C3GPLibComposeFile::doTestStepL returns failed result")); sl@0: } sl@0: SetTestStepResult(verdict); sl@0: sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF2(_L("C3GPLibComposeFile::doTestStepL returns %d"), TestStepResult()); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeFileWithFileFormatCheck::VerifyFileFormatL(const RFile& aFile) sl@0: { sl@0: // Seek to the beginning of the file sl@0: TInt pos = 0; sl@0: User::LeaveIfError(aFile.Seek(ESeekStart, pos)); sl@0: sl@0: TVerdict verdict = EFail; sl@0: TBuf8<4> atom; sl@0: sl@0: while(ETrue) sl@0: { sl@0: // read the file content and search for the 'ftyp' atom to check sl@0: // the 32bit value of brand attribute immediately following the 'ftyp' type. sl@0: User::LeaveIfError(aFile.Read(atom)); sl@0: if (atom.Length() < atom.MaxLength()) sl@0: { sl@0: break; sl@0: } sl@0: sl@0: // read 4 bytes at a time, if 'ftyp' is found sl@0: if (Mem::Compare((&KFtypAtom)->Ptr(), (&KFtypAtom)->Length(), atom.Ptr(), atom.Length()) == 0) sl@0: { sl@0: // read 4 more bytes, and it should contain the brand value sl@0: User::LeaveIfError(aFile.Read(atom)); sl@0: if (atom.Length() < atom.MaxLength()) sl@0: { sl@0: // cannot read brand value, test failed. sl@0: ERR_PRINTF1(_L("Failed to read enough data for comparison.")); sl@0: break; sl@0: } sl@0: sl@0: switch(iOutputFileFormat) sl@0: { sl@0: case E3GP3G2: sl@0: { sl@0: // check if file type is 3G2 sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF1(_L("Check 3GP2 file format.")); sl@0: } sl@0: if (Mem::Compare((&K3g2Brand)->Ptr(), (&K3g2Brand)->Length(), atom.Ptr(), atom.Length()) == 0) sl@0: { sl@0: verdict = EPass; sl@0: break; sl@0: } sl@0: } sl@0: break; sl@0: sl@0: case E3GPMP4: sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF1(_L("Check MP4 file format.")); sl@0: } sl@0: // check if file type is MP4 sl@0: if (Mem::Compare((&KMp4Brand)->Ptr(), (&KMp4Brand)->Length(), atom.Ptr(), atom.Length()) == 0) sl@0: { sl@0: verdict = EPass; sl@0: } sl@0: } sl@0: break; sl@0: sl@0: case E3GP3GP: sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF1(_L("Check 3GP file format.")); sl@0: } sl@0: // check if file type is 3GP sl@0: // Both 3gp4 & 3gp6 are valid brands, thus checking ONLY "3gp" instead of the full atom size sl@0: if (Mem::Compare((&K3gpBrand)->Ptr(), (&K3gpBrand)->Length(), atom.Ptr(), (&K3gpBrand)->Length()) == 0) sl@0: { sl@0: verdict = EPass; sl@0: } sl@0: } sl@0: break; sl@0: sl@0: default: sl@0: INFO_PRINTF1(_L("Unknown format expected.")); sl@0: verdict = EInconclusive; sl@0: break; sl@0: } sl@0: sl@0: // ftyp is found, regardless of the result, finish reading the file sl@0: break; sl@0: } sl@0: } sl@0: sl@0: return verdict; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeFrameDependency sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeFrameDependency::C3GPLibComposeFrameDependency() sl@0: { sl@0: } sl@0: sl@0: void C3GPLibComposeFrameDependency::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer) sl@0: { sl@0: TInt err = KErrNone; sl@0: T3GPFrameDependencies dep; sl@0: sl@0: for (TInt i = 0; i <= (TInt)E3GPDependencyNone; i++) sl@0: { sl@0: for (TInt j = 0; j <= (TInt)E3GPDependencyNone; j++) sl@0: { sl@0: for (TInt k = 0; k <= (TInt)E3GPRedundancyNone; k++) sl@0: { sl@0: dep.iDependsOn = (T3GPVideoFrameDependency)i; sl@0: dep.iIsDependedOn = (T3GPVideoFrameDependency)j; sl@0: dep.iHasRedundancy = (T3GPVideoFrameRedundancy)k; sl@0: sl@0: // add a dummy video frame. The content is of no importance for this test case, sl@0: // only the different dependency/redundancy is the focus of this test sl@0: err = aComposer.WriteVideoFrame(KDummyData, 100, ETrue, dep); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("C3GPCompose::WriteVideoFrame (with frame dependency) failed with error = %d"), err); sl@0: SetTestStepResult(EFail); sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeVideoProperties sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeVideoProperties::C3GPLibComposeVideoProperties() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeVideoProperties::doTestStepPreambleL() sl@0: { sl@0: C3GPLibComposeFile::doTestStepPreambleL(); sl@0: if (TestStepResult() != EPass) sl@0: { sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TInt temp; sl@0: TBool result = ETrue; sl@0: result = GetIntFromConfig(ConfigSection(), _L("width"), temp); sl@0: if (result) sl@0: { sl@0: iSize.iWidth = temp; sl@0: result = GetIntFromConfig(ConfigSection(), _L("height"), temp); sl@0: if (result) sl@0: { sl@0: iSize.iHeight = temp; sl@0: result = GetIntFromConfig(ConfigSection(), _L("timescale"), temp); sl@0: if (result) sl@0: { sl@0: iTimescale = temp; sl@0: } sl@0: } sl@0: } sl@0: sl@0: if (result && sl@0: (iVideoType == E3GPMpeg4Video || sl@0: iVideoType == E3GPAvcProfileBaseline || sl@0: iVideoType == E3GPAvcProfileMain || sl@0: iVideoType == E3GPAvcProfileExtended || sl@0: iVideoType == E3GPAvcProfileHigh ) sl@0: ) sl@0: { sl@0: TPtrC decoder; sl@0: result = GetStringFromConfig(ConfigSection(), _L("decoderSpecInfo"), decoder); sl@0: if (result) sl@0: { sl@0: iDecoderSpecInfo.CreateL(decoder.Length()); sl@0: iDecoderSpecInfo.Copy(decoder); sl@0: } sl@0: } sl@0: sl@0: if (result && (iVideoType == E3GPMpeg4Video)) sl@0: { sl@0: result = GetIntFromConfig(ConfigSection(), _L("avgBR"), temp); sl@0: if (result) sl@0: { sl@0: iAvgBitRate = temp; sl@0: result = GetIntFromConfig(ConfigSection(), _L("maxBR"), temp); sl@0: if (result) sl@0: { sl@0: iMaxBitRate = temp; sl@0: } sl@0: } sl@0: } sl@0: sl@0: if (result && (iVideoType == E3GPH263Profile0 || iVideoType == E3GPH263Profile3)) sl@0: { sl@0: result = GetIntFromConfig(ConfigSection(), _L("level"), temp); sl@0: if (result) sl@0: { sl@0: iVideoLevel = temp; sl@0: } sl@0: } sl@0: sl@0: if (!result) sl@0: { sl@0: ERR_PRINTF1(_L("Cannot retrieve necessary video properties to complete this test.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeVideoProperties::doTestStepPostambleL() sl@0: { sl@0: iDecoderSpecInfo.Close(); sl@0: sl@0: // clean up base class setups sl@0: C3GPLibComposeFile::doTestStepPostambleL(); sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: T3GPVideoPropertiesBase* C3GPLibComposeVideoProperties::SetupAvcVideoL() sl@0: { sl@0: T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesAvc(iTimescale, iSize, iDecoderSpecInfo); sl@0: return video; sl@0: } sl@0: sl@0: T3GPVideoPropertiesBase* C3GPLibComposeVideoProperties::SetupH263VideoL() sl@0: { sl@0: T3GPVideoPropertiesH263::TProfile profile = T3GPVideoPropertiesH263::EProfile0; sl@0: if (iVideoType == E3GPH263Profile3) sl@0: { sl@0: profile = T3GPVideoPropertiesH263::EProfile3; sl@0: } sl@0: T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesH263(iTimescale, iSize, iVideoLevel, profile); sl@0: return video; sl@0: } sl@0: sl@0: T3GPVideoPropertiesBase* C3GPLibComposeVideoProperties::SetupMpeg4VideoL() sl@0: { sl@0: T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesMpeg4Video(iTimescale, sl@0: iSize, sl@0: iMaxBitRate, sl@0: iAvgBitRate, sl@0: iDecoderSpecInfo); sl@0: return video; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeWithSpecificBufferSize sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeWithSpecificBufferSize::C3GPLibComposeWithSpecificBufferSize() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeWithSpecificBufferSize::doTestStepPreambleL() sl@0: { sl@0: TVerdict verdict = C3GPLibComposeFile::doTestStepPreambleL(); sl@0: if (verdict != EPass) sl@0: { sl@0: return verdict; sl@0: } sl@0: sl@0: TInt temp; sl@0: if (GetIntFromConfig(ConfigSection(), _L("bufferSize"), temp)) sl@0: { sl@0: iBufferSize = temp; sl@0: if (GetIntFromConfig(ConfigSection(), _L("bufferCount"), temp)) sl@0: { sl@0: iBufferMaxCount = temp; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF1(_L("C3GPLibComposeWithSpecificBufferSize cannot read Buffer Max Count")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF1(_L("C3GPLibComposeWithSpecificBufferSize cannot read Buffer Size")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: C3GPCompose* C3GPLibComposeWithSpecificBufferSize::doTestStepCreateComposerL() sl@0: { sl@0: return C3GPCompose::NewL(iBufferSize, iBufferMaxCount); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeUserData sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeUserData::C3GPLibComposeUserData() : sl@0: iUdtaLocation(-1) sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeUserData::doTestStepPreambleL() sl@0: { sl@0: // ensure all basic setup is completed first sl@0: C3GPLibComposeFile::doTestStepPreambleL(); sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: GetBoolFromConfig(ConfigSection(), _L("udtaMoov"), iUdtaMoov); sl@0: GetBoolFromConfig(ConfigSection(), _L("udtaVideo"), iUdtaVideo); sl@0: GetBoolFromConfig(ConfigSection(), _L("udtaAudio"), iUdtaAudio); sl@0: GetIntFromConfig(ConfigSection(), _L("udtaLocation"), iUdtaLocation); sl@0: sl@0: if (!iUdtaMoov && !iUdtaVideo && !iUdtaAudio && iUdtaLocation == -1) sl@0: { sl@0: ERR_PRINTF1(_L("No user data location is specified. Test cannot proceed.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: else sl@0: { sl@0: TPtrC userDataPtr; sl@0: if (GetStringFromConfig(ConfigSection(), _L("userData"), userDataPtr)) sl@0: { sl@0: iUserData.CreateL(userDataPtr.Length()); sl@0: iUserData.Copy(userDataPtr); sl@0: } sl@0: else sl@0: { sl@0: // user data not specified, use dummy data sl@0: iUserData.CreateL(KDummyData); sl@0: } sl@0: } sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeUserData::doTestStepPostambleL() sl@0: { sl@0: iUserData.Close(); sl@0: sl@0: // clean up base class setups sl@0: C3GPLibComposeFile::doTestStepPostambleL(); sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibComposeUserData::doTestStepComposeSetUserDataL(C3GPCompose& aComposer) sl@0: { sl@0: TInt err = KErrNone; sl@0: if (iUdtaVideo) sl@0: { sl@0: err = aComposer.SetUserData(E3GPUdtaVideoTrak, iUserData); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("C3GPComposer::SetUserData(E3GPUdtaVideoTrak) fails with %d"), err); sl@0: SetTestStepError(err); sl@0: } sl@0: } sl@0: if (iUdtaAudio) sl@0: { sl@0: err = aComposer.SetUserData(E3GPUdtaAudioTrak, iUserData); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("C3GPComposer::SetUserData(E3GPUdtaAudioTrak) fails with %d"), err); sl@0: SetTestStepError(err); sl@0: } sl@0: } sl@0: if (iUdtaMoov) sl@0: { sl@0: err = aComposer.SetUserData(E3GPUdtaMoov, iUserData); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("C3GPComposer::SetUserData(E3GPUdtaMoov) fails with %d"), err); sl@0: SetTestStepError(err); sl@0: } sl@0: } sl@0: sl@0: if (iUdtaLocation != -1) sl@0: { sl@0: // if a specific user data location has been specified, try it! sl@0: err = aComposer.SetUserData((T3GPUdtaLocation)iUdtaLocation, iUserData); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF3(_L("C3GPComposer::SetUserData(%d) fails with %d"), iUdtaLocation, err); sl@0: SetTestStepError(err); sl@0: } sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeWithFlag sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeWithFlag::C3GPLibComposeWithFlag() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeWithFlag::doTestStepPreambleL() sl@0: { sl@0: // ensure the base class setup is completed first sl@0: C3GPLibComposeFile::doTestStepPreambleL(); sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: if (!GetIntFromConfig(ConfigSection(), _L("flag"), iComposeFlag)) sl@0: { sl@0: ERR_PRINTF1(_L("C3GPLibComposeWithFlag::doTestStepPreambleL cannot retrieve any composer flags.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibComposeWithFlag::doTestStepComposeOpenL(C3GPCompose& aComposer) sl@0: { sl@0: T3GPVideoPropertiesBase* video = SetupVideoPropertiesL(); sl@0: CleanupStack::PushL(video); sl@0: sl@0: T3GPAudioPropertiesBase* audio = SetupAudioPropertiesL(); sl@0: CleanupStack::PushL(audio); sl@0: sl@0: TInt err = aComposer.Open(iInputFileFormat, video, audio, iFile, iComposeFlag); sl@0: if (err == KErrNone) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("C3GPLibComposeFile::doTestStepComposeOpenL => C3GPComposer::Open returns = %d"), err); sl@0: SetTestStepResult(EInconclusive); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2); // audio, video sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeAudioProperties sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeAudioProperties::C3GPLibComposeAudioProperties() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeAudioProperties::doTestStepPreambleL() sl@0: { sl@0: C3GPLibComposeFile::doTestStepPreambleL(); sl@0: if (TestStepResult() != EPass) sl@0: { sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TInt temp; sl@0: TBool result = ETrue; sl@0: result = GetIntFromConfig(ConfigSection(), _L("timescale"), temp); sl@0: if (result) sl@0: { sl@0: iTimescale = temp; sl@0: } sl@0: sl@0: if (result && (iAudioType == E3GPQcelp13K)) sl@0: { sl@0: result = GetIntFromConfig(ConfigSection(), _L("storage"), temp); sl@0: if (result) sl@0: { sl@0: iQCelpMode = (T3GPQcelpStorageMode) temp; sl@0: if (iQCelpMode == E3GPMP4AudioDescriptionBox) sl@0: { sl@0: TPtrC decoder; sl@0: result = GetStringFromConfig(ConfigSection(), _L("decoderSpecInfo"), decoder); sl@0: if (result) sl@0: { sl@0: iDecoderSpecInfo.CreateL(decoder.Length()); sl@0: iDecoderSpecInfo.Copy(decoder); sl@0: } sl@0: } sl@0: } sl@0: sl@0: if (result) sl@0: { sl@0: result = GetIntFromConfig(ConfigSection(), _L("fps"), iFps); sl@0: } sl@0: } sl@0: sl@0: if (result && (iAudioType == E3GPMpeg4Audio)) sl@0: { sl@0: TPtrC decoder; sl@0: result = GetStringFromConfig(ConfigSection(), _L("decoderSpecInfo"), decoder); sl@0: if (result) sl@0: { sl@0: iDecoderSpecInfo.CreateL(decoder.Length()); sl@0: iDecoderSpecInfo.Copy(decoder); sl@0: } sl@0: } sl@0: sl@0: if (result && (iAudioType == E3GPAmrNB || iAudioType == E3GPAmrWB)) sl@0: { sl@0: result = GetIntFromConfig(ConfigSection(), _L("modeSet"), iModeSet); sl@0: if (result) sl@0: { sl@0: result = GetIntFromConfig(ConfigSection(), _L("fps"), iFps); sl@0: } sl@0: } sl@0: sl@0: if (!result) sl@0: { sl@0: // sl@0: ERR_PRINTF1(_L("Cannot retrieve necessary a properties to complete this test.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeAudioProperties::doTestStepPostambleL() sl@0: { sl@0: iDecoderSpecInfo.Close(); sl@0: sl@0: // clean up base class setups sl@0: C3GPLibComposeFile::doTestStepPostambleL(); sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: T3GPAudioPropertiesBase* C3GPLibComposeAudioProperties::SetupQcelpAudioL() sl@0: { sl@0: T3GPAudioPropertiesBase* audio = NULL; sl@0: sl@0: if (iQCelpMode == E3GPQcelpSampleEntryBox) sl@0: { sl@0: audio = new (ELeave) T3GPAudioPropertiesQcelp(iTimescale, iFps); sl@0: } sl@0: else if (iQCelpMode == E3GPMP4AudioDescriptionBox) sl@0: { sl@0: audio = new (ELeave) T3GPAudioPropertiesQcelp(iTimescale, iFps, iDecoderSpecInfo); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrNotFound); sl@0: } sl@0: sl@0: return audio; sl@0: } sl@0: sl@0: T3GPAudioPropertiesBase* C3GPLibComposeAudioProperties::SetupAmrAudioL() sl@0: { sl@0: T3GPAudioPropertiesAmr::TSpeechCodec codec = T3GPAudioPropertiesAmr::EAmrWB; sl@0: if (iAudioType == E3GPAmrNB) sl@0: { sl@0: codec = T3GPAudioPropertiesAmr::EAmrNB; sl@0: } sl@0: T3GPAudioPropertiesBase* audio = new (ELeave) T3GPAudioPropertiesAmr(iTimescale, iFps, iModeSet, codec); sl@0: return audio; sl@0: } sl@0: sl@0: T3GPAudioPropertiesBase* C3GPLibComposeAudioProperties::SetupMpeg4AudioL() sl@0: { sl@0: T3GPAudioPropertiesBase* audio = new (ELeave)T3GPAudioPropertiesMpeg4Audio(iTimescale, iDecoderSpecInfo); sl@0: return audio; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeWithNoAudioVideo sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeWithNoAudioVideo::C3GPLibComposeWithNoAudioVideo() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeWithNoAudioVideo::doTestStepPreambleL() sl@0: { sl@0: // ensure the base class setup is completed first sl@0: C3GPLibComposeFile::doTestStepPreambleL(); sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: // reset the video / audio type both of No Video & No Audio sl@0: iVideoType = E3GPNoVideo; sl@0: iAudioType = E3GPNoAudio; sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeAudioFrames sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeAudioFrames::C3GPLibComposeAudioFrames() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeAudioFrames::doTestStepPreambleL() sl@0: { sl@0: // ensure all basic setup is completed first sl@0: C3GPLibComposeFile::doTestStepPreambleL(); sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: if (GetIntFromConfig(ConfigSection(), _L("duration"), iDuration)) sl@0: { sl@0: TPtrC audioFramePtr; sl@0: if (GetStringFromConfig(ConfigSection(), _L("audioFrame"), audioFramePtr)) sl@0: { sl@0: iAudioFrames.CreateL(audioFramePtr.Length()); sl@0: iAudioFrames.Copy(audioFramePtr); sl@0: } sl@0: else sl@0: { sl@0: // cannot find expected error! sl@0: ERR_PRINTF1(_L("audioFrame not specified. Test cannot proceed.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: // cannot find expected error! sl@0: ERR_PRINTF1(_L("duration not specified. Test cannot proceed.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeAudioFrames::doTestStepPostambleL() sl@0: { sl@0: // cleanup sl@0: iAudioFrames.Close(); sl@0: sl@0: // ensure all base cleanup is done sl@0: C3GPLibComposeFile::doTestStepPostambleL(); sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibComposeAudioFrames::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer) sl@0: { sl@0: // add the audio frame sl@0: TInt err = aComposer.WriteAudioFrames(iAudioFrames, iDuration); sl@0: if (err != KErrNone) sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF2(_L("C3GPCompose::WriteAudioFrames returns %d"), err); sl@0: } sl@0: SetTestStepError(err); sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeVideoFrame sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeVideoFrame::C3GPLibComposeVideoFrame() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeVideoFrame::doTestStepPreambleL() sl@0: { sl@0: // ensure all basic setup is completed first sl@0: C3GPLibComposeFile::doTestStepPreambleL(); sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: if (GetBoolFromConfig(ConfigSection(), _L("keyFrame"), iKeyFrame)) sl@0: { sl@0: if (GetIntFromConfig(ConfigSection(), _L("duration"), iDuration)) sl@0: { sl@0: TPtrC framePtr; sl@0: if (GetStringFromConfig(ConfigSection(), _L("videoFrame"), framePtr)) sl@0: { sl@0: iVideoFrame.CreateL(framePtr.Length()); sl@0: iVideoFrame.Copy(framePtr); sl@0: sl@0: TInt dependsOn; sl@0: TInt isDependedOn; sl@0: TInt hasRedundancy; sl@0: if (GetIntFromConfig(ConfigSection(), _L("dependsOn"), dependsOn) && sl@0: GetIntFromConfig(ConfigSection(), _L("isDependedOn"), isDependedOn) && sl@0: GetIntFromConfig(ConfigSection(), _L("hasRedundancy"), hasRedundancy)) sl@0: { sl@0: iDependencies = new (ELeave) T3GPFrameDependencies(); sl@0: iDependencies->iDependsOn = (T3GPVideoFrameDependency) dependsOn; sl@0: iDependencies->iIsDependedOn = (T3GPVideoFrameDependency) isDependedOn; sl@0: iDependencies->iHasRedundancy = (T3GPVideoFrameRedundancy) hasRedundancy; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: // cannot find expected error! sl@0: ERR_PRINTF1(_L("videoFrame not specified. Test cannot proceed.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: // cannot find expected error! sl@0: ERR_PRINTF1(_L("duration not specified. Test cannot proceed.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: // cannot find expected error! sl@0: ERR_PRINTF1(_L("keyFrame not specified. Test cannot proceed.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeVideoFrame::doTestStepPostambleL() sl@0: { sl@0: // cleanup sl@0: iVideoFrame.Close(); sl@0: delete iDependencies; sl@0: sl@0: // ensure all base cleanup is done sl@0: C3GPLibComposeFile::doTestStepPostambleL(); sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibComposeVideoFrame::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer) sl@0: { sl@0: // add the video frame sl@0: TInt err = KErrNone; sl@0: if (iDependencies) sl@0: { sl@0: err = aComposer.WriteVideoFrame(iVideoFrame, iDuration, iKeyFrame, *iDependencies); sl@0: } sl@0: else sl@0: { sl@0: err = aComposer.WriteVideoFrame(iVideoFrame, iDuration, iKeyFrame); sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: INFO_PRINTF2(_L("C3GPCompose::WriteVideoFrame returns %d"), err); sl@0: SetTestStepError(err); sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeOpenAgain sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeOpenAgain::C3GPLibComposeOpenAgain() sl@0: { sl@0: } sl@0: sl@0: void C3GPLibComposeOpenAgain::doTestStepComposeOpenL(C3GPCompose& aComposer) sl@0: { sl@0: C3GPLibComposeFile::doTestStepComposeOpenL(aComposer); sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: // ensure the composer is opened, then try open it again! sl@0: T3GPVideoPropertiesBase* video = SetupVideoPropertiesL(); sl@0: CleanupStack::PushL(video); sl@0: sl@0: T3GPAudioPropertiesBase* audio = SetupAudioPropertiesL(); sl@0: CleanupStack::PushL(audio); sl@0: sl@0: // retrieve the current location of the temp file created when sl@0: // opening the composer the first time in C3GPLibComposeFile::doTestStepComposeOpenL sl@0: RBuf folderName; sl@0: folderName.CreateL(KMaxFileName); sl@0: CleanupClosePushL(folderName); sl@0: User::LeaveIfError(iFile.FullName(folderName)); sl@0: sl@0: TParsePtrC folderParse(folderName); sl@0: TPtrC folder = folderParse.DriveAndPath(); sl@0: sl@0: // create another file temp file within the same folder sl@0: RFile file; sl@0: TFileName fileName; sl@0: User::LeaveIfError(file.Temp(iFs, folder, fileName, EFileWrite)); sl@0: sl@0: TInt err = aComposer.Open(iInputFileFormat, video, audio, file); sl@0: TInt err2 = aComposer.Open(iInputFileFormat, video, audio, fileName); sl@0: if (err != KErrNone && err == err2) sl@0: { sl@0: SetTestStepError(err); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("C3GPLibComposeOpenAgain C3GPCompose::Open returns inconsistent error.")); sl@0: } sl@0: sl@0: // clean up sl@0: file.Close(); sl@0: iFs.Delete(fileName); sl@0: sl@0: CleanupStack::PopAndDestroy(3); // audio, video, folderName sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeOpenReadOnlyFile sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeOpenReadOnlyFile::C3GPLibComposeOpenReadOnlyFile() sl@0: { sl@0: } sl@0: sl@0: void C3GPLibComposeOpenReadOnlyFile::doTestStepComposeOpenL(C3GPCompose& aComposer) sl@0: { sl@0: RBuf fileName; sl@0: fileName.CreateL(KMaxFilename); sl@0: CleanupClosePushL(fileName); sl@0: sl@0: // change the file to be opened to be a READ-ONLY file sl@0: User::LeaveIfError(iFile.FullName(fileName)); sl@0: iFile.Close(); sl@0: sl@0: User::LeaveIfError(iFile.Open(iFs, fileName, EFileShareReadersOnly)); sl@0: CleanupStack::PopAndDestroy(&fileName); sl@0: sl@0: C3GPLibComposeWithFlag::doTestStepComposeOpenL(aComposer); sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeOpenReadOnlyFile::doTestStepL() sl@0: { sl@0: TVerdict verdict(EFail); sl@0: sl@0: TRAP_IGNORE(verdict = C3GPLibComposeWithFlag::doTestStepL()); sl@0: sl@0: return verdict; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeOpenedFile sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeOpenedFile::C3GPLibComposeOpenedFile() sl@0: { sl@0: } sl@0: sl@0: void C3GPLibComposeOpenedFile::doTestStepComposeOpenL(C3GPCompose& aComposer) sl@0: { sl@0: RBuf fileName; sl@0: fileName.CreateL(KMaxFilename); sl@0: CleanupClosePushL(fileName); sl@0: sl@0: // change the file to be opened to be a READ-ONLY file sl@0: User::LeaveIfError(iFile.FullName(fileName)); sl@0: iFile.Close(); sl@0: sl@0: User::LeaveIfError(iFile.Open(iFs, fileName, EFileShareAny)); sl@0: sl@0: T3GPVideoPropertiesBase* video = SetupVideoPropertiesL(); sl@0: CleanupStack::PushL(video); sl@0: sl@0: T3GPAudioPropertiesBase* audio = SetupAudioPropertiesL(); sl@0: CleanupStack::PushL(audio); sl@0: sl@0: TInt err1 = aComposer.Open(iInputFileFormat, video, audio, fileName); sl@0: if (err1 != KErrNone) sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF2(_L("C3GPLibComposeOpenedFile::doTestStepComposeOpenL => C3GPComposer::Open returns = %d"), err1); sl@0: } sl@0: sl@0: iFile.Close(); sl@0: User::LeaveIfError(iFile.Open(iFs, fileName, EFileShareReadersOrWriters)); sl@0: TInt err2 = aComposer.Open(iInputFileFormat, video, audio, fileName); sl@0: sl@0: if (err1 == err2) sl@0: { sl@0: SetTestStepError(err1); sl@0: } sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(3); // audio, video, fileName sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeMultiComposeOnSameFile sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeMultiComposeOnSameFile::C3GPLibComposeMultiComposeOnSameFile() sl@0: { sl@0: } sl@0: sl@0: void C3GPLibComposeMultiComposeOnSameFile::doTestStepComposeOpenL(C3GPCompose& aComposer) sl@0: { sl@0: C3GPLibComposeFilename::doTestStepComposeOpenL(aComposer); sl@0: if (TestStepError() == KErrNone && TestStepResult() == EPass) sl@0: { sl@0: T3GPAudioPropertiesMpeg4Audio audio(100, KDummyData); sl@0: T3GPVideoPropertiesAvc video(100, TSize(100, 100), KDummyData); sl@0: C3GPCompose* composer2 = C3GPCompose::NewL(); sl@0: sl@0: TInt err = composer2->Open(E3GP3GP, &video, &audio, iFilename); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepError(err); sl@0: } sl@0: sl@0: // close the composer sl@0: composer2->Complete(); sl@0: delete composer2; sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeMultiComposers sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeMultiComposers::C3GPLibComposeMultiComposers() sl@0: { sl@0: } sl@0: sl@0: void C3GPLibComposeMultiComposers::doTestStepComposeOpenL(C3GPCompose& aComposer) sl@0: { sl@0: C3GPLibComposeFilename::doTestStepComposeOpenL(aComposer); sl@0: if (TestStepError() == KErrNone && TestStepResult() == EPass) sl@0: { sl@0: #ifdef __WINSCW__ sl@0: _LIT(KTestFolderName, "testFolderNameEmu"); sl@0: #else sl@0: _LIT(KTestFolderName, "testFolderNameHw"); sl@0: #endif sl@0: sl@0: TPtrC testFolderName; sl@0: if (!GetStringFromConfig(_L("general"), KTestFolderName, testFolderName)) sl@0: { sl@0: User::Leave(KErrNotFound); sl@0: } sl@0: sl@0: TFileName fileName; sl@0: RFs fs; sl@0: User::LeaveIfError(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: sl@0: // Composer 2 sl@0: T3GPAudioPropertiesMpeg4Audio audio1(100, KDummyData); sl@0: T3GPVideoPropertiesAvc video1(100, TSize(100, 100), KDummyData); sl@0: sl@0: RFile file1; sl@0: CleanupClosePushL(file1); sl@0: User::LeaveIfError(file1.Temp(fs, testFolderName, fileName, EFileShareExclusive)); sl@0: sl@0: C3GPCompose* composer2 = C3GPCompose::NewL(); sl@0: CleanupStack::PushL(composer2); sl@0: User::LeaveIfError(composer2->Open(E3GP3GP, &video1, &audio1, file1)); sl@0: sl@0: // composer 3 sl@0: T3GPAudioPropertiesMpeg4Audio audio2(50, KDummyData); sl@0: T3GPVideoPropertiesAvc video2(50, TSize(20, 20), KDummyData); sl@0: sl@0: RFile file2; sl@0: CleanupClosePushL(file2); sl@0: User::LeaveIfError(file2.Temp(fs, testFolderName, fileName, EFileShareExclusive)); sl@0: sl@0: C3GPCompose* composer3 = C3GPCompose::NewL(); sl@0: CleanupStack::PushL(composer3); sl@0: User::LeaveIfError(composer3->Open(E3GP3GP, &video2, &audio2, file2)); sl@0: sl@0: // write some data into composer 1, then 2, then 3 sl@0: User::LeaveIfError(aComposer.WriteVideoFrame(KDummyData, 10, EFalse)); sl@0: User::LeaveIfError(composer2->WriteVideoFrame(KDummyData, 10, EFalse)); sl@0: User::LeaveIfError(composer3->WriteVideoFrame(KDummyData, 10, EFalse)); sl@0: sl@0: // clean up for composer 3 sl@0: User::LeaveIfError(composer3->Complete()); sl@0: CleanupStack::PopAndDestroy(composer3); sl@0: CleanupStack::PopAndDestroy(&file2); sl@0: sl@0: // Parse file2 sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: User::LeaveIfError(parser->Open(fileName)); sl@0: sl@0: // write some data into composer 1 & 2 sl@0: User::LeaveIfError(aComposer.WriteVideoFrame(KDummyData, 10, EFalse)); sl@0: User::LeaveIfError(composer2->WriteVideoFrame(KDummyData, 10, EFalse)); sl@0: sl@0: // close parser and delete the file sl@0: User::LeaveIfError(parser->Complete()); sl@0: CleanupStack::PopAndDestroy(parser); sl@0: User::LeaveIfError(fs.Delete(fileName)); // delete the temp file created sl@0: sl@0: // clean up for composer 2 sl@0: User::LeaveIfError(composer2->Complete()); sl@0: file1.FullName(fileName); // retrieve the full name of file1 sl@0: CleanupStack::PopAndDestroy(composer2); sl@0: CleanupStack::PopAndDestroy(&file1); sl@0: User::LeaveIfError(fs.Delete(fileName)); // delete the temp file created sl@0: sl@0: // cleanup sl@0: CleanupStack::PopAndDestroy(&fs); sl@0: sl@0: // write some data into composer 1 sl@0: User::LeaveIfError(aComposer.WriteVideoFrame(KDummyData, 10, EFalse)); sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeCloseComposerWithoutComplete sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeCloseComposerWithoutComplete::C3GPLibComposeCloseComposerWithoutComplete() sl@0: { sl@0: } sl@0: sl@0: void C3GPLibComposeCloseComposerWithoutComplete::doTestStepComposeOpenL(C3GPCompose& aComposer) sl@0: { sl@0: // close the composer, then delete the file sl@0: aComposer.Complete(); sl@0: sl@0: RFs fs; sl@0: User::LeaveIfError(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: sl@0: // ignore any error sl@0: fs.Delete(iFilename); sl@0: sl@0: // Reopens it sl@0: T3GPAudioPropertiesMpeg4Audio audio1(100, KDummyData); sl@0: T3GPVideoPropertiesAvc video1(100, TSize(100, 100), KDummyData); sl@0: sl@0: C3GPCompose* composer = C3GPCompose::NewL(); sl@0: CleanupStack::PushL(composer); sl@0: User::LeaveIfError(composer->Open(E3GP3GP, &video1, &audio1, iFilename)); sl@0: sl@0: // write some data into composer 1, then 2, then 3 sl@0: User::LeaveIfError(composer->WriteVideoFrame(KDummyData, 10, EFalse)); sl@0: sl@0: // delete the composer before calling Complete sl@0: CleanupStack::PopAndDestroy(composer); sl@0: sl@0: RFile file; sl@0: CleanupClosePushL(file); sl@0: User::LeaveIfError(file.Open(fs, iFilename, EFileRead)); sl@0: sl@0: TInt fileSize = 0; sl@0: User::LeaveIfError(file.Size(fileSize)); sl@0: sl@0: if (fileSize == 0) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2); // file, fs sl@0: sl@0: // continue the test sl@0: C3GPLibComposeFilename::doTestStepComposeOpenL(aComposer); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposePanic sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposePanic::C3GPLibComposePanic() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibComposePanic::doTestStepPreambleL() sl@0: { sl@0: TVerdict verdict = C3GPLibComposeFilename::doTestStepPreambleL(); sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: if (!GetBoolFromConfig(ConfigSection(), _L("panic"), iPanic)) sl@0: { sl@0: ERR_PRINTF1(_L("Test setting panic not specified. Test cannot proceed.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: else sl@0: { sl@0: TPtrC strPtr; sl@0: if (GetStringFromConfig(ConfigSection(), _L("dir"), strPtr)) sl@0: { sl@0: // save a copy of the dir specified for the test sl@0: iDir.CreateL(strPtr); sl@0: } sl@0: else sl@0: { sl@0: // cannot find filename! sl@0: ERR_PRINTF1(_L("Dir not specified. Test cannot proceed.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: } sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibComposePanic::doTestStepComposeOpenL(C3GPCompose& aComposer) sl@0: { sl@0: // close the composer, then delete the file sl@0: aComposer.Complete(); sl@0: sl@0: RFs fs; sl@0: User::LeaveIfError(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: sl@0: // retrieve the number of items in the directory sl@0: CDir* dirList = NULL; sl@0: User::LeaveIfError(fs.GetDir(iDir, KEntryAttNormal, ESortNone, dirList)); sl@0: TInt orgCount = dirList->Count(); sl@0: delete dirList; sl@0: sl@0: // Reopens it sl@0: T3GPAudioPropertiesMpeg4Audio audio1(100, KDummyData); sl@0: T3GPVideoPropertiesAvc video1(100, TSize(100, 100), KDummyData); sl@0: sl@0: C3GPCompose* composer = C3GPCompose::NewL(); sl@0: CleanupStack::PushL(composer); sl@0: User::LeaveIfError(composer->Open(E3GP3GP, &video1, &audio1, iFilename)); sl@0: sl@0: // write some data into composer 1, then 2, then 3 sl@0: User::LeaveIfError(composer->WriteVideoFrame(KDummyData, 10, EFalse)); sl@0: sl@0: if (iPanic) sl@0: { sl@0: // force a panic so that the composed file and the temporary file is left in the sl@0: // directory sl@0: User::Panic(_L("Testing"), KErrArgument); sl@0: } sl@0: sl@0: // delete the composer before calling Complete sl@0: composer->Complete(); sl@0: CleanupStack::PopAndDestroy(composer); sl@0: sl@0: User::LeaveIfError(fs.GetDir(iDir, KEntryAttNormal, ESortNone, dirList)); sl@0: TInt newCount = dirList->Count(); sl@0: delete dirList; sl@0: sl@0: // When cleaned up properly, only the composed file should be left within the directory. sl@0: if (!(newCount == 1 && orgCount > 0)) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(); // fs sl@0: sl@0: // continue the test sl@0: C3GPLibComposeFilename::doTestStepComposeOpenL(aComposer); sl@0: } sl@0: sl@0: TVerdict C3GPLibComposePanic::doTestStepPostambleL() sl@0: { sl@0: iDir.Close(); sl@0: return C3GPLibComposeFilename::doTestStepPostambleL(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeLargeFile sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeLargeFile::C3GPLibComposeLargeFile() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeLargeFile::doTestStepPreambleL() sl@0: { sl@0: // ensure the base class setup is completed first sl@0: C3GPLibComposeBase::doTestStepPreambleL(); sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: TInt temp; sl@0: if (GetIntFromConfig(ConfigSection(), _L("inputFormat"), temp)) sl@0: { sl@0: iInputFileFormat = (T3GPFileFormatType)temp; sl@0: sl@0: if (GetIntFromConfig(ConfigSection(), _L("video"), temp)) sl@0: { sl@0: iVideoType = (T3GPVideoType)temp; sl@0: } sl@0: sl@0: if (GetIntFromConfig(ConfigSection(), _L("audio"), temp)) sl@0: { sl@0: iAudioType = (T3GPAudioType)temp; sl@0: } sl@0: sl@0: if (iVideoType == E3GPNoVideo && iAudioType == E3GPNoAudio) sl@0: { sl@0: // At least audio or video should be specified sl@0: ERR_PRINTF1(_L("Specify at least video or audio")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: else sl@0: { sl@0: #ifdef __WINSCW__ sl@0: _LIT(KOutputDir, "filenameEmu"); sl@0: #else sl@0: _LIT(KOutputDir, "filenameHw"); sl@0: #endif sl@0: sl@0: TPtrC fileNamePtr; sl@0: if (GetStringFromConfig(ConfigSection(), KOutputDir, fileNamePtr)) sl@0: { sl@0: iFileName.CreateL(fileNamePtr); sl@0: User::LeaveIfError(iFs.Connect()); sl@0: sl@0: TInt err = iFs.MkDirAll(iFileName); sl@0: if (err != KErrNone && err != KErrAlreadyExists) sl@0: { sl@0: User::Leave(err); sl@0: } sl@0: sl@0: err = iFile64.Create(iFs, iFileName, EFileShareAny|EFileStream|EFileWrite); sl@0: if (err == KErrAlreadyExists) sl@0: { sl@0: User::LeaveIfError(iFile64.Replace(iFs, iFileName, EFileShareAny|EFileStream|EFileWrite)); sl@0: } sl@0: else sl@0: { sl@0: User::LeaveIfError(err); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: // cannot find filename! sl@0: ERR_PRINTF1(_L("Filename not specified. Test cannot proceed.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: // file format has to be specified sl@0: ERR_PRINTF1(_L("Specify file format of the file to be composed")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: } sl@0: sl@0: if (!GetIntFromConfig(ConfigSection(), _L("flag"), iComposeFlag)) sl@0: { sl@0: iComposeFlag = E3GPNoFlag; sl@0: } sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeLargeFile::doTestStepPostambleL() sl@0: { sl@0: // clean up of temp file sl@0: iFile64.Close(); sl@0: iFs.Delete(iFileName); sl@0: iFs.Close(); sl@0: sl@0: iFileName.Close(); sl@0: sl@0: // clean up all composer test base setups sl@0: C3GPLibComposeBase::doTestStepPostambleL(); sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: C3GPCompose* C3GPLibComposeLargeFile::doTestStepCreateComposerL() sl@0: { sl@0: return C3GPCompose::NewL(KLargeFileWriteBufferSize, KLargeFileWriteBufferMaxCount); sl@0: } sl@0: sl@0: void C3GPLibComposeLargeFile::doTestStepComposeOpenL(C3GPCompose& aComposer) sl@0: { sl@0: T3GPVideoPropertiesBase* video = SetupVideoPropertiesL(); sl@0: CleanupStack::PushL(video); sl@0: sl@0: T3GPAudioPropertiesBase* audio = SetupAudioPropertiesL(); sl@0: CleanupStack::PushL(audio); sl@0: sl@0: TInt err = aComposer.Open(iInputFileFormat, video, audio, iFile64, iComposeFlag); sl@0: if (err == KErrNone) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF2(_L("C3GPLibComposeFile::doTestStepComposeOpenL => C3GPComposer::Open returns = %d"), err); sl@0: } sl@0: SetTestStepError(err); sl@0: SetTestStepResult(EInconclusive); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2); // audio, video sl@0: } sl@0: sl@0: void C3GPLibComposeLargeFile::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer) sl@0: { sl@0: RBuf8 videoBuf1; sl@0: CleanupClosePushL(videoBuf1); sl@0: TBool keyFrame1; sl@0: TUint videoTimestampMS = 0; sl@0: TUint videoTS1; sl@0: TUint frameSize = 0; sl@0: T3GPFrameDependencies aDependencies; sl@0: sl@0: RFile fileName; sl@0: CleanupClosePushL(fileName); sl@0: User::LeaveIfError(fileName.Open(iFs, KLargeVideoFile(), EFileRead)); sl@0: sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: User::LeaveIfError(parser->Open(fileName)); sl@0: User::LeaveIfError(parser->GetVideoFrameSize(frameSize)); sl@0: User::LeaveIfError(videoBuf1.Create((TInt)frameSize)); sl@0: User::LeaveIfError(parser->ReadVideoFrame(videoBuf1, keyFrame1, videoTimestampMS, videoTS1)); sl@0: sl@0: TInt error = parser->GetVideoFrameDependencies(aDependencies); sl@0: if (error != KErrNone) sl@0: { sl@0: aDependencies.iDependsOn = E3GPDependencyUnknown; sl@0: aDependencies.iIsDependedOn = E3GPDependencyUnknown; sl@0: aDependencies.iHasRedundancy = E3GPRedundancyUnknown; sl@0: } sl@0: sl@0: TInt err = KErrNone; sl@0: TInt64 size = 0; sl@0: TTime startTime; sl@0: TTime endTime; sl@0: startTime.UniversalTime(); sl@0: sl@0: // create a 3GB video file sl@0: TInt videoLength = videoBuf1.Length(); sl@0: while (size + videoLength < K3GigaBytes) sl@0: { sl@0: err = aComposer.WriteVideoFrame(videoBuf1, 100, keyFrame1, aDependencies); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Fail to write video frame, err = %d"), err); sl@0: break; sl@0: } sl@0: iFile64.Size(size); sl@0: } sl@0: sl@0: endTime.UniversalTime(); sl@0: TTimeIntervalMinutes composeTime; sl@0: endTime.MinutesFrom(startTime, composeTime); sl@0: INFO_PRINTF3(_L("Took %d minutes to compose a video file of size %d bytes"), composeTime.Int(), size); sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: User::LeaveIfError(parser->Complete()); sl@0: CleanupStack::PopAndDestroy(3, &videoBuf1); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeLargeFileUserData sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeLargeFileUserData::C3GPLibComposeLargeFileUserData() sl@0: { sl@0: } sl@0: sl@0: void C3GPLibComposeLargeFileUserData::doTestStepComposeSetUserDataL(C3GPCompose& aComposer) sl@0: { sl@0: TInt bufferUdtaSize = 0; sl@0: TBuf8<256> bufferUdta; sl@0: TUint8* ptr = const_cast(bufferUdta.Ptr()); sl@0: TInt size = 0; sl@0: sl@0: _LIT8(KTitle,"titl"); sl@0: _LIT8(KData1,"This Udta titl test data 01!!"); sl@0: size = KTitle().Length() + KData1().Length() + 4; sl@0: WriteInt32(ptr, size); sl@0: ptr += 4; sl@0: Mem::Copy(ptr, KTitle().Ptr(), KTitle().Length()); sl@0: ptr += KTitle().Length(); sl@0: Mem::Copy(ptr, KData1().Ptr(), KData1().Length()); sl@0: ptr += KData1().Length(); sl@0: bufferUdtaSize += size; sl@0: sl@0: _LIT8(KTitle1,"titl"); sl@0: _LIT8(KData2,"This Udta titl test data 02!!blahblahblahbla"); sl@0: size = KTitle1().Length() + KData2().Length() + 4; sl@0: WriteInt32(ptr, size); sl@0: ptr += 4; sl@0: Mem::Copy(ptr, KTitle1().Ptr(), KTitle1().Length()); sl@0: ptr += KTitle1().Length(); sl@0: Mem::Copy(ptr, KData2().Ptr(), KData2().Length()); sl@0: ptr += KData2().Length(); sl@0: bufferUdtaSize += size; sl@0: sl@0: _LIT8(KTitle2,"titl"); sl@0: _LIT8(KData3,"This Udta titl test data 03!!Moreblahblahblahblahblahblahblahblahblah"); sl@0: size = KTitle2().Length() + KData3().Length() + 4; sl@0: WriteInt32(ptr, size); sl@0: ptr += 4; sl@0: Mem::Copy(ptr, KTitle2().Ptr(), KTitle2().Length()); sl@0: ptr += KTitle2().Length(); sl@0: Mem::Copy(ptr, KData3().Ptr(), KData3().Length()); sl@0: ptr += KData3().Length(); sl@0: bufferUdtaSize += size; sl@0: sl@0: bufferUdta.SetLength(bufferUdtaSize); sl@0: TInt error = aComposer.SetUserData(E3GPUdtaVideoTrak, bufferUdta); sl@0: sl@0: if (error != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("C3GPComposer::SetUserData failed with %d"), error); sl@0: SetTestStepError(error); sl@0: } sl@0: } sl@0: sl@0: void C3GPLibComposeLargeFileUserData::WriteInt32(TUint8* aPtr, TInt32 aData) sl@0: { sl@0: aPtr[0] = TUint8(aData>>24); sl@0: aPtr[1] = TUint8(aData>>16); sl@0: aPtr[2] = TUint8(aData>>8); sl@0: aPtr[3] = TUint8(aData); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeLargeFile32bitAPI sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeLargeFile32bitAPI::C3GPLibComposeLargeFile32bitAPI() sl@0: { sl@0: } sl@0: sl@0: C3GPCompose* C3GPLibComposeLargeFile32bitAPI::doTestStepCreateComposerL() sl@0: { sl@0: return C3GPCompose::NewL(KLargeFileWriteBufferSize, KLargeFileWriteBufferMaxCount); sl@0: } sl@0: sl@0: void C3GPLibComposeLargeFile32bitAPI::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer) sl@0: { sl@0: RBuf8 videoBuf1; sl@0: CleanupClosePushL(videoBuf1); sl@0: TBool keyFrame1; sl@0: TUint videoTimestampMS = 0; sl@0: TUint videoTS1; sl@0: TUint frameSize = 0; sl@0: T3GPFrameDependencies aDependencies; sl@0: sl@0: RFile fileName; sl@0: CleanupClosePushL(fileName); sl@0: User::LeaveIfError(fileName.Open(iFs, KLargeVideoFile(), EFileRead)); sl@0: sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: User::LeaveIfError(parser->Open(fileName)); sl@0: User::LeaveIfError(parser->GetVideoFrameSize(frameSize)); sl@0: User::LeaveIfError(videoBuf1.Create((TInt)frameSize)); sl@0: User::LeaveIfError(parser->ReadVideoFrame(videoBuf1, keyFrame1, videoTimestampMS, videoTS1)); sl@0: sl@0: TInt error = parser->GetVideoFrameDependencies(aDependencies); sl@0: if (error != KErrNone) sl@0: { sl@0: aDependencies.iDependsOn = E3GPDependencyUnknown; sl@0: aDependencies.iIsDependedOn = E3GPDependencyUnknown; sl@0: aDependencies.iHasRedundancy = E3GPRedundancyUnknown; sl@0: } sl@0: sl@0: TInt err = KErrNone; sl@0: TInt size = 0; sl@0: TTime startTime; sl@0: TTime endTime; sl@0: startTime.UniversalTime(); sl@0: sl@0: // create a 3GB video file sl@0: TInt videoLength = videoBuf1.Length(); sl@0: while (size + videoLength < K3GigaBytes) sl@0: { sl@0: err = aComposer.WriteVideoFrame(videoBuf1, 100, keyFrame1, aDependencies); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Fail to write video frame, err = %d"), err); sl@0: break; sl@0: } sl@0: iFile.Size(size); sl@0: } sl@0: sl@0: endTime.UniversalTime(); sl@0: TTimeIntervalMinutes composeTime; sl@0: endTime.MinutesFrom(startTime, composeTime); sl@0: INFO_PRINTF3(_L("Took %d minutes to compose a video file of size %d bytes"), composeTime.Int(), size); sl@0: sl@0: err = aComposer.Complete(); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepError(err); sl@0: } sl@0: sl@0: User::LeaveIfError(parser->Complete()); sl@0: CleanupStack::PopAndDestroy(3, &videoBuf1); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeLargeFileDiskFull sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibComposeLargeFileDiskFull::C3GPLibComposeLargeFileDiskFull() sl@0: { sl@0: } sl@0: sl@0: void C3GPLibComposeLargeFileDiskFull::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer) sl@0: { sl@0: RBuf8 videoBuf1; sl@0: CleanupClosePushL(videoBuf1); sl@0: TBool keyFrame1; sl@0: TUint videoTimestampMS = 0; sl@0: TUint videoTS1; sl@0: TUint frameSize = 0; sl@0: T3GPFrameDependencies aDependencies; sl@0: sl@0: RFile fileName; sl@0: CleanupClosePushL(fileName); sl@0: User::LeaveIfError(fileName.Open(iFs, KLargeVideoFile(), EFileRead)); sl@0: sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: User::LeaveIfError(parser->Open(fileName)); sl@0: User::LeaveIfError(parser->GetVideoFrameSize(frameSize)); sl@0: User::LeaveIfError(videoBuf1.Create((TInt)frameSize)); sl@0: User::LeaveIfError(parser->ReadVideoFrame(videoBuf1, keyFrame1, videoTimestampMS, videoTS1)); sl@0: sl@0: TInt error = parser->GetVideoFrameDependencies(aDependencies); sl@0: if (error != KErrNone) sl@0: { sl@0: aDependencies.iDependsOn = E3GPDependencyUnknown; sl@0: aDependencies.iIsDependedOn = E3GPDependencyUnknown; sl@0: aDependencies.iHasRedundancy = E3GPRedundancyUnknown; sl@0: } sl@0: sl@0: TInt err = KErrNone; sl@0: TInt64 size = 0; sl@0: TTime startTime; sl@0: TTime endTime; sl@0: startTime.UniversalTime(); sl@0: sl@0: // create a 3GB video file sl@0: TInt videoLength = videoBuf1.Length(); sl@0: while (size + videoLength < K3GigaBytes) sl@0: { sl@0: err = aComposer.WriteVideoFrame(videoBuf1, 100, keyFrame1, aDependencies); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Fail to write video frame, err = %d"), err); sl@0: break; sl@0: } sl@0: iFile64.Size(size); sl@0: } sl@0: sl@0: endTime.UniversalTime(); sl@0: TTimeIntervalMinutes composeTime; sl@0: endTime.MinutesFrom(startTime, composeTime); sl@0: INFO_PRINTF3(_L("Took %d minutes to compose a video file of size %d bytes"), composeTime.Int(), size); sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepError(err); sl@0: } sl@0: sl@0: User::LeaveIfError(parser->Complete()); sl@0: CleanupStack::PopAndDestroy(3, &videoBuf1); sl@0: sl@0: // ignore the error sl@0: aComposer.Complete(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLibComposeFileWithAvcProfileCheck sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: sl@0: const TInt KAvcDecoderConfigRecordLength = 7; sl@0: sl@0: _LIT8(KAvcCTag, "avcC"); sl@0: sl@0: const TUint8 KAvcConfigVersion = 1; sl@0: sl@0: const TUint8 KAvcProfileByteBaseline = 66; sl@0: const TUint8 KAvcProfileByteExtended = 77; sl@0: const TUint8 KAvcProfileByteMain = 88; sl@0: const TUint8 KAvcProfileByteHigh = 100; sl@0: sl@0: C3GPLibComposeFileWithAvcProfileCheck::C3GPLibComposeFileWithAvcProfileCheck() sl@0: : iAvcDecoderConfigRecord( KAvcDecoderConfigRecordLength ) sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeFileWithAvcProfileCheck::doTestStepL() sl@0: { sl@0: if (TestStepResult() != EPass) sl@0: { sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: // this triggers: sl@0: // 1. Create a composer sl@0: // 2. Open the composer - C3GPLibComposeFileFormatCheck::doTestStepComposeOpenL sl@0: // 3. Write Video & Audio Data - C3GPLibComposeFileFormatCheck::doTestStepComposeWriteVideoAudioL sl@0: // 4. Write User Data - C3GPLibComposeFileFormatCheck::doTestStepComposeSetUserDataL sl@0: // 5. Complete the composer sl@0: TVerdict verdict = C3GPLibComposeFile::doTestStepL(); sl@0: if (verdict == EPass) sl@0: { sl@0: // once the file is composed, it can be verified if the file composed has the same sl@0: // AVC profile. sl@0: verdict = VerifyAvcProfileL(iFile); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L(" C3GPLibComposeFile::doTestStepL returns failed result")); sl@0: } sl@0: SetTestStepResult(verdict); sl@0: sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF2(_L("C3GPLibComposeFileWithAvcProfileCheck::doTestStepL returns %d"), TestStepResult()); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /* sl@0: * The aDecoderSpecificInfo argument is used by 3GPlib to populate the sl@0: * avcC box. As this contains details of the AVC profile which is being sl@0: * checked by this test we cannot use KDummyData as the other tests do. sl@0: * sl@0: */ sl@0: T3GPVideoPropertiesBase* C3GPLibComposeFileWithAvcProfileCheck::SetupAvcVideoL() sl@0: { sl@0: // See ISO 14496-15, chapter 5.2.4.1.1 for details of these... sl@0: // config version (always 1) sl@0: iAvcDecoderConfigRecord[0] = KAvcConfigVersion; sl@0: // constraint flags sl@0: iAvcDecoderConfigRecord[2] = 0; // dummy data sl@0: // level sl@0: iAvcDecoderConfigRecord[3] = 0; // dummy data sl@0: // reserved (6bits) + lengthSizeMinusOne (2bits) sl@0: iAvcDecoderConfigRecord[4] = 0xFC; // 111111 00 sl@0: // reserved (3bits) + numOfSeqParamSets (5bits) sl@0: iAvcDecoderConfigRecord[5] = 0xE0; // 111 00000 sl@0: // numOfPicParamSets sl@0: iAvcDecoderConfigRecord[6] = 0; sl@0: sl@0: switch( iVideoType ) sl@0: { sl@0: case E3GPAvcProfileBaseline: sl@0: iAvcDecoderConfigRecord[1] = KAvcProfileByteBaseline; sl@0: break; sl@0: sl@0: case E3GPAvcProfileMain: sl@0: iAvcDecoderConfigRecord[1] = KAvcProfileByteMain; sl@0: break; sl@0: sl@0: case E3GPAvcProfileExtended: sl@0: iAvcDecoderConfigRecord[1] = KAvcProfileByteExtended; sl@0: break; sl@0: sl@0: case E3GPAvcProfileHigh: sl@0: iAvcDecoderConfigRecord[1] = KAvcProfileByteHigh; sl@0: break; sl@0: sl@0: default: sl@0: User::Leave(KErrUnknown); sl@0: } sl@0: T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesAvc(1000, TSize(100, 100), iAvcDecoderConfigRecord ); sl@0: return video; sl@0: } sl@0: sl@0: TVerdict C3GPLibComposeFileWithAvcProfileCheck::VerifyAvcProfileL(const RFile& aFile) sl@0: { sl@0: // Seek to the beginning of the file sl@0: TInt pos = 0; sl@0: User::LeaveIfError(aFile.Seek(ESeekStart, pos)); sl@0: sl@0: TVerdict verdict = EFail; sl@0: TBuf8<4> atom; sl@0: TBuf8<1> byte; sl@0: TInt rewind = -1 * ( atom.MaxLength() - 1 ); sl@0: TInt tmp = rewind; sl@0: sl@0: while(ETrue) sl@0: { sl@0: // Search for the 'avcC' atom to check the profile that follows it. sl@0: sl@0: // Read in next 4 bytes sl@0: User::LeaveIfError(aFile.Read(atom)); sl@0: if (atom.Length() < atom.MaxLength()) sl@0: { sl@0: break; sl@0: } sl@0: sl@0: // Check if 'avcC' was found sl@0: if (Mem::Compare((&KAvcCTag)->Ptr(), (&KAvcCTag)->Length(), atom.Ptr(), atom.Length()) == 0) sl@0: { sl@0: // read next byte, and it should contain config version (always 1) sl@0: User::LeaveIfError(aFile.Read(byte)); sl@0: if( byte[0] != KAvcConfigVersion ) sl@0: { sl@0: ERR_PRINTF2(_L("avcC atom config type not as expected! (%d instead of 1)"), byte[0] ); sl@0: break; sl@0: } sl@0: sl@0: // read next byte, and it should contain profile indication sl@0: User::LeaveIfError(aFile.Read(byte)); sl@0: switch( iVideoType ) sl@0: { sl@0: case E3GPAvcProfileBaseline: sl@0: if( byte[0] == KAvcProfileByteBaseline ) sl@0: { sl@0: verdict = EPass; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF3(_L("avcC atom config type not as expected! (%d instead of %d)"), byte[0], KAvcProfileByteBaseline ); sl@0: } sl@0: break; sl@0: sl@0: sl@0: case E3GPAvcProfileMain: sl@0: if( byte[0] == KAvcProfileByteMain ) sl@0: { sl@0: verdict = EPass; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF3(_L("avcC atom config type not as expected! (%d instead of %d)"), byte[0], KAvcProfileByteMain ); sl@0: } sl@0: break; sl@0: sl@0: sl@0: case E3GPAvcProfileExtended: sl@0: if( byte[0] == KAvcProfileByteExtended ) sl@0: { sl@0: verdict = EPass; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF3(_L("avcC atom config type not as expected! (%d instead of %d)"), byte[0], KAvcProfileByteExtended ); sl@0: } sl@0: break; sl@0: sl@0: sl@0: case E3GPAvcProfileHigh: sl@0: if( byte[0] == KAvcProfileByteHigh ) sl@0: { sl@0: verdict = EPass; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF3(_L("avcC atom config type not as expected! (%d instead of %d)"), byte[0], KAvcProfileByteHigh ); sl@0: } sl@0: break; sl@0: sl@0: default: sl@0: ERR_PRINTF2(_L("avcC has unknown profile indication: %d"), byte[0] ); sl@0: } sl@0: sl@0: // 'avcC' was found, regardless of the result, finish reading the file sl@0: break; sl@0: } sl@0: else sl@0: { sl@0: // The 4 bytes read were not 'avcC'. sl@0: // Need to rewind by 3 bytes since we need to step through the file sl@0: // byte-by-byte... sl@0: tmp = rewind; // Avoid rewind value being changed by Seek() function sl@0: User::LeaveIfError( aFile.Seek( ESeekCurrent, tmp ) ); sl@0: } sl@0: } sl@0: sl@0: return verdict; sl@0: } sl@0: