blob: 4ba5b30e1d0530cfd95377643ca617103dafb08f [file] [log] [blame]
hong.liucd370792025-05-28 06:29:19 -07001/**
2* @file : gsw_voice_interface.h
3* @brief : voice mic and rtp
4* @date : 2022-06-29
5* @author :
6* @version : v1.0
7* @copyright copyright Copyright (c) 2022 www.gosuncn.com
8*/
9#ifndef GSW_VOICE_INTERFACE_H
10#define GSW_VOICE_INTERFACE_H
11
12#include <stdint.h>
13#include <stdbool.h>
14#include "gsw_hal_errcode.h"
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20#define INVALID_CALL_HANDLE (-1)
21#define GSW_VOICE_SUCCESS GSW_HAL_SUCCESS
22#define GSW_VOICE_ERROR GSW_HAL_NORMAL_FAIL
23#define ERR_FAILED GSW_HAL_NORMAL_FAIL
24#define ERR_SUCCESS GSW_HAL_SUCCESS
25
26#define GSW_VOICE_MAX_SPEAKER_VOLUME (7)
27#define GSW_VOICE_MIN_SPEAKER_VOLUME (1)
28#define GSW_VOICE_MAX_MIC_VOLUME (7)
29#define GSW_VOICE_MIN_MIC_VOLUME (1)
30
31typedef int CallHandle;
32
33typedef enum {
34 GSW_VOICE_CALL_HOLDING = 0, /**< holding */
35 GSW_VOICE_CALL_DIALING, /**< dialing */
36 GSW_VOICE_CALL_ALERTING, /**< alerting */
37 GSW_VOICE_CALL_CONNECTED, /**< connected */
38 GSW_VOICE_CALL_INCOMING, /**< incoming */
39 GSW_VOICE_CALL_WAITING, /**< waiting */
40 GSW_VOICE_CALL_END, /**< call end */
41} VoiceCallState;
42
43typedef enum {
44 GSW_AUDIO_MODE_CODEC = 0, /**< Codec */
45 GSW_AUDIO_MODE_RTP = 1, /**< RTP */
46} AudioMode;
47
48typedef enum {
49 GSW_RTP_CLIENT = 0, /**< rtp client */
50 GSW_RTP_SERVER, /**< rtp server */
51} RTPMode;
52
53typedef void (*CallStateInd)(CallHandle, VoiceCallState);
54
55/**
56 * @brief voice sdk init function
57 * @param [in] ind callback function to handle new voice call state
58 * @retval 0: success
59 * @retval other: fail
60 */
61int32_t gsw_voice_sdk_init(CallStateInd ind);
62
63/**
64 * @brief voice sdk deinit function
65 * @retval 0: success
66 * @retval other: fail
67 */
68void gsw_voice_sdk_deinit(void);
69
70/**
71 * @brief normal voice start
72 * @param [in] handle
73 * @param [in] callNumber
74 * @retval 0: success
75 * @retval other: fail
76 */
77int32_t gsw_voice_normal_voice_start(CallHandle *handle, const char *callNumber);
78
79/**
80 * @brief hangup voice
81 * @param [in] handle
82 * @retval 0: success
83 * @retval other: fail
84 */
85int32_t gsw_voice_hangup(CallHandle handle);
86
87/**
88 * @brief answer voice
89 * @param [in] handle
90 * @retval 0: success
91 * @retval other: fail
92 */
93int32_t gsw_voice_answer(CallHandle handle);
94
95/**
96 * @brief auto answer mode
97 * @param [in] mode: ture/false
98 * @retval 0: success
99 * @retval other: fail
100 */
101int32_t gsw_voice_set_auto_answer_mode(int32_t mode);
102
103/**
104 * @brief get current call state
105 * @param [in] handle
106 * @param [in] state
107 * @retval 0: success
108 * @retval other: fail
109 */
110int32_t gsw_voice_get_current_call_state(CallHandle handle, VoiceCallState *state);
111
112/**
113 * @brief get speaker volume
114 * @param [out] volume: 0 ~ 7
115 * @retval 0: success
116 * @retval other: fail
117 */
118int32_t gsw_voice_get_speaker_volume(int32_t *volume);
119
120/**
121 * @brief set speaker volume
122 * @param [in] volume: 0 ~ 7
123 * @retval 0: success
124 * @retval other: fail
125 */
126int32_t gsw_voice_set_speaker_volume(int32_t volume);
127
128/**
129 * @brief set mic volume
130 * @param [out] volume: 0 ~ 7
131 * @retval 0: success
132 * @retval other: fail
133 */
134int32_t gsw_voice_get_mic_volume(int32_t *volume);
135
136/**
137 * @brief set mic volume
138 * @param [in] volume: 0 ~ 7
139 * @retval 0: success
140 * @retval other: fail
141 */
142int32_t gsw_voice_set_mic_volume(int32_t volume);
143
144/**
145 * @brief set audio mode.
146 * @details mode change from GSW_AUDIO_MODE_RTP to GSW_AUDIO_MODE_CODEC, should close RTP immediately and change to codec mode.
147 * change from GSW_AUDIO_MODE_CODEC to GSW_AUDIO_MODE_RTP, should close codec immediately and change to RTP mode.
148 *
149 * @param [in] audioMode
150 * @retval 0: success
151 * @retval other: fail
152 */
153int32_t gsw_voice_set_audio_mode(AudioMode audioMode);
154
155/**
156 * @brief get audio mode
157 * @param [out] audioMode
158 * @retval 0: success
159 * @retval other: fail
160 */
161int32_t gsw_voice_get_audio_mode(AudioMode *audioMode);
162
163/**
164 * @brief set rtp ip
165 * @param [in] ip rtp ip
166 * @param [in] len rtp ip length
167 * @retval 0: success
168 * @retval other: fail
169 */
170int32_t gsw_voice_set_remote_rtp_ip(const char *ip, int32_t len);
171
172/**
173 * @brief get rtp ip
174 * @param [out] ip rtp ip
175 * @param [out] len rtp ip length
176 * @retval 0: success
177 * @retval other: fail
178 */
179int32_t gsw_voice_get_remote_rtp_ip(char *ip, int32_t len);
180
181/**
182 * @brief set rtp port
183 * @param [in] RTPMode rtp mode
184 * @param [in] port rtp port
185 * @retval 0: success
186 * @retval other: fail
187 */
188int32_t gsw_voice_set_rtp_port(RTPMode rtpMode, int32_t port);
189
190/**
191 * @brief get rtp port
192 * @param [out] RTPMode rtp mode
193 * @param [out] port rtp port
194 * @retval 0: success
195 * @retval other: fail
196 */
197int32_t gsw_voice_get_rtp_port(RTPMode rtpMode, int32_t *port);
198
199/**
200 * @brief set rtp port
201 * @param [in] clockRate rtp clock rate
202 * @param [in] channel rtp channel
203 * @param [in] latency rtp latency
204 * @retval 0: success
205 * @retval other: fail
206 */
207int32_t gsw_voice_set_rtp_param(int32_t clockRate, int32_t channel, int32_t latency);
208
209/**
210 * @brief get rtp param
211 * @param [out] clockRate rtp clock rate
212 * @param [out] channel rtp channel
213 * @param [out] latency rtp latency
214 * @retval 0: success
215 * @retval other: fail
216 */
217int32_t gsw_voice_get_rtp_param(int32_t *clockRate, int32_t *channel, int32_t *latency);
218
219/**
220 * @brief set rtp vlan
221 * @param [in] interfaceName network interface name
222 * @retval 0: success
223 * @retval other: fail
224 */
225int32_t gsw_voice_set_rtp_vlan_info(const char *interfaceName);
226
227/**
228 * @brief get rtp vlan
229 * @param [out] interfaceName network interface name
230 * @param [out] len network interface name length
231 * @retval 0: success
232 * @retval other: fail
233 */
234int32_t gsw_voice_get_rtp_vlan_info(char *interfaceName, uint32_t len);
235
236/**
237 * @brief get current call end reason
238 * @param [in] handle
239 * @retval call_end_reason
240 */
241int32_t gsw_voice_get_current_call_end_reason(CallHandle handle);
242
243#ifdef __cplusplus
244}
245#endif
246#endif /* GSW_VOICE_INTERFACE_H */