videoeditorengine/mp3aacManipLib/inc/Mp3API.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 
       
    21 #ifndef _MP3API_
       
    22 #define    _MP3API_
       
    23 
       
    24 
       
    25 #include "defines.h"
       
    26 #include "mstream.h"
       
    27 
       
    28 
       
    29 
       
    30 
       
    31 
       
    32 /*
       
    33    Purpose:     Structure interface for MP1/2/3 transport stream.
       
    34    Explanation: - */
       
    35 class TMpTransportHandle
       
    36 {
       
    37 public:
       
    38 
       
    39   TMPEG_Header header;
       
    40   TMPEG_Header headerOld;
       
    41 
       
    42   int16 SlotTable[15];
       
    43   int16 FreeFormatSlots;      /*-- Number of bytes in free format frame.     */
       
    44 
       
    45   int16 mainDataSlots;        /*-- Payload size.                             */
       
    46 
       
    47   BOOL ms_stereo;             /* MS (Mid/Side) stereo used.                  */
       
    48   BOOL is_stereo;             /* Intensity stereo used.                      */
       
    49   BOOL lsf;                   /* MPEG-2 LSF stream present.                  */
       
    50   BOOL mpeg25;                /* MPEG-2.5 stream present.                    */
       
    51 
       
    52   /*-- Transport stream to be used/in use. --*/
       
    53   SYNC_STATUS transportType;
       
    54   SyncInfo syncInfo;
       
    55 
       
    56   /*-- Exec state when seeking next MPx frame. --*/
       
    57   int16 offsetBits;
       
    58   ExecState execState;
       
    59 
       
    60   /*-- CRC codeword. --*/
       
    61   TCRC_Check crc;
       
    62 
       
    63   /*-- Average number of bytes reserved for each frame. --*/
       
    64   int32 aveFrameLen;
       
    65   
       
    66 };
       
    67 
       
    68 
       
    69 /**
       
    70  * Data structure for mp3 frame search.
       
    71  */
       
    72 class TMpFrameState
       
    73 {
       
    74 public:
       
    75   /**
       
    76    * Number of read bytes when searching start of frame. 
       
    77    * This value is within the input buffer and also the header
       
    78    * is read after start of frame has been found.
       
    79    */
       
    80   int16 readBytes;
       
    81 
       
    82   /**
       
    83    * Number of header bytes present for current MP3 frame.
       
    84    */
       
    85   int16 headerBytes;
       
    86 
       
    87   /**
       
    88    * Number of payload bytes for current MP3 frame. The total frame
       
    89    * size is 'headerBytes' + 'frameBytes'.
       
    90    */
       
    91   int16 frameBytes;
       
    92 
       
    93   /**
       
    94    * Total number of bytes read when searching the start of frame.
       
    95    */
       
    96   int32 totalReadBytes;
       
    97 
       
    98 };
       
    99 
       
   100 
       
   101 
       
   102 
       
   103 /*
       
   104    Purpose:     Parameters of core engine.
       
   105    Explanation: - */
       
   106 class CMPAudDec : public CBase
       
   107 {
       
   108 public:
       
   109 
       
   110     IMPORT_C static CMPAudDec* NewL();
       
   111     IMPORT_C ~CMPAudDec();
       
   112     IMPORT_C void Init(TMpTransportHandle *aMpFileFormat);
       
   113 
       
   114     /*-- Common to all layers. --*/
       
   115     uint8 *bitReserv;
       
   116     TMPEG_Frame *frame;
       
   117 
       
   118     /*-- Layer III specific parameters. --*/
       
   119     TBitStream br;
       
   120     CHuffman *huffman;
       
   121     CIII_Side_Info *side_info;
       
   122 
       
   123     int16 PrevSlots;
       
   124     //int32 FrameStart;
       
   125     BOOL SkipBr;
       
   126     BOOL WasSeeking;
       
   127 
       
   128     /*-- Transport handle. --*/
       
   129     TMpTransportHandle *mpFileFormat;
       
   130 
       
   131   
       
   132 private:
       
   133 
       
   134     CMPAudDec();
       
   135     void ConstructL();
       
   136 
       
   137 };
       
   138 
       
   139 class CMp3Edit : public CBase
       
   140     {
       
   141 
       
   142 public:
       
   143 
       
   144     IMPORT_C static CMp3Edit* NewL();
       
   145     IMPORT_C ~CMp3Edit();
       
   146 
       
   147     IMPORT_C uint32
       
   148     FileLengthInMs(TMpTransportHandle *tHandle, int32 fileSize) const;
       
   149 
       
   150     IMPORT_C int32
       
   151     GetSeekOffset(TMpTransportHandle *tHandle, int32 seekPos) const;
       
   152 
       
   153     IMPORT_C int32
       
   154     GetFrameTime(TMpTransportHandle *tHandle) const;
       
   155 
       
   156     IMPORT_C void 
       
   157     InitTransport(TMpTransportHandle *tHandle) const;
       
   158 
       
   159     IMPORT_C int16
       
   160     SeekSync(TMpTransportHandle *tHandle, uint8 *syncBuf, 
       
   161             uint32 syncBufLen, int16 *readBytes, 
       
   162             int16 *frameBytes, int16 *headerBytes,
       
   163             uint8 initMode) const;
       
   164 
       
   165     IMPORT_C int16
       
   166         FreeMode(TMpTransportHandle *tHandle, uint8 *syncBuf, 
       
   167         uint32 syncBufLen, int16 *readBytes, 
       
   168         int16 *frameBytes, int16 *headerBytes) const;
       
   169     
       
   170     IMPORT_C int16
       
   171         EstimateBitrate(TMpTransportHandle *tHandle, uint8 isVbr) const;
       
   172     
       
   173 
       
   174 
       
   175 
       
   176     /*-- Closes MPEG Layer I/II/III decoder handle. --*/
       
   177     IMPORT_C CMPAudDec *
       
   178         DeleteMPAudDec(CMPAudDec *mpAud);
       
   179     
       
   180     /*-- Creates MPEG Layer I/II/III decoder handle. --*/
       
   181     IMPORT_C CMPAudDec *
       
   182         CreateMPAudDec(void);
       
   183     
       
   184     /*-- Initializes MPEG Layer I/II/III decoder handle. --*/
       
   185     IMPORT_C void
       
   186         InitMPAudDec(CMPAudDec *mpAud, TMpTransportHandle *mpFileFormat);
       
   187     
       
   188     /*-- Resets MPEG Layer I/II/III decoder handle. --*/
       
   189     IMPORT_C void
       
   190         ResetMPAudDec(CMPAudDec *mpAud);
       
   191     
       
   192     /*-- Stores global gain values. --*/
       
   193     IMPORT_C void
       
   194         SetMPGlobalGains(TBitStream *bs, uint8 numGains, uint8 *globalGain, uint32 *gainPos);
       
   195     
       
   196     /*-- Extracts global gain values. --*/
       
   197     IMPORT_C uint8
       
   198         GetMPGlobalGains(TBitStream *bs, TMpTransportHandle *tHandle, uint8 *globalGain, uint32 *gainPos);
       
   199 
       
   200 private:
       
   201     
       
   202     void ConstructL();
       
   203     CMp3Edit();
       
   204 
       
   205     };
       
   206 
       
   207 
       
   208 #endif