sl@0: // Copyright (c) 2006-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: #ifndef __ASYNCFILEPARSER_H sl@0: #define __ASYNCFILEPARSER_H sl@0: sl@0: // INCLUDES sl@0: #include sl@0: #include "mp4atom.h" sl@0: sl@0: // CONSTANTS sl@0: sl@0: // FORWARD DECLARATIONS sl@0: class RFile64; sl@0: struct MP4HandleStruct; sl@0: sl@0: // CLASS DECLARATION sl@0: sl@0: /** sl@0: * Async file parser sl@0: */ sl@0: NONSHARABLE_CLASS(CFileAsyncParser) : public CActive sl@0: { sl@0: public: // Constructors and destructor sl@0: sl@0: /** sl@0: * Two-phased constructor. sl@0: */ sl@0: static CFileAsyncParser* NewL( MP4HandleStruct* aHandle, RFile64& aFile ); sl@0: sl@0: /** sl@0: * Destructor. sl@0: */ sl@0: ~CFileAsyncParser(); sl@0: sl@0: public: // New functions sl@0: sl@0: /** sl@0: * Reads audio frames from file asynchronously sl@0: * @since 3.1 sl@0: * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes. sl@0: */ sl@0: TInt ReadAudioFrames( mp4_u8 *buffer, mp4_i64 aPosition, mp4_u32 aBytesToRead ); sl@0: sl@0: /** sl@0: * Reads video frames from file asynchronously sl@0: * @since 3.1 sl@0: * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes. sl@0: */ sl@0: TInt ReadVideoFrame( mp4_u8 *buffer, mp4_i64 aPosition, mp4_u32 aBytesToRead ); sl@0: sl@0: protected: // Functions from base classes sl@0: /** sl@0: * From CActive Cancels async request. sl@0: */ sl@0: void DoCancel(); sl@0: sl@0: /** sl@0: * From CActive Called when async request completes. sl@0: */ sl@0: void RunL(); sl@0: sl@0: private: sl@0: /** sl@0: * C++ default constructor. sl@0: */ sl@0: CFileAsyncParser(); sl@0: sl@0: /** sl@0: * By default Symbian 2nd phase constructor is private. sl@0: */ sl@0: void ConstructL( MP4HandleStruct* aHandle, RFile64& aFile ); sl@0: sl@0: /** sl@0: * By default Symbian 2nd phase constructor is private. sl@0: */ sl@0: TInt ReadDataAsync( mp4_u8 *buffer, mp4_i64 aPosition, mp4_u32 aBytesToRead ); sl@0: sl@0: /** sl@0: * Return audio frames to observer sl@0: */ sl@0: void ReturnAudioFrames(); sl@0: sl@0: /** sl@0: * Return video frame to observer sl@0: */ sl@0: void ReturnVideoFrame(); sl@0: sl@0: /** sl@0: * Calculates audio framecount in buffer sl@0: */ sl@0: TInt CalculateAudioFrameCount(); sl@0: sl@0: private: sl@0: // Handle to parsed file structure. sl@0: MP4HandleStruct* iHandle; sl@0: sl@0: // Disk buffer. sl@0: HBufC8* iDiskBuffer; sl@0: // Pointer to iDiskBuffer data sl@0: TPtr8 iDiskBufferPointer; sl@0: // Disk buffer size sl@0: TInt iReadBufferSize; sl@0: // Position of last read Diskbuffer in file sl@0: TInt64 iCurrentDiskReadPosition; sl@0: // Position of last read inside iDiskBuffer. sl@0: TUint iCurrentBufferReadPosition; sl@0: // Whether on last parse request all data was found on internal buffer. sl@0: TBool iAllDataInMemory; sl@0: sl@0: // Audio parameters to be filled. sl@0: // Size of audio frame returned to client. sl@0: mp4_u32 iAudioSize; sl@0: // Number of audio frames in buffer. sl@0: mp4_u32 iReturnedAudioFrames; sl@0: // Audio frame presentation time in milliseconds from the beginning of the audio sequence. sl@0: mp4_u32 iAudioTimeStamp; sl@0: // Audio frame presentation time in timescale from the beginning of the audio sequence sl@0: mp4_u32 iAudioTimeStamp2; sl@0: sl@0: // Video parameter to be filled. sl@0: // Size of video frame returned to client. sl@0: mp4_u32 iVideoSize; sl@0: // Whether returned video frame is keyframe or not. sl@0: mp4_bool iVideoKeyFrame; sl@0: // Video frame presentation time in milliseconds from the beginning of the video sequence. sl@0: mp4_u32 iVideoTimeStamp; sl@0: // Video frame presentation time in timescale from the beginning of the video sequence sl@0: mp4_u32 iVideoTimeStamp2; sl@0: sl@0: // Read logic variables. sl@0: // Amount of bytes client wants to read sl@0: TInt iBytesToRead; sl@0: // Amount of bytes read. sl@0: TInt64 iBytesRead; sl@0: // Flag whether there is async writing going. sl@0: TBool iAsyncReadOngoing; sl@0: // Flag whether current read is audio. sl@0: TBool iProcessingAudio; sl@0: // Write error code. sl@0: TInt iError; sl@0: sl@0: // Parsed file being read. sl@0: RFile64* iInputFile; sl@0: // Output buffer being written to sl@0: mp4_u8* iBuffer; sl@0: }; sl@0: sl@0: #endif //__ASYNCFILEPARSER_H sl@0: // End of File