os/mm/mmplugins/lib3gp/impl/inc/asyncfileparser.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmplugins/lib3gp/impl/inc/asyncfileparser.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,162 @@
     1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef __ASYNCFILEPARSER_H
    1.20 +#define __ASYNCFILEPARSER_H
    1.21 +
    1.22 +//  INCLUDES
    1.23 +#include <e32base.h>
    1.24 +#include "mp4atom.h"
    1.25 +
    1.26 +// CONSTANTS
    1.27 +
    1.28 +// FORWARD DECLARATIONS
    1.29 +class RFile64;
    1.30 +struct MP4HandleStruct;
    1.31 +
    1.32 +// CLASS DECLARATION
    1.33 +
    1.34 +/**
    1.35 +*  Async file parser
    1.36 +*/
    1.37 +NONSHARABLE_CLASS(CFileAsyncParser) : public CActive
    1.38 +    {
    1.39 +	public: // Constructors and destructor
    1.40 +
    1.41 +        /**
    1.42 +        * Two-phased constructor.
    1.43 +        */
    1.44 +        static CFileAsyncParser* NewL( MP4HandleStruct* aHandle, RFile64& aFile );
    1.45 +
    1.46 +        /**
    1.47 +        * Destructor.
    1.48 +        */
    1.49 +        ~CFileAsyncParser();
    1.50 +    
    1.51 +	public: // New functions
    1.52 +
    1.53 +        /**
    1.54 +        * Reads audio frames from file asynchronously
    1.55 +        * @since 3.1
    1.56 +        * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes.
    1.57 +        */
    1.58 +        TInt ReadAudioFrames( mp4_u8 *buffer, mp4_i64 aPosition, mp4_u32 aBytesToRead );
    1.59 +
    1.60 +        /**
    1.61 +        * Reads video frames from file asynchronously
    1.62 +        * @since 3.1
    1.63 +        * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes.
    1.64 +        */
    1.65 +        TInt ReadVideoFrame(  mp4_u8 *buffer, mp4_i64 aPosition, mp4_u32 aBytesToRead );
    1.66 +
    1.67 +	protected: // Functions from base classes
    1.68 +        /**
    1.69 +        * From CActive Cancels async request.
    1.70 +        */
    1.71 +        void DoCancel();
    1.72 +
    1.73 +        /**
    1.74 +        * From CActive Called when async request completes.
    1.75 +        */
    1.76 +	    void RunL();
    1.77 +
    1.78 +	private:
    1.79 +        /**
    1.80 +        * C++ default constructor.
    1.81 +        */
    1.82 +        CFileAsyncParser();
    1.83 +
    1.84 +        /**
    1.85 +        * By default Symbian 2nd phase constructor is private.
    1.86 +        */
    1.87 +        void ConstructL( MP4HandleStruct* aHandle, RFile64& aFile );
    1.88 +        
    1.89 +        /**
    1.90 +        * By default Symbian 2nd phase constructor is private.
    1.91 +        */
    1.92 +        TInt ReadDataAsync( mp4_u8 *buffer, mp4_i64 aPosition, mp4_u32 aBytesToRead );
    1.93 +        
    1.94 +        /**
    1.95 +        * Return audio frames to observer
    1.96 +        */
    1.97 +		void ReturnAudioFrames();
    1.98 +
    1.99 +        /**
   1.100 +        * Return video frame to observer
   1.101 +        */
   1.102 +        void ReturnVideoFrame();
   1.103 +
   1.104 +        /**
   1.105 +        * Calculates audio framecount in buffer
   1.106 +        */        
   1.107 +        TInt CalculateAudioFrameCount();
   1.108 +        
   1.109 +	private:
   1.110 +		// Handle to parsed file structure.
   1.111 +		MP4HandleStruct* iHandle;
   1.112 +		
   1.113 +		// Disk buffer.
   1.114 +		HBufC8* iDiskBuffer;
   1.115 +		// Pointer to iDiskBuffer data
   1.116 +		TPtr8 iDiskBufferPointer;
   1.117 +		// Disk buffer size
   1.118 +		TInt iReadBufferSize;		
   1.119 +		// Position of last read Diskbuffer in file
   1.120 +		TInt64 iCurrentDiskReadPosition;
   1.121 +		// Position of last read inside iDiskBuffer.
   1.122 +		TUint iCurrentBufferReadPosition;
   1.123 +		// Whether on last parse request all data was found on internal buffer.
   1.124 +		TBool iAllDataInMemory;
   1.125 +		
   1.126 +		// Audio parameters to be filled.
   1.127 +		// Size of audio frame returned to client.
   1.128 +		mp4_u32 iAudioSize;
   1.129 +		// Number of audio frames in buffer.
   1.130 +		mp4_u32 iReturnedAudioFrames;
   1.131 +		// Audio frame presentation time in milliseconds from the beginning of the audio sequence.
   1.132 +		mp4_u32 iAudioTimeStamp; 		
   1.133 +		// 	Audio frame presentation time in timescale from the	beginning of the audio sequence
   1.134 +		mp4_u32 iAudioTimeStamp2; 		
   1.135 +	
   1.136 +		// Video parameter to be filled.
   1.137 +		// Size of video frame returned to client.
   1.138 +		mp4_u32 iVideoSize;
   1.139 +		// Whether returned video frame is keyframe or not.
   1.140 +		mp4_bool iVideoKeyFrame;
   1.141 +		// Video frame presentation time in milliseconds from the beginning of the video sequence.
   1.142 +		mp4_u32 iVideoTimeStamp; 		
   1.143 +		// Video frame presentation time in timescale from the	beginning of the video sequence
   1.144 +		mp4_u32 iVideoTimeStamp2; 		
   1.145 +		
   1.146 +		// Read logic variables.
   1.147 +		// Amount of bytes client wants to read
   1.148 +		TInt iBytesToRead;
   1.149 +		// Amount of bytes read.
   1.150 +		TInt64 iBytesRead;
   1.151 +		// Flag whether there is async writing going.
   1.152 +	    TBool iAsyncReadOngoing;
   1.153 +	    // Flag whether current read is audio.
   1.154 +	    TBool iProcessingAudio;
   1.155 +		// Write error code.
   1.156 +	    TInt iError;
   1.157 +
   1.158 +        // Parsed file being read.
   1.159 +        RFile64* iInputFile;
   1.160 +		// Output buffer being written to
   1.161 +		mp4_u8* iBuffer;
   1.162 +};
   1.163 +
   1.164 +#endif  //__ASYNCFILEPARSER_H
   1.165 +// End of File