os/mm/mmplugins/lib3gp/impl/inc/metadatafilewriter.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#ifndef __METADATAFILEWRITER_H
sl@0
    17
#define __METADATAFILEWRITER_H
sl@0
    18
sl@0
    19
//  INCLUDES
sl@0
    20
#include <e32base.h>
sl@0
    21
#include <3gplibrary/mp4lib.h>
sl@0
    22
#include "mp4atom.h"
sl@0
    23
sl@0
    24
// FORWARD DECLARATIONS
sl@0
    25
class RFile64;
sl@0
    26
sl@0
    27
#define NUM_MDF      10     /* Number of temporary metadata files */
sl@0
    28
sl@0
    29
// CLASS DECLARATION
sl@0
    30
sl@0
    31
NONSHARABLE_CLASS(CMetaDataWriterBuffer) : public CBase
sl@0
    32
    {
sl@0
    33
    public:  // Constructors and destructor
sl@0
    34
sl@0
    35
        inline CMetaDataWriterBuffer() : iData( NULL ), iOutputFileNum( -1 ) {}
sl@0
    36
sl@0
    37
        inline CMetaDataWriterBuffer( HBufC8& aBuffer, 
sl@0
    38
                            const TInt aOutputFileNum) 
sl@0
    39
                            : iData(&aBuffer), iOutputFileNum(aOutputFileNum) {}
sl@0
    40
sl@0
    41
        /**
sl@0
    42
        * Destructor.
sl@0
    43
        */
sl@0
    44
        ~CMetaDataWriterBuffer();
sl@0
    45
sl@0
    46
    public:
sl@0
    47
        HBufC8* iData;
sl@0
    48
        TInt iOutputFileNum;
sl@0
    49
    };
sl@0
    50
sl@0
    51
/**
sl@0
    52
*  Async buffering file writer.
sl@0
    53
*/
sl@0
    54
NONSHARABLE_CLASS(CMetaDataFileWriter) : public CActive
sl@0
    55
    {
sl@0
    56
    public: // Constructors and destructor
sl@0
    57
sl@0
    58
        /**
sl@0
    59
        * Two-phased constructor.
sl@0
    60
        */
sl@0
    61
        static CMetaDataFileWriter* NewL( );
sl@0
    62
sl@0
    63
        /**
sl@0
    64
        * Destructor.
sl@0
    65
        */
sl@0
    66
        ~CMetaDataFileWriter();
sl@0
    67
    
sl@0
    68
    public: // New functions
sl@0
    69
sl@0
    70
        /**
sl@0
    71
        * Writes incoming buffer data to internal buffers for writing to disk.
sl@0
    72
        * @since 2.6
sl@0
    73
        * @param aFileNumber Index of file the data is to be written
sl@0
    74
        * @param aBuf Data to be written
sl@0
    75
        * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes.
sl@0
    76
        */
sl@0
    77
        TInt Write( RFile64& aFile, const TInt aFileNumber, const TDesC8& aBuf );
sl@0
    78
sl@0
    79
        /**
sl@0
    80
        * Flush internal buffers to disk.
sl@0
    81
        * @since 2.6
sl@0
    82
        * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes.
sl@0
    83
        */
sl@0
    84
        TInt Flush();
sl@0
    85
sl@0
    86
        /**
sl@0
    87
        * Reads data from internal buffers that have not yet been written to disk.
sl@0
    88
        * @since 5.0
sl@0
    89
        * @param aFileNumber Index of file
sl@0
    90
        * @param aBuf Data to be written
sl@0
    91
        * @param bytestoread Number of bytes to readData
sl@0
    92
        * @return number of bytes read
sl@0
    93
        */
sl@0
    94
        TInt ReadBuffer( const TInt aFileNumber, TDes8& aBuf, TInt bytestoread );
sl@0
    95
sl@0
    96
    protected: // Functions from base classes
sl@0
    97
        
sl@0
    98
        /**
sl@0
    99
        * From CActive Cancels async request.
sl@0
   100
        */
sl@0
   101
        void DoCancel();
sl@0
   102
sl@0
   103
        /**
sl@0
   104
        * From CActive Called when async request completes.
sl@0
   105
        */
sl@0
   106
	    void RunL();
sl@0
   107
	    
sl@0
   108
	    /**
sl@0
   109
	    * Called when errors in RunL force Leave. 
sl@0
   110
	    */
sl@0
   111
	    TInt RunError(TInt aError);
sl@0
   112
sl@0
   113
private:
sl@0
   114
sl@0
   115
        /**
sl@0
   116
        * C++ default constructor.
sl@0
   117
        */
sl@0
   118
        CMetaDataFileWriter();
sl@0
   119
sl@0
   120
        /**
sl@0
   121
        * By default Symbian 2nd phase constructor is private.
sl@0
   122
        */
sl@0
   123
        void ConstructL( );
sl@0
   124
sl@0
   125
        /**
sl@0
   126
        * Writes incoming data to internal buffers and buffer queues..
sl@0
   127
        * @since 2.6
sl@0
   128
        * @param aFileNumber Index of file the data is to be written
sl@0
   129
        * @param aBuf Data to be added to buffers..
sl@0
   130
        * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes.
sl@0
   131
        */
sl@0
   132
        TInt AddDataToBuffer(const TInt aFileNumber, const TDesC8& aBuf );
sl@0
   133
sl@0
   134
private:
sl@0
   135
		// Write error code.
sl@0
   136
	    TInt iError;
sl@0
   137
        // Whether we are flushing after async write.
sl@0
   138
    	TBool iFlush;
sl@0
   139
        // Whether the flushing is done.
sl@0
   140
    	TBool iFlushDone;
sl@0
   141
        // Array to keep file status information
sl@0
   142
        TBool iAsyncWritingOngoing;
sl@0
   143
        // Outputfiles
sl@0
   144
        RPointerArray<RFile64> iOutputFile;
sl@0
   145
        // Array of output buffers.
sl@0
   146
        RPointerArray<CMetaDataWriterBuffer> iOutputBufferQueue;
sl@0
   147
        // Array of input buffers.
sl@0
   148
        RPointerArray<CMetaDataWriterBuffer> iInputBufferArray;
sl@0
   149
        // Queue of empty write buffers.
sl@0
   150
        RPointerArray<CMetaDataWriterBuffer> iEmptyBufferQueue;
sl@0
   151
        // Array to count delivered bytes from iInputBufferArray
sl@0
   152
        TInt iInputBufferArrayDelivered[NUM_MDF];
sl@0
   153
};
sl@0
   154
sl@0
   155
#endif  //__METADATAFILEWRITER_H
sl@0
   156
// End of File