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 sl@0: #include "tsu3gplibraryapi.h" sl@0: sl@0: using namespace ContentAccess; sl@0: sl@0: // -------------------------- sl@0: // C3GPLibParser_base sl@0: // -------------------------- sl@0: // sl@0: TVerdict C3GPLibParser_base::doTestStepPreambleL() sl@0: { sl@0: SetTestStepResult(EPass); sl@0: SetTestStepError(KErrNone); sl@0: sl@0: TPtrC testSection = ConfigSection(); sl@0: sl@0: TInt err = iTestSection.Create(testSection.Length()); sl@0: if( err != KErrNone ) sl@0: { sl@0: ERR_PRINTF2(_L("Cannot create buffer for inputFilename. err = %d"), err); sl@0: SetTestStepResult(EInconclusive); sl@0: return TestStepResult(); sl@0: } sl@0: iTestSection += testSection; sl@0: sl@0: TBuf<20> testFolderName; sl@0: testFolderName.Zero(); sl@0: if (ConfigSection().Compare(_L("3GP-H264-MP4-LARGE")) == 0) sl@0: { sl@0: #ifdef __WINSCW__ sl@0: testFolderName.Append(_L("inputFileEmu")); sl@0: #else sl@0: testFolderName.Append(_L("inputFileHw")); sl@0: #endif sl@0: } sl@0: else sl@0: { sl@0: testFolderName.Append(_L("inputFile")); sl@0: } sl@0: sl@0: TPtrC inputFile; sl@0: if(!GetStringFromConfig(ConfigSection(), testFolderName, inputFile)) sl@0: { sl@0: ERR_PRINTF1(_L("Cannot read inputFile from ini file.")); sl@0: SetTestStepResult(ETestSuiteError); sl@0: return TestStepResult(); sl@0: } sl@0: err = iInputFile.Create(inputFile.Length() + 1); sl@0: if( err != KErrNone ) sl@0: { sl@0: ERR_PRINTF2(_L("Cannot create buffer for inputFilename. err = %d"), err); sl@0: SetTestStepResult(EInconclusive); sl@0: return TestStepResult(); sl@0: } sl@0: iInputFile += inputFile; sl@0: iInputFile.ZeroTerminate(); sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_base::doTestStepPostambleL() sl@0: { sl@0: iInputFile.Close(); sl@0: iTestSection.Close(); sl@0: sl@0: // Close file sl@0: iSourceFile.Close(); sl@0: iSourceFile64.Close(); sl@0: sl@0: //Close the file server session sl@0: iFsSession.Close(); sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TInt C3GPLibParser_base::CheckError(TInt aError, TInt aExpectError, const TDesC& aFunction) sl@0: { sl@0: if (aError != aExpectError) sl@0: { sl@0: ERR_PRINTF4(_L("%S expected %d, but returns %d; "), &aFunction, aExpectError, aError); sl@0: if (aError != KErrNone) sl@0: { sl@0: return aError; sl@0: } sl@0: // expected an error, but return KErrNone sl@0: return KErrGeneral; sl@0: } sl@0: return KErrNone; sl@0: } sl@0: sl@0: void C3GPLibParser_base::ParserOpenL(C3GPParse* aParser, TInt aExpectedError) sl@0: { sl@0: ASSERT(aParser); sl@0: sl@0: TInt err = aParser->Open(); sl@0: if (aExpectedError == KErrInUse && err == KErrNone) sl@0: { sl@0: err = aParser->Open(); sl@0: } sl@0: sl@0: if (ShouldRunOOMTest() && err != KErrNone && err != aExpectedError) sl@0: { sl@0: INFO_PRINTF2(_L("Parser open using buffer mode (OOM), returns %d"), err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF2(_L("Parser open using buffer mode, returns %d"), err); sl@0: } sl@0: sl@0: User::LeaveIfError(CheckError(err, aExpectedError, _L("aParser->Open() buffer mode"))); sl@0: } sl@0: sl@0: void C3GPLibParser_base::ParserOpenFileL(C3GPParse* aParser, TInt aExpectedError) sl@0: { sl@0: ASSERT(aParser); sl@0: sl@0: TInt err = aParser->Open(iInputFile); sl@0: if (aExpectedError == KErrInUse && err == KErrNone) sl@0: { sl@0: err = aParser->Open(iInputFile); sl@0: } sl@0: sl@0: if (ShouldRunOOMTest() && err != KErrNone && err != aExpectedError) sl@0: { sl@0: INFO_PRINTF2(_L("Parser open using file path (OOM), returns %d"), err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF2(_L("Parser open using file path, returns %d"), err); sl@0: } sl@0: sl@0: User::LeaveIfError(CheckError(err, aExpectedError, _L("aParser->Open() file path"))); sl@0: } sl@0: sl@0: void C3GPLibParser_base::ParserCompleteL(C3GPParse* aParser) sl@0: { sl@0: ASSERT(aParser); sl@0: sl@0: TInt err = aParser->Complete(); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("aParser->Complete()"))); sl@0: } sl@0: sl@0: void C3GPLibParser_base::FileOpenL(TUint aFileMode) sl@0: { sl@0: iSourceFile.Close(); sl@0: //Create a connection to the file server sl@0: User::LeaveIfError(iFsSession.Connect()); sl@0: sl@0: //Open the source file passing in the file server session handle, source sl@0: //file path and file access mode sl@0: User::LeaveIfError(iSourceFile.Open(iFsSession, iInputFile, aFileMode )); sl@0: } sl@0: sl@0: void C3GPLibParser_base::FileClose() sl@0: { sl@0: // Close file sl@0: iSourceFile.Close(); sl@0: sl@0: //Close the file server session sl@0: iFsSession.Close(); sl@0: } sl@0: sl@0: void C3GPLibParser_base::FileOpen64L(TUint aFileMode) sl@0: { sl@0: iSourceFile64.Close(); sl@0: //Create a connection to the file server sl@0: User::LeaveIfError(iFsSession.Connect()); sl@0: sl@0: //Open the source file passing in the file server session handle, source sl@0: //file path and file access mode sl@0: User::LeaveIfError(iSourceFile64.Open(iFsSession, iInputFile, aFileMode )); sl@0: } sl@0: sl@0: void C3GPLibParser_base::FileClose64() sl@0: { sl@0: // Close file sl@0: iSourceFile64.Close(); sl@0: sl@0: //Close the file server session sl@0: iFsSession.Close(); sl@0: } sl@0: sl@0: void C3GPLibParser_base::ParserOpenFileHandleL(C3GPParse* aParser, TUint aFileMode, TInt aExpectedError) sl@0: { sl@0: ASSERT(aParser); sl@0: sl@0: FileOpenL(aFileMode); sl@0: TInt err = aParser->Open(iSourceFile); sl@0: if (aExpectedError == KErrInUse && err == KErrNone) sl@0: { sl@0: err = aParser->Open(iSourceFile); sl@0: } sl@0: sl@0: if (err != KErrNone && err != aExpectedError) sl@0: { sl@0: FileClose(); sl@0: sl@0: if (ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF2(_L("Parser open using file handle (OOM), returns %d"), err); sl@0: User::Leave(err); sl@0: } sl@0: } sl@0: sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF2(_L("Parser open using file handle, returns %d"), err); sl@0: } sl@0: sl@0: if (err == aExpectedError ) sl@0: { sl@0: err = KErrNone; sl@0: } sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: void C3GPLibParser_base::ParserCompleteHandleL(C3GPParse* aParser) sl@0: { sl@0: ASSERT(aParser); sl@0: sl@0: TInt err = aParser->Complete(); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("aParser->Complete() file handle failed with %d"), err); sl@0: } sl@0: sl@0: FileClose(); sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: void C3GPLibParser_base::ParserOpenFileHandle64L(C3GPParse* aParser, TUint aFileMode, TInt aExpectedError) sl@0: { sl@0: ASSERT(aParser); sl@0: sl@0: FileOpen64L(aFileMode); sl@0: TInt err = aParser->Open(iSourceFile64); sl@0: if (aExpectedError == KErrInUse && err == KErrNone) sl@0: { sl@0: err = aParser->Open(iSourceFile64); sl@0: } sl@0: sl@0: if (err != KErrNone && err != aExpectedError) sl@0: { sl@0: FileClose(); sl@0: sl@0: if (ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF2(_L("Parser open using 64bit file handle (OOM), returns %d"), err); sl@0: User::Leave(err); sl@0: } sl@0: } sl@0: sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF2(_L("Parser open using 64bit file handle, returns %d"), err); sl@0: } sl@0: sl@0: if (err == aExpectedError ) sl@0: { sl@0: err = KErrNone; sl@0: } sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: void C3GPLibParser_base::ParserCompleteHandle64L(C3GPParse* aParser) sl@0: { sl@0: ASSERT(aParser); sl@0: sl@0: TInt err = aParser->Complete(); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("aParser->Complete() 64bit file handle failed with %d"), err); sl@0: } sl@0: sl@0: FileClose64(); sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: void C3GPLibParser_base::ParserOpenCafLC(C3GPParse* aParser, TInt aExpectedError) sl@0: { sl@0: ASSERT(aParser); sl@0: CContent* content = CContent::NewLC(iInputFile, EContentShareReadWrite); sl@0: CData* data = content->OpenContentL(EPeek); sl@0: sl@0: CleanupStack::PushL(data); sl@0: sl@0: TInt err = aParser->Open(*data); sl@0: if (aExpectedError == KErrInUse && err == KErrNone) sl@0: { sl@0: err = aParser->Open(*data); sl@0: } sl@0: sl@0: if (ShouldRunOOMTest() && err != KErrNone && err != aExpectedError) sl@0: { sl@0: INFO_PRINTF2(_L("Parser open using CAF (OOM), returns %d"), err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF2(_L("Parser open using CAF, returns %d"), err); sl@0: } sl@0: sl@0: if (err == aExpectedError) sl@0: { sl@0: err = KErrNone; sl@0: } sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: void C3GPLibParser_base::ParserCompleteCafL(C3GPParse* aParser) sl@0: { sl@0: ASSERT(aParser); sl@0: TInt err = aParser->Complete(); sl@0: if ( err != KErrNone ) sl@0: { sl@0: ERR_PRINTF2(_L("parse->Complete() CAF failed with %d."), err); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2); // content, data sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: // Retrieve both video & audio stream properties sl@0: TInt C3GPLibParser_base::GetClipProperties(C3GPParse* aParse, TInt& aVideoError, TUint& aVideoLength, TUint& aAudioLength) sl@0: { sl@0: TInt err = KErrCorrupt; sl@0: T3GPVideoType videoType; sl@0: TReal frameRate; sl@0: TUint avgBitRate; sl@0: TSize videoSize; sl@0: TUint timeScale; sl@0: sl@0: aVideoError = aParse->GetVideoProperties(videoType, aVideoLength, frameRate, avgBitRate, videoSize, timeScale); sl@0: sl@0: if (aVideoError == KErrNone || aVideoError == KErrNotSupported || aVideoError == KErr3gpLibMoreDataRequired) sl@0: { sl@0: T3GPAudioType audioType; sl@0: TInt framesPerSample; sl@0: err = aParse->GetAudioProperties(audioType, aAudioLength, framesPerSample, avgBitRate, timeScale); sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: // Get both audio and video decorder information sl@0: TInt C3GPLibParser_base::ParserGetDecoderInfo(C3GPParse* aParser) sl@0: { sl@0: TInt dsiSize; sl@0: RBuf8 dsiBuffer; sl@0: sl@0: TInt err = aParser->GetAudioDecoderSpecificInfoSize(dsiSize); sl@0: if ( err == KErrNone ) sl@0: { sl@0: err = dsiBuffer.Create(dsiSize); sl@0: if ( err != KErrNone ) sl@0: { sl@0: ERR_PRINTF2(_L("dsiBuffer.Create failed with %d"), err); sl@0: dsiBuffer.Close(); sl@0: return err; sl@0: } sl@0: sl@0: err = aParser->GetAudioDecoderSpecificInfo(dsiBuffer); sl@0: } sl@0: if ( err != KErrNone ) sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF3(_L("GetAudioDecoderSpecificInfo/Size() failed with %d, size %d"), err, dsiSize); sl@0: } sl@0: dsiBuffer.Close(); sl@0: return err; sl@0: } sl@0: sl@0: err = aParser->GetVideoDecoderSpecificInfoSize(dsiSize); sl@0: if ( err != KErrNone && err != KErrNotSupported) sl@0: { sl@0: dsiBuffer.Close(); sl@0: ERR_PRINTF2(_L("parse->GetVideoDecoderSpecificInfoSize() failed with %d"), err); sl@0: return err; sl@0: } sl@0: if (err != KErrNotSupported) sl@0: { sl@0: dsiBuffer.Close(); sl@0: err = dsiBuffer.Create(dsiSize); sl@0: if ( err != KErrNone ) sl@0: { sl@0: ERR_PRINTF2(_L("dsiBuffer.Create failed with %d"), err); sl@0: dsiBuffer.Close(); sl@0: return err; sl@0: } sl@0: sl@0: err = aParser->GetVideoDecoderSpecificInfo(dsiBuffer); sl@0: if ( err != KErrNone ) sl@0: { sl@0: ERR_PRINTF2(_L("VideoDecoderSpecificInfo() failed with %d"), err); sl@0: } sl@0: } sl@0: dsiBuffer.Close(); sl@0: return err; sl@0: } sl@0: sl@0: // Read data from file and insert it to the buffer sl@0: void C3GPLibParser_base::InsertDataL(C3GPParse* aParse, RFile aFile, TInt aBufferSize, TInt aPos) sl@0: { sl@0: TInt err = KErrNone; sl@0: RBuf8 buffer; sl@0: CleanupClosePushL(buffer); sl@0: buffer.CreateL(aBufferSize); sl@0: err = aFile.Read(aPos, buffer); sl@0: if (err == KErrNone) sl@0: { sl@0: err = aParse->InsertData(buffer); sl@0: if ( err != KErrNone ) sl@0: { sl@0: ERR_PRINTF2(_L("parse->InsertData() failed with %d"), err); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("aFile.Read(aPos, buffer) failed with %d"), err); sl@0: } sl@0: buffer.Close(); sl@0: CleanupStack::PopAndDestroy(&buffer); sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: // Read audio or video frame(s) depending on the input parameter synchronously sl@0: TInt C3GPLibParser_base::ReadAudioVideoFrame(C3GPParse* aParse, TBool aRepeat, TBool aReadAudio) sl@0: { sl@0: TInt err = KErrNone; sl@0: // If repeat, read all frames; otherwise, read only one frame sl@0: while (err == KErrNone) sl@0: { sl@0: TUint size; sl@0: if (aReadAudio) sl@0: { sl@0: err = aParse->GetAudioFramesSize(size); sl@0: } sl@0: else sl@0: { sl@0: err = aParse->GetVideoFrameSize(size); sl@0: } sl@0: sl@0: if (err == KErrNone) sl@0: { sl@0: TUint timeStampInMs; sl@0: TUint timeStampInTimescale; sl@0: RBuf8 buffer; sl@0: err = buffer.Create(size); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("buffer.Create(size) failed with %d"), err); sl@0: buffer.Close(); sl@0: return err; sl@0: } sl@0: sl@0: if (aReadAudio) sl@0: { sl@0: TInt returnedFrames; sl@0: err = aParse->ReadAudioFrames(buffer, returnedFrames, timeStampInMs, timeStampInTimescale); sl@0: } sl@0: else sl@0: { sl@0: TBool keyframe; sl@0: err = aParse->ReadVideoFrame(buffer, keyframe, timeStampInMs, timeStampInTimescale); sl@0: } sl@0: sl@0: if (err != KErrNone && err != KErrNotFound && err != KErr3gpLibMoreDataRequired) sl@0: { sl@0: if (aReadAudio) sl@0: { sl@0: ERR_PRINTF3(_L("parse->GetAudioFrames() failed with %d; frame size: %d"), err, size); sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF3(_L("parse->GetVideoFrame() failed with %d; frame size: %d"), err, size); sl@0: } sl@0: buffer.Close(); sl@0: return err; sl@0: } sl@0: buffer.Close(); sl@0: } sl@0: sl@0: if (!aRepeat) sl@0: { sl@0: break; sl@0: } sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: // Retrieve user data atom. sl@0: TInt C3GPLibParser_base::CallUDTApi(C3GPParse* aParse, TUint32 aUdtType, TUint& aIndex, T3GPUdtaLocation aLocation) sl@0: { sl@0: TInt err = KErrNone; sl@0: TInt udtSize; sl@0: sl@0: // use a copy of the target index requested by the user, so it does not get overwritten sl@0: // when calling the APIs GetUserDataAtomSize & GetUserDataAtom sl@0: TUint tempIndex1 = aIndex; sl@0: TUint tempIndex2 = aIndex; sl@0: sl@0: err = aParse->GetUserDataAtomSize(aUdtType, aLocation, tempIndex1, udtSize); sl@0: if (err == KErrNone) sl@0: { sl@0: RBuf8 buffer; sl@0: sl@0: err = buffer.Create(udtSize); // Use size retrieved from GetUserDataAtomSize sl@0: if (err == KErrNone) sl@0: { sl@0: err = aParse->GetUserDataAtom(aUdtType, aLocation, buffer, tempIndex2); sl@0: if (err == KErrNone && tempIndex1 != tempIndex2) sl@0: { sl@0: ERR_PRINTF1(_L("C3GPLibParser_base::CallUDTApi - Highest Index returned is different when calling GetUserDataAtomSize vs GetUserDataAtom")); sl@0: err = KErrGeneral; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("buffer.Create(size) failed with %d"), err); sl@0: } sl@0: buffer.Close(); sl@0: } sl@0: sl@0: if (err == KErrNone) sl@0: { sl@0: // return the highest index found sl@0: aIndex = tempIndex1; sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: sl@0: void C3GPLibParser_base::DoGetVideoAudioAttributesL(C3GPParse* aParser) sl@0: { sl@0: // Retrieve video & audio stream attributes sl@0: T3GPVideoType videoType; sl@0: TUint length; sl@0: TReal frameRate; sl@0: TUint avgBitRate; sl@0: TSize videoSize; sl@0: TUint timeScale; sl@0: sl@0: TInt err = aParser->GetVideoProperties(videoType, length, frameRate, avgBitRate, videoSize, timeScale); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("aParser->GetVideoProperties()"))); sl@0: sl@0: T3GPAudioType audioType; sl@0: TInt framesPerSample; sl@0: err = aParser->GetAudioProperties(audioType, length, framesPerSample, avgBitRate, timeScale); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("aParser->GetAudioProperties()"))); sl@0: sl@0: err = ParserGetDecoderInfo(aParser); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("ParserGetDecoderInfo(aParser)"))); sl@0: sl@0: TUint numVideoFrames; sl@0: err = aParser->GetNumberOfVideoFrames(numVideoFrames); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("parse->GetNumberOfVideoFrames"))); sl@0: sl@0: TUint startIndex = 0; sl@0: RArray array; sl@0: err = aParser->GetVideoFrameProperties(startIndex, numVideoFrames, array); sl@0: array.Close(); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("parse->GetVideoFrameProperties"))); sl@0: } sl@0: sl@0: TInt C3GPLibParser_base::DoReadFrame(C3GPParse* aParse) sl@0: { sl@0: TInt numBufferedBytes; sl@0: TInt err = aParse->GetNumBufferedBytes(numBufferedBytes); sl@0: if (err != KErrNone && numBufferedBytes != 0) sl@0: { sl@0: // when GetNumBufferedBytes returns error, numBufferedBytes is set to zero. sl@0: return err; sl@0: } sl@0: err = CheckError(err, KErrNotSupported, _L("parse->GetNumBufferedBytes()")); sl@0: if (err == KErrNone) sl@0: { sl@0: // read audio frame sl@0: err = ReadAudioVideoFrame(aParse, ETrue, ETrue); sl@0: // When finishing reading all frames, it returns KErrNotFound sl@0: err = CheckError(err, KErrNotFound, _L("ReadAudioVideoFrame(aParse, ETrue)")); sl@0: sl@0: if (err == KErrNone) sl@0: { sl@0: // read video frame sl@0: err = ReadAudioVideoFrame(aParse, ETrue, EFalse); sl@0: // When finishing reading all frames, it returns KErrNotFound sl@0: err = CheckError(err, KErrNotFound, _L("ReadAudioVideoFrame(aParse, EFalse)")); sl@0: } sl@0: sl@0: // After finishing reading all frame, the next video time stamp should return with KErrEof sl@0: TUint timeStampInMs; sl@0: TUint timeStampInTimescale; sl@0: err = aParse->GetVideoTimestamp(timeStampInMs, timeStampInTimescale); sl@0: err = CheckError(err, KErrEof, _L("GetVideoTimestamp()")); sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: sl@0: void C3GPLibParser_base::DoSeekTestL(C3GPParse* aParser) sl@0: { sl@0: // testclip_h263_qcif_15fps_armnb_8khz_onlyvideo.3GP with some key frame sl@0: TUint num; sl@0: TUint audioPos; sl@0: TUint videoPos; sl@0: TUint timeStampInMs = 0; // for key frame sl@0: TUint timeStampInTimescale = 0; // for key frame sl@0: TUint timeStampInMs1 = 0; // for non key frame immediately after key frame sl@0: TUint timeStampInTimescale1 = 0; // for non-key frame immediately after key frame sl@0: TUint keyFrameIndex = 0; sl@0: TBool keyFrame; sl@0: TInt err = aParser->GetNumberOfVideoFrames(num); sl@0: if (err == KErrNone) sl@0: { sl@0: for (TInt i = 0; i < num; i++) sl@0: { sl@0: err = aParser->GetVideoFrameKeyType(i, keyFrame); sl@0: if (err == KErrNone && keyFrame) sl@0: { sl@0: keyFrameIndex = i; sl@0: err = aParser->GetVideoFrameStartTime(keyFrameIndex, timeStampInMs, timeStampInTimescale); sl@0: } sl@0: if (err == KErrNone && !keyFrame && keyFrameIndex > 0) sl@0: { sl@0: keyFrameIndex = i; sl@0: err = aParser->GetVideoFrameStartTime(keyFrameIndex, timeStampInMs1, timeStampInTimescale1); sl@0: break; sl@0: } sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF3(_L("aParser->GetVideoFrameKeyType() failed with %d at i %d"), err, i); sl@0: User::Leave(err); sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("aParser->GetNumberOfVideoFrames() failed with %d"), err); sl@0: User::Leave(err); sl@0: } sl@0: err = aParser->Seek(timeStampInMs, ETrue, audioPos, videoPos); sl@0: if (err != KErrNone || timeStampInMs != videoPos) sl@0: { sl@0: ERR_PRINTF4(_L("aParser->Seek() return %d, timeStampInMs %d, videoPos %d"), err, timeStampInMs, videoPos); sl@0: } sl@0: if (err == KErrNone && timeStampInMs != videoPos) sl@0: { sl@0: User::LeaveIfError(KErrGeneral); sl@0: } sl@0: User::LeaveIfError(err); sl@0: sl@0: err = aParser->Seek(timeStampInMs1, EFalse, audioPos, videoPos); sl@0: if (err != KErrNone || timeStampInMs1 != videoPos) sl@0: { sl@0: ERR_PRINTF4(_L("aParser->Seek() return %d, timeStampInMs1 %d, videoPos %d"), err, timeStampInMs1, videoPos); sl@0: } sl@0: if (err == KErrNone && timeStampInMs1 != videoPos) sl@0: { sl@0: User::LeaveIfError(KErrGeneral); sl@0: } sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: void C3GPLibParser_base::ReadFrameBufferModeL(C3GPParse* aParser) sl@0: { sl@0: ParserOpenL(aParser); sl@0: sl@0: TInt errReadAudio = KErrNone; sl@0: TInt errReadVideo = KErrNone; sl@0: // Insert 1K data into the library sl@0: TInt pos = 0; sl@0: TInt bufferSize = 1000; sl@0: sl@0: InsertDataL(aParser, iSourceFile, bufferSize, pos); sl@0: errReadAudio = ReadAudioVideoFrame(aParser, ETrue, ETrue); sl@0: errReadVideo = ReadAudioVideoFrame(aParser, ETrue, EFalse); sl@0: sl@0: while (errReadAudio == KErr3gpLibMoreDataRequired || errReadVideo == KErr3gpLibMoreDataRequired) sl@0: { sl@0: pos = pos + bufferSize; sl@0: InsertDataL(aParser, iSourceFile, bufferSize, pos); sl@0: if (errReadAudio == KErr3gpLibMoreDataRequired) sl@0: { sl@0: errReadAudio = ReadAudioVideoFrame(aParser, ETrue, ETrue); sl@0: } sl@0: sl@0: if (errReadVideo == KErr3gpLibMoreDataRequired) sl@0: { sl@0: errReadVideo = ReadAudioVideoFrame(aParser, ETrue, EFalse); sl@0: } sl@0: } sl@0: sl@0: // When last frame has been read, it should return KErrNotFound sl@0: if (errReadAudio != KErrNotFound) sl@0: { sl@0: ERR_PRINTF1(_L("parse->ReadAudioFrames() expects KErrNotFound. ")); sl@0: User::Leave(errReadAudio); sl@0: } sl@0: if (errReadVideo != KErrNotFound) sl@0: { sl@0: ERR_PRINTF1(_L("parse->ReadVideoFrame expects KErrNotFound. ")); sl@0: User::Leave(errReadVideo); sl@0: } sl@0: sl@0: ParserCompleteL(aParser); sl@0: } sl@0: sl@0: C3GPLib_AsyncObserver::C3GPLib_AsyncObserver() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLib_AsyncObserver::doTestStepPreambleL() sl@0: { sl@0: C3GPLibParser_base::doTestStepPreambleL(); sl@0: sl@0: iSchedulerWait = new (ELeave) CActiveSchedulerWait; sl@0: if(!iSchedulerWait) sl@0: { sl@0: SetTestStepResult(EInconclusive); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // C3GPLib_AsyncObserver for asynchronous read sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TVerdict C3GPLib_AsyncObserver::doTestStepPostambleL() sl@0: { sl@0: C3GPLibParser_base::doTestStepPostambleL(); sl@0: if ( iSchedulerWait) sl@0: { sl@0: if (iSchedulerWait->IsStarted()) sl@0: { sl@0: iSchedulerWait->AsyncStop(); sl@0: } sl@0: delete iSchedulerWait; sl@0: iSchedulerWait = NULL; sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: // Read audio or video frame(s) depending on the input parameter asynchronously sl@0: TInt C3GPLib_AsyncObserver::ReadAudioVideoFrameAsync(C3GPParse* aParse, TBool aReadAudio, TBool aCancel) sl@0: { sl@0: TInt err = KErrNone; sl@0: TUint size; sl@0: sl@0: while (err == KErrNone) sl@0: { sl@0: if (aReadAudio) sl@0: { sl@0: err = aParse->GetAudioFramesSize(size); sl@0: } sl@0: else sl@0: { sl@0: err = aParse->GetVideoFrameSize(size); sl@0: } sl@0: sl@0: RBuf8 buffer; sl@0: if (err == KErrNone) sl@0: { sl@0: err = buffer.Create(size); sl@0: } sl@0: else sl@0: { sl@0: err = buffer.Create(KBufferSize); sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("buffer.Create(KBufferSize) failed with %d"), err); sl@0: buffer.Close(); sl@0: return err; sl@0: } sl@0: sl@0: iWaitForNotification = ETrue; sl@0: if (aReadAudio) sl@0: { sl@0: aParse->ReadAudioFrames(*this, buffer); sl@0: } sl@0: else sl@0: { sl@0: aParse->ReadVideoFrame(*this, buffer); sl@0: } sl@0: sl@0: if (aCancel && iAsyncError == KErrNone) sl@0: { sl@0: aParse->CancelReadFrame(); sl@0: // Calling cancel again won't have effects sl@0: aParse->CancelReadFrame(); sl@0: sl@0: // Do read frame again sl@0: if (aReadAudio) sl@0: { sl@0: aParse->ReadAudioFrames(*this, buffer); sl@0: } sl@0: else sl@0: { sl@0: aParse->ReadVideoFrame(*this, buffer); sl@0: } sl@0: } sl@0: sl@0: if (iWaitForNotification) sl@0: { sl@0: iSchedulerWait->Start(); sl@0: } sl@0: sl@0: err = iAsyncError; sl@0: buffer.Close(); sl@0: } sl@0: sl@0: if ( iSchedulerWait->IsStarted() ) sl@0: { sl@0: iSchedulerWait->AsyncStop(); sl@0: } sl@0: sl@0: if (err != KErrNone && err != KErrNotFound) sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF2(_L("ReadAudioVideoFrameAsync failed with %d;"), err); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: err = KErrNone; sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: sl@0: void C3GPLib_AsyncObserver::AudioFramesAvailable(TInt aError, TUint aReturnedFrames, sl@0: TUint aTimeStampInMs, TUint aTimeStampInTimescale) sl@0: { sl@0: iWaitForNotification = EFalse; sl@0: iAsyncLastNotificationFromAudio = EFalse; sl@0: iAsyncError = aError; sl@0: iAsyncAudioTimeStampInMs = aTimeStampInMs; sl@0: iAsyncAudioReturnedFrames = aReturnedFrames; sl@0: iAsyncAudioTimestampInTimescale = aTimeStampInTimescale; sl@0: if (iSchedulerWait->IsStarted()) sl@0: { sl@0: iSchedulerWait->AsyncStop(); sl@0: } sl@0: sl@0: } sl@0: sl@0: void C3GPLib_AsyncObserver::VideoFrameAvailable(TInt aError, TBool aKeyFrame, TUint sl@0: aTimeStampInMs, TUint aTimeStampInTimescale) sl@0: { sl@0: iWaitForNotification = EFalse; sl@0: iAsyncLastNotificationFromAudio = EFalse; sl@0: iAsyncError = aError; sl@0: iAsyncVideoTimeStampInMs = aTimeStampInMs; sl@0: iAsyncVideoKeyFrame = aKeyFrame; sl@0: iAsyncVideoTimestampInTimescale = aTimeStampInTimescale; sl@0: sl@0: if (iSchedulerWait->IsStarted()) sl@0: { sl@0: iSchedulerWait->AsyncStop(); sl@0: } sl@0: sl@0: } sl@0: sl@0: sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Setup parser to read file by file path. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0001::C3GPLibParser_0001() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0001::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: OpenCompleteL(parser); sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0001::OpenCompleteL(C3GPParse* aParser) sl@0: { sl@0: // Test open and complete with default file access mode sl@0: ParserOpenFileL(aParser); sl@0: ParserCompleteL(aParser); sl@0: sl@0: FileOpenL(); sl@0: ParserOpenFileL(aParser); sl@0: ParserCompleteL(aParser); sl@0: ParserCompleteL(aParser); // Should not fail when calling complete twice sl@0: FileClose(); sl@0: sl@0: //Open the source file passing in the file server session handle, source sl@0: //file path and file access mode (read-write) sl@0: FileOpenL(EFileShareReadersOrWriters | EFileWrite); sl@0: ParserOpenFileL(aParser); sl@0: ParserCompleteL(aParser); sl@0: ParserCompleteL(aParser); sl@0: FileClose(); sl@0: sl@0: //Open the source file passing in the file server session handle, source sl@0: //file path and file access mode (read-write) sl@0: FileOpenL(EFileShareReadersOrWriters | EFileRead); sl@0: ParserOpenFileL(aParser); sl@0: ParserCompleteL(aParser); sl@0: FileClose(); sl@0: sl@0: //Open the source file passing in the file server session handle, source sl@0: //file path and file access mode (read-write) sl@0: FileOpenL(EFileShareAny | EFileWrite); sl@0: ParserOpenFileL(aParser); sl@0: ParserCompleteL(aParser); sl@0: FileClose(); sl@0: sl@0: //Open the source file passing in the file server session handle, source sl@0: //file path and file access mode (read-write) sl@0: FileOpenL(EFileShareAny | EFileRead); sl@0: ParserOpenFileL(aParser); sl@0: ParserCompleteL(aParser); sl@0: FileClose(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Setup parser to read file by buffer mode. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0002::C3GPLibParser_0002() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0002::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: OpenCompleteBufferModeL(parser); sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0002::OpenCompleteBufferModeL(C3GPParse* aParser) sl@0: { sl@0: // buffer mode sl@0: FileOpenL(); sl@0: ParserOpenL(aParser); sl@0: sl@0: ParserCompleteL(aParser); sl@0: FileClose(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Setup parser to read file by file handle. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0003::C3GPLibParser_0003() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0003::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: OpenCompleteFileHandleL(parser); sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0003::OpenCompleteFileHandleL(C3GPParse* aParser) sl@0: { sl@0: ParserOpenFileHandleL(aParser); sl@0: ParserCompleteHandleL(aParser); sl@0: sl@0: //Open the source file passing in the file server session handle, source sl@0: //file path and file access mode (read-only) sl@0: ParserOpenFileHandleL(aParser, EFileRead | EFileShareReadersOnly); sl@0: ParserCompleteHandleL(aParser); sl@0: sl@0: //Open the source file passing in the file server session handle, source sl@0: //file path and file access mode (read-only) sl@0: ParserOpenFileHandleL(aParser, EFileShareReadersOrWriters | EFileWrite); sl@0: ParserCompleteHandleL(aParser); sl@0: sl@0: //Open the source file passing in the file server session handle, source sl@0: //file path and file access mode (read-only) sl@0: ParserOpenFileHandleL(aParser, EFileShareReadersOrWriters | EFileRead); sl@0: ParserCompleteHandleL(aParser); sl@0: sl@0: //Open the source file passing in the file server session handle, source sl@0: //file path and file access mode (read-only) sl@0: ParserOpenFileHandleL(aParser, EFileShareAny | EFileWrite); sl@0: ParserCompleteHandleL(aParser); sl@0: sl@0: //Open the source file passing in the file server session handle, source sl@0: //file path and file access mode (read-only) sl@0: ParserOpenFileHandleL(aParser, EFileShareAny | EFileRead); sl@0: ParserCompleteHandleL(aParser); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Setup parser to read file by CAF. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0004::C3GPLibParser_0004() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0004::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: CContent* content = CContent::NewLC(iInputFile, EContentShareReadWrite); sl@0: sl@0: CData* data = content->OpenContentL(EPeek); sl@0: CleanupStack::PushL(data); sl@0: sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TInt err = parser->Open(*data); sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: CleanupStack::PopAndDestroy(parser); sl@0: CleanupStack::PopAndDestroy(2); // content, data sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: err = parser->Complete(); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: CleanupStack::PopAndDestroy(2); // content, data sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Retrieve video & audio stream attributes from a mp4/3gp/3g2 file with supported sl@0: // video and audio streams using file mode - file path / file handle and CAF object. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0005::C3GPLibParser_0005() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0005::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, GetVideoAudioAttributesL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0005::GetVideoAudioAttributesL(C3GPParse* aParser) sl@0: { sl@0: // Open parser in File path sl@0: ParserOpenFileL(aParser); sl@0: DoGetVideoAudioAttributesL(aParser); sl@0: ParserCompleteL(aParser); sl@0: sl@0: // open parser in file handle sl@0: ParserOpenFileHandleL(aParser); sl@0: DoGetVideoAudioAttributesL(aParser); sl@0: ParserCompleteHandleL(aParser); sl@0: sl@0: // Open parser in CAF sl@0: ParserOpenCafLC(aParser); sl@0: DoGetVideoAudioAttributesL(aParser); sl@0: ParserCompleteCafL(aParser); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Retrieve video & audio stream attributes from a mp4/3gp/3g2 file sl@0: // with supported video and audio streams using buffer mode. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0006::C3GPLibParser_0006() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0006::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, VideoAudioAttributesBufferModeL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: FileClose(); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0006::VideoAudioAttributesBufferModeL(C3GPParse* aParser) sl@0: { sl@0: // buffer mode sl@0: FileOpenL(); sl@0: ParserOpenL(aParser); sl@0: sl@0: TInt err = KErrNone; sl@0: // Retrieve number of buffered bytes before and after data is supplied to the parser. sl@0: err = GetVideoAudioAttributes(aParser, ENumBufferedBytes); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoAudioAttributes(aParser, ENumBufferedBytes)"))); sl@0: sl@0: ParserCompleteL(aParser); sl@0: FileClose(); sl@0: sl@0: // Open the parser again sl@0: FileOpenL(); sl@0: ParserOpenL(aParser); sl@0: sl@0: // Retrieve video and audio descriptions before and after data is supplied to the parser. sl@0: err = GetVideoAudioAttributes(aParser, EClipProperties); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoAudioAttributes(aParser, EClipProperties)"))); sl@0: sl@0: ParserCompleteL(aParser); sl@0: FileClose(); sl@0: sl@0: // Open the parser again sl@0: FileOpenL(); sl@0: ParserOpenL(aParser); sl@0: sl@0: // Retrieve video and audio decoder before and after data is supplied to the parser. sl@0: err = GetVideoAudioAttributes(aParser, EDecoderInfo); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoAudioAttributes(aParser, EDecoderInfo)"))); sl@0: sl@0: ParserCompleteL(aParser); sl@0: FileClose(); sl@0: sl@0: // Open the parser again sl@0: FileOpenL(); sl@0: ParserOpenL(aParser); sl@0: sl@0: sl@0: // Retrieve video frame properties and number of frames before and after data is supplied to the parser. sl@0: sl@0: err = GetVideoAudioAttributes(aParser, EVideoFrameProp); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoAudioAttributes(aParser, EVideoFrameProp)"))); sl@0: sl@0: ParserCompleteL(aParser); sl@0: FileClose(); sl@0: } sl@0: sl@0: TInt C3GPLibParser_0006::CallTest(C3GPParse* aParser, TBufferModeTest aTest, TInt aExpectedNumBuffered) sl@0: { sl@0: TInt err = KErrNone; sl@0: TInt numBufferedBytes; sl@0: sl@0: // Before insert any data. Retrieving video and audio attributes should fail sl@0: switch (aTest) sl@0: { sl@0: case (ENumBufferedBytes): sl@0: err = aParser->GetNumBufferedBytes(numBufferedBytes); sl@0: if (err == KErrNone && numBufferedBytes != aExpectedNumBuffered) sl@0: { sl@0: err = KErrGeneral; sl@0: } sl@0: break; sl@0: case (EClipProperties): sl@0: TInt videoError; sl@0: TUint videoLength; sl@0: TUint audioLength; sl@0: err = GetClipProperties(aParser, videoError, videoLength, audioLength); sl@0: if ((videoError != KErrNone && videoError != KErr3gpLibMoreDataRequired) || sl@0: (err != KErrNone && err != KErr3gpLibMoreDataRequired)) sl@0: { sl@0: err = KErrGeneral; sl@0: } sl@0: break; sl@0: case (EDecoderInfo): sl@0: err = ParserGetDecoderInfo(aParser); sl@0: break; sl@0: case (EVideoFrameProp): sl@0: if (aExpectedNumBuffered == 0) sl@0: { sl@0: err = GetVideoFramePropAndNumVideoFrame(aParser, EFalse); sl@0: } sl@0: else sl@0: { sl@0: err = GetVideoFramePropAndNumVideoFrame(aParser, ETrue); sl@0: } sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: TInt C3GPLibParser_0006::GetVideoAudioAttributes(C3GPParse* aParser, TBufferModeTest aTest) sl@0: { sl@0: TInt err = KErrNone; sl@0: sl@0: // Before insert any data. Retrieving video and audio attributes should fail sl@0: err = CallTest(aParser, aTest, 0); sl@0: if (aTest != ENumBufferedBytes) sl@0: { sl@0: err = CheckError(err, KErr3gpLibMoreDataRequired, _L("CallTest(aParser, aTest, 0)")); sl@0: } sl@0: else sl@0: { sl@0: err = CheckError(err, KErrNone, _L("CallTest()")); sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("GetVideoAudioAttributes failed with %d; "), err); sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: // Insert 1K data to buffer sl@0: TInt bufferSize = 0; sl@0: TInt pos = 0; // from begining of the file sl@0: err = KErr3gpLibMoreDataRequired; sl@0: // Insert data until enough data has been inserted sl@0: while (err == KErr3gpLibMoreDataRequired) sl@0: { sl@0: // Insert more data to buffer sl@0: pos = bufferSize + pos; sl@0: bufferSize = KBufferSize; sl@0: RBuf8 buffer; sl@0: err = buffer.Create(bufferSize); sl@0: if (err == KErrNone) sl@0: { sl@0: err = iSourceFile.Read(pos, buffer); sl@0: if (err == KErrNone) sl@0: { sl@0: err = aParser->InsertData(buffer); sl@0: if ( err == KErrNone ) sl@0: { sl@0: err = CallTest(aParser, aTest, (bufferSize + pos)); sl@0: } sl@0: } sl@0: } sl@0: buffer.Close(); sl@0: } sl@0: sl@0: err = CheckError(err, KErrNone, _L("CallTest()")); sl@0: return err; sl@0: } sl@0: sl@0: TInt C3GPLibParser_0006::GetVideoFramePropAndNumVideoFrame(C3GPParse* aParse, TBool aExpectPass) sl@0: { sl@0: TInt err = KErrNone; sl@0: TUint numVideoFrames; sl@0: err = aParse->GetNumberOfVideoFrames(numVideoFrames); sl@0: if (aExpectPass) sl@0: { sl@0: if ( err == KErrNone ) sl@0: { sl@0: // Only when GetNumberOfVideoFrames returns KErrNone, the method GetVideoFrameProperties sl@0: // can be called sl@0: TUint startIndex = 0; sl@0: RArray array; sl@0: err = aParse->GetVideoFrameProperties(startIndex, numVideoFrames, array); sl@0: array.Close(); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: // When there is no data in the handler, GetNumberOfVideoFrames will fail with KErrGeneral, sl@0: // not the KErr3gpLibMoreDataRequired sl@0: if ( err == KErr3gpLibMoreDataRequired || err == KErrGeneral) sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF2(_L("Expect parse->GetNumberOfVideoFrames() failed with %d"), err); sl@0: } sl@0: err = KErr3gpLibMoreDataRequired; sl@0: } sl@0: // expected failure, but get KErrNone. sl@0: if (err == KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("parse->GetNumberOfVideoFrames() should fail due to buffer too small")); sl@0: err = KErrGeneral; sl@0: } sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Check if the clip is streamable in file mode from a mp4/3gp/3g2 file sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0007::C3GPLibParser_0007() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0007::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, GetstreamableL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0007::GetstreamableL(C3GPParse* aParser) sl@0: { sl@0: // Open parser in File mode sl@0: ParserOpenFileL(aParser); sl@0: sl@0: // Check if the file is streamable sl@0: TBool streamable; sl@0: TInt err = aParser->GetStreamable(streamable); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepError(err); sl@0: } sl@0: else if (!streamable) sl@0: { sl@0: INFO_PRINTF2(_L("aParser->GetStreamable() returns %d"), streamable); sl@0: SetTestStepError(KErrNotSupported); sl@0: } sl@0: sl@0: ParserCompleteL(aParser); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Check if the clip is streamable in buffer mode from a mp4/3gp/3g2 file sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0008::C3GPLibParser_0008() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0008::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, GetstreamableL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0008::GetstreamableL(C3GPParse* aParser) sl@0: { sl@0: // buffer mode sl@0: FileOpenL(); sl@0: ParserOpenL(aParser); sl@0: sl@0: // Check if the file is streamable before the data is inserted sl@0: TBool streamable; sl@0: TInt err = aParser->GetStreamable(streamable); sl@0: sl@0: // Insert 1K data to buffer sl@0: TInt bufferSize = 0; sl@0: TInt pos = 0; // from begining of the file sl@0: sl@0: // Insert data until enough data has been inserted sl@0: while (err == KErr3gpLibMoreDataRequired) sl@0: { sl@0: // Insert more data to buffer sl@0: pos = bufferSize + pos; sl@0: bufferSize = KBufferSize; sl@0: InsertDataL(aParser, iSourceFile, bufferSize, pos); sl@0: sl@0: err = aParser->GetStreamable(streamable); sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF2(_L("aParser->GetStreamable() returns %d"), err); sl@0: } sl@0: SetTestStepError(err); sl@0: } sl@0: sl@0: ParserCompleteL(aParser); sl@0: FileClose(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Retrieve buffered bytes, and video & audio frames synchronously in file mode sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0011::C3GPLibParser_0011() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0011::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, ReadFrameL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0011::ReadFrameL(C3GPParse* aParse) sl@0: { sl@0: // Parser open using File path sl@0: ParserOpenFileL(aParse); sl@0: User::LeaveIfError(DoReadFrame(aParse)); sl@0: ParserCompleteL(aParse); sl@0: sl@0: // Parser open using file handler sl@0: ParserOpenFileHandleL(aParse); sl@0: User::LeaveIfError(DoReadFrame(aParse)); sl@0: ParserCompleteHandleL(aParse); sl@0: sl@0: // Parser open using CAF sl@0: ParserOpenCafLC(aParse); sl@0: User::LeaveIfError(DoReadFrame(aParse)); sl@0: ParserCompleteCafL(aParse); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Parse video & audio frames from a mp4/3gp file asynchronously in file mode sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0014::C3GPLibParser_0014() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0014::doTestStepPreambleL() sl@0: { sl@0: C3GPLib_AsyncObserver::doTestStepPreambleL(); sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: iScheduler = new (ELeave) CActiveScheduler; sl@0: CActiveScheduler::Install(iScheduler); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0014::doTestStepPostambleL() sl@0: { sl@0: C3GPLib_AsyncObserver::doTestStepPostambleL(); sl@0: if( iScheduler ) sl@0: { sl@0: INFO_PRINTF1(_L("delete iScheduler")); sl@0: CActiveScheduler::Install(NULL); sl@0: delete iScheduler; sl@0: iScheduler = NULL; sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0014::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, ReadFrameAsyncL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0014::ReadFrameAsyncL(C3GPParse* aParser) sl@0: { sl@0: ParserOpenFileL(aParser); sl@0: User::LeaveIfError(DoReadFrameAsync(aParser)); sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL()")); sl@0: } sl@0: ParserCompleteL(aParser); sl@0: sl@0: ParserOpenFileL(aParser); sl@0: User::LeaveIfError(DoReadFrameAsync(aParser, ETrue)); sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL(), then cancel the read")); sl@0: } sl@0: ParserCompleteL(aParser); sl@0: sl@0: ParserOpenFileHandleL(aParser); sl@0: User::LeaveIfError(DoReadFrameAsync(aParser)); sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL() using file handler")); sl@0: } sl@0: ParserCompleteHandleL(aParser); sl@0: sl@0: ParserOpenCafLC(aParser); sl@0: User::LeaveIfError(DoReadFrameAsync(aParser)); sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL() using CAF")); sl@0: } sl@0: ParserCompleteCafL(aParser); sl@0: } sl@0: sl@0: TInt C3GPLibParser_0014::DoReadFrameAsync(C3GPParse* aParser, TBool aCancel) sl@0: { sl@0: TInt err = KErrNone; sl@0: sl@0: if (!aCancel) sl@0: { sl@0: err = ReadAudioVideoFrameAsync(aParser, ETrue); sl@0: if (err == KErrNone) sl@0: { sl@0: err = ReadAudioVideoFrameAsync(aParser, EFalse); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: err = ReadAudioVideoFrameAsync(aParser, EFalse, ETrue); sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Parse video & audio frames from a mp4/3gp file synchronously sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0015::C3GPLibParser_0015() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0015::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, ReadFrameL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0015::ReadFrameL(C3GPParse* aParser) sl@0: { sl@0: FileOpenL(); sl@0: ReadFrameBufferModeL(aParser); sl@0: FileClose(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Get frame type using file path sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0016::C3GPLibParser_0016() sl@0: { sl@0: } sl@0: sl@0: sl@0: TVerdict C3GPLibParser_0016::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, GetFrameTypeL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0016::GetFrameTypeL(C3GPParse* aParser) sl@0: { sl@0: ParserOpenFileL(aParser); sl@0: sl@0: T3GPFrameType type; sl@0: TInt err = aParser->GetFrameType(type); sl@0: if (err == KErrNone) sl@0: { sl@0: TUint num; sl@0: err = aParser->GetNumberOfVideoFrames(num); sl@0: if (err == KErrNone) sl@0: { sl@0: // There is number of video in the file. Calling GetFrameType num+1 time won't affect sl@0: //the parser’s current position. It should return the same results sl@0: for (TInt i = 0; i < num; i++) sl@0: { sl@0: err = aParser->GetFrameType(type); sl@0: User::LeaveIfError(err); sl@0: } sl@0: err = aParser->GetFrameType(type); sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF2(_L("GetFrameType return type %d. "), type); sl@0: } sl@0: if (type == E3GPAudio) sl@0: { sl@0: // read 1 audio frame sl@0: err = ReadAudioVideoFrame(aParser, EFalse, ETrue); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("ReadAudioVideoFrame"))); sl@0: sl@0: err = aParser->GetFrameType(type); sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF3(_L("After read 1 audio frame, GetFrameType return err %d; type %d. "), err, type); sl@0: } sl@0: SetTestStepError(err); sl@0: } sl@0: if (err == KErrNone && type == E3GPVideo) sl@0: { sl@0: // read 1 video frame sl@0: err = ReadAudioVideoFrame(aParser, EFalse, EFalse); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("ReadAudioVideoFrame"))); sl@0: sl@0: err = aParser->GetFrameType(type); sl@0: SetTestStepError(err); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: SetTestStepError(err); sl@0: } sl@0: ParserCompleteL(aParser); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Get the QCELP storage mode in file path and buffer mode sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0017::C3GPLibParser_0017() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0017::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, GetQcelModeL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0017::GetQcelModeL(C3GPParse* aParser) sl@0: { sl@0: // file mode sl@0: ParserOpenFileL(aParser); sl@0: TInt err = KErrNone; sl@0: T3GPQcelpStorageMode mode; sl@0: err = aParser->GetQcelpStorageMode(mode); sl@0: if (err != KErrNone) sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF3(_L("aParser->GetQcelpStorageMode(mode) file mode return %d; mode %d. "), err, mode); sl@0: } sl@0: SetTestStepError(err); sl@0: } sl@0: sl@0: if ((iTestSection.Compare(KEsds) == 0 && mode != E3GPQcelpSampleEntryBox ) || sl@0: (iTestSection.Compare(KSqcp) == 0 && mode != E3GPMP4AudioDescriptionBox )) sl@0: { sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: sl@0: ParserCompleteL(aParser); sl@0: sl@0: // buffer mode sl@0: ParserOpenL(aParser); sl@0: FileOpenL(); sl@0: sl@0: // Insert 1K data into the library sl@0: TInt pos = 0; sl@0: TInt bufferSize = 1000; sl@0: sl@0: InsertDataL(aParser, iSourceFile, bufferSize, pos); sl@0: err = aParser->GetQcelpStorageMode(mode); sl@0: sl@0: while (err == KErr3gpLibMoreDataRequired ) sl@0: { sl@0: pos = pos + bufferSize; sl@0: InsertDataL(aParser, iSourceFile, bufferSize, pos); sl@0: err = aParser->GetQcelpStorageMode(mode); sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF3(_L("aParser->GetQcelpStorageMode(mode) file mode return %d; mode %d. "), err, mode); sl@0: } sl@0: SetTestStepError(err); sl@0: } sl@0: sl@0: if ((iTestSection.Compare(KEsds) == 0 && mode != E3GPQcelpSampleEntryBox ) || sl@0: (iTestSection.Compare(KSqcp) == 0 && mode != E3GPMP4AudioDescriptionBox )) sl@0: { sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: sl@0: ParserCompleteL(aParser); sl@0: FileClose(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Get H263 video leve in file path and buffer mode. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0021::C3GPLibParser_0021() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0021::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, GetH263LevelL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0021::GetH263LevelL(C3GPParse* aParser) sl@0: { sl@0: // file mode sl@0: ParserOpenFileL(aParser); sl@0: TInt err = KErrNone; sl@0: TInt level; sl@0: err = aParser->GetH263VideoLevel(level); sl@0: if (err != KErrNone) sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF3(_L("aParser->GetH263VideoLevel() file mode return %d; level %d. "), err, level); sl@0: } sl@0: SetTestStepError(err); sl@0: } sl@0: sl@0: ParserCompleteL(aParser); sl@0: sl@0: // buffer mode sl@0: ParserOpenL(aParser); sl@0: FileOpenL(); sl@0: sl@0: // Insert 1K data into the library sl@0: TInt pos = 0; sl@0: TInt bufferSize = KBufferSize; sl@0: sl@0: InsertDataL(aParser, iSourceFile, bufferSize, pos); sl@0: err = aParser->GetH263VideoLevel(level);; sl@0: sl@0: while (err == KErr3gpLibMoreDataRequired ) sl@0: { sl@0: pos = pos + bufferSize; sl@0: InsertDataL(aParser, iSourceFile, bufferSize, pos); sl@0: err = aParser->GetH263VideoLevel(level);; sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF3(_L("aParser->GetH263VideoLevel() file mode return %d; level %d. "), err, level); sl@0: } sl@0: SetTestStepError(err); sl@0: } sl@0: sl@0: ParserCompleteL(aParser); sl@0: FileClose(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Read Video and audio Decoder Info size and info in file path and buffer mode. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0023::C3GPLibParser_0023() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0023::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, GetDecoderInfoL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0023::GetDecoderInfoL(C3GPParse* aParser) sl@0: { sl@0: // file mode sl@0: ParserOpenFileL(aParser); sl@0: sl@0: TInt errReadAudio = KErrNone; sl@0: TInt errReadVideo = KErrNone; sl@0: // Retrieve the info with buffer size = 0. Should fail with KErrOverflow sl@0: RBuf8 dsiBuffer; sl@0: CleanupClosePushL(dsiBuffer); sl@0: dsiBuffer.CreateL(0); sl@0: errReadAudio = aParser->GetAudioDecoderSpecificInfo(dsiBuffer); sl@0: errReadVideo = aParser->GetVideoDecoderSpecificInfo(dsiBuffer); sl@0: sl@0: if (errReadAudio == KErrOverflow && errReadVideo == KErrOverflow) sl@0: { sl@0: errReadAudio = ParserGetDecoderInfo(aParser); sl@0: sl@0: if (errReadAudio != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("ParserGetDecoderInfo file mode return %d; "), errReadAudio); sl@0: User::Leave(errReadAudio); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("ParserGetDecoderInfo file mode expected KErrOverflow, but return %d; "), errReadAudio); sl@0: User::Leave(errReadAudio); sl@0: } sl@0: sl@0: ParserCompleteL(aParser); sl@0: sl@0: // buffer mode sl@0: ParserOpenL(aParser); sl@0: FileOpenL(); sl@0: sl@0: // Insert 1K data into the library sl@0: TInt pos = 0; sl@0: TInt bufferSize = KBufferSize; sl@0: sl@0: InsertDataL(aParser, iSourceFile, bufferSize, pos); sl@0: sl@0: // Retrieve the info with buffer size = 0. Should fail with KErrOverflow sl@0: dsiBuffer.Close(); sl@0: dsiBuffer.CreateL(0); sl@0: errReadAudio = aParser->GetAudioDecoderSpecificInfo(dsiBuffer); sl@0: errReadVideo = aParser->GetVideoDecoderSpecificInfo(dsiBuffer); sl@0: CleanupStack::PopAndDestroy(&dsiBuffer); sl@0: sl@0: if (errReadAudio != KErrOverflow || errReadVideo != KErrOverflow) sl@0: { sl@0: ERR_PRINTF2(_L("ParserGetDecoderInfo buffer mode expected KErrOverflow, but return %d; "), errReadAudio); sl@0: User::Leave(errReadAudio); sl@0: } sl@0: errReadAudio = ParserGetDecoderInfo(aParser); sl@0: sl@0: while (errReadAudio == KErr3gpLibMoreDataRequired ) sl@0: { sl@0: pos = pos + bufferSize; sl@0: InsertDataL(aParser, iSourceFile, bufferSize, pos); sl@0: errReadAudio = ParserGetDecoderInfo(aParser); sl@0: } sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF2(_L("ParserGetDecoderInfo(aParser) buffer mode return %d. "), errReadAudio); sl@0: } sl@0: ParserCompleteL(aParser); sl@0: FileClose(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Seek different position of a video/audio file sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0027::C3GPLibParser_0027() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0027::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, SeekTestL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0027::SeekTestL(C3GPParse* aParse) sl@0: { sl@0: // file mode sl@0: ParserOpenFileL(aParse); sl@0: sl@0: TUint audioPos; sl@0: TUint videoPos; sl@0: TUint timeStampInMs = 0; sl@0: sl@0: // Seek to position 0. sl@0: TInt err = KErrNone; sl@0: if (iTestSection.Compare(KNoAudioNoVideo) != 0) sl@0: { sl@0: // Retrieve video & audio stream length sl@0: TUint videoLength; sl@0: TUint audioLength; sl@0: TInt videoError; sl@0: sl@0: err = GetClipProperties(aParse, videoError, videoLength, audioLength); sl@0: if (iTestSection.Compare(KAudioOnly) == 0) sl@0: { sl@0: // audio only, GetVideoProperties should fail with KErrNotSupported. Set video length to 0 sl@0: User::LeaveIfError(CheckError(videoError, KErrNotSupported, _L("GetClipProperties(aParse, videoError, videoLength, audioLength))"))); sl@0: videoLength = 0; sl@0: } sl@0: else if (iTestSection.Compare(KVideoOnly) == 0) sl@0: { sl@0: // video only, GetAudioProperties should fail with KErrNotSupported. Set audio length to 0 sl@0: User::LeaveIfError(CheckError(err, KErrNotSupported, _L("GetClipProperties(aParse, videoError, videoLength, audioLength)"))); sl@0: audioLength = 0; sl@0: } sl@0: else sl@0: { sl@0: // All other files contains audio and video data sl@0: User::LeaveIfError(CheckError(videoError, KErrNone, _L("GetClipProperties(aParse, videoError, videoLength, audioLength)"))); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("GetClipProperties(aParse, videoError, videoLength, audioLength)"))); sl@0: } sl@0: sl@0: if (audioLength >= videoLength) sl@0: { sl@0: timeStampInMs = audioLength; sl@0: } sl@0: else sl@0: { sl@0: timeStampInMs = videoLength; sl@0: } sl@0: sl@0: if (iTestSection.Compare(KSameLenAudioVideo) == 0 || iTestSection.Compare(KAudioOnly) == 0) sl@0: { sl@0: err = ParserSeek(aParse, timeStampInMs, audioPos, videoPos); sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: if (iTestSection.Compare(KAudioMore) == 0 || iTestSection.Compare(KVideoMore) == 0 ) sl@0: { sl@0: timeStampInMs = (audioLength + videoLength)/2; sl@0: err = aParse->Seek(timeStampInMs, EFalse, audioPos, videoPos); sl@0: User::LeaveIfError(err); sl@0: } sl@0: } sl@0: sl@0: ParserCompleteL(aParse); sl@0: } sl@0: sl@0: // Seek position 0, half the length and the length of the stream sl@0: TInt C3GPLibParser_0027::ParserSeek(C3GPParse* aParser, TInt aLen, TUint& aAudioPos, TUint& aVideoPos) sl@0: { sl@0: TInt err = KErrNone; sl@0: TUint position = 0; sl@0: while (err == KErrNone && position <= aLen) sl@0: { sl@0: err = aParser->Seek(position, ETrue, aAudioPos, aVideoPos); sl@0: if (err == KErrNone) sl@0: { sl@0: err = aParser->Seek(position, EFalse, aAudioPos, aVideoPos); sl@0: } sl@0: position = position + aLen/2; sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF3(_L("aParser->Seek() failed with %d when positon is %d"), err, position); sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Seek positions after any keyframe and immediately after a non-key frame. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0031::C3GPLibParser_0031() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0031::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, SeekTestL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0031::SeekTestL(C3GPParse* aParser) sl@0: { sl@0: // file mode sl@0: ParserOpenFileL(aParser); sl@0: DoSeekTestL(aParser); sl@0: ParserCompleteL(aParser); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Check frame availability using file path sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0032::C3GPLibParser_0032() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0032::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, GetFrameAvailabilityL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0032::GetFrameAvailabilityL(C3GPParse* aParser) sl@0: { sl@0: // file mode sl@0: ParserOpenFileL(aParser); sl@0: DoGetFrameAvailabilityL(aParser); sl@0: ParserCompleteL(aParser); sl@0: } sl@0: sl@0: void C3GPLibParser_0032::DoGetFrameAvailabilityL(C3GPParse* aParser) sl@0: { sl@0: T3GPFrameType audioType = E3GPAudio; sl@0: T3GPFrameType videoType = E3GPVideo; sl@0: TBool audioAvailable; sl@0: TBool videoAvailable; sl@0: TUint num; sl@0: TInt audioErr = aParser->GetFrameAvailability(audioType, audioAvailable); sl@0: if (audioErr != KErrNone && audioErr != KErrNotFound) sl@0: { sl@0: SetTestStepError(audioErr); sl@0: User::LeaveIfError(audioErr); sl@0: } sl@0: sl@0: TInt videoErr = aParser->GetFrameAvailability(videoType, videoAvailable); sl@0: if (videoErr != KErrNone && videoErr != KErrNotFound) sl@0: { sl@0: SetTestStepError(videoErr); sl@0: User::LeaveIfError(videoErr); sl@0: } sl@0: sl@0: TInt err = aParser->GetNumberOfVideoFrames(num); sl@0: if (err != KErrNone && err != KErrNotSupported) sl@0: { sl@0: SetTestStepError(err); sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: if (iTestSection.Compare(KNoAudioNoVideo) == 0) sl@0: { sl@0: if (audioErr != KErrNotFound || videoErr != KErrNotFound sl@0: || audioAvailable || videoAvailable) sl@0: { sl@0: ERR_PRINTF2(_L("GetFrameAvailability() audio failed with %d, expected KErrNotFound"), audioErr); sl@0: ERR_PRINTF2(_L("GetFrameAvailability() expected audioAvailable returns false, actual %d "), audioAvailable); sl@0: ERR_PRINTF2(_L("GetFrameAvailability() video failed with %d, expected KErrNotFound;"), videoErr); sl@0: ERR_PRINTF2(_L("GetFrameAvailability() expected videoAvailable returns false, actual %d "), videoAvailable); sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: User::LeaveIfError(CheckError(err, KErrNotSupported, _L("aParser->GetNumberOfVideoFrames(num)"))); sl@0: } sl@0: else if (iTestSection.Compare(KAudioOnly) == 0) sl@0: { sl@0: if (audioErr != KErrNone || videoErr != KErrNotFound sl@0: || !audioAvailable || videoAvailable) sl@0: { sl@0: ERR_PRINTF2(_L("aParser->GetFrameAvailability() audio failed with %d, expected KErrNone"), audioErr); sl@0: ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected audioAvailable returns True, actual %d "), audioAvailable); sl@0: ERR_PRINTF2(_L("aParser->GetFrameAvailability() video failed with %d, expected KErrNotFound;"), videoErr); sl@0: ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected videoAvailable returns false, actual %d"), videoAvailable); sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: User::LeaveIfError(CheckError(err, KErrNotSupported, _L("aParser->GetNumberOfVideoFrames(num)"))); sl@0: } sl@0: else if (iTestSection.Compare(KVideoOnly) == 0) sl@0: { sl@0: if (audioErr != KErrNotFound || videoErr != KErrNone sl@0: || audioAvailable || !videoAvailable) sl@0: { sl@0: ERR_PRINTF2(_L("aParser->GetFrameAvailability() audio failed with %d, expected KErrNotFound"), audioErr); sl@0: ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected audioAvailable returns false, actual %d "), audioAvailable); sl@0: ERR_PRINTF2(_L("aParser->GetFrameAvailability() video failed with %d, expected KErrNone;"), videoErr); sl@0: ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected videoAvailable returns true, actual %d"), videoAvailable); sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("aParser->GetNumberOfVideoFrames(num)"))); sl@0: if (num != 265) sl@0: { sl@0: ERR_PRINTF2(_L("file h263-no-audio.MP4 has 265 video frames. Got %d instread"), num); sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: } sl@0: else // File contains both valid audio and video data sl@0: { sl@0: // If file contains avc profile main or extended, videoErr could be KErrNotFound sl@0: if (audioErr != KErrNone || !audioAvailable) sl@0: { sl@0: ERR_PRINTF2(_L("aParser->GetFrameAvailability() audio failed with %d, expected KErrNone"), audioErr); sl@0: ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected audioAvailable returns True, actual %d "), audioAvailable); sl@0: ERR_PRINTF2(_L("aParser->GetFrameAvailability() video failed with %d, expected KErrNone;"), videoErr); sl@0: ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected videoAvailable returns True, actual %d"), videoAvailable); sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: if (videoErr != KErrNone) sl@0: { sl@0: SetTestStepError(videoErr); sl@0: } sl@0: else sl@0: { sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("aParser->GetNumberOfVideoFrames(num)"))); sl@0: } sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Retrieve video frame size & start time without parsing the content file frame sl@0: // by frame in file mode sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0033::C3GPLibParser_0033() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0033::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, VideoInfoL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0033::VideoInfoL(C3GPParse* aParser) sl@0: { sl@0: // file mode sl@0: ParserOpenFileL(aParser); sl@0: sl@0: TUint num; sl@0: TInt num1 = 0; sl@0: TUint timeStampInMs = 0; sl@0: TUint timeStampInTimescale = 0; sl@0: TUint timeStampInMs1 = 0; sl@0: TUint timeStampInTimescale1 = 0; sl@0: TUint frameIndex; sl@0: TUint frameSize; sl@0: TBool keyFrame; sl@0: User::LeaveIfError(aParser->GetNumberOfVideoFrames(num)); sl@0: sl@0: RBuf8 buffer; sl@0: CleanupClosePushL(buffer); sl@0: buffer.CreateL(0); sl@0: TInt err = aParser->ReadVideoFrame(buffer, keyFrame, timeStampInMs, timeStampInTimescale); sl@0: if (err != KErrOverflow) sl@0: { sl@0: ERR_PRINTF2(_L("aParser->ReadVideoFrame() expected KErrOverflow, actual %d"), err); sl@0: User::Leave(err); sl@0: } sl@0: User::LeaveIfError(aParser->GetVideoSampleEntryIndex(frameIndex)); sl@0: CleanupStack::PopAndDestroy(&buffer); sl@0: sl@0: sl@0: err = KErrNone; sl@0: while (err == KErrNone) sl@0: { sl@0: timeStampInMs = 0; sl@0: timeStampInTimescale = 0; sl@0: timeStampInMs1 = 0; sl@0: timeStampInTimescale1 = 0; sl@0: sl@0: if (num1 < num) sl@0: { sl@0: User::LeaveIfError(aParser->GetVideoFrameSize(num1, frameSize)); sl@0: User::LeaveIfError(aParser->GetVideoFrameStartTime(num1, timeStampInMs, timeStampInTimescale)); sl@0: } sl@0: else sl@0: { sl@0: err = aParser->GetVideoFrameStartTime(num1, timeStampInMs, timeStampInTimescale); sl@0: err = aParser->GetVideoFrameSize(num1, frameSize); sl@0: } sl@0: RBuf8 buffer1; sl@0: CleanupClosePushL(buffer1); sl@0: buffer1.CreateL(frameSize); sl@0: err = aParser->ReadVideoFrame(buffer1, keyFrame, timeStampInMs1, timeStampInTimescale1); sl@0: sl@0: if (timeStampInMs != timeStampInMs1) sl@0: { sl@0: ERR_PRINTF3(_L("Two timestamps should be the same. timeStampInMs %d, timeStampInMs1 %d"), timeStampInMs, timeStampInMs1); sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: CleanupStack::PopAndDestroy(&buffer1); sl@0: num1++; sl@0: } sl@0: sl@0: if (err != KErrNotFound) sl@0: { sl@0: ERR_PRINTF2(_L("expected KErrNotFound when finishing reading video frames. Actual err %d"), err); sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: sl@0: if ((num1 - 1) != num) sl@0: { sl@0: ERR_PRINTF3(_L("Two numOfFrame should be the same. num %d, num1 %d"), num, num1); sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: sl@0: // use an invalid index to attempt retrieving video frame size & start time. Both should failed with error. sl@0: err = aParser->GetVideoFrameSize((num + 100), frameSize); sl@0: User::LeaveIfError(CheckError(err, KErrGeneral, _L("GetVideoFrameSize"))); sl@0: sl@0: err = aParser->GetVideoFrameStartTime((num + 5), timeStampInMs, timeStampInTimescale); sl@0: User::LeaveIfError(CheckError(err, KErrGeneral, _L("GetVideoFrameStartTime"))); sl@0: sl@0: ParserCompleteL(aParser); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Retrieve video frame size & start time without parsing the content file frame sl@0: // by frame in buffe mode sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0034::C3GPLibParser_0034() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0034::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, VideoInfoBufferModeL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0034::VideoInfoBufferModeL(C3GPParse* aParser) sl@0: { sl@0: // buffer mode sl@0: ParserOpenL(aParser); sl@0: FileOpenL(); sl@0: sl@0: TUint num; sl@0: TUint timeStampInMs = 0; sl@0: TUint timeStampInTimescale = 0; sl@0: TUint frameSize; sl@0: sl@0: // Insert 1K data into the library sl@0: TInt pos = 0; sl@0: TInt bufferSize = KBufferSize; sl@0: InsertDataL(aParser, iSourceFile, bufferSize, pos); sl@0: TInt err = aParser->GetNumberOfVideoFrames(num); sl@0: if (err != KErrNone && err != KErrNotSupported && err != KErr3gpLibMoreDataRequired) sl@0: { sl@0: SetTestStepError(err); sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: while (err == KErr3gpLibMoreDataRequired ) sl@0: { sl@0: pos = pos + bufferSize; sl@0: InsertDataL(aParser, iSourceFile, bufferSize, pos); sl@0: err = aParser->GetNumberOfVideoFrames(num); sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepError(err); sl@0: } sl@0: else sl@0: { sl@0: for (TUint i = 0; i < num; i++) sl@0: { sl@0: User::LeaveIfError(aParser->GetVideoFrameSize(i, frameSize)); sl@0: User::LeaveIfError(aParser->GetVideoFrameStartTime(i, timeStampInMs, timeStampInTimescale)); sl@0: } sl@0: } sl@0: sl@0: ParserCompleteL(aParser); sl@0: FileClose(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Retrieve user atoms in all the possible locations sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0035::C3GPLibParser_0035() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0035::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, GetUserDataAtomL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0035::GetUserDataAtomL(C3GPParse* aParse) sl@0: { sl@0: // file mode sl@0: ParserOpenFileL(aParse); sl@0: sl@0: TUint32 udtType = 0x6d657461; // The udt type of test files is 'meta' sl@0: T3GPUdtaLocation location = E3GPUdtaAudioTrak; sl@0: TUint indexMoov = 0; sl@0: TUint indexAudio = 0; sl@0: TUint indexVideo = 0; sl@0: sl@0: TInt err = CallUDTApi(aParse, udtType, indexAudio, location); sl@0: if (err == KErrNone) sl@0: { sl@0: location = E3GPUdtaMoov; sl@0: err = CallUDTApi(aParse, udtType, indexMoov, location); sl@0: sl@0: if (err == KErrNone) sl@0: { sl@0: // By default, the location is video track sl@0: err = CallUDTApi(aParse, udtType, indexVideo); sl@0: } sl@0: if (err == KErrNone) sl@0: { sl@0: // Test file KMultiUdta contains 1 udta at E3GPUdtaMoov, 5 udta at E3GPUdtaAudioTrak and sl@0: // 3 udta at E3GPUdtaVideoTrak sl@0: if (iTestSection.Compare(KMultiUdta) == 0 && (indexMoov != 0 || indexAudio != 4 || indexVideo != 2)) sl@0: { sl@0: SetTestStepError(KErrNotFound); sl@0: } sl@0: } sl@0: } sl@0: sl@0: SetTestStepError(err); sl@0: sl@0: ParserCompleteL(aParse); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Retrieve user atoms from a valid mp4/3gp file containing multiple entries of sl@0: // the same user atom type within a user atom sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0036::C3GPLibParser_0036() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0036::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, GetUserDataAtomL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0036::GetUserDataAtomL(C3GPParse* aParse) sl@0: { sl@0: // file mode sl@0: ParserOpenFileL(aParse); sl@0: sl@0: TUint index; sl@0: TUint32 udtType = 0x6d657461; // The udt type of test files could be 'meta' sl@0: T3GPUdtaLocation location = E3GPUdtaMoov; // The test files should not contain udta in audio trak sl@0: sl@0: // First read user data atom with empty buffer. It should return KErrOverflow sl@0: RBuf8 buffer; sl@0: CleanupClosePushL(buffer); sl@0: buffer.CreateL(0); sl@0: TInt err = aParse->GetUserDataAtom(udtType, location, buffer, index); sl@0: buffer.Close(); sl@0: CleanupStack::PopAndDestroy(&buffer); sl@0: sl@0: if (err != KErrOverflow) sl@0: { sl@0: ERR_PRINTF2(_L("GetUserDataAtom with empty buffer should return KErrOverflow, failed with err %d"), err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: err = CallUDTApi(aParse, udtType, index); // By default, the location is videoTrack sl@0: sl@0: if (err == KErrNotFound || err == KErrNone) sl@0: { sl@0: err = CallUDTApi(aParse, udtType, index, location); sl@0: sl@0: if (err == KErrNotFound || err == KErrNone) sl@0: { sl@0: location = E3GPUdtaAudioTrak; sl@0: err = CallUDTApi(aParse, udtType, index, location); sl@0: } sl@0: } sl@0: sl@0: SetTestStepError(err); sl@0: sl@0: ParserCompleteL(aParse); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Retrieve video frame dependencies sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0037::C3GPLibParser_0037() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0037::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, VideoDependencyL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0037::VideoDependencyL(C3GPParse* aParser) sl@0: { sl@0: // file mode sl@0: ParserOpenFileL(aParser); sl@0: sl@0: TUint num; sl@0: User::LeaveIfError(aParser->GetNumberOfVideoFrames(num)); sl@0: sl@0: TInt err = KErrNone; sl@0: T3GPFrameDependencies dependencies; sl@0: for (TInt i = 0; i < num; i++) sl@0: { sl@0: err = aParser->GetVideoFrameDependencies(dependencies); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("GetVideoFrameDependencies failed with %d"), err); sl@0: SetTestStepError(err); sl@0: break; sl@0: } sl@0: } sl@0: ParserCompleteL(aParser); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Get Video Frame Properties sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0038::C3GPLibParser_0038() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0038::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, VideoInfoL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0038::VideoInfoL(C3GPParse* aParser) sl@0: { sl@0: // file mode sl@0: ParserOpenFileL(aParser); sl@0: sl@0: TUint num; sl@0: TUint timeStampInMs = 0; sl@0: TUint timeStampInTimescale = 0; sl@0: TUint frameIndex; sl@0: TBool keyFrame; sl@0: User::LeaveIfError(aParser->GetNumberOfVideoFrames(num)); sl@0: User::LeaveIfError(aParser->GetVideoSampleEntryIndex(frameIndex)); sl@0: sl@0: TInt err = KErrNone; sl@0: for (TInt i = 0; i < num; i++) sl@0: { sl@0: err = aParser->GetVideoFrameKeyType(i, keyFrame); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoFrameKeyType()"))); sl@0: sl@0: err = aParser->GetVideoFrameStartTime(i, timeStampInMs, timeStampInTimescale); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoFrameStartTime()"))); sl@0: } sl@0: sl@0: TUint startIndex = 0; sl@0: RArray array; sl@0: CleanupClosePushL(array); sl@0: sl@0: err = aParser->GetVideoFrameProperties(startIndex, num, array); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoFrameProperties"))); sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF1(_L("aParser->GetVideoFrameProperties passed.")); sl@0: } sl@0: sl@0: RArray array1; sl@0: CleanupClosePushL(array1); sl@0: sl@0: // Filled in array with some data, say array with size 3 sl@0: TInt arraySize = 3; sl@0: T3GPFrameInfoParameters fip; sl@0: for (TInt i = 0; i < arraySize; i++) sl@0: { sl@0: fip.iSize = i; sl@0: fip.iStartTime = 1000; sl@0: fip.iIsRandomAccessPoint = ETrue; sl@0: array1.AppendL(fip); sl@0: } sl@0: sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF1(_L("Filled in array with some junk data and call aParser->GetVideoFrameProperties() ago.")); sl@0: } sl@0: sl@0: err = aParser->GetVideoFrameProperties(startIndex, num, array1); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoFrameProperties"))); sl@0: sl@0: // Check two arrays are the same sl@0: if (array.Count() != array1.Count()) sl@0: { sl@0: ERR_PRINTF3(_L("array1.Count() is %d; expected array.Count() is %d."), array1.Count(), array.Count()); sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: for (TInt j = 0; j < array.Count(); j++) sl@0: { sl@0: if (array1[j].iSize != array[j].iSize || array1[j].iStartTime != array1[j].iStartTime || sl@0: array1[j].iIsRandomAccessPoint != array1[j].iIsRandomAccessPoint) sl@0: { sl@0: ERR_PRINTF1(_L("Two array are not the same.")); sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: } sl@0: sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF1(_L("Two arrays are the same.")); sl@0: } sl@0: CleanupStack::PopAndDestroy(&array1); sl@0: CleanupStack::PopAndDestroy(&array); sl@0: sl@0: ParserCompleteL(aParser); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Read a audio and a video frame into a buffer of filled with junk content and sl@0: // ensure the buffer gets properly reset when retrieve video / audio frame data. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0039::C3GPLibParser_0039() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0039::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, AudioAndVideoFrameL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0039::AudioAndVideoFrameL(C3GPParse* aParser) sl@0: { sl@0: // file mode sl@0: ParserOpenFileL(aParser); sl@0: sl@0: TUint size; sl@0: TInt err = aParser->GetVideoFrameSize(size); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoFrameSize"))); sl@0: sl@0: RBuf8 buffer; sl@0: CleanupClosePushL(buffer); sl@0: buffer.CreateL(size + 15); // Create a buffer bigger than the size returned by GetVideoFrameSize sl@0: // Filled in junk data into the buffer sl@0: TChar c = 'a'; sl@0: buffer.AppendFill(c, (size + 15)); sl@0: sl@0: TBool keyFrame; sl@0: TUint timeStampInMs; sl@0: TUint timeStampInTimescale; sl@0: err = aParser->ReadVideoFrame(buffer, keyFrame, timeStampInMs, timeStampInTimescale); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("ReadVideoFrame"))); sl@0: // Check the buffer size is the same as size returned by GetVideoFrameSize sl@0: if (buffer.Length() != size) sl@0: { sl@0: ERR_PRINTF3(_L("buffer size is %d; expected size is %d."), buffer.Length(), size); sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: CleanupStack::PopAndDestroy(&buffer); sl@0: sl@0: err = aParser->GetAudioFramesSize(size); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("GetAudioFramesSize"))); sl@0: sl@0: RBuf8 bufferBig; sl@0: CleanupClosePushL(bufferBig); sl@0: bufferBig.CreateL(size + 10); // Create a buffer bigger than the size returned by GetVideoFrameSize sl@0: // Filled in junk data into the buffer sl@0: bufferBig.AppendFill(c, (size + 10)); sl@0: sl@0: TInt returnedFrames; sl@0: err = aParser->ReadAudioFrames(bufferBig, returnedFrames, timeStampInMs, timeStampInTimescale); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("ReadAudioFrames"))); sl@0: // Check the buffer size is the same as size returned by GetVideoFrameSize sl@0: if (bufferBig.Length() != size) sl@0: { sl@0: ERR_PRINTF3(_L("buffer size is %d; expected size is %d."), buffer.Length(), size); sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(&bufferBig); sl@0: sl@0: ParserCompleteL(aParser); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Multiple parser working simultaneously. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0041::C3GPLibParser_0041() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0041::doTestStepPreambleL() sl@0: { sl@0: // Add the names of the new files to the following file list array. sl@0: TInt numOfFiles = 2; // This is the array number. Should be the same as the number of the array. sl@0: const TText* SelectedFiles[] = sl@0: { sl@0: _S("mpeg4-aac.3gp"), // File with both audio and video sl@0: _S("arm-nb-acelp-only.3gp") // File with audio only sl@0: }; sl@0: sl@0: for (TInt index = 0; index < numOfFiles; index++) sl@0: { sl@0: // Create a zero terminated version of the file name sl@0: TFileName inputFile(K3GPLibTestFilePath); sl@0: inputFile += TPtrC(SelectedFiles[index]); sl@0: inputFile.ZeroTerminate(); sl@0: sl@0: if (index == 0) sl@0: { sl@0: User::LeaveIfError(iInputFile1.Create(inputFile.Length() + 1)); sl@0: iInputFile1.Copy(inputFile); sl@0: } sl@0: else sl@0: { sl@0: User::LeaveIfError(iInputFile2.Create(inputFile.Length() + 1)); sl@0: iInputFile2.Copy(inputFile); sl@0: } sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0041::doTestStepPostambleL() sl@0: { sl@0: iInputFile1.Close(); sl@0: iInputFile2.Close(); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0041::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser1 = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser1); sl@0: sl@0: TInt err = parser1->Open(iInputFile1); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("aParser1->Open"))); sl@0: sl@0: C3GPParse* parser2 = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser2); sl@0: sl@0: err = parser2->Open(iInputFile1); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("aParser2->Open"))); sl@0: sl@0: C3GPParse* parser3 = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser3); sl@0: sl@0: err = parser3->Open(iInputFile2); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("aParser3->Open"))); sl@0: sl@0: TRAP(err, MultipleParserL(parser1, parser2, parser3)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: ParserCompleteL(parser1); sl@0: ParserCompleteL(parser2); sl@0: ParserCompleteL(parser3); sl@0: sl@0: CleanupStack::PopAndDestroy(parser3); sl@0: CleanupStack::PopAndDestroy(parser2); sl@0: CleanupStack::PopAndDestroy(parser1); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0041::MultipleParserL(C3GPParse* aParser1, C3GPParse* aParser2, C3GPParse* aParser3) sl@0: { sl@0: TInt err = ReadAudioVideoFrame(aParser1); sl@0: User::LeaveIfError(CheckError(err, KErrNotFound, _L("ReadAudioVideoFrame(aParser1)"))); sl@0: sl@0: // Read one video frame with parser2 sl@0: err = ReadAudioVideoFrame(aParser2, EFalse, EFalse); sl@0: User::LeaveIfError(CheckError(err, KErrNone, _L("ReadAudioVideoFrame(aParser2)"))); sl@0: sl@0: // Read video properties with parser3. Expected failed with KErrNotSupported sl@0: T3GPVideoType videoType; sl@0: TUint length; sl@0: TReal frameRate; sl@0: TUint avgBitRate; sl@0: TSize videoSize; sl@0: TUint timeScale; sl@0: sl@0: err = aParser3->GetVideoProperties(videoType, length, frameRate, avgBitRate, videoSize, timeScale); sl@0: User::LeaveIfError(CheckError(err, KErrNotSupported, _L("aParser3->GetVideoProperties"))); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Seek position in buffer mode sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0043::C3GPLibParser_0043() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0043::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, SeekBufferModeL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0043::SeekBufferModeL(C3GPParse* aParser) sl@0: { sl@0: // buffer mode sl@0: ParserOpenL(aParser); sl@0: FileOpenL(); sl@0: sl@0: // Insert buffer data into the library sl@0: TInt pos = 0; sl@0: TInt bufferSize = KBufferSize; sl@0: InsertDataL(aParser, iSourceFile, bufferSize, pos); sl@0: sl@0: TUint audioPos; sl@0: TUint videoPos; sl@0: TUint timeStampInMs = 0; sl@0: sl@0: // Seek the position sl@0: TInt err = aParser->Seek(timeStampInMs, EFalse, audioPos, videoPos); sl@0: while (err == KErr3gpLibMoreDataRequired) sl@0: { sl@0: pos = pos + bufferSize; sl@0: InsertDataL(aParser, iSourceFile, bufferSize, pos); sl@0: err = aParser->Seek(timeStampInMs, EFalse, audioPos, videoPos); sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepError(err); sl@0: } sl@0: ParserCompleteL(aParser); sl@0: FileClose(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Test C3GPParse with large file (>2GB) sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0045::C3GPLibParser_0045() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0045::doTestStepPreambleL() sl@0: { sl@0: C3GPLib_AsyncObserver::doTestStepPreambleL(); sl@0: if (TestStepResult() == EPass) sl@0: { sl@0: iScheduler = new (ELeave) CActiveScheduler; sl@0: CActiveScheduler::Install(iScheduler); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0045::doTestStepPostambleL() sl@0: { sl@0: C3GPLib_AsyncObserver::doTestStepPostambleL(); sl@0: if( iScheduler ) sl@0: { sl@0: INFO_PRINTF1(_L("delete iScheduler")); sl@0: CActiveScheduler::Install(NULL); sl@0: delete iScheduler; sl@0: iScheduler = NULL; sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0045::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, TestParserWithLargeFileL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0045::TestParserWithLargeFileL(C3GPParse* aParser) sl@0: { sl@0: INFO_PRINTF1(_L("Test Parser With Large File (>2GB)")); sl@0: INFO_PRINTF1(_L("Open and complete parser with 64 bit file handle")); sl@0: sl@0: ParserOpenFileHandle64L(aParser); sl@0: ParserCompleteHandle64L(aParser); sl@0: sl@0: ParserOpenFileHandle64L(aParser, EFileRead | EFileShareReadersOnly); sl@0: ParserCompleteHandle64L(aParser); sl@0: sl@0: ParserOpenFileHandle64L(aParser, EFileShareReadersOrWriters | EFileWrite); sl@0: ParserCompleteHandle64L(aParser); sl@0: sl@0: ParserOpenFileHandle64L(aParser, EFileShareReadersOrWriters | EFileRead); sl@0: ParserCompleteHandle64L(aParser); sl@0: sl@0: ParserOpenFileHandle64L(aParser, EFileShareAny | EFileWrite); sl@0: ParserCompleteHandle64L(aParser); sl@0: sl@0: ParserOpenFileHandle64L(aParser, EFileShareAny | EFileRead); sl@0: ParserCompleteHandle64L(aParser); sl@0: sl@0: INFO_PRINTF1(_L("Test parser with 64 bit file handle")); sl@0: sl@0: // Read audio/video attributes sl@0: ParserOpenFileHandle64L(aParser); sl@0: DoGetVideoAudioAttributesL(aParser); sl@0: ParserCompleteHandle64L(aParser); sl@0: sl@0: // Read audio/video frames sl@0: ParserOpenFileHandle64L(aParser); sl@0: User::LeaveIfError(DoReadFrame(aParser)); sl@0: ParserCompleteHandle64L(aParser); sl@0: sl@0: // Asynchronous Read of audio/video frames sl@0: ParserOpenFileHandle64L(aParser); sl@0: User::LeaveIfError(DoReadFrameAsync(aParser)); sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF1(_L("C3GPLibParser_0045::ReadFrameAsyncL() using 64 bit file handle")); sl@0: } sl@0: ParserCompleteHandle64L(aParser); sl@0: sl@0: // Seek positions after any keyframe and immediately after a non-key frame sl@0: ParserOpenFileHandle64L(aParser); sl@0: DoSeekTestL(aParser); sl@0: ParserCompleteHandle64L(aParser); sl@0: sl@0: INFO_PRINTF1(_L("Test parser in File path")); sl@0: sl@0: // Read audio/video attributes sl@0: ParserOpenFileL(aParser); sl@0: DoGetVideoAudioAttributesL(aParser); sl@0: ParserCompleteL(aParser); sl@0: sl@0: // Read audio/video frames sl@0: ParserOpenFileL(aParser); sl@0: User::LeaveIfError(DoReadFrame(aParser)); sl@0: ParserCompleteL(aParser); sl@0: sl@0: // Asynchronous Read of audio/video frames sl@0: ParserOpenFileL(aParser); sl@0: User::LeaveIfError(DoReadFrameAsync(aParser)); sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL()")); sl@0: } sl@0: ParserCompleteL(aParser); sl@0: sl@0: ParserOpenFileL(aParser); sl@0: User::LeaveIfError(DoReadFrameAsync(aParser, ETrue)); sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL(), then cancel the read")); sl@0: } sl@0: ParserCompleteL(aParser); sl@0: sl@0: INFO_PRINTF1(_L("Test parser in CAF")); sl@0: sl@0: // Read audio/video attributes sl@0: ParserOpenCafLC(aParser); sl@0: DoGetVideoAudioAttributesL(aParser); sl@0: ParserCompleteCafL(aParser); sl@0: sl@0: // Read audio/video frames sl@0: ParserOpenCafLC(aParser); sl@0: User::LeaveIfError(DoReadFrame(aParser)); sl@0: ParserCompleteCafL(aParser); sl@0: sl@0: // Asynchronous Read of audio/video frames sl@0: ParserOpenCafLC(aParser); sl@0: User::LeaveIfError(DoReadFrameAsync(aParser)); sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL() using CAF")); sl@0: } sl@0: ParserCompleteCafL(aParser); sl@0: } sl@0: sl@0: TInt C3GPLibParser_0045::DoReadFrameAsync(C3GPParse* aParser, TBool aCancel) sl@0: { sl@0: TInt err = KErrNone; sl@0: sl@0: if (!aCancel) sl@0: { sl@0: err = ReadAudioVideoFrameAsync(aParser, ETrue); sl@0: if (err == KErrNone) sl@0: { sl@0: err = ReadAudioVideoFrameAsync(aParser, EFalse); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: err = ReadAudioVideoFrameAsync(aParser, EFalse, ETrue); sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Parse video & audio frames from >2GB file synchronously in buffer mode sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: C3GPLibParser_0047::C3GPLibParser_0047() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPLibParser_0047::doTestStepL() sl@0: { sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: TRAPD(err, ReadFrameL(parser)); sl@0: if (err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void C3GPLibParser_0047::ReadFrameL(C3GPParse* aParser) sl@0: { sl@0: FileOpen64L(); sl@0: ReadFrameBufferModeL(aParser); sl@0: FileClose64(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Retrieve User Data Atoms with Multiple atoms sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: _LIT(KAtomFileNamePrefix, "AtomFile"); sl@0: sl@0: C3GPUserDataAtomRetrieval::C3GPUserDataAtomRetrieval() sl@0: { sl@0: } sl@0: sl@0: TVerdict C3GPUserDataAtomRetrieval::doTestStepL() sl@0: { sl@0: // ensure test step error & result reset before each test sl@0: if (TestStepResult() != EPass) sl@0: { sl@0: return TestStepResult(); sl@0: } sl@0: SetTestStepError(KErrNone); sl@0: sl@0: C3GPParse* parser = C3GPParse::NewL(); sl@0: CleanupStack::PushL(parser); sl@0: sl@0: if (iLargeFile) sl@0: { sl@0: User::LeaveIfError(parser->Open(iInputFile64)); sl@0: } sl@0: else sl@0: { sl@0: User::LeaveIfError(parser->Open(iInputFile)); sl@0: } sl@0: sl@0: TBool keepLooking = ETrue; sl@0: TInt atomFound = 0; sl@0: TInt atomSize = 0; sl@0: TUint atomIndex = 0; sl@0: TUint atomHighestIndex1 = 0; sl@0: TUint atomHighestIndex2 = 0; sl@0: TInt err = KErrNone; sl@0: RFile atomFile; sl@0: RBuf8 atomContent; sl@0: RBuf8 fileContent; sl@0: CleanupClosePushL(fileContent); sl@0: CleanupClosePushL(atomFile); sl@0: CleanupClosePushL(atomContent); sl@0: sl@0: while(keepLooking && err == KErrNone) sl@0: { sl@0: TInt atomIndexInput = atomIndex; sl@0: err = parser->GetUserDataAtomSize(iAtomType, iAtomLocation, atomIndex, atomSize); sl@0: if (err == KErrNone) sl@0: { sl@0: atomHighestIndex1 = atomIndex; sl@0: atomIndex = atomIndexInput; sl@0: atomContent.CreateL(atomSize); sl@0: sl@0: err = parser->GetUserDataAtom(iAtomType, iAtomLocation, atomContent, atomIndex); sl@0: if (err == KErrNone) sl@0: { sl@0: if (atomFound == 0) sl@0: { sl@0: // remember the highest atom index found during first run sl@0: atomHighestIndex2 = atomIndex; sl@0: if (atomHighestIndex1 != atomHighestIndex2) sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF1(_L("Highest Atom Index returned is different when calling GetUserDataAtomSize vs GetUserDataAtom")); sl@0: } sl@0: } sl@0: } sl@0: atomFound++; sl@0: sl@0: User::LeaveIfError(atomFile.Open(iFs, (*iAtomFileArray)[atomIndexInput], EFileRead | EFileStream)); sl@0: TInt fileSize = 0; sl@0: User::LeaveIfError(atomFile.Size(fileSize)); sl@0: if (atomContent.Size() != fileSize) sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF4(_L("Atom %d retrieved is of different size as expected. Expected=%d Retrieved=%d"), atomIndexInput, fileSize, atomContent.Size()); sl@0: } sl@0: SetTestStepResult(EFail); sl@0: keepLooking = EFalse; sl@0: } sl@0: else sl@0: { sl@0: fileContent.CreateL(fileSize); sl@0: User::LeaveIfError(atomFile.Read(fileContent)); sl@0: if (fileContent != atomContent) sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF4(_L("Atom %d retrieved is of different content. Expected=%S Retrieved=%S"), atomIndexInput, &fileContent, &atomContent); sl@0: } sl@0: SetTestStepResult(EFail); sl@0: keepLooking = EFalse; sl@0: } sl@0: else sl@0: { sl@0: if (atomIndex != atomHighestIndex2) sl@0: { sl@0: // seems like there's an error occurred, as the highest index for this atom sl@0: // type should stay the same throughout sl@0: keepLooking = EFalse; sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF3(_L("Previous highest atom index is %d but now it is %d. Data inconsistency."), atomHighestIndex2, atomIndex); sl@0: } sl@0: SetTestStepResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: // look for the next atom of the same type now sl@0: atomIndex = atomIndexInput + 1; sl@0: } sl@0: } sl@0: fileContent.Close(); sl@0: } sl@0: atomFile.Close(); sl@0: } sl@0: else sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF4(_L("Fail to get user atom: index = %d, location = %d, type = %d"), atomIndex, iAtomLocation, iAtomType); sl@0: } sl@0: User::Leave(err); sl@0: } sl@0: sl@0: atomContent.Close(); sl@0: } sl@0: } sl@0: if (TestStepResult() == EPass && atomFound != iExpectedNumAtom && atomFound == (atomHighestIndex2 + 1)) sl@0: { sl@0: if (!ShouldRunOOMTest()) sl@0: { sl@0: ERR_PRINTF3(_L("Number of atoms found (%d) does not match expected # of atoms (%d)."), atomFound, iExpectedNumAtom); sl@0: } sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(&atomContent); sl@0: CleanupStack::PopAndDestroy(&atomFile); sl@0: CleanupStack::PopAndDestroy(&fileContent); sl@0: sl@0: parser->Complete(); sl@0: sl@0: CleanupStack::PopAndDestroy(parser); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPUserDataAtomRetrieval::doTestStepPreambleL() sl@0: { sl@0: SetTestStepResult(ETestSuiteError); sl@0: sl@0: #ifdef __WINSCW__ sl@0: _LIT(KFileToParse, "FileToParseEmu"); sl@0: #else sl@0: _LIT(KFileToParse, "FileToParseHw"); sl@0: #endif sl@0: sl@0: TPtrC inputFilename; sl@0: if (!GetStringFromConfig(ConfigSection(), KFileToParse, inputFilename)) sl@0: { sl@0: // file need to be specified sl@0: ERR_PRINTF1(_L("Specify the file to be parsed.")); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: if (!GetBoolFromConfig(ConfigSection(), _L("largeFile"), iLargeFile)) sl@0: { sl@0: ERR_PRINTF1(_L("Specify whether the file is larger than 2GB.")); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: User::LeaveIfError(iFs.Connect()); sl@0: if (iLargeFile) sl@0: { sl@0: User::LeaveIfError(iInputFile64.Open(iFs, inputFilename, EFileRead | EFileStream | EFileShareReadersOnly)); sl@0: } sl@0: else sl@0: { sl@0: User::LeaveIfError(iInputFile.Open(iFs, inputFilename, EFileRead | EFileStream | EFileShareReadersOnly)); sl@0: } sl@0: sl@0: if (!GetIntFromConfig(ConfigSection(), _L("ExpectedNumOfAtom"), iExpectedNumAtom)) sl@0: { sl@0: // Number of expected number of atoms needs to be specified sl@0: ERR_PRINTF1(_L("Specify the number of atoms to be expected.")); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: iAtomFileArray = new CDesCArrayFlat(4); sl@0: TInt temp; sl@0: if (!GetIntFromConfig(ConfigSection(), _L("AtomType"), temp)) sl@0: { sl@0: // atom type to retrieve needs to be specified sl@0: ERR_PRINTF1(_L("Specify the atoms type to be retrieved.")); sl@0: return TestStepResult(); sl@0: } sl@0: else sl@0: { sl@0: iAtomType = (TUint32) temp; sl@0: } sl@0: sl@0: if (!GetIntFromConfig(ConfigSection(), _L("AtomLocation"), temp)) sl@0: { sl@0: // atom location to retrieve needs to be specified sl@0: ERR_PRINTF1(_L("Specify the atoms location for the atoms to be retrieved.")); sl@0: return TestStepResult(); sl@0: } sl@0: else sl@0: { sl@0: iAtomLocation = (T3GPUdtaLocation) temp; sl@0: } sl@0: sl@0: if (iExpectedNumAtom > 0) sl@0: { sl@0: TBuf<50> keyName; sl@0: TPtrC fileName; sl@0: for (TInt i = 1; i <= iExpectedNumAtom; i++) sl@0: { sl@0: keyName.Zero(); sl@0: keyName.AppendFormat(_L("%S%d"), &KAtomFileNamePrefix, i); sl@0: sl@0: if (!GetStringFromConfig(ConfigSection(), keyName, fileName)) sl@0: { sl@0: // atom content file needs to be specified sl@0: ERR_PRINTF1(_L("Specify the file name that contents the matching atom content.")); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: iAtomFileArray->AppendL(fileName); sl@0: } sl@0: } sl@0: sl@0: SetTestStepResult(EPass); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict C3GPUserDataAtomRetrieval::doTestStepPostambleL() sl@0: { sl@0: if (iAtomFileArray) sl@0: { sl@0: iAtomFileArray->Reset(); sl@0: delete iAtomFileArray; sl@0: } sl@0: sl@0: if (iLargeFile) sl@0: { sl@0: iInputFile64.Close(); sl@0: } sl@0: else sl@0: { sl@0: iInputFile.Close(); sl@0: } sl@0: iFs.Close(); sl@0: sl@0: return TestStepResult(); sl@0: }