os/mm/mmplugins/lib3gp/impl/inc/asyncfileparser.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#ifndef __ASYNCFILEPARSER_H
sl@0
    17
#define __ASYNCFILEPARSER_H
sl@0
    18
sl@0
    19
//  INCLUDES
sl@0
    20
#include <e32base.h>
sl@0
    21
#include "mp4atom.h"
sl@0
    22
sl@0
    23
// CONSTANTS
sl@0
    24
sl@0
    25
// FORWARD DECLARATIONS
sl@0
    26
class RFile64;
sl@0
    27
struct MP4HandleStruct;
sl@0
    28
sl@0
    29
// CLASS DECLARATION
sl@0
    30
sl@0
    31
/**
sl@0
    32
*  Async file parser
sl@0
    33
*/
sl@0
    34
NONSHARABLE_CLASS(CFileAsyncParser) : public CActive
sl@0
    35
    {
sl@0
    36
	public: // Constructors and destructor
sl@0
    37
sl@0
    38
        /**
sl@0
    39
        * Two-phased constructor.
sl@0
    40
        */
sl@0
    41
        static CFileAsyncParser* NewL( MP4HandleStruct* aHandle, RFile64& aFile );
sl@0
    42
sl@0
    43
        /**
sl@0
    44
        * Destructor.
sl@0
    45
        */
sl@0
    46
        ~CFileAsyncParser();
sl@0
    47
    
sl@0
    48
	public: // New functions
sl@0
    49
sl@0
    50
        /**
sl@0
    51
        * Reads audio frames from file asynchronously
sl@0
    52
        * @since 3.1
sl@0
    53
        * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes.
sl@0
    54
        */
sl@0
    55
        TInt ReadAudioFrames( mp4_u8 *buffer, mp4_i64 aPosition, mp4_u32 aBytesToRead );
sl@0
    56
sl@0
    57
        /**
sl@0
    58
        * Reads video frames from file asynchronously
sl@0
    59
        * @since 3.1
sl@0
    60
        * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes.
sl@0
    61
        */
sl@0
    62
        TInt ReadVideoFrame(  mp4_u8 *buffer, mp4_i64 aPosition, mp4_u32 aBytesToRead );
sl@0
    63
sl@0
    64
	protected: // Functions from base classes
sl@0
    65
        /**
sl@0
    66
        * From CActive Cancels async request.
sl@0
    67
        */
sl@0
    68
        void DoCancel();
sl@0
    69
sl@0
    70
        /**
sl@0
    71
        * From CActive Called when async request completes.
sl@0
    72
        */
sl@0
    73
	    void RunL();
sl@0
    74
sl@0
    75
	private:
sl@0
    76
        /**
sl@0
    77
        * C++ default constructor.
sl@0
    78
        */
sl@0
    79
        CFileAsyncParser();
sl@0
    80
sl@0
    81
        /**
sl@0
    82
        * By default Symbian 2nd phase constructor is private.
sl@0
    83
        */
sl@0
    84
        void ConstructL( MP4HandleStruct* aHandle, RFile64& aFile );
sl@0
    85
        
sl@0
    86
        /**
sl@0
    87
        * By default Symbian 2nd phase constructor is private.
sl@0
    88
        */
sl@0
    89
        TInt ReadDataAsync( mp4_u8 *buffer, mp4_i64 aPosition, mp4_u32 aBytesToRead );
sl@0
    90
        
sl@0
    91
        /**
sl@0
    92
        * Return audio frames to observer
sl@0
    93
        */
sl@0
    94
		void ReturnAudioFrames();
sl@0
    95
sl@0
    96
        /**
sl@0
    97
        * Return video frame to observer
sl@0
    98
        */
sl@0
    99
        void ReturnVideoFrame();
sl@0
   100
sl@0
   101
        /**
sl@0
   102
        * Calculates audio framecount in buffer
sl@0
   103
        */        
sl@0
   104
        TInt CalculateAudioFrameCount();
sl@0
   105
        
sl@0
   106
	private:
sl@0
   107
		// Handle to parsed file structure.
sl@0
   108
		MP4HandleStruct* iHandle;
sl@0
   109
		
sl@0
   110
		// Disk buffer.
sl@0
   111
		HBufC8* iDiskBuffer;
sl@0
   112
		// Pointer to iDiskBuffer data
sl@0
   113
		TPtr8 iDiskBufferPointer;
sl@0
   114
		// Disk buffer size
sl@0
   115
		TInt iReadBufferSize;		
sl@0
   116
		// Position of last read Diskbuffer in file
sl@0
   117
		TInt64 iCurrentDiskReadPosition;
sl@0
   118
		// Position of last read inside iDiskBuffer.
sl@0
   119
		TUint iCurrentBufferReadPosition;
sl@0
   120
		// Whether on last parse request all data was found on internal buffer.
sl@0
   121
		TBool iAllDataInMemory;
sl@0
   122
		
sl@0
   123
		// Audio parameters to be filled.
sl@0
   124
		// Size of audio frame returned to client.
sl@0
   125
		mp4_u32 iAudioSize;
sl@0
   126
		// Number of audio frames in buffer.
sl@0
   127
		mp4_u32 iReturnedAudioFrames;
sl@0
   128
		// Audio frame presentation time in milliseconds from the beginning of the audio sequence.
sl@0
   129
		mp4_u32 iAudioTimeStamp; 		
sl@0
   130
		// 	Audio frame presentation time in timescale from the	beginning of the audio sequence
sl@0
   131
		mp4_u32 iAudioTimeStamp2; 		
sl@0
   132
	
sl@0
   133
		// Video parameter to be filled.
sl@0
   134
		// Size of video frame returned to client.
sl@0
   135
		mp4_u32 iVideoSize;
sl@0
   136
		// Whether returned video frame is keyframe or not.
sl@0
   137
		mp4_bool iVideoKeyFrame;
sl@0
   138
		// Video frame presentation time in milliseconds from the beginning of the video sequence.
sl@0
   139
		mp4_u32 iVideoTimeStamp; 		
sl@0
   140
		// Video frame presentation time in timescale from the	beginning of the video sequence
sl@0
   141
		mp4_u32 iVideoTimeStamp2; 		
sl@0
   142
		
sl@0
   143
		// Read logic variables.
sl@0
   144
		// Amount of bytes client wants to read
sl@0
   145
		TInt iBytesToRead;
sl@0
   146
		// Amount of bytes read.
sl@0
   147
		TInt64 iBytesRead;
sl@0
   148
		// Flag whether there is async writing going.
sl@0
   149
	    TBool iAsyncReadOngoing;
sl@0
   150
	    // Flag whether current read is audio.
sl@0
   151
	    TBool iProcessingAudio;
sl@0
   152
		// Write error code.
sl@0
   153
	    TInt iError;
sl@0
   154
sl@0
   155
        // Parsed file being read.
sl@0
   156
        RFile64* iInputFile;
sl@0
   157
		// Output buffer being written to
sl@0
   158
		mp4_u8* iBuffer;
sl@0
   159
};
sl@0
   160
sl@0
   161
#endif  //__ASYNCFILEPARSER_H
sl@0
   162
// End of File