• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef  __HI_COMM_AENC_H__
17 #define  __HI_COMM_AENC_H__
18 
19 #include "hi_type.h"
20 #include "hi_common.h"
21 #include "hi_comm_aio.h"
22 
23 
24 #ifdef __cplusplus
25 #if __cplusplus
26 extern "C" {
27 #endif
28 #endif /* End of #ifdef __cplusplus */
29 
30 typedef struct hiAENC_ATTR_G711_S {
31     HI_U32 resv;            /* reserve item */
32 } AENC_ATTR_G711_S;
33 
34 typedef struct hiAENC_ATTR_G726_S {
35     G726_BPS_E enG726bps;
36 } AENC_ATTR_G726_S;
37 
38 typedef struct hiAENC_ATTR_ADPCM_S {
39     ADPCM_TYPE_E enADPCMType;
40 } AENC_ATTR_ADPCM_S;
41 
42 typedef struct hiAENC_ATTR_LPCM_S {
43     HI_U32 resv;            /* reserve item */
44 } AENC_ATTR_LPCM_S;
45 
46 typedef struct hiAENC_ENCODER_S {
47     PAYLOAD_TYPE_E  enType;
48     HI_U32          u32MaxFrmLen;
49     HI_CHAR         aszName[17];    /* encoder type, be used to print proc information, 17: length */
50     /* pEncoder is the handle to control the encoder */
51     HI_S32          (*pfnOpenEncoder)(HI_VOID *pEncoderAttr, HI_VOID **ppEncoder);
52     HI_S32          (*pfnEncodeFrm)(HI_VOID *pEncoder, const AUDIO_FRAME_S *pstData,
53                         HI_U8 *pu8Outbuf, HI_U32 *pu32OutLen);
54     HI_S32          (*pfnCloseEncoder)(HI_VOID *pEncoder);
55 } AENC_ENCODER_S;
56 
57 typedef struct hiAENC_CHN_ATTR_S {
58     PAYLOAD_TYPE_E      enType;
59     HI_U32              u32PtNumPerFrm;
60     HI_U32              u32BufSize;      /* buf size [2~MAX_AUDIO_FRAME_NUM] */
61     HI_VOID ATTRIBUTE   *pValue;  /* point to attribute of definite audio encoder */
62 } AENC_CHN_ATTR_S;
63 
64 typedef enum hiEN_AENC_ERR_CODE_E {
65     AENC_ERR_ENCODER_ERR     = 64,
66     AENC_ERR_VQE_ERR         = 65,
67 } EN_AENC_ERR_CODE_E;
68 
69 
70 /* invalid device ID */
71 #define HI_ERR_AENC_INVALID_DEVID     HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_DEVID)
72 /* invalid channel ID */
73 #define HI_ERR_AENC_INVALID_CHNID     HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_CHNID)
74 /* at lease one parameter is illagal ,eg, an illegal enumeration value  */
75 #define HI_ERR_AENC_ILLEGAL_PARAM     HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, EN_ERR_ILLEGAL_PARAM)
76 /* channel exists */
77 #define HI_ERR_AENC_EXIST             HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, EN_ERR_EXIST)
78 /* channel unexists */
79 #define HI_ERR_AENC_UNEXIST           HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, EN_ERR_UNEXIST)
80 /* using a NULL point */
81 #define HI_ERR_AENC_NULL_PTR          HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, EN_ERR_NULL_PTR)
82 /* try to enable or initialize system,device or channel, before configing attribute */
83 #define HI_ERR_AENC_NOT_CONFIG        HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_CONFIG)
84 /* operation is not supported by NOW */
85 #define HI_ERR_AENC_NOT_SUPPORT       HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_SUPPORT)
86 /* operation is not permitted ,eg, try to change static attribute */
87 #define HI_ERR_AENC_NOT_PERM          HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_PERM)
88 /* failure caused by malloc memory */
89 #define HI_ERR_AENC_NOMEM             HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, EN_ERR_NOMEM)
90 /* failure caused by malloc buffer */
91 #define HI_ERR_AENC_NOBUF             HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, EN_ERR_NOBUF)
92 /* no data in buffer */
93 #define HI_ERR_AENC_BUF_EMPTY         HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_EMPTY)
94 /* no buffer for new data */
95 #define HI_ERR_AENC_BUF_FULL          HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_FULL)
96 /* system is not ready,had not initialed or loaded */
97 #define HI_ERR_AENC_SYS_NOTREADY      HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, EN_ERR_SYS_NOTREADY)
98 /* encoder internal err */
99 #define HI_ERR_AENC_ENCODER_ERR       HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, AENC_ERR_ENCODER_ERR)
100 /* vqe internal err */
101 #define HI_ERR_AENC_VQE_ERR       HI_DEF_ERR(HI_ID_AENC, EN_ERR_LEVEL_ERROR, AENC_ERR_VQE_ERR)
102 
103 
104 #ifdef __cplusplus
105 #if __cplusplus
106 }
107 #endif
108 #endif /* End of #ifdef __cplusplus */
109 
110 #endif /* End of #ifndef __HI_COMM_AENC_H__ */
111 
112