1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmplugins/lib3gp/impl/inc/metadatafilewriter.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,156 @@
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 __METADATAFILEWRITER_H
1.20 +#define __METADATAFILEWRITER_H
1.21 +
1.22 +// INCLUDES
1.23 +#include <e32base.h>
1.24 +#include <3gplibrary/mp4lib.h>
1.25 +#include "mp4atom.h"
1.26 +
1.27 +// FORWARD DECLARATIONS
1.28 +class RFile64;
1.29 +
1.30 +#define NUM_MDF 10 /* Number of temporary metadata files */
1.31 +
1.32 +// CLASS DECLARATION
1.33 +
1.34 +NONSHARABLE_CLASS(CMetaDataWriterBuffer) : public CBase
1.35 + {
1.36 + public: // Constructors and destructor
1.37 +
1.38 + inline CMetaDataWriterBuffer() : iData( NULL ), iOutputFileNum( -1 ) {}
1.39 +
1.40 + inline CMetaDataWriterBuffer( HBufC8& aBuffer,
1.41 + const TInt aOutputFileNum)
1.42 + : iData(&aBuffer), iOutputFileNum(aOutputFileNum) {}
1.43 +
1.44 + /**
1.45 + * Destructor.
1.46 + */
1.47 + ~CMetaDataWriterBuffer();
1.48 +
1.49 + public:
1.50 + HBufC8* iData;
1.51 + TInt iOutputFileNum;
1.52 + };
1.53 +
1.54 +/**
1.55 +* Async buffering file writer.
1.56 +*/
1.57 +NONSHARABLE_CLASS(CMetaDataFileWriter) : public CActive
1.58 + {
1.59 + public: // Constructors and destructor
1.60 +
1.61 + /**
1.62 + * Two-phased constructor.
1.63 + */
1.64 + static CMetaDataFileWriter* NewL( );
1.65 +
1.66 + /**
1.67 + * Destructor.
1.68 + */
1.69 + ~CMetaDataFileWriter();
1.70 +
1.71 + public: // New functions
1.72 +
1.73 + /**
1.74 + * Writes incoming buffer data to internal buffers for writing to disk.
1.75 + * @since 2.6
1.76 + * @param aFileNumber Index of file the data is to be written
1.77 + * @param aBuf Data to be written
1.78 + * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes.
1.79 + */
1.80 + TInt Write( RFile64& aFile, const TInt aFileNumber, const TDesC8& aBuf );
1.81 +
1.82 + /**
1.83 + * Flush internal buffers to disk.
1.84 + * @since 2.6
1.85 + * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes.
1.86 + */
1.87 + TInt Flush();
1.88 +
1.89 + /**
1.90 + * Reads data from internal buffers that have not yet been written to disk.
1.91 + * @since 5.0
1.92 + * @param aFileNumber Index of file
1.93 + * @param aBuf Data to be written
1.94 + * @param bytestoread Number of bytes to readData
1.95 + * @return number of bytes read
1.96 + */
1.97 + TInt ReadBuffer( const TInt aFileNumber, TDes8& aBuf, TInt bytestoread );
1.98 +
1.99 + protected: // Functions from base classes
1.100 +
1.101 + /**
1.102 + * From CActive Cancels async request.
1.103 + */
1.104 + void DoCancel();
1.105 +
1.106 + /**
1.107 + * From CActive Called when async request completes.
1.108 + */
1.109 + void RunL();
1.110 +
1.111 + /**
1.112 + * Called when errors in RunL force Leave.
1.113 + */
1.114 + TInt RunError(TInt aError);
1.115 +
1.116 +private:
1.117 +
1.118 + /**
1.119 + * C++ default constructor.
1.120 + */
1.121 + CMetaDataFileWriter();
1.122 +
1.123 + /**
1.124 + * By default Symbian 2nd phase constructor is private.
1.125 + */
1.126 + void ConstructL( );
1.127 +
1.128 + /**
1.129 + * Writes incoming data to internal buffers and buffer queues..
1.130 + * @since 2.6
1.131 + * @param aFileNumber Index of file the data is to be written
1.132 + * @param aBuf Data to be added to buffers..
1.133 + * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes.
1.134 + */
1.135 + TInt AddDataToBuffer(const TInt aFileNumber, const TDesC8& aBuf );
1.136 +
1.137 +private:
1.138 + // Write error code.
1.139 + TInt iError;
1.140 + // Whether we are flushing after async write.
1.141 + TBool iFlush;
1.142 + // Whether the flushing is done.
1.143 + TBool iFlushDone;
1.144 + // Array to keep file status information
1.145 + TBool iAsyncWritingOngoing;
1.146 + // Outputfiles
1.147 + RPointerArray<RFile64> iOutputFile;
1.148 + // Array of output buffers.
1.149 + RPointerArray<CMetaDataWriterBuffer> iOutputBufferQueue;
1.150 + // Array of input buffers.
1.151 + RPointerArray<CMetaDataWriterBuffer> iInputBufferArray;
1.152 + // Queue of empty write buffers.
1.153 + RPointerArray<CMetaDataWriterBuffer> iEmptyBufferQueue;
1.154 + // Array to count delivered bytes from iInputBufferArray
1.155 + TInt iInputBufferArrayDelivered[NUM_MDF];
1.156 +};
1.157 +
1.158 +#endif //__METADATAFILEWRITER_H
1.159 +// End of File