mmplugins/lib3gp/impl/inc/filewriter.h
branchRCL_3
changeset 39 3f0ddfac3ede
parent 23 545d349d14da
child 49 735348f59235
equal deleted inserted replaced
28:f50f14318409 39:3f0ddfac3ede
    19 //  INCLUDES
    19 //  INCLUDES
    20 #include <e32base.h>
    20 #include <e32base.h>
    21 #include "mp4atom.h"
    21 #include "mp4atom.h"
    22 
    22 
    23 // CONSTANTS
    23 // CONSTANTS
    24 const TInt KFileWriterBufferSizeSmall = 2048;
    24 const TInt KFileWriterBufferSizeSmall = 65536;
    25 const TInt KFileWriterBufferSizeLarge = (2*65536);  
    25 const TInt KFileWriterBufferSizeLarge = (4*65536);  
    26 const TInt KFileWriterSoftBufLimit = 10;
    26 const TInt KFileWriterSoftBufLimit = 12;
    27 const TInt KFileWriterHardBufLimit = 15;
    27 const TInt KFileWriterHardBufLimit = 16;
    28 const TInt KFileWriterMinBufferCount = 4; // shouldn't be less than 4
    28 const TInt KFileWriterMinBufferCount = 4; // shouldn't be less than 4
    29 
    29 
    30 // FORWARD DECLARATIONS
    30 // FORWARD DECLARATIONS
    31 class RFile64;
    31 class RFile64;
    32 
    32 
    48     public: // Constructors and destructor
    48     public: // Constructors and destructor
    49 
    49 
    50         /**
    50         /**
    51         * Two-phased constructor.
    51         * Two-phased constructor.
    52         */
    52         */
    53         static CFileWriter* NewL( RFile64& aFile );
    53         static CFileWriter* NewL( RFile64& aFile, TInt aInitSetSize = 0, TInt aOutputBufferSizeSmall = KFileWriterBufferSizeSmall, TInt aOutputBufferSizeLarge = KFileWriterBufferSizeLarge );
    54 
    54 
    55         /**
    55         /**
    56         * Destructor.
    56         * Destructor.
    57         */
    57         */
    58         ~CFileWriter();
    58         ~CFileWriter();
    87         /**
    87         /**
    88         * Set file output buffer count
    88         * Set file output buffer count
    89         * @since 3.0
    89         * @since 3.0
    90         * @param aHandle MP4Handle.
    90         * @param aHandle MP4Handle.
    91         */
    91         */
    92         void SetOutputBufferCount( MP4Handle aHandle );        
    92         void SetOutputBufferCount( MP4Handle aHandle ); 
       
    93 
       
    94         inline TInt64 OutputFileSize() const
       
    95 			{
       
    96 			return iOutputFileSize;
       
    97 			}    
    93 
    98 
    94     protected: // Functions from base classes
    99     protected: // Functions from base classes
    95         
   100         
    96         /**
   101         /**
    97         * From CActive Cancels async request.
   102         * From CActive Cancels async request.
   106 private:
   111 private:
   107 
   112 
   108         /**
   113         /**
   109         * C++ default constructor.
   114         * C++ default constructor.
   110         */
   115         */
   111         CFileWriter();
   116         CFileWriter( TInt aInitSetSize, TInt aOutputBufferSizeSmall, TInt aOutputBufferSizeLarge );
   112 
   117 
   113         /**
   118         /**
   114         * By default Symbian 2nd phase constructor is private.
   119         * By default Symbian 2nd phase constructor is private.
   115         */
   120         */
   116         void ConstructL( RFile64& aFile );
   121         void ConstructL( RFile64& aFile );
   126         /**
   131         /**
   127         * Allocates input and output buffers.
   132         * Allocates input and output buffers.
   128         * @since 2.6
   133         * @since 2.6
   129         */
   134         */
   130         void AllocateBuffersL();
   135         void AllocateBuffersL();
       
   136 		
       
   137 		/**
       
   138 		* Updates output file size and reserves extra space for following writing if iSetSize is set.
       
   139 		* Takes into account if the position in the file was changed.
       
   140 		*/
       
   141         void UpdateOutputFileSize();
   131 
   142 
   132 private:
   143 private:
   133         // Whether we are flushing after async write.
   144         // Whether we are flushing after async write.
   134     	TBool iFlush;
   145     	TBool iFlush;
   135 		// Flag whether there is async writing going.
   146 		// Flag whether there is async writing going.
   137 		// Flag whether we have received any data.
   148 		// Flag whether we have received any data.
   138         TBool iWritingStarted;
   149         TBool iWritingStarted;
   139         // Flag whether init has been done
   150         // Flag whether init has been done
   140         TBool iMemReadyForWriting;
   151         TBool iMemReadyForWriting;
   141 
   152 
   142 		// Write error code.
   153         // Write error code.
   143 	    TInt iError;
   154         TInt iError;
       
   155         
       
   156         // Current set file size
       
   157         TInt64 iSetSize;
       
   158         // Current output file size
       
   159 	    TInt64 iOutputFileSize;		
       
   160 
       
   161         TInt iOutputBufferSizeSmall;
       
   162         TInt iOutputBufferSizeLarge;
       
   163         
   144         // Output buffer size.
   164         // Output buffer size.
   145         TInt iOutputBufferSize;
   165         TInt iOutputBufferSize;
   146         // Hard limit for max output buffers
   166         // Hard limit for max output buffers
   147         TInt iMaxOutputBufHardLimit;
   167         TInt iMaxOutputBufHardLimit;
   148         // Soft limit for max output buffers
   168         // Soft limit for max output buffers
   149         TInt iMaxOutputBufSoftLimit;
   169         TInt iMaxOutputBufSoftLimit;
   150         // Current output file size
   170 
   151 		TInt64 iOutputFileSize;
       
   152 
   171 
   153         // Output file for writes.
   172         // Output file for writes.
   154         RFile64* iOutputFile;
   173         RFile64* iOutputFile;
   155         // Queue of empty write buffers.
   174         // Queue of empty write buffers.
   156         RPointerArray<HBufC8> iEmptyBufferQueue;
   175         RPointerArray<HBufC8> iEmptyBufferQueue;