Home | History | Annotate | Download | only in include
      1 /* ------------------------------------------------------------------
      2  * Copyright (C) 1998-2009 PacketVideo
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
     13  * express or implied.
     14  * See the License for the specific language governing permissions
     15  * and limitations under the License.
     16  * -------------------------------------------------------------------
     17  */
     18 /*  =====================================================================   */
     19 /*  File: LATMPayloadParser.h                                               */
     20 /*  Description:                                                            */
     21 /*                                                                          */
     22 /*      RTP packet payload parser.                                          */
     23 /*                                                                          */
     24 /*  Rev:   0.2                                                              */
     25 /*  =====================================================================   */
     26 /*                                                                          */
     27 /*  Revision History:                                                       */
     28 /*                                                                          */
     29 /*  Rev:                                                                    */
     30 /*  Date:                                                                   */
     31 /*  Description:                                                            */
     32 /*                                                                          */
     33 /* //////////////////////////////////////////////////////////////////////// */
     34 
     35 #ifndef _LATMPAYLOADPARSER_H_
     36 #define _LATMPAYLOADPARSER_H_
     37 
     38 #ifndef OSCL_BASE_H_INCLUDED
     39 #include "oscl_base.h"
     40 #endif
     41 #ifndef PVMF_MEDIA_DATA_H_INCLUDED
     42 #include "pvmf_media_data.h"
     43 #endif
     44 #ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
     45 #include "oscl_mem_mempool.h"
     46 #endif
     47 #ifndef PVMF_MEDIA_FRAG_GROUP_H_INCLUDED
     48 #include "pvmf_media_frag_group.h"
     49 #endif
     50 #ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
     51 #include "pvmf_simple_media_buffer.h"
     52 #endif
     53 
     54 
     55 //status return type used by PayloadParser class API, up to 16-bit map
     56 #define FRAME_ERROR                         0x10    //error during composing
     57 #define FRAME_INCOMPLETE                    0x01    //frame incomplete
     58 #define FRAME_COMPLETE                      0x80    //frame complete
     59 
     60 // Don't understand the organization of the status codes so using available bit
     61 #define FRAME_OUTPUTNOTAVAILABLE            0x20    //memory for parser output data not available
     62 
     63 
     64 
     65 // this is a structure i need to hold information used in demultiplexing
     66 typedef struct _streamMuxConfig
     67 {
     68     bool cpresent;
     69     uint32 audioMuxVersion;
     70     uint32 allStreamsSameTimeFraming;
     71     uint32 numSubFrames;
     72     uint32 frameLengthType;  // 0 == 1024 samples, 1 == 960 (not supported)
     73     uint32 bufferFullness;
     74     bool otherDataPresent;
     75     uint32 otherDataLenBits;
     76     bool crcCheckPresent;
     77     uint8 crcCheckSum;
     78 
     79     uint32 audioObjectType;
     80     uint32 samplingFrequency;
     81     uint32 channelConfiguration;
     82     /*  AAC+ data */
     83 
     84     int32 sbrPresentFlag;
     85     uint32 extensionAudioObjectType;
     86     uint32 extensionSamplingFrequencyIndex;
     87     uint32 extensionSamplingFrequency;
     88 
     89     // include this because the payload parser may need to deal with inline
     90     // audioSpecificConfigs and if it is the same as the current one, we dont
     91     // want to reset the decoder to the same settings..
     92     uint8 * audioSpecificConfigPtr;
     93     uint32 audioSpecificConfigSize;
     94 
     95     uint8 ** audioSpecificConfigPtrPtr;
     96     uint32 * audioSpecificConfigSizePtr;
     97 
     98     uint32 parseResult;
     99 } streamMuxConfig;
    100 
    101 
    102 //////////////////////////////////AAC LATM parser
    103 class PV_LATM_Parser
    104 {
    105     public:
    106 
    107         OSCL_IMPORT_REF PV_LATM_Parser();
    108         OSCL_IMPORT_REF ~PV_LATM_Parser();
    109 
    110         OSCL_IMPORT_REF uint8 compose(PVMFSharedMediaDataPtr&);
    111         OSCL_IMPORT_REF uint8* ParseStreamMuxConfig(uint8* decoderSpecificConfig, int32 * size);
    112 
    113         //added to return streammuxconfig
    114         streamMuxConfig *GetStreamMuxConfig()
    115         {
    116             return sMC;
    117         }
    118         PVMFSharedMediaDataPtr GetOutputBuffer()
    119         {
    120             return mediaDataOut;
    121         }
    122         OSCL_IMPORT_REF uint8 compose(uint8* aData, uint32 aDataLen, uint32 aTimestamp, uint32 aSeqNum, uint32 aMbit);
    123 
    124 
    125     private:
    126         uint8 composeSingleFrame(PVMFSharedMediaDataPtr&);
    127         uint8 composeMultipleFrame(PVMFSharedMediaDataPtr&);
    128         uint8 composeSingleFrame(uint8* aData, uint32 aDataLen, uint32 aTimestamp, uint32 aSeqNum, uint32 aMbit);
    129         uint8 composeMultipleFrame(uint8* aData, uint32 aDataLen, uint32 aTimestamp, uint32 aSeqNum, uint32 aMbit);
    130 
    131 
    132     private:
    133         uint32  last_timestamp;
    134         uint32  last_sequence_num;
    135         uint32  last_mbit;
    136         uint8*  next_frame;         //next audio data
    137         int8    frame;          // number of frames in this packet
    138         int16   offset;         //for multiple frame in a packet
    139         bool    framestart;     //start a frame yet
    140         int32   bufsize;        //original buffer size
    141         int32   framesize;  // current composing frame size
    142 
    143         int32   currLen;
    144         bool    firstBlock;
    145         int32   bytesRead;
    146         bool    myBool;
    147         int32   frameNum;
    148         int32   compositenumframes;
    149 
    150         //memory pool for output data
    151         //OsclRefCounterMemFrag memFragOut;
    152         PVMFSharedMediaDataPtr mediaDataOut;
    153 
    154         PVMFSimpleMediaBufferCombinedAlloc iMediaDataSimpleAlloc;
    155 
    156         // Memory pool for latm data
    157         OsclMemPoolFixedChunkAllocator iLATMDataMemPool;
    158 
    159         // Memory pool for simple media data
    160         OsclMemPoolFixedChunkAllocator iMediaDataMemPool;
    161 
    162 
    163         streamMuxConfig * sMC;
    164         uint8*  multiFrameBuf;
    165         int32     currSize;
    166         bool firstPacket;
    167         bool dropFrames;
    168         uint32  maxFrameSize;
    169         bool firstSMC;
    170         bool startedParsing;
    171         uint8* framePos;
    172         int32 frameCount;
    173 
    174         OsclErrorTrapImp* iOsclErrorTrapImp;
    175 
    176 };
    177 
    178 #endif // _LATMPAYLOADPARSER_H_
    179 
    180