// ****************** Copyright (c) 2013 by Gigaset Communications GmbH ******
// Filename : tdav_codec_fsl_amr_wrapper.h
// Owner    : Souparna Lodh [STC]
//-------------------------------------------------------------------------
// Defintion : FSL AMR-NB and AMR-WB codecs.
// Freescale Enhanced Software AMR codec wrapper Header
//-------------------------------------------------------------------------
// 30-07-2013, Gigaset Communications GmbH
// Added FSL AMR-NB and AMR-WB codec plugin to Doubango Framework
//*************************************************************************

/*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*	
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*	
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/

#ifndef _TDAV_CODEC_FSL_AMR_WRAPPER_H_
#define _TDAV_CODEC_FSL_AMR_WRAPPER_H_

#include "tsk_memory.h"
#include "tsk_debug.h"

//NB AMR
#include "nb_amr_dec_api.h"
#include "nb_amr_enc_api.h"
#include "nb_amr_common_api.h"

//WB AMR
#include "wbamr_common_interface.h"
#include "wbamr_dec_interface.h"
#include "wbamr_enc_interface.h"

#define FRAMESPERLOOP                   1
#define ENCORD_FRAME                    (1)

enum Mode {
	MR475 = 0,/* 4.75 kbps */
	MR515,    /* 5.15 kbps */
	MR59,     /* 5.90 kbps */
	MR67,     /* 6.70 kbps */
	MR74,     /* 7.40 kbps */
	MR795,    /* 7.95 kbps */
	MR102,    /* 10.2 kbps */
	MR122,    /* 12.2 kbps */
	MRDTX,    /* DTX       */
	N_MODES   /* Not Used  */
};

typedef enum
{
     E_AMRFF_Conformance = 0,
     E_AMRFF_MMS,
     E_AMRFF_IF1,
     E_AMRFF_IF2
} eAMRFrameFormatType;

typedef struct AMRDecWrapper_s {

    uint32_t nChannels;                      /** Number of channels */
    uint32_t nBitRate;                       /** Bit rate read only field */

    WBAMRD_Decoder_Config  *pWbAmrDecConfig;
    sAMRDDecoderConfigType *pNbAmrDecConfig;

    eAMRFrameFormatType amrFrameFormatType;

    int32_t  (*InstanceInit)(struct AMRDecWrapper_s *);
    int32_t  (*CodecInit)(struct AMRDecWrapper_s *);
    int32_t  (*InstanceDeInit)(struct AMRDecWrapper_s *);
    int32_t  (*decodeFrame)(struct AMRDecWrapper_s *, uint8_t *, uint8_t *, uint32_t, uint32_t *);
    uint32_t (*getFrameOutputSize)(struct AMRDecWrapper_s *);
    uint32_t (*getBitRate)(struct AMRDecWrapper_s *, uint32_t);

}AMRDecWrapper_t;

typedef struct AMREncWrapper_s {

    WBAMRE_Encoder_Config  *pWbAmrEncConfig;
    sAMREEncoderConfigType *pNbAmrEncConfig;

    eAMRFrameFormatType amrFrameFormatType;

    int32_t  (*InstanceInit)(struct AMREncWrapper_s *);
    int32_t  (*CodecInit)(struct AMREncWrapper_s *);
    int32_t  (*InstanceDeInit)(struct AMREncWrapper_s * );
    int32_t  (*encodeFrame)(struct AMREncWrapper_s *, uint8_t *, enum Mode, uint8_t *, uint32_t * ,uint32_t *);
    uint32_t (*getFrameOutputSize)(struct AMREncWrapper_s *);
    uint32_t (*getBitRate)(struct AMREncWrapper_s *, uint32_t );

}AMREncWrapper_t;

AMREncWrapper_t *CreateAMREncWrapper(tsk_bool_t nbAMR);
AMRDecWrapper_t *CreateAMRDecWrapper(tsk_bool_t nbAMR);

void DeleteAMREncWrapper(AMREncWrapper_t *pEncWrapper);
void DeleteAMRDecWrapper(AMRDecWrapper_t *pDecWrapper);

#endif //_TDAV_CODEC_FSL_AMR_WRAPPER_H_

