videoeditorengine/vedengine/videoprocessor/inc/mp4composer.h
changeset 0 951a5db380a0
equal deleted inserted replaced
-1:000000000000 0:951a5db380a0
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 * Ixonos Plc
       
    14 *
       
    15 * Description:  
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 //FC: A wrapper class for mp4composer
       
    21 // Based on the CMP4Parser class
       
    22 // end FC.
       
    23 
       
    24 
       
    25 #ifndef __MP4COMPOSER_H__
       
    26 #define __MP4COMPOSER_H__
       
    27 
       
    28 //  INCLUDES
       
    29 
       
    30 
       
    31 #include "Composer.h"
       
    32 #include <mp4lib.h>
       
    33 #include "parser.h"
       
    34 #include "vedavcedit.h"
       
    35 
       
    36 // CONSTANTS
       
    37 // MACROS
       
    38 // DATA TYPES
       
    39 // FUNCTION PROTOTYPES
       
    40 // FORWARD DECLARATIONS
       
    41 
       
    42 
       
    43 // CLASS DECLARATION
       
    44 
       
    45 
       
    46 /**
       
    47 *  MP4 -format Composer class
       
    48 *  ?other_description_lines
       
    49 */
       
    50 class CMP4Composer : public CComposer
       
    51     {
       
    52 
       
    53     public: // Constants
       
    54 
       
    55         enum TFrameType
       
    56         {
       
    57             EFrameTypeNone = 0,
       
    58             EFrameTypeAudio,
       
    59             EFrameTypeVideo
       
    60         };
       
    61 
       
    62     public:  // Constructors and destructor
       
    63 
       
    64         /**
       
    65         * C++ default constructor.
       
    66         */
       
    67         CMP4Composer();
       
    68 
       
    69 		/**
       
    70         * Two-phased constructor.(overloaded for Mp4 support)
       
    71         */
       
    72         static CMP4Composer* NewL(const TDesC &aFileName, 
       
    73                                   CParser::TVideoFormat aVideoFormat,
       
    74                                   CParser::TAudioFormat aAudioFormat,
       
    75                                   CVedAVCEdit *aAvcEdit);
       
    76                                   
       
    77         static CMP4Composer* NewL(RFile* aFileHandle, 
       
    78                                   CParser::TVideoFormat aVideoFormat,
       
    79                                   CParser::TAudioFormat aAudioFormat,
       
    80                                   CVedAVCEdit *aAvcEdit);
       
    81 
       
    82         /**
       
    83         * Destructor.
       
    84         */
       
    85         ~CMP4Composer();
       
    86     
       
    87     public: // Functions from base classes     
       
    88 
       
    89                 
       
    90 		/**
       
    91         * Write a number of frames of requested type from inserted data or file
       
    92         * @param aSrcBuffer SOurce buffer
       
    93         * @param aType Type of frame(s) to write
       
    94         * @param aNumWritten Number of frames actually written
       
    95         * @return TInt error code
       
    96         */
       
    97 
       
    98         TInt WriteFrames(TDesC8& aSrcBuffer, TInt aFrameSize,TInt aDuration, 
       
    99 					TInt aKeyFrame,TInt aNumberOfFrames,TInt aFrameType);               
       
   100 
       
   101 		TInt WriteFrames(TDesC8& aSrcBuffer, TInt aFrameSize,TInt aDuration, 
       
   102 					TInt aKeyFrame,TInt aNumberOfFrames,TInt aFrameType,TInt& aMP4Size,
       
   103 					TBool aModeChanged,TBool aFirstFrameOfClip,TInt aMode, TBool aFromEncoder);
       
   104 
       
   105         /**
       
   106         * From CComposer composes the stream header.
       
   107         * @param aStreamParameters Common stream parameters
       
   108         * @param aOutputVideoTimeScale Video time scale for output file
       
   109         * @param aOutputAudioTimeScale Audio time scale for output file
       
   110         * @param aAudioFramesInSample Number of audio frames in sample
       
   111         */
       
   112 		void ComposeHeaderL(CComposer::TStreamParameters& aStreamParameters,
       
   113 			TInt aOutputVideoTimeScale, TInt aOutputAudioTimeScale, TInt aAudioFramesInSample);		
       
   114 
       
   115         /**
       
   116         * From CComposer Closes the composer instance
       
   117         */
       
   118         TInt Close();
       
   119 
       
   120         /**
       
   121         * From CComposer Calculate drive free space 
       
   122         */
       
   123         TInt64 DriveFreeSpaceL();
       
   124 
       
   125         /**
       
   126         * Get the Composed Buffer
       
   127         */
       
   128 		TUint8* GetComposedBuffer();
       
   129 
       
   130 		/**
       
   131         * Get the Composed Buffer size till now
       
   132         */
       
   133 		TUint GetComposedBufferSize();
       
   134 
       
   135 		TInt GetMp4SpecificSize(TDesC8& aSrcBuf,TBool aModeChange,TInt aStreamMode);
       
   136 
       
   137     private:
       
   138 
       
   139 		/**
       
   140         * By default Symbian OS constructor is private.
       
   141         */
       
   142         void ConstructL(const TDesC &aFileName,
       
   143                         CParser::TVideoFormat aVideoFormat,
       
   144                         CParser::TAudioFormat aAudioFormat,
       
   145                         CVedAVCEdit *aAvcEdit);
       
   146                         
       
   147         void ConstructL(RFile* aFileHandle,
       
   148                         CParser::TVideoFormat aVideoFormat,
       
   149                         CParser::TAudioFormat aAudioFormat,
       
   150                         CVedAVCEdit *aAvcEdit);
       
   151                         
       
   152         void SetMediaOptions(CParser::TVideoFormat aVideoFormat, 
       
   153                              CParser::TAudioFormat aAudioFormat,
       
   154                              TUint& aMediaFlag);
       
   155                         
       
   156         void SetComposerOptionsL(CParser::TVideoFormat aVideoFormat, 
       
   157                                  CParser::TAudioFormat aAudioFormat);
       
   158                         
       
   159         TInt GetAVCDecoderSpecificInfoSize(TDesC8& aSrcBuf);
       
   160 
       
   161 	public: // New Functions 
       
   162 
       
   163 		/**
       
   164         * Writes audio decoder specific info which is required in case of AAC
       
   165 		*
       
   166 		* @param aSrcBuf - buffer containing the data to be written(decoder specific informtion)
       
   167         */
       
   168 		TInt WriteAudioSpecificInfo(HBufC8*& aSrcBuf);
       
   169 
       
   170         /**
       
   171         * Writes audio decoder specific info which is required in case of AAC
       
   172 		*
       
   173 		* @param aSampleRate Output sample rate of the movie
       
   174         * @param aNumChannels Output num. of audio channels
       
   175         */
       
   176         TInt WriteAudioSpecificInfo(TInt aSampleRate, TInt aNumChannels);
       
   177 
       
   178     private:    // Data
       
   179        
       
   180         // The MP4 parser library handle
       
   181         MP4Handle iMP4Handle;
       
   182         mp4_u32 iVideoType;
       
   183 		mp4_u32 iAudioType;
       
   184 
       
   185          // File server session handle
       
   186         RFs iFS;
       
   187         TBool iFsOpened;
       
   188 
       
   189         // Output filename
       
   190         TFileName iOutputMovieFileName;
       
   191 
       
   192         // Drive number of the output file
       
   193         TInt iDriveNumber;
       
   194 
       
   195         // Remaining free disk space
       
   196         TInt64 iFreeDiskSpace;        
       
   197 
       
   198         // Counter to check the real free disk space
       
   199         TUint iFreeDiskSpaceCounter;
       
   200 
       
   201 		TBool iFirstWrite;
       
   202 
       
   203         // for compose buffer
       
   204         TUint8 *iComposeBuffer;
       
   205         mp4_u32 iComposedSize;
       
   206         
       
   207         // For AVC writing
       
   208         TInt iFrameNumber;
       
   209 
       
   210 	    CVedAVCEdit* iAvcEdit;  // Avc editing instance
       
   211 	    
       
   212 	    RFile* iFileHandle;
       
   213     };
       
   214 
       
   215 #endif      // __MP4COMPOSER_H__
       
   216 
       
   217 
       
   218 // End of File