Esempio n. 1
0
bool RTCP_SR::set_max_report_blocks(uint new_max_report_blocks)
{

    if (additional_reports)
    {
        // reports array already exists
        if (new_max_report_blocks > max_report_blocks)
        {
            // only update max if greater than old max
            max_report_blocks = new_max_report_blocks;
            if (new_max_report_blocks > NUM_PREALLOCATED_RTCP_SR_REPORT_BLOCKS)
            {
                // free current additional reports and allocate new array
                delete[] additional_reports;
                additional_reports = OSCL_ARRAY_NEW(RTCP_ReportBlock, new_max_report_blocks - NUM_PREALLOCATED_RTCP_SR_REPORT_BLOCKS);
            }
        }
    }
    else if (new_max_report_blocks > NUM_PREALLOCATED_RTCP_SR_REPORT_BLOCKS)
    {
        // allocate additional_reports array
        additional_reports = OSCL_ARRAY_NEW(RTCP_ReportBlock, new_max_report_blocks - NUM_PREALLOCATED_RTCP_SR_REPORT_BLOCKS);
        max_report_blocks = new_max_report_blocks;
    }

    return true;

}
Esempio n. 2
0
OSCL_EXPORT_REF RTCP_ReportBlock* RTCP_RR::get_report_block(uint index)
{


    if (index >= max_report_blocks)
    {
        return NULL;
    }

    if (index >= num_report_blocks)
    {
        num_report_blocks = index + 1;
    }

    if (index < NUM_PREALLOCATED_RTCP_RR_REPORT_BLOCKS)
    {
        return preallocated_reports + index;
    }

    if (!additional_reports)
    {

        additional_reports = OSCL_ARRAY_NEW(RTCP_ReportBlock, max_report_blocks - NUM_PREALLOCATED_RTCP_RR_REPORT_BLOCKS);
    }

    return additional_reports + (index - NUM_PREALLOCATED_RTCP_RR_REPORT_BLOCKS);

}
Esempio n. 3
0
bool RTCP_SDES::add_chunk(const SDES_chunk& chunk)
{

    const uint SDES_ARRAY_INCREMENT = 10;

    if (chunk_count > max_chunks)
    {
        // allocate more
        set_max_chunks(max_chunks + SDES_ARRAY_INCREMENT);
    }

    if (chunk_count >= NUM_PREALLOCATED_RTCP_CHUNKS)
    {
        if (!additional_chunks)
        {
            additional_chunks = OSCL_ARRAY_NEW(SDES_chunk, max_chunks - NUM_PREALLOCATED_RTCP_CHUNKS);
        }
        additional_chunks[chunk_count - NUM_PREALLOCATED_RTCP_CHUNKS] = chunk;
    }
    else
    {
        chunk_array[chunk_count] = chunk;
    }

    ++chunk_count;
    return true;

}
Esempio n. 4
0
bool SDES_chunk::add_item(const SDES_item& item)
{

    const uint SDES_ARRAY_INCREMENT = 10;

    if (num_sdes_items > max_sdes_items)
    {
        // allocate more
        set_max_items(max_sdes_items + SDES_ARRAY_INCREMENT);
    }

    if (num_sdes_items >= NUM_PREALLOCATED_RTCP_CHUNK_ITEMS)
    {
        if (!additional_items)
        {
            additional_items = OSCL_ARRAY_NEW(SDES_item, max_sdes_items - NUM_PREALLOCATED_RTCP_CHUNK_ITEMS);
        }
        additional_items[num_sdes_items - NUM_PREALLOCATED_RTCP_CHUNK_ITEMS] = item;
        chunk_size += item.content.len + 2;
    }
    else
    {

        chunk_items[num_sdes_items] = item;
        chunk_size += item.content.len + 2;
    }

    ++num_sdes_items;
    return true;

}
Esempio n. 5
0
bool RTCP_SR::set_report_block(uint index, const RTCP_ReportBlock& report_block)
{
    if (index >= max_report_blocks)
    {
        return false;
    }

    if (index < NUM_PREALLOCATED_RTCP_SR_REPORT_BLOCKS)
    {

        preallocated_reports[index] = report_block;

    }
    else if (!additional_reports)
    {
        // allocate the additional reports array
        additional_reports = OSCL_ARRAY_NEW(RTCP_ReportBlock, max_report_blocks - NUM_PREALLOCATED_RTCP_SR_REPORT_BLOCKS);
        additional_reports[index - NUM_PREALLOCATED_RTCP_SR_REPORT_BLOCKS] =
            report_block;
    }
    else
    {

        additional_reports[index - NUM_PREALLOCATED_RTCP_SR_REPORT_BLOCKS] =
            report_block;

    }

    num_report_blocks = index + 1;
    return true;
}
OSCL_EXPORT_REF PVDlCfgFile::PVDlCfgFile()
    : iTmpBuf(NULL)
    , iFile(NULL)
    , iProxyPort(0)
    , iMaxAllowedFileSize(0)
    , iOverallFileSize(0)
    , iCurrentFileSize(0)
    , iHasContentLength(1)
    , iConnectTimeout(0)
    , iSendTimeout(0)
    , iRecvTimeout(0)
    , iRangeStartTime(0)
    , iMagic32(0x4a6a446c)
    , iVersion(1)
    , iFlag(0)
    , iTotalFixedHeaderSize(PVDLCONFIGFILE_FIXED_HEADER_SIZE)
    , PVDL_CFG_FILE_CACHE_BUF(PVDLCONFIGFILE_FILE_CACHE_BUFFER_SIZE)
    , iLogger(NULL)
    , bIsNewSession(true)
    , iHttpVersionNum(PDL_HTTP_VERSION_NUMBER) // assume 0 => Http 1.0 ; 1 => Http 1.1
    , iDisableHeadRequest(false)
{
    int32 err;
    OSCL_TRY(err,
             iFileServer.Connect();
             iTmpBuf = OSCL_ARRAY_NEW(uint8, iTotalFixedHeaderSize);
             iLogger = PVLogger::GetLoggerObject("PVDlCfgFile");
             iExtensionHeaderKeys.reserve(PVDLCONFIGFILE_VECTOR_RESERVE_NUMBER);
             iExtensionHeaderValues.reserve(PVDLCONFIGFILE_VECTOR_RESERVE_NUMBER);
             iMethodMaskForExtensionHeaders.reserve(PVDLCONFIGFILE_VECTOR_RESERVE_NUMBER);
             iExtensionHeadersPurgeOnRedirect.reserve(PVDLCONFIGFILE_VECTOR_RESERVE_NUMBER);
            );
/*
-----------------------------------------------------------------------------

    CDecoder_AMR_NB

    StartL

    Start decoder object. Initialize codec status.

    Parameters:     none

    Return Values:  status

-----------------------------------------------------------------------------
*/
OSCL_EXPORT_REF int32 CDecoder_AMR_NB::StartL(tPVAmrDecoderExternal * pExt,
        bool aAllocateInputBuffer,
        bool aAllocateOutputBuffer)
{

    if (aAllocateInputBuffer)
    {
        iInputBuf = OSCL_ARRAY_NEW(int16, MAX_NUM_PACKED_INPUT_BYTES);
        if (iInputBuf == NULL)
        {
            return KCAI_CODEC_INIT_FAILURE;
        }
    }
    else
    {
        iInputBuf = NULL;
    }
    pExt->pInputBuffer = (uint8 *)iInputBuf;

    if (aAllocateOutputBuffer)
    {
        iOutputBuf = OSCL_ARRAY_NEW(int16, L_FRAME);

        if (iOutputBuf == NULL)
        {
            return KCAI_CODEC_INIT_FAILURE;
        }
    }
    else
    {
        iOutputBuf = NULL;
    }
    pExt->pOutputBuffer = iOutputBuf;

    pExt->samplingRate = 8000;
    pExt->desiredChannels = 1;

    pExt->reset_flag = 0;
    pExt->reset_flag_old = 1;
    pExt->mode_old = 0;

    return GSMInitDecode(&iDecState, (int8*)"Decoder");
}
Esempio n. 8
0
SDES_chunk* RTCP_SDES::get_chunk(uint chunk_index)
{
    if (chunk_index >= max_chunks)
    {
        return NULL;
    }

    if (chunk_index >= chunk_count)
    {
        chunk_count = chunk_index + 1;
    }

    if (chunk_index >= NUM_PREALLOCATED_RTCP_CHUNKS)
    {
        if (!additional_chunks)
        {
            additional_chunks = OSCL_ARRAY_NEW(SDES_chunk, max_chunks - NUM_PREALLOCATED_RTCP_CHUNKS);
        }

        return additional_chunks + (chunk_index - NUM_PREALLOCATED_RTCP_CHUNKS);
    }

    return chunk_array + chunk_index;
}
Esempio n. 9
0
void RTCP_SDES::set_max_chunks(uint new_max_chunks)
{

    if (new_max_chunks > max_chunks)
    {
        // update sdes items
        max_chunks = new_max_chunks;

        if (new_max_chunks > NUM_PREALLOCATED_RTCP_CHUNKS)
        {
            int32 extra_chunks = new_max_chunks - NUM_PREALLOCATED_RTCP_CHUNKS;

            // now allocate the extra array
            SDES_chunk* new_additional = OSCL_ARRAY_NEW(SDES_chunk, extra_chunks);

            if (additional_chunks)
            {
                if (chunk_count >  NUM_PREALLOCATED_RTCP_CHUNKS)
                {
                    // copy old additional to the new array
                    for (uint ii = 0; ii < chunk_count -
                            NUM_PREALLOCATED_RTCP_CHUNKS; ++ii)
                    {
                        new_additional[ii] = additional_chunks[ii];
                    }
                }
                delete[] additional_chunks;
            }

            additional_chunks = new_additional;

        }

    }

}
Esempio n. 10
0
SDES_item* SDES_chunk::get_item(uint item_index)
{
    if (item_index >= max_sdes_items)
    {
        return NULL;
    }

    if (item_index >= num_sdes_items)
    {
        num_sdes_items = item_index + 1;
    }

    if (item_index >= NUM_PREALLOCATED_RTCP_CHUNK_ITEMS)
    {
        if (!additional_items)
        {
            additional_items = OSCL_ARRAY_NEW(SDES_item, max_sdes_items - NUM_PREALLOCATED_RTCP_CHUNK_ITEMS);
        }

        return additional_items + (item_index - NUM_PREALLOCATED_RTCP_CHUNK_ITEMS);
    }

    return chunk_items + item_index;
}
Esempio n. 11
0
void SDES_chunk::set_max_items(uint new_max_items)
{

    if (new_max_items > max_sdes_items)
    {
        // update sdes items
        max_sdes_items = new_max_items;

        if (new_max_items > NUM_PREALLOCATED_RTCP_CHUNK_ITEMS)
        {
            int32 extra_items = new_max_items - NUM_PREALLOCATED_RTCP_CHUNK_ITEMS;

            // now allocate the extra array
            SDES_item* new_additional = OSCL_ARRAY_NEW(SDES_item, extra_items);

            if (additional_items)
            {
                if (num_sdes_items >  NUM_PREALLOCATED_RTCP_CHUNK_ITEMS)
                {
                    // copy old additional to the new array
                    for (uint ii = 0; ii < num_sdes_items -
                            NUM_PREALLOCATED_RTCP_CHUNK_ITEMS; ++ii)
                    {
                        new_additional[ii] = additional_items[ii];
                    }
                }
                delete[] additional_items;
            }

            additional_items = new_additional;

        }

    }

}
Esempio n. 12
0
OSCL_EXPORT_REF int32 CDecoder_AAC::StartL(tPVMP4AudioDecoderExternal * pExt,
        uint8  num_channels,
        bool aAllocateInputBuffer,
        bool aAllocateOutputBuffer,
        bool aAacplusEnabler)
{
    iFirstFrame = true;

    iAllocateInputBuffer = aAllocateInputBuffer;
    iAllocateOutputBuffer = aAllocateOutputBuffer;

    if (iAllocateInputBuffer)
    {
        iInputBuf = OSCL_ARRAY_NEW(uint8, KAAC_MAX_STREAMING_BUFFER_SIZE);
        if (iInputBuf == NULL)
        {
            return KCAI_CODEC_INIT_FAILURE;
        }
        pExt->pInputBuffer = iInputBuf;
        pExt->inputBufferMaxLength = KAAC_MAX_STREAMING_BUFFER_SIZE;
    }
    else
    {
        pExt->pInputBuffer = NULL;
        pExt->inputBufferMaxLength = 0;
    }

    if (iAllocateOutputBuffer)
    {
#ifdef AAC_PLUS
        iOutputBuf = OSCL_ARRAY_NEW(int16, 4096);
#else
        iOutputBuf = OSCL_ARRAY_NEW(int16, 2048);
#endif

        if (iOutputBuf == NULL)
        {
            return KCAI_CODEC_INIT_FAILURE;
        }

        pExt->pOutputBuffer = iOutputBuf;
#ifdef AAC_PLUS
        pExt->pOutputBuffer_plus = &iOutputBuf[2048];
#else
        pExt->pOutputBuffer_plus = NULL;
#endif
    }
    else
    {
        pExt->pOutputBuffer = NULL;
        pExt->pOutputBuffer_plus = NULL;
    }

    pExt->desiredChannels          = num_channels;
    pExt->inputBufferCurrentLength = 0;
    pExt->outputFormat             = OUTPUTFORMAT_16PCM_INTERLEAVED;
    pExt->repositionFlag           = TRUE;
    pExt->aacPlusEnabled           = aAacplusEnabler;  /* Dynamically enable AAC+ decoding */
    pExt->inputBufferUsedLength    = 0;
    pExt->remainderBits            = 0;

    int32 memreq =  PVMP4AudioDecoderGetMemRequirements();

    pMem = OSCL_ARRAY_NEW(uint8 , memreq);

    if (pMem == 0)
    {
        return KCAI_CODEC_NO_MEMORY;
    }

    return SUCCESS;
}
Esempio n. 13
0
OSCL_EXPORT_REF int32 CDecoder_AAC::StartL(tPVMP4AudioDecoderExternal * pExt,
        uint8  num_channels,
        bool aAllocateInputBuffer,
        bool aAllocateOutputBuffer,
        Int upsamplingFactor,
        Int samp_rate,
        tMP4AudioObjectType  audioObjectType)
{
    iFirstFrame = true;

    iAllocateInputBuffer = aAllocateInputBuffer;
    iAllocateOutputBuffer = aAllocateOutputBuffer;

    if (iAllocateInputBuffer)
    {
        iInputBuf = OSCL_ARRAY_NEW(uint8, KAAC_MAX_STREAMING_BUFFER_SIZE);
        if (iInputBuf == NULL)
        {
            return KCAI_CODEC_INIT_FAILURE;
        }
        pExt->pInputBuffer = iInputBuf;
        pExt->inputBufferMaxLength = KAAC_MAX_STREAMING_BUFFER_SIZE;
    }
    else
    {
        pExt->pInputBuffer = NULL;
        pExt->inputBufferMaxLength = 0;
    }

    if (iAllocateOutputBuffer)
    {
#ifdef AAC_PLUS
        iOutputBuf = OSCL_ARRAY_NEW(int16, 4096);
#else
        iOutputBuf = OSCL_ARRAY_NEW(int16, 2048);
#endif

        if (iOutputBuf == NULL)
        {
            return KCAI_CODEC_INIT_FAILURE;
        }

        pExt->pOutputBuffer = iOutputBuf;
#ifdef AAC_PLUS
        pExt->pOutputBuffer_plus = &iOutputBuf[2048];
#else
        pExt->pOutputBuffer_plus = NULL;
#endif
    }
    else
    {
        pExt->pOutputBuffer = NULL;
        pExt->pOutputBuffer_plus = NULL;
    }

    pExt->desiredChannels          = num_channels;
    pExt->inputBufferCurrentLength = 0;
    pExt->outputFormat             = OUTPUTFORMAT_16PCM_INTERLEAVED;
    pExt->repositionFlag           = TRUE;
    pExt->inputBufferUsedLength    = 0;
    pExt->remainderBits            = 0;

    int32 memreq =  PVMP4AudioDecoderGetMemRequirements();

    pMem = OSCL_ARRAY_NEW(uint8 , memreq);

    if (pMem == 0)
    {
        return KCAI_CODEC_NO_MEMORY;
    }

    if (PVMP4AudioDecoderInitLibrary(pExt, pMem) != 0)
    {
        return(KCAI_CODEC_INIT_FAILURE);
    }


    if (PVMP4SetAudioConfig(pExt,
                            pMem,
                            upsamplingFactor,
                            samp_rate,
                            num_channels,
                            audioObjectType) != SUCCESS)
    {
        return KCAI_CODEC_INIT_FAILURE;
    }

    iNumSamplesPerFrame = KAAC_NUM_SAMPLES_PER_FRAME;

    pExt->desiredChannels = pExt->encodedChannels;

    iFirstFrame = false;

    return SUCCESS;
}
/**************************************************************
nRotation : Rotation direction is defined at run time
            0 -- No rotation
            1 -- 90 degree counter clockwise (default)
            2 -- 180 degree rotation (upside-down)
            3 -- 90 degree clockwise
            -1 -- flip left-right
            -2 -- flip and rotate 90 degree cnt clk
            -3 -- flip and rotate 180 degree
            -4 -- flip and rotate 270 degree
**************************************************************/
int32 ColorConvertBase::Init(int32 Src_width, int32 Src_height, int32 Src_pitch, int32 Dst_width, int32 Dst_height, int32 Dst_pitch, int32 nRotation)
{

    /* check the followings, must be multiple of 2 */
    if ((Src_pitch&1) || (Dst_pitch&1) || (Dst_height&1) || (Src_height&1) || (Src_width&1))
    {
        return 0;
    }

    _mInitialized = false;
    _mSrc_mheight = Src_height;
    _mRotation  =   nRotation;
    _mDisp.src_pitch = _mSrc_pitch  =   Src_pitch;
    _mDisp.dst_pitch = _mDst_pitch  =   Dst_pitch;
    _mDisp.src_width = _mSrc_width  =   Src_width;
    _mDisp.src_height = _mSrc_height =  Src_height;
    _mDisp.dst_width = _mDst_width  =   Dst_width;
    _mDisp.dst_height = _mDst_height =  Dst_height;

    /* Check support for rotation */
    if (_mRotation&0x1)
    {
        if (!(GetCapability()&CCSUPPORT_ROTATION))
        {
            return 0;
        }
    }

    _mIsFlip = false;
    if (_mRotation & 0x4)
    {
        _mIsFlip = true;
        _mRotation -= 4;
    }

    //For now, we only support the zoom ratio <=3
    if (_mRotation&0x1)
    {
        if (((Src_width*3) < Dst_height) || ((Src_height*3) < Dst_width))
        {
            return 0;
        }
    }
    else
    {
        if (((Src_width*3) < Dst_width) || ((Src_height*3) < Dst_height))
        {
            return 0;
        }
    }

    if (_mRowPix)
    {
        OSCL_ARRAY_DELETE(_mRowPix);
    }
    if (_mColPix)
    {
        OSCL_ARRAY_DELETE(_mColPix);
    }
    _mRowPix = NULL;
    _mColPix = NULL;

    if ((_mRotation&0x1) == 0)
    { /* no rotation */
        if ((_mDst_width != _mSrc_width) || (_mDst_height != _mSrc_height))
        { /* scaling */
            //calulate the Row
            int32 leavecode = 0;
            OSCL_TRY(leavecode,
                     _mRowPix = OSCL_ARRAY_NEW(uint8, _mSrc_width);
                     _mColPix = OSCL_ARRAY_NEW(uint8, _mSrc_height);
                    );
            OSCL_FIRST_CATCH_ANY(leavecode,
                                 if (_mRowPix)
        {
            OSCL_ARRAY_DELETE(_mRowPix);
            }
            if (_mColPix)
        {
            OSCL_ARRAY_DELETE(_mColPix);
            }
            _mRowPix = NULL;
            _mColPix = NULL;
            return 0;
                                );
OSCL_EXPORT_REF int32 GetActualAacConfig(uint8* aConfigHeader,
        uint8* aAudioObjectType,
        int32* aConfigHeaderSize,
        uint8* SamplingRateIndex,
        uint32* NumChannels)
{

    tPVMP4AudioDecoderExternal * iAACDecExt = NULL;
    UInt           initialUsedBits;  /* Unsigned for C55x */
    tDec_Int_File *pVars;            /* Helper pointer */
    MC_Info       *pMC_Info;         /* Helper pointer */


    Int            status = ERROR_BUFFER_OVERRUN;



    /*
     *  Allocate memory to decode one AAC frame
     */

    if (!iAACDecExt)
    {
        iAACDecExt = new tPVMP4AudioDecoderExternal;
        if (!iAACDecExt)
        {
            return 1;
        }
        iAACDecExt->inputBufferCurrentLength = 0;
    }

    iAACDecExt->pInputBuffer = aConfigHeader;
    iAACDecExt->inputBufferMaxLength = PVMP4AUDIODECODER_INBUFSIZE;


    iAACDecExt->inputBufferUsedLength    = 0;
    iAACDecExt->remainderBits            = 0;

    int32 memreq =  PVMP4AudioDecoderGetMemRequirements();

    uint8 *pMem = OSCL_ARRAY_NEW(uint8 , memreq);

    if (pMem == 0)
    {
        return KCODEC_INIT_FAILURE;
    }

    if (PVMP4AudioDecoderInitLibrary(iAACDecExt, pMem) != 0)
    {
        return KCODEC_INIT_FAILURE;
    }

    iAACDecExt->inputBufferCurrentLength =  *aConfigHeaderSize;


    /*
     * Initialize "helper" pointers to existing memory.
     */

    pVars = (tDec_Int_File *)pMem;


    pMC_Info = &pVars->mc_info;



    /*
     * Translate input buffer variables.
     */
    pVars->inputStream.pBuffer = iAACDecExt->pInputBuffer;

    pVars->inputStream.availableBits =
        (UInt)(iAACDecExt->inputBufferCurrentLength << INBUF_ARRAY_INDEX_SHIFT);

    initialUsedBits =
        (UInt)((iAACDecExt->inputBufferUsedLength << INBUF_ARRAY_INDEX_SHIFT) +
               iAACDecExt->remainderBits);

    pVars->inputStream.inputBufferCurrentLength =
        (UInt)iAACDecExt->inputBufferCurrentLength;

    pVars->inputStream.usedBits = initialUsedBits;

    pVars->aacPlusEnabled = true;   /* Always enable aacplus decoding */


    if (initialUsedBits <= pVars->inputStream.availableBits)
    {
        /*
         * Buffer is not overrun, then
         * decode the AudioSpecificConfig() structure
         */
        status = get_audio_specific_config(pVars);

    }


    byte_align(&pVars->inputStream);

    *aConfigHeaderSize = (Int32)((pVars->inputStream.usedBits) >> 3);


    *SamplingRateIndex = pVars->prog_config.sampling_rate_idx;

    *NumChannels = pVars->mc_info.nch;

    *aAudioObjectType = pVars->mc_info.audioObjectType;

    /*
     *  Set parameters  based on the explicit information from the
     *  audio specific config
     */

    if (pVars->mc_info.sbrPresentFlag)
    {
        if (pVars->mc_info.psPresentFlag)
        {
            *NumChannels += 1;
        }
    }


    pVars->status = status;

    /*
     *  Clear allocated memory
     */
    if (pMem != NULL)
    {
        OSCL_ARRAY_DELETE(pMem);
        pMem = NULL;
    }

    if (iAACDecExt)
    {
        OSCL_DELETE(iAACDecExt);
        iAACDecExt = NULL;
    }

    return status;
}