videoeditorengine/audioeditorengine/codecs/MP4/inc/ProcMP4InFileHandler.h
changeset 9 d87d32eab1a9
parent 0 951a5db380a0
equal deleted inserted replaced
0:951a5db380a0 9:d87d32eab1a9
     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 #ifndef __CPROCMP4INFILEHANDLER_H__
       
    21 #define __CPROCMP4INFILEHANDLER_H__
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <f32file.h>
       
    25 #include "mp4lib.h"
       
    26 
       
    27 #include "AudCommon.h"
       
    28 #include "ProcConstants.h"
       
    29 #include "ProcInFileHandler.h"
       
    30 //#include "mp4aud.h"
       
    31 #include "AACConstants.h"
       
    32 
       
    33 #include "ProcDecoder.h"
       
    34 
       
    35 
       
    36 class CMP4Parser;
       
    37 
       
    38 class CProcMP4InFileHandler: public CProcInFileHandler 
       
    39     {
       
    40 
       
    41 public:
       
    42 
       
    43     /*
       
    44     *
       
    45     * Constructors & destructor
       
    46     * 
       
    47     */
       
    48 
       
    49     static CProcMP4InFileHandler* NewL(const TDesC& aFileName, RFile* aFileHandle,
       
    50                                         CAudClip* aClip, TInt aReadBufferSize,
       
    51                                             TInt aTargetSampleRate = 0, 
       
    52                                             TChannelMode aChannelMode = EAudSingleChannel);
       
    53                                             
       
    54     static CProcMP4InFileHandler* NewLC(const TDesC& aFileName,  RFile* aFileHandle,
       
    55                                         CAudClip* aClip, TInt aReadBufferSize,
       
    56                                             TInt aTargetSampleRate = 0, 
       
    57                                             TChannelMode aChannelMode = EAudSingleChannel);
       
    58     virtual ~CProcMP4InFileHandler();
       
    59 
       
    60     // From base class --------->
       
    61 
       
    62     void GetPropertiesL(TAudFileProperties* aProperties);
       
    63     
       
    64     /**
       
    65     * Seeks a certain audio frame for reading
       
    66     *
       
    67     * Possible leave codes:  
       
    68     *    
       
    69     * @param aTime            time from the beginning of file in milliseconds
       
    70     *
       
    71     * @return    ETrue if successful
       
    72     *            EFalse if beyond the file
       
    73     */
       
    74     TBool SeekAudioFrame(TInt32 aTime);
       
    75 
       
    76     
       
    77     /**
       
    78     * Seeks a cut in audio frame for reading
       
    79     *
       
    80     * Possible leave codes:  
       
    81     *    
       
    82     *
       
    83     * @return    ETrue if successful
       
    84     *                
       
    85     */
       
    86     TBool SeekCutInFrame();
       
    87 
       
    88     virtual TBool SetNormalizingGainL(const CProcFrameHandler* aFrameHandler);
       
    89 
       
    90     // <-------------------------------------- from base class
       
    91 
       
    92     /*
       
    93     *
       
    94     * Used to retrieve information for frame handler
       
    95     *
       
    96     * @param    aBytes (output) decoder specific info
       
    97     * @param     aBufferSize        maximum allowed aBytes
       
    98     *
       
    99     * @return    ETrue     if successful (memory reserved)
       
   100     *            EFalse    if not successful (no memory reserved)
       
   101     *
       
   102     * NOTE: The caller is responsible for releasing the memory!
       
   103     */
       
   104     virtual TBool ReadAudioDecoderSpecificInfoL(HBufC8*& aBytes, TInt aBufferSize);
       
   105     
       
   106     /*
       
   107     * Reads the time scale of the MP4 file
       
   108     *
       
   109     * @param    aTimescale    timescale
       
   110     *
       
   111     */
       
   112     virtual TBool ReadTimeScale(mp4_u32& aTimescale);
       
   113 
       
   114     /*
       
   115     * Reads the audio description of the MP4 file
       
   116     *
       
   117     * @param    aAudiolength            length of the clip
       
   118     * @param    aAudiotype                type of the clip
       
   119     * @param    aFramespersample        number of frames in sample
       
   120     * @param    aTimescale                timescale
       
   121     * @param    aAveragebitrate            average bitrate
       
   122     * 
       
   123     */
       
   124     MP4Err ParseRequestAudioDescription(mp4_u32 *aAudiolength,
       
   125                                            mp4_u32 *aAudiotype,
       
   126                                            mp4_u8 *aFramespersample,
       
   127                                            mp4_u32 *aTimescale,
       
   128                                            mp4_u32 *aAveragebitrate);
       
   129 
       
   130     /*
       
   131     *
       
   132     * Returns AAC info
       
   133     * @param    aAACInfo    AAC info
       
   134     *
       
   135     */
       
   136     TBool GetInfoForFrameHandler(TAACFrameHandlerInfo& aAACInfo);
       
   137 
       
   138     
       
   139 
       
   140 
       
   141     
       
   142 
       
   143 private:
       
   144 
       
   145     // constructL
       
   146     void ConstructL(const TDesC& aFileName,  RFile* aFileHandle, CAudClip* aClip, 
       
   147                     TInt aReadBufferSize, TInt aTargetSampleRate = 0, 
       
   148                     TChannelMode aChannelMode = EAudSingleChannel);
       
   149     
       
   150     // c++ construtor
       
   151     CProcMP4InFileHandler();
       
   152 
       
   153     // gets audio frame info
       
   154     TBool GetAudioFrameInfoL(TInt& aFrameAmount, TInt& aAverageFrameDuration, TInt& aAverageFrameSize,
       
   155                             TAudFileProperties* aProperties);
       
   156 
       
   157     TBool GetEncAudioFrameL(HBufC8*& aFrame, TInt& aSize, TInt32& aTime);
       
   158     
       
   159     /*
       
   160     * Reads one amr frame from iReadBuffer and updates iReadBufferPos
       
   161     *
       
   162     * @param aOneAMRFrame        amr frame in return
       
   163     *
       
   164     * @return                     ETrue if successful, the caller must release the memory
       
   165     *                            EFalse if frame can not be read, no need to release memory
       
   166     */
       
   167     TBool ReadOneAMRFrameL(HBufC8*& aOneAMRFrame);
       
   168     
       
   169     TBool ReadOneAWBFrameL(HBufC8*& aOneAWBFrame);
       
   170     
       
   171 private:
       
   172 
       
   173     // Handle to MP4Lib
       
   174     MP4Handle iParser;
       
   175     
       
   176     // timestamp of a previous frame
       
   177     TInt32 iLastTimeStamp;
       
   178 
       
   179     // information for frame handler
       
   180     TAACFrameHandlerInfo* iFrameInfo;
       
   181 
       
   182     // read buffer
       
   183     mp4_u8 *iMP4ReadBuffer;
       
   184     // read buffer size
       
   185     TInt iMP4ReadBufferSize;
       
   186     // position of the read buffer
       
   187     TInt iMP4ReadBufferPos;
       
   188     
       
   189 
       
   190 
       
   191 
       
   192 protected:
       
   193     
       
   194     
       
   195     
       
   196     };
       
   197 
       
   198 #endif