First public contribution.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include "tsu_3gplibrary_composer_api.h"
19 _LIT8(KDummyData, "DummyData");
20 _LIT8(KFtypAtom, "ftyp");
21 _LIT8(K3g2Brand, "3g2a"); // 3g2a
22 _LIT8(K3gpBrand, "3gp"); // 3gp4, 3gp6
23 _LIT8(KMp4Brand, "mp42"); // mp42
25 _LIT(KLargeVideoFile, "c:\\3gplibrary\\cube-xvid-640x480-10fps-10s.3gp");
26 const TInt KLargeFileWriteBufferSize = 16384; // 16K
27 const TInt KLargeFileWriteBufferMaxCount = 15;
28 const TInt64 K3GigaBytes = 0xC0000000;
30 // -----------------------------------------------------------------------------
31 // C3GPLibComposeBase - this should not be used directly
32 // -----------------------------------------------------------------------------
34 C3GPLibComposeBase::C3GPLibComposeBase()
38 TVerdict C3GPLibComposeBase::doTestStepPreambleL()
40 // ensure there's always a Active Scheduler for the Composer
41 if (!CActiveScheduler::Current())
43 iScheduler = new (ELeave) CActiveScheduler;
44 CActiveScheduler::Install(iScheduler);
47 SetTestStepResult(EPass);
48 return TestStepResult();
51 TVerdict C3GPLibComposeBase::doTestStepPostambleL()
55 CActiveScheduler::Install(NULL);
59 return TestStepResult();
62 TVerdict C3GPLibComposeBase::doTestStepL()
64 if (TestStepResult() != EPass)
66 return TestStepResult();
68 SetTestStepError(KErrNone);
70 C3GPCompose* composer = doTestStepCreateComposerL();
71 CleanupStack::PushL(composer);
73 doTestStepComposeOpenL(*composer);
74 if (TestStepResult() == EPass)
76 // set it to EFail, if both calls below does not leave, then it will be reset
78 SetTestStepResult(EFail);
79 doTestStepComposeWriteVideoAudioL(*composer);
80 doTestStepComposeSetUserDataL(*composer);
81 SetTestStepResult(EPass);
84 TInt err = composer->Complete();
87 SetTestStepResult(EFail);
90 CleanupStack::PopAndDestroy(composer);
92 return TestStepResult();
95 C3GPCompose* C3GPLibComposeBase::doTestStepCreateComposerL()
97 return C3GPCompose::NewL();
100 void C3GPLibComposeBase::doTestStepComposeWriteVideoAudioL(C3GPCompose& /* aComposer */)
104 void C3GPLibComposeBase::doTestStepComposeSetUserDataL(C3GPCompose& /* aComposer */)
108 // -----------------------------------------------------------------------------
109 // C3GPLibComposeFilename
110 // -----------------------------------------------------------------------------
112 C3GPLibComposeFilename::C3GPLibComposeFilename()
116 TVerdict C3GPLibComposeFilename::doTestStepPreambleL()
118 // ensure all basic setup is completed first
119 C3GPLibComposeBase::doTestStepPreambleL();
120 if (TestStepResult() == EPass)
123 if (GetStringFromConfig(ConfigSection(), _L("filename"), fileNamePtr))
125 // save a copy of the filename specified for the test
126 iFilename.CreateL(fileNamePtr);
130 // cannot find filename!
131 ERR_PRINTF1(_L("Filename not specified. Test cannot proceed."));
132 SetTestStepResult(ETestSuiteError);
136 return TestStepResult();
139 TVerdict C3GPLibComposeFilename::doTestStepPostambleL()
143 // clean up all composer test base setups
144 C3GPLibComposeBase::doTestStepPostambleL();
146 return TestStepResult();
149 void C3GPLibComposeFilename::doTestStepComposeOpenL(C3GPCompose& aComposer)
151 T3GPAudioPropertiesMpeg4Audio audio(100, KDummyData);
152 T3GPVideoPropertiesAvc video(100, TSize(100, 100), KDummyData);
154 TInt err = aComposer.Open(E3GP3GP, &video, &audio, iFilename);
157 if (!ShouldRunOOMTest())
159 ERR_PRINTF2(_L("C3GPCompose::Open failed with error = %d"), err);
161 SetTestStepError(err);
162 SetTestStepResult(EFail);
166 INFO_PRINTF1(_L("C3GPCompose::Open completes with no error"));
167 SetTestStepResult(EPass);
171 // -----------------------------------------------------------------------------
172 // C3GPLibComposeWithoutOpen
173 // -----------------------------------------------------------------------------
175 C3GPLibComposeWithoutOpen::C3GPLibComposeWithoutOpen()
179 void C3GPLibComposeWithoutOpen::doTestStepComposeOpenL(C3GPCompose& /* aComposer */)
181 // This test needs the composer NOT initialised. Do nothing here
184 void C3GPLibComposeWithoutOpen::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
186 if (TestStepResult() != EPass)
191 TInt err = aComposer.WriteVideoFrame(KDummyData, 100, ETrue);
192 if (err != KErrNotReady)
194 ERR_PRINTF2(_L("C3GPCompose::WriteVideoFrame failed with error = %d instead of KErrNotReady"), err);
195 SetTestStepResult(EFail);
198 if (TestStepResult() == EPass)
200 T3GPFrameDependencies dependencies;
201 err = aComposer.WriteVideoFrame(KDummyData, 100, ETrue, dependencies);
202 if (err != KErrNotReady)
204 ERR_PRINTF2(_L("C3GPCompose::WriteVideoFrame failed with error = %d instead of KErrNotReady"), err);
205 SetTestStepResult(EFail);
209 if (TestStepResult() == EPass)
211 err = aComposer.WriteAudioFrames(KDummyData, 100);
212 if (err != KErrNotReady)
214 ERR_PRINTF2(_L("C3GPCompose::WriteAudioFrames failed with error = %d instead of KErrNotReady"), err);
215 SetTestStepResult(EFail);
220 void C3GPLibComposeWithoutOpen::doTestStepComposeSetUserDataL(C3GPCompose& aComposer)
222 if (TestStepResult() != EPass)
227 TInt err = aComposer.SetUserData(E3GPUdtaMoov, KDummyData);
228 if (err != KErrNotReady)
230 ERR_PRINTF2(_L("C3GPCompose::SetUserData failed with error = %d instead of KErrNotReady"), err);
231 SetTestStepResult(EFail);
234 if (TestStepResult() == EPass)
236 err = aComposer.SetUserData(E3GPUdtaVideoTrak, KDummyData);
237 if (err != KErrNotReady)
239 ERR_PRINTF2(_L("C3GPCompose::SetUserData failed with error = %d instead of KErrNotReady"), err);
240 SetTestStepResult(EFail);
244 if (TestStepResult() == EPass)
246 err = aComposer.SetUserData(E3GPUdtaAudioTrak, KDummyData);
247 if (err != KErrNotReady)
249 ERR_PRINTF2(_L("C3GPCompose::SetUserData failed with error = %d instead of KErrNotReady"), err);
250 SetTestStepResult(EFail);
255 // -----------------------------------------------------------------------------
256 // C3GPLibComposeFile
257 // -----------------------------------------------------------------------------
259 C3GPLibComposeFile::C3GPLibComposeFile() :
260 iInputFileFormat(E3GP3GP),
261 iVideoType(E3GPNoVideo),
262 iAudioType(E3GPNoAudio)
266 TVerdict C3GPLibComposeFile::doTestStepPreambleL()
268 // ensure the base class setup is completed first
269 C3GPLibComposeBase::doTestStepPreambleL();
270 if (TestStepResult() == EPass)
273 if (GetIntFromConfig(ConfigSection(), _L("inputFormat"), temp))
275 iInputFileFormat = (T3GPFileFormatType)temp;
277 if (GetIntFromConfig(ConfigSection(), _L("video"), temp))
279 iVideoType = (T3GPVideoType)temp;
282 if (GetIntFromConfig(ConfigSection(), _L("audio"), temp))
284 iAudioType = (T3GPAudioType)temp;
287 if (iVideoType == E3GPNoVideo && iAudioType == E3GPNoAudio)
289 // At least audio or video should be specified
290 ERR_PRINTF1(_L("Specify at least video or audio"));
291 SetTestStepResult(ETestSuiteError);
296 _LIT(KTestFolderName, "testFolderNameEmu");
298 _LIT(KTestFolderName, "testFolderNameHw");
301 TPtrC testFolderName;
302 if (GetStringFromConfig(_L("general"), KTestFolderName, testFolderName))
304 TInt err = iFs.Connect();
307 iFs.MkDirAll(testFolderName);
310 // Create a temp file for the composer to write data into
311 err = iFile.Temp(iFs, testFolderName, fileName, EFileShareExclusive);
314 iFileName.CreateL(fileName);
320 ERR_PRINTF1(_L("Fail to create temp file for testing."));
321 SetTestStepResult(ETestSuiteError);
326 ERR_PRINTF1(_L("Fail to provide test directory."));
327 SetTestStepResult(ETestSuiteError);
333 // file format has to be specified
334 ERR_PRINTF1(_L("Specify file format of the file to be composed"));
335 SetTestStepResult(ETestSuiteError);
339 return TestStepResult();
342 TVerdict C3GPLibComposeFile::doTestStepPostambleL()
344 // clean up of temp file
346 iFs.Delete(iFileName);
351 // clean up all composer test base setups
352 C3GPLibComposeBase::doTestStepPostambleL();
354 return TestStepResult();
357 void C3GPLibComposeFile::doTestStepComposeOpenL(C3GPCompose& aComposer)
359 T3GPVideoPropertiesBase* video = SetupVideoPropertiesL();
360 CleanupStack::PushL(video);
362 T3GPAudioPropertiesBase* audio = SetupAudioPropertiesL();
363 CleanupStack::PushL(audio);
365 TInt err = aComposer.Open(iInputFileFormat, video, audio, iFile);
368 SetTestStepResult(EPass);
372 if (!ShouldRunOOMTest())
374 ERR_PRINTF2(_L("C3GPLibComposeFile::doTestStepComposeOpenL => C3GPComposer::Open returns = %d"), err);
376 SetTestStepError(err);
377 SetTestStepResult(EInconclusive);
380 CleanupStack::PopAndDestroy(2); // audio, video
383 void C3GPLibComposeFile::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
385 // add a dummy video frame. The content is of no importance for this test case,
386 // only the file format is of interest
389 if (iVideoType != E3GPNoVideo)
391 err = aComposer.WriteVideoFrame(KDummyData, 10, ETrue);
394 ERR_PRINTF2(_L("Fail to write video frame, err = %d"), err);
398 if (err == KErrNone && iAudioType != E3GPNoAudio)
400 // add a dummy audio frame. The content is of no importance for this test case,
401 // only the file format is of interest
402 err = aComposer.WriteAudioFrames(KDummyData, 10);
405 ERR_PRINTF2(_L("Fail to write audio frame, err = %d"), err);
411 SetTestStepResult(EInconclusive);
415 T3GPVideoPropertiesBase* C3GPLibComposeFile::SetupVideoPropertiesL()
417 if (iVideoType == E3GPNoVideo)
422 // create a dummy video property for setting the composer
423 T3GPVideoPropertiesBase* video = NULL;
427 video = SetupMpeg4VideoL();
430 case E3GPAvcProfileBaseline:
431 case E3GPAvcProfileMain:
432 case E3GPAvcProfileExtended:
433 case E3GPAvcProfileHigh:
434 video = SetupAvcVideoL();
437 case E3GPH263Profile0:
438 case E3GPH263Profile3:
439 video = SetupH263VideoL();
443 User::Leave(KErrUnknown);
449 T3GPVideoPropertiesBase* C3GPLibComposeFile::SetupAvcVideoL()
451 T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesAvc(1000, TSize(100, 100), KDummyData);
455 T3GPVideoPropertiesBase* C3GPLibComposeFile::SetupH263VideoL()
457 T3GPVideoPropertiesH263::TProfile profile = T3GPVideoPropertiesH263::EProfile0;
458 if (iVideoType == E3GPH263Profile3)
460 profile = T3GPVideoPropertiesH263::EProfile3;
462 T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesH263(1000, TSize(100, 100), 10, profile);
466 T3GPVideoPropertiesBase* C3GPLibComposeFile::SetupMpeg4VideoL()
468 T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesMpeg4Video(1000, TSize(100, 100), 4000, 400, KDummyData);
472 T3GPAudioPropertiesBase* C3GPLibComposeFile::SetupAudioPropertiesL()
474 if (iAudioType == E3GPNoAudio)
479 // create a dummy audio property for setting the composer
480 T3GPAudioPropertiesBase* audio = NULL;
484 audio = SetupMpeg4AudioL();
488 audio = SetupQcelpAudioL();
493 audio = SetupAmrAudioL();
497 User::Leave(KErrUnknown);
504 T3GPAudioPropertiesBase* C3GPLibComposeFile::SetupQcelpAudioL()
506 // for this test's purpose, just use the default QCELP sample entry storage mode
507 T3GPAudioPropertiesBase* audio = new (ELeave) T3GPAudioPropertiesQcelp(1000, 10);
511 T3GPAudioPropertiesBase* C3GPLibComposeFile::SetupAmrAudioL()
513 T3GPAudioPropertiesAmr::TSpeechCodec codec = T3GPAudioPropertiesAmr::EAmrWB;
514 if (iAudioType == E3GPAmrNB)
516 codec = T3GPAudioPropertiesAmr::EAmrNB;
518 T3GPAudioPropertiesBase* audio = new (ELeave) T3GPAudioPropertiesAmr(1000, 10, 150, codec);
522 T3GPAudioPropertiesBase* C3GPLibComposeFile::SetupMpeg4AudioL()
524 T3GPAudioPropertiesBase* audio = new (ELeave)T3GPAudioPropertiesMpeg4Audio(1000, KDummyData);
528 // -----------------------------------------------------------------------------
529 // C3GPLibComposeFileWithFileFormatCheck
530 // -----------------------------------------------------------------------------
532 C3GPLibComposeFileWithFileFormatCheck::C3GPLibComposeFileWithFileFormatCheck() :
533 iOutputFileFormat(E3GP3GP)
537 TVerdict C3GPLibComposeFileWithFileFormatCheck::doTestStepPreambleL()
539 // ensure base class setup is completed first
540 C3GPLibComposeFile::doTestStepPreambleL();
542 if (TestStepResult() == EPass)
545 if (!GetIntFromConfig(ConfigSection(), _L("outputFormat"), temp))
547 ERR_PRINTF1(_L("outputFormat not specified"));
548 SetTestStepResult(ETestSuiteError);
552 iOutputFileFormat = (T3GPFileFormatType)temp;
556 return TestStepResult();
559 TVerdict C3GPLibComposeFileWithFileFormatCheck::doTestStepL()
561 if (TestStepResult() != EPass)
563 return TestStepResult();
567 // 1. Create a composer
568 // 2. Open the composer - C3GPLibComposeFileFormatCheck::doTestStepComposeOpenL
569 // 3. Write Video & Audio Data - C3GPLibComposeFileFormatCheck::doTestStepComposeWriteVideoAudioL
570 // 4. Write User Data - C3GPLibComposeFileFormatCheck::doTestStepComposeSetUserDataL
571 // 5. Complete the composer
572 TVerdict verdict = C3GPLibComposeFile::doTestStepL();
573 if (verdict == EPass)
575 // once the file is composed, it can be verified if the file composed is the same as the
576 // expected file format
577 verdict = VerifyFileFormatL(iFile);
581 INFO_PRINTF1(_L("<C3GPLibComposeFileWithFileFormatCheck> C3GPLibComposeFile::doTestStepL returns failed result"));
583 SetTestStepResult(verdict);
585 if (!ShouldRunOOMTest())
587 INFO_PRINTF2(_L("C3GPLibComposeFile::doTestStepL returns %d"), TestStepResult());
589 return TestStepResult();
592 TVerdict C3GPLibComposeFileWithFileFormatCheck::VerifyFileFormatL(const RFile& aFile)
594 // Seek to the beginning of the file
596 User::LeaveIfError(aFile.Seek(ESeekStart, pos));
598 TVerdict verdict = EFail;
603 // read the file content and search for the 'ftyp' atom to check
604 // the 32bit value of brand attribute immediately following the 'ftyp' type.
605 User::LeaveIfError(aFile.Read(atom));
606 if (atom.Length() < atom.MaxLength())
611 // read 4 bytes at a time, if 'ftyp' is found
612 if (Mem::Compare((&KFtypAtom)->Ptr(), (&KFtypAtom)->Length(), atom.Ptr(), atom.Length()) == 0)
614 // read 4 more bytes, and it should contain the brand value
615 User::LeaveIfError(aFile.Read(atom));
616 if (atom.Length() < atom.MaxLength())
618 // cannot read brand value, test failed.
619 ERR_PRINTF1(_L("Failed to read enough data for comparison."));
623 switch(iOutputFileFormat)
627 // check if file type is 3G2
628 if (!ShouldRunOOMTest())
630 INFO_PRINTF1(_L("Check 3GP2 file format."));
632 if (Mem::Compare((&K3g2Brand)->Ptr(), (&K3g2Brand)->Length(), atom.Ptr(), atom.Length()) == 0)
642 if (!ShouldRunOOMTest())
644 INFO_PRINTF1(_L("Check MP4 file format."));
646 // check if file type is MP4
647 if (Mem::Compare((&KMp4Brand)->Ptr(), (&KMp4Brand)->Length(), atom.Ptr(), atom.Length()) == 0)
656 if (!ShouldRunOOMTest())
658 INFO_PRINTF1(_L("Check 3GP file format."));
660 // check if file type is 3GP
661 // Both 3gp4 & 3gp6 are valid brands, thus checking ONLY "3gp" instead of the full atom size
662 if (Mem::Compare((&K3gpBrand)->Ptr(), (&K3gpBrand)->Length(), atom.Ptr(), (&K3gpBrand)->Length()) == 0)
670 INFO_PRINTF1(_L("Unknown format expected."));
671 verdict = EInconclusive;
675 // ftyp is found, regardless of the result, finish reading the file
683 // -----------------------------------------------------------------------------
684 // C3GPLibComposeFrameDependency
685 // -----------------------------------------------------------------------------
687 C3GPLibComposeFrameDependency::C3GPLibComposeFrameDependency()
691 void C3GPLibComposeFrameDependency::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
694 T3GPFrameDependencies dep;
696 for (TInt i = 0; i <= (TInt)E3GPDependencyNone; i++)
698 for (TInt j = 0; j <= (TInt)E3GPDependencyNone; j++)
700 for (TInt k = 0; k <= (TInt)E3GPRedundancyNone; k++)
702 dep.iDependsOn = (T3GPVideoFrameDependency)i;
703 dep.iIsDependedOn = (T3GPVideoFrameDependency)j;
704 dep.iHasRedundancy = (T3GPVideoFrameRedundancy)k;
706 // add a dummy video frame. The content is of no importance for this test case,
707 // only the different dependency/redundancy is the focus of this test
708 err = aComposer.WriteVideoFrame(KDummyData, 100, ETrue, dep);
711 ERR_PRINTF2(_L("C3GPCompose::WriteVideoFrame (with frame dependency) failed with error = %d"), err);
712 SetTestStepResult(EFail);
720 // -----------------------------------------------------------------------------
721 // C3GPLibComposeVideoProperties
722 // -----------------------------------------------------------------------------
724 C3GPLibComposeVideoProperties::C3GPLibComposeVideoProperties()
728 TVerdict C3GPLibComposeVideoProperties::doTestStepPreambleL()
730 C3GPLibComposeFile::doTestStepPreambleL();
731 if (TestStepResult() != EPass)
733 return TestStepResult();
737 TBool result = ETrue;
738 result = GetIntFromConfig(ConfigSection(), _L("width"), temp);
742 result = GetIntFromConfig(ConfigSection(), _L("height"), temp);
745 iSize.iHeight = temp;
746 result = GetIntFromConfig(ConfigSection(), _L("timescale"), temp);
755 (iVideoType == E3GPMpeg4Video ||
756 iVideoType == E3GPAvcProfileBaseline ||
757 iVideoType == E3GPAvcProfileMain ||
758 iVideoType == E3GPAvcProfileExtended ||
759 iVideoType == E3GPAvcProfileHigh )
763 result = GetStringFromConfig(ConfigSection(), _L("decoderSpecInfo"), decoder);
766 iDecoderSpecInfo.CreateL(decoder.Length());
767 iDecoderSpecInfo.Copy(decoder);
771 if (result && (iVideoType == E3GPMpeg4Video))
773 result = GetIntFromConfig(ConfigSection(), _L("avgBR"), temp);
777 result = GetIntFromConfig(ConfigSection(), _L("maxBR"), temp);
785 if (result && (iVideoType == E3GPH263Profile0 || iVideoType == E3GPH263Profile3))
787 result = GetIntFromConfig(ConfigSection(), _L("level"), temp);
796 ERR_PRINTF1(_L("Cannot retrieve necessary video properties to complete this test."));
797 SetTestStepResult(ETestSuiteError);
800 return TestStepResult();
803 TVerdict C3GPLibComposeVideoProperties::doTestStepPostambleL()
805 iDecoderSpecInfo.Close();
807 // clean up base class setups
808 C3GPLibComposeFile::doTestStepPostambleL();
810 return TestStepResult();
813 T3GPVideoPropertiesBase* C3GPLibComposeVideoProperties::SetupAvcVideoL()
815 T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesAvc(iTimescale, iSize, iDecoderSpecInfo);
819 T3GPVideoPropertiesBase* C3GPLibComposeVideoProperties::SetupH263VideoL()
821 T3GPVideoPropertiesH263::TProfile profile = T3GPVideoPropertiesH263::EProfile0;
822 if (iVideoType == E3GPH263Profile3)
824 profile = T3GPVideoPropertiesH263::EProfile3;
826 T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesH263(iTimescale, iSize, iVideoLevel, profile);
830 T3GPVideoPropertiesBase* C3GPLibComposeVideoProperties::SetupMpeg4VideoL()
832 T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesMpeg4Video(iTimescale,
840 // -----------------------------------------------------------------------------
841 // C3GPLibComposeWithSpecificBufferSize
842 // -----------------------------------------------------------------------------
844 C3GPLibComposeWithSpecificBufferSize::C3GPLibComposeWithSpecificBufferSize()
848 TVerdict C3GPLibComposeWithSpecificBufferSize::doTestStepPreambleL()
850 TVerdict verdict = C3GPLibComposeFile::doTestStepPreambleL();
851 if (verdict != EPass)
857 if (GetIntFromConfig(ConfigSection(), _L("bufferSize"), temp))
860 if (GetIntFromConfig(ConfigSection(), _L("bufferCount"), temp))
862 iBufferMaxCount = temp;
866 ERR_PRINTF1(_L("C3GPLibComposeWithSpecificBufferSize cannot read Buffer Max Count"));
867 SetTestStepResult(ETestSuiteError);
872 ERR_PRINTF1(_L("C3GPLibComposeWithSpecificBufferSize cannot read Buffer Size"));
873 SetTestStepResult(ETestSuiteError);
876 return TestStepResult();
879 C3GPCompose* C3GPLibComposeWithSpecificBufferSize::doTestStepCreateComposerL()
881 return C3GPCompose::NewL(iBufferSize, iBufferMaxCount);
884 // -----------------------------------------------------------------------------
885 // C3GPLibComposeUserData
886 // -----------------------------------------------------------------------------
888 C3GPLibComposeUserData::C3GPLibComposeUserData() :
893 TVerdict C3GPLibComposeUserData::doTestStepPreambleL()
895 // ensure all basic setup is completed first
896 C3GPLibComposeFile::doTestStepPreambleL();
897 if (TestStepResult() == EPass)
899 GetBoolFromConfig(ConfigSection(), _L("udtaMoov"), iUdtaMoov);
900 GetBoolFromConfig(ConfigSection(), _L("udtaVideo"), iUdtaVideo);
901 GetBoolFromConfig(ConfigSection(), _L("udtaAudio"), iUdtaAudio);
902 GetIntFromConfig(ConfigSection(), _L("udtaLocation"), iUdtaLocation);
904 if (!iUdtaMoov && !iUdtaVideo && !iUdtaAudio && iUdtaLocation == -1)
906 ERR_PRINTF1(_L("No user data location is specified. Test cannot proceed."));
907 SetTestStepResult(ETestSuiteError);
912 if (GetStringFromConfig(ConfigSection(), _L("userData"), userDataPtr))
914 iUserData.CreateL(userDataPtr.Length());
915 iUserData.Copy(userDataPtr);
919 // user data not specified, use dummy data
920 iUserData.CreateL(KDummyData);
925 return TestStepResult();
928 TVerdict C3GPLibComposeUserData::doTestStepPostambleL()
932 // clean up base class setups
933 C3GPLibComposeFile::doTestStepPostambleL();
935 return TestStepResult();
938 void C3GPLibComposeUserData::doTestStepComposeSetUserDataL(C3GPCompose& aComposer)
943 err = aComposer.SetUserData(E3GPUdtaVideoTrak, iUserData);
946 ERR_PRINTF2(_L("C3GPComposer::SetUserData(E3GPUdtaVideoTrak) fails with %d"), err);
947 SetTestStepError(err);
952 err = aComposer.SetUserData(E3GPUdtaAudioTrak, iUserData);
955 ERR_PRINTF2(_L("C3GPComposer::SetUserData(E3GPUdtaAudioTrak) fails with %d"), err);
956 SetTestStepError(err);
961 err = aComposer.SetUserData(E3GPUdtaMoov, iUserData);
964 ERR_PRINTF2(_L("C3GPComposer::SetUserData(E3GPUdtaMoov) fails with %d"), err);
965 SetTestStepError(err);
969 if (iUdtaLocation != -1)
971 // if a specific user data location has been specified, try it!
972 err = aComposer.SetUserData((T3GPUdtaLocation)iUdtaLocation, iUserData);
975 ERR_PRINTF3(_L("C3GPComposer::SetUserData(%d) fails with %d"), iUdtaLocation, err);
976 SetTestStepError(err);
981 // -----------------------------------------------------------------------------
982 // C3GPLibComposeWithFlag
983 // -----------------------------------------------------------------------------
985 C3GPLibComposeWithFlag::C3GPLibComposeWithFlag()
989 TVerdict C3GPLibComposeWithFlag::doTestStepPreambleL()
991 // ensure the base class setup is completed first
992 C3GPLibComposeFile::doTestStepPreambleL();
993 if (TestStepResult() == EPass)
995 if (!GetIntFromConfig(ConfigSection(), _L("flag"), iComposeFlag))
997 ERR_PRINTF1(_L("C3GPLibComposeWithFlag::doTestStepPreambleL cannot retrieve any composer flags."));
998 SetTestStepResult(ETestSuiteError);
1001 return TestStepResult();
1004 void C3GPLibComposeWithFlag::doTestStepComposeOpenL(C3GPCompose& aComposer)
1006 T3GPVideoPropertiesBase* video = SetupVideoPropertiesL();
1007 CleanupStack::PushL(video);
1009 T3GPAudioPropertiesBase* audio = SetupAudioPropertiesL();
1010 CleanupStack::PushL(audio);
1012 TInt err = aComposer.Open(iInputFileFormat, video, audio, iFile, iComposeFlag);
1013 if (err == KErrNone)
1015 SetTestStepResult(EPass);
1019 ERR_PRINTF2(_L("C3GPLibComposeFile::doTestStepComposeOpenL => C3GPComposer::Open returns = %d"), err);
1020 SetTestStepResult(EInconclusive);
1023 CleanupStack::PopAndDestroy(2); // audio, video
1026 // -----------------------------------------------------------------------------
1027 // C3GPLibComposeAudioProperties
1028 // -----------------------------------------------------------------------------
1030 C3GPLibComposeAudioProperties::C3GPLibComposeAudioProperties()
1034 TVerdict C3GPLibComposeAudioProperties::doTestStepPreambleL()
1036 C3GPLibComposeFile::doTestStepPreambleL();
1037 if (TestStepResult() != EPass)
1039 return TestStepResult();
1043 TBool result = ETrue;
1044 result = GetIntFromConfig(ConfigSection(), _L("timescale"), temp);
1050 if (result && (iAudioType == E3GPQcelp13K))
1052 result = GetIntFromConfig(ConfigSection(), _L("storage"), temp);
1055 iQCelpMode = (T3GPQcelpStorageMode) temp;
1056 if (iQCelpMode == E3GPMP4AudioDescriptionBox)
1059 result = GetStringFromConfig(ConfigSection(), _L("decoderSpecInfo"), decoder);
1062 iDecoderSpecInfo.CreateL(decoder.Length());
1063 iDecoderSpecInfo.Copy(decoder);
1070 result = GetIntFromConfig(ConfigSection(), _L("fps"), iFps);
1074 if (result && (iAudioType == E3GPMpeg4Audio))
1077 result = GetStringFromConfig(ConfigSection(), _L("decoderSpecInfo"), decoder);
1080 iDecoderSpecInfo.CreateL(decoder.Length());
1081 iDecoderSpecInfo.Copy(decoder);
1085 if (result && (iAudioType == E3GPAmrNB || iAudioType == E3GPAmrWB))
1087 result = GetIntFromConfig(ConfigSection(), _L("modeSet"), iModeSet);
1090 result = GetIntFromConfig(ConfigSection(), _L("fps"), iFps);
1097 ERR_PRINTF1(_L("Cannot retrieve necessary a properties to complete this test."));
1098 SetTestStepResult(ETestSuiteError);
1101 return TestStepResult();
1104 TVerdict C3GPLibComposeAudioProperties::doTestStepPostambleL()
1106 iDecoderSpecInfo.Close();
1108 // clean up base class setups
1109 C3GPLibComposeFile::doTestStepPostambleL();
1111 return TestStepResult();
1114 T3GPAudioPropertiesBase* C3GPLibComposeAudioProperties::SetupQcelpAudioL()
1116 T3GPAudioPropertiesBase* audio = NULL;
1118 if (iQCelpMode == E3GPQcelpSampleEntryBox)
1120 audio = new (ELeave) T3GPAudioPropertiesQcelp(iTimescale, iFps);
1122 else if (iQCelpMode == E3GPMP4AudioDescriptionBox)
1124 audio = new (ELeave) T3GPAudioPropertiesQcelp(iTimescale, iFps, iDecoderSpecInfo);
1128 User::Leave(KErrNotFound);
1134 T3GPAudioPropertiesBase* C3GPLibComposeAudioProperties::SetupAmrAudioL()
1136 T3GPAudioPropertiesAmr::TSpeechCodec codec = T3GPAudioPropertiesAmr::EAmrWB;
1137 if (iAudioType == E3GPAmrNB)
1139 codec = T3GPAudioPropertiesAmr::EAmrNB;
1141 T3GPAudioPropertiesBase* audio = new (ELeave) T3GPAudioPropertiesAmr(iTimescale, iFps, iModeSet, codec);
1145 T3GPAudioPropertiesBase* C3GPLibComposeAudioProperties::SetupMpeg4AudioL()
1147 T3GPAudioPropertiesBase* audio = new (ELeave)T3GPAudioPropertiesMpeg4Audio(iTimescale, iDecoderSpecInfo);
1151 // -----------------------------------------------------------------------------
1152 // C3GPLibComposeWithNoAudioVideo
1153 // -----------------------------------------------------------------------------
1155 C3GPLibComposeWithNoAudioVideo::C3GPLibComposeWithNoAudioVideo()
1159 TVerdict C3GPLibComposeWithNoAudioVideo::doTestStepPreambleL()
1161 // ensure the base class setup is completed first
1162 C3GPLibComposeFile::doTestStepPreambleL();
1163 if (TestStepResult() == EPass)
1165 // reset the video / audio type both of No Video & No Audio
1166 iVideoType = E3GPNoVideo;
1167 iAudioType = E3GPNoAudio;
1170 return TestStepResult();
1173 // -----------------------------------------------------------------------------
1174 // C3GPLibComposeAudioFrames
1175 // -----------------------------------------------------------------------------
1177 C3GPLibComposeAudioFrames::C3GPLibComposeAudioFrames()
1181 TVerdict C3GPLibComposeAudioFrames::doTestStepPreambleL()
1183 // ensure all basic setup is completed first
1184 C3GPLibComposeFile::doTestStepPreambleL();
1185 if (TestStepResult() == EPass)
1187 if (GetIntFromConfig(ConfigSection(), _L("duration"), iDuration))
1189 TPtrC audioFramePtr;
1190 if (GetStringFromConfig(ConfigSection(), _L("audioFrame"), audioFramePtr))
1192 iAudioFrames.CreateL(audioFramePtr.Length());
1193 iAudioFrames.Copy(audioFramePtr);
1197 // cannot find expected error!
1198 ERR_PRINTF1(_L("audioFrame not specified. Test cannot proceed."));
1199 SetTestStepResult(ETestSuiteError);
1204 // cannot find expected error!
1205 ERR_PRINTF1(_L("duration not specified. Test cannot proceed."));
1206 SetTestStepResult(ETestSuiteError);
1210 return TestStepResult();
1213 TVerdict C3GPLibComposeAudioFrames::doTestStepPostambleL()
1216 iAudioFrames.Close();
1218 // ensure all base cleanup is done
1219 C3GPLibComposeFile::doTestStepPostambleL();
1221 return TestStepResult();
1224 void C3GPLibComposeAudioFrames::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
1226 // add the audio frame
1227 TInt err = aComposer.WriteAudioFrames(iAudioFrames, iDuration);
1228 if (err != KErrNone)
1230 if (!ShouldRunOOMTest())
1232 INFO_PRINTF2(_L("C3GPCompose::WriteAudioFrames returns %d"), err);
1234 SetTestStepError(err);
1238 // -----------------------------------------------------------------------------
1239 // C3GPLibComposeVideoFrame
1240 // -----------------------------------------------------------------------------
1242 C3GPLibComposeVideoFrame::C3GPLibComposeVideoFrame()
1246 TVerdict C3GPLibComposeVideoFrame::doTestStepPreambleL()
1248 // ensure all basic setup is completed first
1249 C3GPLibComposeFile::doTestStepPreambleL();
1250 if (TestStepResult() == EPass)
1252 if (GetBoolFromConfig(ConfigSection(), _L("keyFrame"), iKeyFrame))
1254 if (GetIntFromConfig(ConfigSection(), _L("duration"), iDuration))
1257 if (GetStringFromConfig(ConfigSection(), _L("videoFrame"), framePtr))
1259 iVideoFrame.CreateL(framePtr.Length());
1260 iVideoFrame.Copy(framePtr);
1265 if (GetIntFromConfig(ConfigSection(), _L("dependsOn"), dependsOn) &&
1266 GetIntFromConfig(ConfigSection(), _L("isDependedOn"), isDependedOn) &&
1267 GetIntFromConfig(ConfigSection(), _L("hasRedundancy"), hasRedundancy))
1269 iDependencies = new (ELeave) T3GPFrameDependencies();
1270 iDependencies->iDependsOn = (T3GPVideoFrameDependency) dependsOn;
1271 iDependencies->iIsDependedOn = (T3GPVideoFrameDependency) isDependedOn;
1272 iDependencies->iHasRedundancy = (T3GPVideoFrameRedundancy) hasRedundancy;
1277 // cannot find expected error!
1278 ERR_PRINTF1(_L("videoFrame not specified. Test cannot proceed."));
1279 SetTestStepResult(ETestSuiteError);
1284 // cannot find expected error!
1285 ERR_PRINTF1(_L("duration not specified. Test cannot proceed."));
1286 SetTestStepResult(ETestSuiteError);
1291 // cannot find expected error!
1292 ERR_PRINTF1(_L("keyFrame not specified. Test cannot proceed."));
1293 SetTestStepResult(ETestSuiteError);
1297 return TestStepResult();
1300 TVerdict C3GPLibComposeVideoFrame::doTestStepPostambleL()
1303 iVideoFrame.Close();
1304 delete iDependencies;
1306 // ensure all base cleanup is done
1307 C3GPLibComposeFile::doTestStepPostambleL();
1309 return TestStepResult();
1312 void C3GPLibComposeVideoFrame::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
1314 // add the video frame
1315 TInt err = KErrNone;
1318 err = aComposer.WriteVideoFrame(iVideoFrame, iDuration, iKeyFrame, *iDependencies);
1322 err = aComposer.WriteVideoFrame(iVideoFrame, iDuration, iKeyFrame);
1325 if (err != KErrNone)
1327 INFO_PRINTF2(_L("C3GPCompose::WriteVideoFrame returns %d"), err);
1328 SetTestStepError(err);
1332 // -----------------------------------------------------------------------------
1333 // C3GPLibComposeOpenAgain
1334 // -----------------------------------------------------------------------------
1336 C3GPLibComposeOpenAgain::C3GPLibComposeOpenAgain()
1340 void C3GPLibComposeOpenAgain::doTestStepComposeOpenL(C3GPCompose& aComposer)
1342 C3GPLibComposeFile::doTestStepComposeOpenL(aComposer);
1343 if (TestStepResult() == EPass)
1345 // ensure the composer is opened, then try open it again!
1346 T3GPVideoPropertiesBase* video = SetupVideoPropertiesL();
1347 CleanupStack::PushL(video);
1349 T3GPAudioPropertiesBase* audio = SetupAudioPropertiesL();
1350 CleanupStack::PushL(audio);
1352 // retrieve the current location of the temp file created when
1353 // opening the composer the first time in C3GPLibComposeFile::doTestStepComposeOpenL
1355 folderName.CreateL(KMaxFileName);
1356 CleanupClosePushL(folderName);
1357 User::LeaveIfError(iFile.FullName(folderName));
1359 TParsePtrC folderParse(folderName);
1360 TPtrC folder = folderParse.DriveAndPath();
1362 // create another file temp file within the same folder
1365 User::LeaveIfError(file.Temp(iFs, folder, fileName, EFileWrite));
1367 TInt err = aComposer.Open(iInputFileFormat, video, audio, file);
1368 TInt err2 = aComposer.Open(iInputFileFormat, video, audio, fileName);
1369 if (err != KErrNone && err == err2)
1371 SetTestStepError(err);
1375 INFO_PRINTF1(_L("C3GPLibComposeOpenAgain C3GPCompose::Open returns inconsistent error."));
1380 iFs.Delete(fileName);
1382 CleanupStack::PopAndDestroy(3); // audio, video, folderName
1386 // -----------------------------------------------------------------------------
1387 // C3GPLibComposeOpenReadOnlyFile
1388 // -----------------------------------------------------------------------------
1390 C3GPLibComposeOpenReadOnlyFile::C3GPLibComposeOpenReadOnlyFile()
1394 void C3GPLibComposeOpenReadOnlyFile::doTestStepComposeOpenL(C3GPCompose& aComposer)
1397 fileName.CreateL(KMaxFilename);
1398 CleanupClosePushL(fileName);
1400 // change the file to be opened to be a READ-ONLY file
1401 User::LeaveIfError(iFile.FullName(fileName));
1404 User::LeaveIfError(iFile.Open(iFs, fileName, EFileShareReadersOnly));
1405 CleanupStack::PopAndDestroy(&fileName);
1407 C3GPLibComposeWithFlag::doTestStepComposeOpenL(aComposer);
1410 TVerdict C3GPLibComposeOpenReadOnlyFile::doTestStepL()
1412 TVerdict verdict(EFail);
1414 TRAP_IGNORE(verdict = C3GPLibComposeWithFlag::doTestStepL());
1419 // -----------------------------------------------------------------------------
1420 // C3GPLibComposeOpenedFile
1421 // -----------------------------------------------------------------------------
1423 C3GPLibComposeOpenedFile::C3GPLibComposeOpenedFile()
1427 void C3GPLibComposeOpenedFile::doTestStepComposeOpenL(C3GPCompose& aComposer)
1430 fileName.CreateL(KMaxFilename);
1431 CleanupClosePushL(fileName);
1433 // change the file to be opened to be a READ-ONLY file
1434 User::LeaveIfError(iFile.FullName(fileName));
1437 User::LeaveIfError(iFile.Open(iFs, fileName, EFileShareAny));
1439 T3GPVideoPropertiesBase* video = SetupVideoPropertiesL();
1440 CleanupStack::PushL(video);
1442 T3GPAudioPropertiesBase* audio = SetupAudioPropertiesL();
1443 CleanupStack::PushL(audio);
1445 TInt err1 = aComposer.Open(iInputFileFormat, video, audio, fileName);
1446 if (err1 != KErrNone)
1448 if (!ShouldRunOOMTest())
1450 ERR_PRINTF2(_L("C3GPLibComposeOpenedFile::doTestStepComposeOpenL => C3GPComposer::Open returns = %d"), err1);
1454 User::LeaveIfError(iFile.Open(iFs, fileName, EFileShareReadersOrWriters));
1455 TInt err2 = aComposer.Open(iInputFileFormat, video, audio, fileName);
1459 SetTestStepError(err1);
1463 CleanupStack::PopAndDestroy(3); // audio, video, fileName
1466 // -----------------------------------------------------------------------------
1467 // C3GPLibComposeMultiComposeOnSameFile
1468 // -----------------------------------------------------------------------------
1470 C3GPLibComposeMultiComposeOnSameFile::C3GPLibComposeMultiComposeOnSameFile()
1474 void C3GPLibComposeMultiComposeOnSameFile::doTestStepComposeOpenL(C3GPCompose& aComposer)
1476 C3GPLibComposeFilename::doTestStepComposeOpenL(aComposer);
1477 if (TestStepError() == KErrNone && TestStepResult() == EPass)
1479 T3GPAudioPropertiesMpeg4Audio audio(100, KDummyData);
1480 T3GPVideoPropertiesAvc video(100, TSize(100, 100), KDummyData);
1481 C3GPCompose* composer2 = C3GPCompose::NewL();
1483 TInt err = composer2->Open(E3GP3GP, &video, &audio, iFilename);
1484 if (err != KErrNone)
1486 SetTestStepError(err);
1489 // close the composer
1490 composer2->Complete();
1495 // -----------------------------------------------------------------------------
1496 // C3GPLibComposeMultiComposers
1497 // -----------------------------------------------------------------------------
1499 C3GPLibComposeMultiComposers::C3GPLibComposeMultiComposers()
1503 void C3GPLibComposeMultiComposers::doTestStepComposeOpenL(C3GPCompose& aComposer)
1505 C3GPLibComposeFilename::doTestStepComposeOpenL(aComposer);
1506 if (TestStepError() == KErrNone && TestStepResult() == EPass)
1509 _LIT(KTestFolderName, "testFolderNameEmu");
1511 _LIT(KTestFolderName, "testFolderNameHw");
1514 TPtrC testFolderName;
1515 if (!GetStringFromConfig(_L("general"), KTestFolderName, testFolderName))
1517 User::Leave(KErrNotFound);
1522 User::LeaveIfError(fs.Connect());
1523 CleanupClosePushL(fs);
1526 T3GPAudioPropertiesMpeg4Audio audio1(100, KDummyData);
1527 T3GPVideoPropertiesAvc video1(100, TSize(100, 100), KDummyData);
1530 CleanupClosePushL(file1);
1531 User::LeaveIfError(file1.Temp(fs, testFolderName, fileName, EFileShareExclusive));
1533 C3GPCompose* composer2 = C3GPCompose::NewL();
1534 CleanupStack::PushL(composer2);
1535 User::LeaveIfError(composer2->Open(E3GP3GP, &video1, &audio1, file1));
1538 T3GPAudioPropertiesMpeg4Audio audio2(50, KDummyData);
1539 T3GPVideoPropertiesAvc video2(50, TSize(20, 20), KDummyData);
1542 CleanupClosePushL(file2);
1543 User::LeaveIfError(file2.Temp(fs, testFolderName, fileName, EFileShareExclusive));
1545 C3GPCompose* composer3 = C3GPCompose::NewL();
1546 CleanupStack::PushL(composer3);
1547 User::LeaveIfError(composer3->Open(E3GP3GP, &video2, &audio2, file2));
1549 // write some data into composer 1, then 2, then 3
1550 User::LeaveIfError(aComposer.WriteVideoFrame(KDummyData, 10, EFalse));
1551 User::LeaveIfError(composer2->WriteVideoFrame(KDummyData, 10, EFalse));
1552 User::LeaveIfError(composer3->WriteVideoFrame(KDummyData, 10, EFalse));
1554 // clean up for composer 3
1555 User::LeaveIfError(composer3->Complete());
1556 CleanupStack::PopAndDestroy(composer3);
1557 CleanupStack::PopAndDestroy(&file2);
1560 C3GPParse* parser = C3GPParse::NewL();
1561 CleanupStack::PushL(parser);
1562 User::LeaveIfError(parser->Open(fileName));
1564 // write some data into composer 1 & 2
1565 User::LeaveIfError(aComposer.WriteVideoFrame(KDummyData, 10, EFalse));
1566 User::LeaveIfError(composer2->WriteVideoFrame(KDummyData, 10, EFalse));
1568 // close parser and delete the file
1569 User::LeaveIfError(parser->Complete());
1570 CleanupStack::PopAndDestroy(parser);
1571 User::LeaveIfError(fs.Delete(fileName)); // delete the temp file created
1573 // clean up for composer 2
1574 User::LeaveIfError(composer2->Complete());
1575 file1.FullName(fileName); // retrieve the full name of file1
1576 CleanupStack::PopAndDestroy(composer2);
1577 CleanupStack::PopAndDestroy(&file1);
1578 User::LeaveIfError(fs.Delete(fileName)); // delete the temp file created
1581 CleanupStack::PopAndDestroy(&fs);
1583 // write some data into composer 1
1584 User::LeaveIfError(aComposer.WriteVideoFrame(KDummyData, 10, EFalse));
1588 // -----------------------------------------------------------------------------
1589 // C3GPLibComposeCloseComposerWithoutComplete
1590 // -----------------------------------------------------------------------------
1592 C3GPLibComposeCloseComposerWithoutComplete::C3GPLibComposeCloseComposerWithoutComplete()
1596 void C3GPLibComposeCloseComposerWithoutComplete::doTestStepComposeOpenL(C3GPCompose& aComposer)
1598 // close the composer, then delete the file
1599 aComposer.Complete();
1602 User::LeaveIfError(fs.Connect());
1603 CleanupClosePushL(fs);
1606 fs.Delete(iFilename);
1609 T3GPAudioPropertiesMpeg4Audio audio1(100, KDummyData);
1610 T3GPVideoPropertiesAvc video1(100, TSize(100, 100), KDummyData);
1612 C3GPCompose* composer = C3GPCompose::NewL();
1613 CleanupStack::PushL(composer);
1614 User::LeaveIfError(composer->Open(E3GP3GP, &video1, &audio1, iFilename));
1616 // write some data into composer 1, then 2, then 3
1617 User::LeaveIfError(composer->WriteVideoFrame(KDummyData, 10, EFalse));
1619 // delete the composer before calling Complete
1620 CleanupStack::PopAndDestroy(composer);
1623 CleanupClosePushL(file);
1624 User::LeaveIfError(file.Open(fs, iFilename, EFileRead));
1627 User::LeaveIfError(file.Size(fileSize));
1631 SetTestStepResult(EFail);
1634 CleanupStack::PopAndDestroy(2); // file, fs
1636 // continue the test
1637 C3GPLibComposeFilename::doTestStepComposeOpenL(aComposer);
1640 // -----------------------------------------------------------------------------
1641 // C3GPLibComposePanic
1642 // -----------------------------------------------------------------------------
1644 C3GPLibComposePanic::C3GPLibComposePanic()
1648 TVerdict C3GPLibComposePanic::doTestStepPreambleL()
1650 TVerdict verdict = C3GPLibComposeFilename::doTestStepPreambleL();
1651 if (TestStepResult() == EPass)
1653 if (!GetBoolFromConfig(ConfigSection(), _L("panic"), iPanic))
1655 ERR_PRINTF1(_L("Test setting panic not specified. Test cannot proceed."));
1656 SetTestStepResult(ETestSuiteError);
1661 if (GetStringFromConfig(ConfigSection(), _L("dir"), strPtr))
1663 // save a copy of the dir specified for the test
1664 iDir.CreateL(strPtr);
1668 // cannot find filename!
1669 ERR_PRINTF1(_L("Dir not specified. Test cannot proceed."));
1670 SetTestStepResult(ETestSuiteError);
1675 return TestStepResult();
1678 void C3GPLibComposePanic::doTestStepComposeOpenL(C3GPCompose& aComposer)
1680 // close the composer, then delete the file
1681 aComposer.Complete();
1684 User::LeaveIfError(fs.Connect());
1685 CleanupClosePushL(fs);
1687 // retrieve the number of items in the directory
1688 CDir* dirList = NULL;
1689 User::LeaveIfError(fs.GetDir(iDir, KEntryAttNormal, ESortNone, dirList));
1690 TInt orgCount = dirList->Count();
1694 T3GPAudioPropertiesMpeg4Audio audio1(100, KDummyData);
1695 T3GPVideoPropertiesAvc video1(100, TSize(100, 100), KDummyData);
1697 C3GPCompose* composer = C3GPCompose::NewL();
1698 CleanupStack::PushL(composer);
1699 User::LeaveIfError(composer->Open(E3GP3GP, &video1, &audio1, iFilename));
1701 // write some data into composer 1, then 2, then 3
1702 User::LeaveIfError(composer->WriteVideoFrame(KDummyData, 10, EFalse));
1706 // force a panic so that the composed file and the temporary file is left in the
1708 User::Panic(_L("Testing"), KErrArgument);
1711 // delete the composer before calling Complete
1712 composer->Complete();
1713 CleanupStack::PopAndDestroy(composer);
1715 User::LeaveIfError(fs.GetDir(iDir, KEntryAttNormal, ESortNone, dirList));
1716 TInt newCount = dirList->Count();
1719 // When cleaned up properly, only the composed file should be left within the directory.
1720 if (!(newCount == 1 && orgCount > 0))
1722 SetTestStepResult(EFail);
1725 CleanupStack::PopAndDestroy(); // fs
1727 // continue the test
1728 C3GPLibComposeFilename::doTestStepComposeOpenL(aComposer);
1731 TVerdict C3GPLibComposePanic::doTestStepPostambleL()
1734 return C3GPLibComposeFilename::doTestStepPostambleL();
1737 // -----------------------------------------------------------------------------
1738 // C3GPLibComposeLargeFile
1739 // -----------------------------------------------------------------------------
1741 C3GPLibComposeLargeFile::C3GPLibComposeLargeFile()
1745 TVerdict C3GPLibComposeLargeFile::doTestStepPreambleL()
1747 // ensure the base class setup is completed first
1748 C3GPLibComposeBase::doTestStepPreambleL();
1749 if (TestStepResult() == EPass)
1752 if (GetIntFromConfig(ConfigSection(), _L("inputFormat"), temp))
1754 iInputFileFormat = (T3GPFileFormatType)temp;
1756 if (GetIntFromConfig(ConfigSection(), _L("video"), temp))
1758 iVideoType = (T3GPVideoType)temp;
1761 if (GetIntFromConfig(ConfigSection(), _L("audio"), temp))
1763 iAudioType = (T3GPAudioType)temp;
1766 if (iVideoType == E3GPNoVideo && iAudioType == E3GPNoAudio)
1768 // At least audio or video should be specified
1769 ERR_PRINTF1(_L("Specify at least video or audio"));
1770 SetTestStepResult(ETestSuiteError);
1775 _LIT(KOutputDir, "filenameEmu");
1777 _LIT(KOutputDir, "filenameHw");
1781 if (GetStringFromConfig(ConfigSection(), KOutputDir, fileNamePtr))
1783 iFileName.CreateL(fileNamePtr);
1784 User::LeaveIfError(iFs.Connect());
1786 TInt err = iFs.MkDirAll(iFileName);
1787 if (err != KErrNone && err != KErrAlreadyExists)
1792 err = iFile64.Create(iFs, iFileName, EFileShareAny|EFileStream|EFileWrite);
1793 if (err == KErrAlreadyExists)
1795 User::LeaveIfError(iFile64.Replace(iFs, iFileName, EFileShareAny|EFileStream|EFileWrite));
1799 User::LeaveIfError(err);
1804 // cannot find filename!
1805 ERR_PRINTF1(_L("Filename not specified. Test cannot proceed."));
1806 SetTestStepResult(ETestSuiteError);
1812 // file format has to be specified
1813 ERR_PRINTF1(_L("Specify file format of the file to be composed"));
1814 SetTestStepResult(ETestSuiteError);
1817 if (!GetIntFromConfig(ConfigSection(), _L("flag"), iComposeFlag))
1819 iComposeFlag = E3GPNoFlag;
1823 return TestStepResult();
1826 TVerdict C3GPLibComposeLargeFile::doTestStepPostambleL()
1828 // clean up of temp file
1830 iFs.Delete(iFileName);
1835 // clean up all composer test base setups
1836 C3GPLibComposeBase::doTestStepPostambleL();
1838 return TestStepResult();
1841 C3GPCompose* C3GPLibComposeLargeFile::doTestStepCreateComposerL()
1843 return C3GPCompose::NewL(KLargeFileWriteBufferSize, KLargeFileWriteBufferMaxCount);
1846 void C3GPLibComposeLargeFile::doTestStepComposeOpenL(C3GPCompose& aComposer)
1848 T3GPVideoPropertiesBase* video = SetupVideoPropertiesL();
1849 CleanupStack::PushL(video);
1851 T3GPAudioPropertiesBase* audio = SetupAudioPropertiesL();
1852 CleanupStack::PushL(audio);
1854 TInt err = aComposer.Open(iInputFileFormat, video, audio, iFile64, iComposeFlag);
1855 if (err == KErrNone)
1857 SetTestStepResult(EPass);
1861 if (!ShouldRunOOMTest())
1863 ERR_PRINTF2(_L("C3GPLibComposeFile::doTestStepComposeOpenL => C3GPComposer::Open returns = %d"), err);
1865 SetTestStepError(err);
1866 SetTestStepResult(EInconclusive);
1869 CleanupStack::PopAndDestroy(2); // audio, video
1872 void C3GPLibComposeLargeFile::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
1875 CleanupClosePushL(videoBuf1);
1877 TUint videoTimestampMS = 0;
1879 TUint frameSize = 0;
1880 T3GPFrameDependencies aDependencies;
1883 CleanupClosePushL(fileName);
1884 User::LeaveIfError(fileName.Open(iFs, KLargeVideoFile(), EFileRead));
1886 C3GPParse* parser = C3GPParse::NewL();
1887 CleanupStack::PushL(parser);
1888 User::LeaveIfError(parser->Open(fileName));
1889 User::LeaveIfError(parser->GetVideoFrameSize(frameSize));
1890 User::LeaveIfError(videoBuf1.Create((TInt)frameSize));
1891 User::LeaveIfError(parser->ReadVideoFrame(videoBuf1, keyFrame1, videoTimestampMS, videoTS1));
1893 TInt error = parser->GetVideoFrameDependencies(aDependencies);
1894 if (error != KErrNone)
1896 aDependencies.iDependsOn = E3GPDependencyUnknown;
1897 aDependencies.iIsDependedOn = E3GPDependencyUnknown;
1898 aDependencies.iHasRedundancy = E3GPRedundancyUnknown;
1901 TInt err = KErrNone;
1905 startTime.UniversalTime();
1907 // create a 3GB video file
1908 TInt videoLength = videoBuf1.Length();
1909 while (size + videoLength < K3GigaBytes)
1911 err = aComposer.WriteVideoFrame(videoBuf1, 100, keyFrame1, aDependencies);
1912 if (err != KErrNone)
1914 ERR_PRINTF2(_L("Fail to write video frame, err = %d"), err);
1920 endTime.UniversalTime();
1921 TTimeIntervalMinutes composeTime;
1922 endTime.MinutesFrom(startTime, composeTime);
1923 INFO_PRINTF3(_L("Took %d minutes to compose a video file of size %d bytes"), composeTime.Int(), size);
1925 if (err != KErrNone)
1927 SetTestStepResult(EFail);
1930 User::LeaveIfError(parser->Complete());
1931 CleanupStack::PopAndDestroy(3, &videoBuf1);
1934 // -----------------------------------------------------------------------------
1935 // C3GPLibComposeLargeFileUserData
1936 // -----------------------------------------------------------------------------
1938 C3GPLibComposeLargeFileUserData::C3GPLibComposeLargeFileUserData()
1942 void C3GPLibComposeLargeFileUserData::doTestStepComposeSetUserDataL(C3GPCompose& aComposer)
1944 TInt bufferUdtaSize = 0;
1945 TBuf8<256> bufferUdta;
1946 TUint8* ptr = const_cast<TUint8*>(bufferUdta.Ptr());
1949 _LIT8(KTitle,"titl");
1950 _LIT8(KData1,"This Udta titl test data 01!!<end>");
1951 size = KTitle().Length() + KData1().Length() + 4;
1952 WriteInt32(ptr, size);
1954 Mem::Copy(ptr, KTitle().Ptr(), KTitle().Length());
1955 ptr += KTitle().Length();
1956 Mem::Copy(ptr, KData1().Ptr(), KData1().Length());
1957 ptr += KData1().Length();
1958 bufferUdtaSize += size;
1960 _LIT8(KTitle1,"titl");
1961 _LIT8(KData2,"This Udta titl test data 02!!blahblahblahbla<end>");
1962 size = KTitle1().Length() + KData2().Length() + 4;
1963 WriteInt32(ptr, size);
1965 Mem::Copy(ptr, KTitle1().Ptr(), KTitle1().Length());
1966 ptr += KTitle1().Length();
1967 Mem::Copy(ptr, KData2().Ptr(), KData2().Length());
1968 ptr += KData2().Length();
1969 bufferUdtaSize += size;
1971 _LIT8(KTitle2,"titl");
1972 _LIT8(KData3,"This Udta titl test data 03!!Moreblahblahblahblahblahblahblahblahblah<end>");
1973 size = KTitle2().Length() + KData3().Length() + 4;
1974 WriteInt32(ptr, size);
1976 Mem::Copy(ptr, KTitle2().Ptr(), KTitle2().Length());
1977 ptr += KTitle2().Length();
1978 Mem::Copy(ptr, KData3().Ptr(), KData3().Length());
1979 ptr += KData3().Length();
1980 bufferUdtaSize += size;
1982 bufferUdta.SetLength(bufferUdtaSize);
1983 TInt error = aComposer.SetUserData(E3GPUdtaVideoTrak, bufferUdta);
1985 if (error != KErrNone)
1987 ERR_PRINTF2(_L("C3GPComposer::SetUserData failed with %d"), error);
1988 SetTestStepError(error);
1992 void C3GPLibComposeLargeFileUserData::WriteInt32(TUint8* aPtr, TInt32 aData)
1994 aPtr[0] = TUint8(aData>>24);
1995 aPtr[1] = TUint8(aData>>16);
1996 aPtr[2] = TUint8(aData>>8);
1997 aPtr[3] = TUint8(aData);
2000 // -----------------------------------------------------------------------------
2001 // C3GPLibComposeLargeFile32bitAPI
2002 // -----------------------------------------------------------------------------
2004 C3GPLibComposeLargeFile32bitAPI::C3GPLibComposeLargeFile32bitAPI()
2008 C3GPCompose* C3GPLibComposeLargeFile32bitAPI::doTestStepCreateComposerL()
2010 return C3GPCompose::NewL(KLargeFileWriteBufferSize, KLargeFileWriteBufferMaxCount);
2013 void C3GPLibComposeLargeFile32bitAPI::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
2016 CleanupClosePushL(videoBuf1);
2018 TUint videoTimestampMS = 0;
2020 TUint frameSize = 0;
2021 T3GPFrameDependencies aDependencies;
2024 CleanupClosePushL(fileName);
2025 User::LeaveIfError(fileName.Open(iFs, KLargeVideoFile(), EFileRead));
2027 C3GPParse* parser = C3GPParse::NewL();
2028 CleanupStack::PushL(parser);
2029 User::LeaveIfError(parser->Open(fileName));
2030 User::LeaveIfError(parser->GetVideoFrameSize(frameSize));
2031 User::LeaveIfError(videoBuf1.Create((TInt)frameSize));
2032 User::LeaveIfError(parser->ReadVideoFrame(videoBuf1, keyFrame1, videoTimestampMS, videoTS1));
2034 TInt error = parser->GetVideoFrameDependencies(aDependencies);
2035 if (error != KErrNone)
2037 aDependencies.iDependsOn = E3GPDependencyUnknown;
2038 aDependencies.iIsDependedOn = E3GPDependencyUnknown;
2039 aDependencies.iHasRedundancy = E3GPRedundancyUnknown;
2042 TInt err = KErrNone;
2046 startTime.UniversalTime();
2048 // create a 3GB video file
2049 TInt videoLength = videoBuf1.Length();
2050 while (size + videoLength < K3GigaBytes)
2052 err = aComposer.WriteVideoFrame(videoBuf1, 100, keyFrame1, aDependencies);
2053 if (err != KErrNone)
2055 ERR_PRINTF2(_L("Fail to write video frame, err = %d"), err);
2061 endTime.UniversalTime();
2062 TTimeIntervalMinutes composeTime;
2063 endTime.MinutesFrom(startTime, composeTime);
2064 INFO_PRINTF3(_L("Took %d minutes to compose a video file of size %d bytes"), composeTime.Int(), size);
2066 err = aComposer.Complete();
2067 if (err != KErrNone)
2069 SetTestStepError(err);
2072 User::LeaveIfError(parser->Complete());
2073 CleanupStack::PopAndDestroy(3, &videoBuf1);
2076 // -----------------------------------------------------------------------------
2077 // C3GPLibComposeLargeFileDiskFull
2078 // -----------------------------------------------------------------------------
2080 C3GPLibComposeLargeFileDiskFull::C3GPLibComposeLargeFileDiskFull()
2084 void C3GPLibComposeLargeFileDiskFull::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
2087 CleanupClosePushL(videoBuf1);
2089 TUint videoTimestampMS = 0;
2091 TUint frameSize = 0;
2092 T3GPFrameDependencies aDependencies;
2095 CleanupClosePushL(fileName);
2096 User::LeaveIfError(fileName.Open(iFs, KLargeVideoFile(), EFileRead));
2098 C3GPParse* parser = C3GPParse::NewL();
2099 CleanupStack::PushL(parser);
2100 User::LeaveIfError(parser->Open(fileName));
2101 User::LeaveIfError(parser->GetVideoFrameSize(frameSize));
2102 User::LeaveIfError(videoBuf1.Create((TInt)frameSize));
2103 User::LeaveIfError(parser->ReadVideoFrame(videoBuf1, keyFrame1, videoTimestampMS, videoTS1));
2105 TInt error = parser->GetVideoFrameDependencies(aDependencies);
2106 if (error != KErrNone)
2108 aDependencies.iDependsOn = E3GPDependencyUnknown;
2109 aDependencies.iIsDependedOn = E3GPDependencyUnknown;
2110 aDependencies.iHasRedundancy = E3GPRedundancyUnknown;
2113 TInt err = KErrNone;
2117 startTime.UniversalTime();
2119 // create a 3GB video file
2120 TInt videoLength = videoBuf1.Length();
2121 while (size + videoLength < K3GigaBytes)
2123 err = aComposer.WriteVideoFrame(videoBuf1, 100, keyFrame1, aDependencies);
2124 if (err != KErrNone)
2126 ERR_PRINTF2(_L("Fail to write video frame, err = %d"), err);
2132 endTime.UniversalTime();
2133 TTimeIntervalMinutes composeTime;
2134 endTime.MinutesFrom(startTime, composeTime);
2135 INFO_PRINTF3(_L("Took %d minutes to compose a video file of size %d bytes"), composeTime.Int(), size);
2137 if (err != KErrNone)
2139 SetTestStepError(err);
2142 User::LeaveIfError(parser->Complete());
2143 CleanupStack::PopAndDestroy(3, &videoBuf1);
2146 aComposer.Complete();
2149 // -----------------------------------------------------------------------------
2150 // C3GPLibComposeFileWithAvcProfileCheck
2151 // -----------------------------------------------------------------------------
2154 const TInt KAvcDecoderConfigRecordLength = 7;
2156 _LIT8(KAvcCTag, "avcC");
2158 const TUint8 KAvcConfigVersion = 1;
2160 const TUint8 KAvcProfileByteBaseline = 66;
2161 const TUint8 KAvcProfileByteExtended = 77;
2162 const TUint8 KAvcProfileByteMain = 88;
2163 const TUint8 KAvcProfileByteHigh = 100;
2165 C3GPLibComposeFileWithAvcProfileCheck::C3GPLibComposeFileWithAvcProfileCheck()
2166 : iAvcDecoderConfigRecord( KAvcDecoderConfigRecordLength )
2170 TVerdict C3GPLibComposeFileWithAvcProfileCheck::doTestStepL()
2172 if (TestStepResult() != EPass)
2174 return TestStepResult();
2178 // 1. Create a composer
2179 // 2. Open the composer - C3GPLibComposeFileFormatCheck::doTestStepComposeOpenL
2180 // 3. Write Video & Audio Data - C3GPLibComposeFileFormatCheck::doTestStepComposeWriteVideoAudioL
2181 // 4. Write User Data - C3GPLibComposeFileFormatCheck::doTestStepComposeSetUserDataL
2182 // 5. Complete the composer
2183 TVerdict verdict = C3GPLibComposeFile::doTestStepL();
2184 if (verdict == EPass)
2186 // once the file is composed, it can be verified if the file composed has the same
2188 verdict = VerifyAvcProfileL(iFile);
2192 INFO_PRINTF1(_L("<C3GPLibComposeFileWithAvcProfileCheck> C3GPLibComposeFile::doTestStepL returns failed result"));
2194 SetTestStepResult(verdict);
2196 if (!ShouldRunOOMTest())
2198 INFO_PRINTF2(_L("C3GPLibComposeFileWithAvcProfileCheck::doTestStepL returns %d"), TestStepResult());
2200 return TestStepResult();
2204 * The aDecoderSpecificInfo argument is used by 3GPlib to populate the
2205 * avcC box. As this contains details of the AVC profile which is being
2206 * checked by this test we cannot use KDummyData as the other tests do.
2209 T3GPVideoPropertiesBase* C3GPLibComposeFileWithAvcProfileCheck::SetupAvcVideoL()
2211 // See ISO 14496-15, chapter 5.2.4.1.1 for details of these...
2212 // config version (always 1)
2213 iAvcDecoderConfigRecord[0] = KAvcConfigVersion;
2215 iAvcDecoderConfigRecord[2] = 0; // dummy data
2217 iAvcDecoderConfigRecord[3] = 0; // dummy data
2218 // reserved (6bits) + lengthSizeMinusOne (2bits)
2219 iAvcDecoderConfigRecord[4] = 0xFC; // 111111 00
2220 // reserved (3bits) + numOfSeqParamSets (5bits)
2221 iAvcDecoderConfigRecord[5] = 0xE0; // 111 00000
2222 // numOfPicParamSets
2223 iAvcDecoderConfigRecord[6] = 0;
2225 switch( iVideoType )
2227 case E3GPAvcProfileBaseline:
2228 iAvcDecoderConfigRecord[1] = KAvcProfileByteBaseline;
2231 case E3GPAvcProfileMain:
2232 iAvcDecoderConfigRecord[1] = KAvcProfileByteMain;
2235 case E3GPAvcProfileExtended:
2236 iAvcDecoderConfigRecord[1] = KAvcProfileByteExtended;
2239 case E3GPAvcProfileHigh:
2240 iAvcDecoderConfigRecord[1] = KAvcProfileByteHigh;
2244 User::Leave(KErrUnknown);
2246 T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesAvc(1000, TSize(100, 100), iAvcDecoderConfigRecord );
2250 TVerdict C3GPLibComposeFileWithAvcProfileCheck::VerifyAvcProfileL(const RFile& aFile)
2252 // Seek to the beginning of the file
2254 User::LeaveIfError(aFile.Seek(ESeekStart, pos));
2256 TVerdict verdict = EFail;
2259 TInt rewind = -1 * ( atom.MaxLength() - 1 );
2264 // Search for the 'avcC' atom to check the profile that follows it.
2266 // Read in next 4 bytes
2267 User::LeaveIfError(aFile.Read(atom));
2268 if (atom.Length() < atom.MaxLength())
2273 // Check if 'avcC' was found
2274 if (Mem::Compare((&KAvcCTag)->Ptr(), (&KAvcCTag)->Length(), atom.Ptr(), atom.Length()) == 0)
2276 // read next byte, and it should contain config version (always 1)
2277 User::LeaveIfError(aFile.Read(byte));
2278 if( byte[0] != KAvcConfigVersion )
2280 ERR_PRINTF2(_L("avcC atom config type not as expected! (%d instead of 1)"), byte[0] );
2284 // read next byte, and it should contain profile indication
2285 User::LeaveIfError(aFile.Read(byte));
2286 switch( iVideoType )
2288 case E3GPAvcProfileBaseline:
2289 if( byte[0] == KAvcProfileByteBaseline )
2295 ERR_PRINTF3(_L("avcC atom config type not as expected! (%d instead of %d)"), byte[0], KAvcProfileByteBaseline );
2300 case E3GPAvcProfileMain:
2301 if( byte[0] == KAvcProfileByteMain )
2307 ERR_PRINTF3(_L("avcC atom config type not as expected! (%d instead of %d)"), byte[0], KAvcProfileByteMain );
2312 case E3GPAvcProfileExtended:
2313 if( byte[0] == KAvcProfileByteExtended )
2319 ERR_PRINTF3(_L("avcC atom config type not as expected! (%d instead of %d)"), byte[0], KAvcProfileByteExtended );
2324 case E3GPAvcProfileHigh:
2325 if( byte[0] == KAvcProfileByteHigh )
2331 ERR_PRINTF3(_L("avcC atom config type not as expected! (%d instead of %d)"), byte[0], KAvcProfileByteHigh );
2336 ERR_PRINTF2(_L("avcC has unknown profile indication: %d"), byte[0] );
2339 // 'avcC' was found, regardless of the result, finish reading the file
2344 // The 4 bytes read were not 'avcC'.
2345 // Need to rewind by 3 bytes since we need to step through the file
2347 tmp = rewind; // Avoid rewind value being changed by Seek() function
2348 User::LeaveIfError( aFile.Seek( ESeekCurrent, tmp ) );