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 __METADATAFILEWRITER_H sl@0: #define __METADATAFILEWRITER_H sl@0: sl@0: // INCLUDES sl@0: #include sl@0: #include <3gplibrary/mp4lib.h> sl@0: #include "mp4atom.h" sl@0: sl@0: // FORWARD DECLARATIONS sl@0: class RFile64; sl@0: sl@0: #define NUM_MDF 10 /* Number of temporary metadata files */ sl@0: sl@0: // CLASS DECLARATION sl@0: sl@0: NONSHARABLE_CLASS(CMetaDataWriterBuffer) : public CBase sl@0: { sl@0: public: // Constructors and destructor sl@0: sl@0: inline CMetaDataWriterBuffer() : iData( NULL ), iOutputFileNum( -1 ) {} sl@0: sl@0: inline CMetaDataWriterBuffer( HBufC8& aBuffer, sl@0: const TInt aOutputFileNum) sl@0: : iData(&aBuffer), iOutputFileNum(aOutputFileNum) {} sl@0: sl@0: /** sl@0: * Destructor. sl@0: */ sl@0: ~CMetaDataWriterBuffer(); sl@0: sl@0: public: sl@0: HBufC8* iData; sl@0: TInt iOutputFileNum; sl@0: }; sl@0: sl@0: /** sl@0: * Async buffering file writer. sl@0: */ sl@0: NONSHARABLE_CLASS(CMetaDataFileWriter) : public CActive sl@0: { sl@0: public: // Constructors and destructor sl@0: sl@0: /** sl@0: * Two-phased constructor. sl@0: */ sl@0: static CMetaDataFileWriter* NewL( ); sl@0: sl@0: /** sl@0: * Destructor. sl@0: */ sl@0: ~CMetaDataFileWriter(); sl@0: sl@0: public: // New functions sl@0: sl@0: /** sl@0: * Writes incoming buffer data to internal buffers for writing to disk. sl@0: * @since 2.6 sl@0: * @param aFileNumber Index of file the data is to be written sl@0: * @param aBuf Data to be written sl@0: * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes. sl@0: */ sl@0: TInt Write( RFile64& aFile, const TInt aFileNumber, const TDesC8& aBuf ); sl@0: sl@0: /** sl@0: * Flush internal buffers to disk. sl@0: * @since 2.6 sl@0: * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes. sl@0: */ sl@0: TInt Flush(); sl@0: sl@0: /** sl@0: * Reads data from internal buffers that have not yet been written to disk. sl@0: * @since 5.0 sl@0: * @param aFileNumber Index of file sl@0: * @param aBuf Data to be written sl@0: * @param bytestoread Number of bytes to readData sl@0: * @return number of bytes read sl@0: */ sl@0: TInt ReadBuffer( const TInt aFileNumber, TDes8& aBuf, TInt bytestoread ); sl@0: sl@0: protected: // Functions from base classes sl@0: 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: /** sl@0: * Called when errors in RunL force Leave. sl@0: */ sl@0: TInt RunError(TInt aError); sl@0: sl@0: private: sl@0: sl@0: /** sl@0: * C++ default constructor. sl@0: */ sl@0: CMetaDataFileWriter(); sl@0: sl@0: /** sl@0: * By default Symbian 2nd phase constructor is private. sl@0: */ sl@0: void ConstructL( ); sl@0: sl@0: /** sl@0: * Writes incoming data to internal buffers and buffer queues.. sl@0: * @since 2.6 sl@0: * @param aFileNumber Index of file the data is to be written sl@0: * @param aBuf Data to be added to buffers.. sl@0: * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes. sl@0: */ sl@0: TInt AddDataToBuffer(const TInt aFileNumber, const TDesC8& aBuf ); sl@0: sl@0: private: sl@0: // Write error code. sl@0: TInt iError; sl@0: // Whether we are flushing after async write. sl@0: TBool iFlush; sl@0: // Whether the flushing is done. sl@0: TBool iFlushDone; sl@0: // Array to keep file status information sl@0: TBool iAsyncWritingOngoing; sl@0: // Outputfiles sl@0: RPointerArray iOutputFile; sl@0: // Array of output buffers. sl@0: RPointerArray iOutputBufferQueue; sl@0: // Array of input buffers. sl@0: RPointerArray iInputBufferArray; sl@0: // Queue of empty write buffers. sl@0: RPointerArray iEmptyBufferQueue; sl@0: // Array to count delivered bytes from iInputBufferArray sl@0: TInt iInputBufferArrayDelivered[NUM_MDF]; sl@0: }; sl@0: sl@0: #endif //__METADATAFILEWRITER_H sl@0: // End of File