os/mm/mmplugins/lib3gp/impl/inc/metadatafilewriter.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.
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __METADATAFILEWRITER_H
    17 #define __METADATAFILEWRITER_H
    18 
    19 //  INCLUDES
    20 #include <e32base.h>
    21 #include <3gplibrary/mp4lib.h>
    22 #include "mp4atom.h"
    23 
    24 // FORWARD DECLARATIONS
    25 class RFile64;
    26 
    27 #define NUM_MDF      10     /* Number of temporary metadata files */
    28 
    29 // CLASS DECLARATION
    30 
    31 NONSHARABLE_CLASS(CMetaDataWriterBuffer) : public CBase
    32     {
    33     public:  // Constructors and destructor
    34 
    35         inline CMetaDataWriterBuffer() : iData( NULL ), iOutputFileNum( -1 ) {}
    36 
    37         inline CMetaDataWriterBuffer( HBufC8& aBuffer, 
    38                             const TInt aOutputFileNum) 
    39                             : iData(&aBuffer), iOutputFileNum(aOutputFileNum) {}
    40 
    41         /**
    42         * Destructor.
    43         */
    44         ~CMetaDataWriterBuffer();
    45 
    46     public:
    47         HBufC8* iData;
    48         TInt iOutputFileNum;
    49     };
    50 
    51 /**
    52 *  Async buffering file writer.
    53 */
    54 NONSHARABLE_CLASS(CMetaDataFileWriter) : public CActive
    55     {
    56     public: // Constructors and destructor
    57 
    58         /**
    59         * Two-phased constructor.
    60         */
    61         static CMetaDataFileWriter* NewL( );
    62 
    63         /**
    64         * Destructor.
    65         */
    66         ~CMetaDataFileWriter();
    67     
    68     public: // New functions
    69 
    70         /**
    71         * Writes incoming buffer data to internal buffers for writing to disk.
    72         * @since 2.6
    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.
    76         */
    77         TInt Write( RFile64& aFile, const TInt aFileNumber, const TDesC8& aBuf );
    78 
    79         /**
    80         * Flush internal buffers to disk.
    81         * @since 2.6
    82         * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes.
    83         */
    84         TInt Flush();
    85 
    86         /**
    87         * Reads data from internal buffers that have not yet been written to disk.
    88         * @since 5.0
    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
    93         */
    94         TInt ReadBuffer( const TInt aFileNumber, TDes8& aBuf, TInt bytestoread );
    95 
    96     protected: // Functions from base classes
    97         
    98         /**
    99         * From CActive Cancels async request.
   100         */
   101         void DoCancel();
   102 
   103         /**
   104         * From CActive Called when async request completes.
   105         */
   106 	    void RunL();
   107 	    
   108 	    /**
   109 	    * Called when errors in RunL force Leave. 
   110 	    */
   111 	    TInt RunError(TInt aError);
   112 
   113 private:
   114 
   115         /**
   116         * C++ default constructor.
   117         */
   118         CMetaDataFileWriter();
   119 
   120         /**
   121         * By default Symbian 2nd phase constructor is private.
   122         */
   123         void ConstructL( );
   124 
   125         /**
   126         * Writes incoming data to internal buffers and buffer queues..
   127         * @since 2.6
   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.
   131         */
   132         TInt AddDataToBuffer(const TInt aFileNumber, const TDesC8& aBuf );
   133 
   134 private:
   135 		// Write error code.
   136 	    TInt iError;
   137         // Whether we are flushing after async write.
   138     	TBool iFlush;
   139         // Whether the flushing is done.
   140     	TBool iFlushDone;
   141         // Array to keep file status information
   142         TBool iAsyncWritingOngoing;
   143         // Outputfiles
   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];
   153 };
   154 
   155 #endif  //__METADATAFILEWRITER_H
   156 // End of File