Update contrib.
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __METADATAFILEWRITER_H
17 #define __METADATAFILEWRITER_H
21 #include <3gplibrary/mp4lib.h>
24 // FORWARD DECLARATIONS
27 #define NUM_MDF 10 /* Number of temporary metadata files */
31 NONSHARABLE_CLASS(CMetaDataWriterBuffer) : public CBase
33 public: // Constructors and destructor
35 inline CMetaDataWriterBuffer() : iData( NULL ), iOutputFileNum( -1 ) {}
37 inline CMetaDataWriterBuffer( HBufC8& aBuffer,
38 const TInt aOutputFileNum)
39 : iData(&aBuffer), iOutputFileNum(aOutputFileNum) {}
44 ~CMetaDataWriterBuffer();
52 * Async buffering file writer.
54 NONSHARABLE_CLASS(CMetaDataFileWriter) : public CActive
56 public: // Constructors and destructor
59 * Two-phased constructor.
61 static CMetaDataFileWriter* NewL( );
66 ~CMetaDataFileWriter();
68 public: // New functions
71 * Writes incoming buffer data to internal buffers for writing to disk.
73 * @param aFileNumber Index of file the data is to be written
74 * @param aBuf Data to be written
75 * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes.
77 TInt Write( RFile64& aFile, const TInt aFileNumber, const TDesC8& aBuf );
80 * Flush internal buffers to disk.
82 * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes.
87 * Reads data from internal buffers that have not yet been written to disk.
89 * @param aFileNumber Index of file
90 * @param aBuf Data to be written
91 * @param bytestoread Number of bytes to readData
92 * @return number of bytes read
94 TInt ReadBuffer( const TInt aFileNumber, TDes8& aBuf, TInt bytestoread );
96 protected: // Functions from base classes
99 * From CActive Cancels async request.
104 * From CActive Called when async request completes.
109 * Called when errors in RunL force Leave.
111 TInt RunError(TInt aError);
116 * C++ default constructor.
118 CMetaDataFileWriter();
121 * By default Symbian 2nd phase constructor is private.
126 * Writes incoming data to internal buffers and buffer queues..
128 * @param aFileNumber Index of file the data is to be written
129 * @param aBuf Data to be added to buffers..
130 * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes.
132 TInt AddDataToBuffer(const TInt aFileNumber, const TDesC8& aBuf );
137 // Whether we are flushing after async write.
139 // Whether the flushing is done.
141 // Array to keep file status information
142 TBool iAsyncWritingOngoing;
144 RPointerArray<RFile64> iOutputFile;
145 // Array of output buffers.
146 RPointerArray<CMetaDataWriterBuffer> iOutputBufferQueue;
147 // Array of input buffers.
148 RPointerArray<CMetaDataWriterBuffer> iInputBufferArray;
149 // Queue of empty write buffers.
150 RPointerArray<CMetaDataWriterBuffer> iEmptyBufferQueue;
151 // Array to count delivered bytes from iInputBufferArray
152 TInt iInputBufferArrayDelivered[NUM_MDF];
155 #endif //__METADATAFILEWRITER_H