1 /* GPL-2.0 WITH Linux-syscall-note OR Apache 2.0 */ 2 /* Copyright (c) 2021 Fuzhou Rockchip Electronics Co., Ltd */ 3 4 #ifndef INCLUDE_RT_MPI_RK_COMM_ADEC_H_ 5 #define INCLUDE_RT_MPI_RK_COMM_ADEC_H_ 6 7 #include "rk_type.h" 8 #include "rk_common.h" 9 #include "rk_comm_mb.h" 10 #include "rk_comm_aio.h" 11 12 #ifdef __cplusplus 13 #if __cplusplus 14 extern "C" { 15 #endif 16 #endif /* End of #ifdef __cplusplus */ 17 18 typedef enum rkADEC_MODE_E { 19 /* 20 * require input is valid dec pack(a complete frame encode result), 21 * e.g.the stream get from AENC is a valid dec pack, the stream know 22 * actually pack len from file is also a dec pack. 23 * this mode is high-performative*/ 24 ADEC_MODE_PACK = 0, 25 26 /* 27 * input is stream,low-performative, if you couldn't find out whether 28 * a stream is vaild dec pack,you could use this mode 29 */ 30 ADEC_MODE_STREAM, 31 32 ADEC_MODE_BUTT 33 } ADEC_MODE_E; 34 35 typedef struct rkADEC_ATTR_CODEC_S { 36 RK_CODEC_ID_E enType; 37 RK_U32 u32Channels; 38 RK_U32 u32SampleRate; 39 RK_U32 u32BitPerCodedSample; /* codewords */ 40 RK_U32 u32Bitrate; 41 42 RK_VOID *pExtraData; 43 RK_U32 u32ExtraDataSize; 44 45 RK_U32 u32Resv[4]; /* resv for user */ 46 RK_VOID *pstResv; /* resv for user */ 47 } ADEC_ATTR_CODEC_S; 48 49 typedef struct rkADEC_FRAME_INFO_S { 50 RK_U32 u32SampleRate; 51 RK_U32 u32Channels; 52 RK_U64 u64ChnLayout; 53 AUDIO_BIT_WIDTH_E enBitWidth; 54 RK_U32 resv[2]; 55 } ADEC_FRAME_INFO_S; 56 57 typedef struct rkADEC_CH_ATTR_S { 58 RK_CODEC_ID_E enType; /* audio codec id */ 59 ADEC_MODE_E enMode; /* decode mode */ 60 RK_U32 u32BufCount; /* decode buffer count */ 61 RK_U32 u32BufSize; /* decode buffer size(buffer size to store pcm data) */ 62 63 ADEC_ATTR_CODEC_S stCodecAttr; 64 } ADEC_CHN_ATTR_S; 65 66 typedef struct rkADEC_CH_STATE_S { 67 RK_BOOL bEndOfStream; /* EOS flag */ 68 RK_U32 u32BufferFrmNum; /* total number of channel buffer */ 69 RK_U32 u32BufferFreeNum; /* free number of channel buffer */ 70 RK_U32 u32BufferBusyNum; /* busy number of channel buffer */ 71 } ADEC_CHN_STATE_S; 72 73 typedef enum rkEN_ADEC_ERR_CODE_E { 74 ADEC_ERR_DECODER_ERR = 64, 75 ADEC_ERR_BUF_LACK, 76 ADEC_ERR_REGISTER_ERR, 77 } RK_ADEC_ERR_CODE_E; 78 79 typedef struct rkADEC_DECODER_S { 80 RK_CODEC_ID_E enType; 81 RK_UCHAR aszName[17]; 82 // open decoder 83 RK_S32 (*pfnOpenDecoder)(RK_VOID *pDecoderAttr, RK_VOID **ppDecoder); 84 RK_S32 (*pfnDecodeFrm)(RK_VOID *pDecoder, RK_VOID *pParam); 85 // get audio frames infor 86 RK_S32 (*pfnGetFrmInfo)(RK_VOID *pDecoder, RK_VOID *pInfo); 87 // close audio decoder 88 RK_S32 (*pfnCloseDecoder)(RK_VOID *pDecoder); 89 // reset audio decoder 90 RK_S32 (*pfnResetDecoder)(RK_VOID *pDecoder); 91 } ADEC_DECODER_S; 92 93 /* result of register ADEC */ 94 typedef enum rkADEC_DECODER_RESULT { 95 ADEC_DECODER_OK = RK_SUCCESS, 96 ADEC_DECODER_TRY_AGAIN, 97 ADEC_DECODER_ERROR, 98 ADEC_DECODER_EOS, 99 } ADEC_DECODER_RESULT; 100 101 /* invlalid device ID */ 102 #define RK_ERR_ADEC_INVALID_DEVID RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, RK_ERR_INVALID_DEVID) 103 /* invlalid channel ID */ 104 #define RK_ERR_ADEC_INVALID_CHNID RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, RK_ERR_INVALID_CHNID) 105 /* at lease one parameter is illagal ,eg, an illegal enumeration value */ 106 #define RK_ERR_ADEC_ILLEGAL_PARAM RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, RK_ERR_ILLEGAL_PARAM) 107 /* channel exists */ 108 #define RK_ERR_ADEC_EXIST RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, RK_ERR_EXIST) 109 /* channel unexists */ 110 #define RK_ERR_ADEC_UNEXIST RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, RK_ERR_UNEXIST) 111 /* using a NULL point */ 112 #define RK_ERR_ADEC_NULL_PTR RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, RK_ERR_NULL_PTR) 113 /* try to enable or initialize system,device or channel, before configing attribute */ 114 #define RK_ERR_ADEC_NOT_CONFIG RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_CONFIG) 115 /* operation is not supported by NOW */ 116 #define RK_ERR_ADEC_NOT_SUPPORT RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_SUPPORT) 117 /* operation is not permitted ,eg, try to change stati attribute */ 118 #define RK_ERR_ADEC_NOT_PERM RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_PERM) 119 /* failure caused by malloc memory */ 120 #define RK_ERR_ADEC_NOMEM RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, RK_ERR_NOMEM) 121 /* failure caused by malloc buffer */ 122 #define RK_ERR_ADEC_NOBUF RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, RK_ERR_NOBUF) 123 /* no data in buffer */ 124 #define RK_ERR_ADEC_BUF_EMPTY RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, RK_ERR_BUF_EMPTY) 125 /* no buffer for new data */ 126 #define RK_ERR_ADEC_BUF_FULL RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, RK_ERR_BUF_FULL) 127 /* system is not ready,had not initialed or loaded*/ 128 #define RK_ERR_ADEC_SYS_NOTREADY RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, RK_ERR_NOTREADY) 129 /* decoder internal err */ 130 #define RK_ERR_ADEC_DECODER_ERR RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, ADEC_ERR_DECODER_ERR) 131 /* input buffer not enough to decode one frame */ 132 #define RK_ERR_ADEC_BUF_LACK RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, ADEC_ERR_BUF_LACK) 133 /* register ADec fail */ 134 #define RK_ERR_ADEC_REGISTER_ERR RK_DEF_ERR(RK_ID_ADEC, RK_ERR_LEVEL_ERROR, ADEC_ERR_REGISTER_ERR) 135 136 137 #ifdef __cplusplus 138 #if __cplusplus 139 } 140 #endif 141 #endif /* End of #ifdef __cplusplus */ 142 143 #endif /* End of #ifndef INCLUDE_RT_MPI_RK_COMM_ADEC_H_ */ 144 145