hong.liu | cd37079 | 2025-05-28 06:29:19 -0700 | [diff] [blame] | 1 | #include "gsw_voice_interface.h"
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2 | #include <dlfcn.h>
|
| 3 | #include <pthread.h>
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 4 | #include <stdio.h>
|
| 5 | #include <string.h>
|
| 6 | #include <stdlib.h>
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 7 | #include "gsw_log_interface.h"
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 8 |
|
| 9 | // mbtk includes
|
| 10 |
|
| 11 | typedef unsigned int uint32;
|
| 12 | typedef unsigned char uint8;
|
| 13 | typedef unsigned short uint16;
|
| 14 | typedef void (*mbtk_info_callback_func)(const void* data, int data_len);
|
| 15 |
|
| 16 | typedef struct
|
| 17 | {
|
| 18 | int client_fd;
|
| 19 | pthread_t read_thread_id;
|
| 20 | int exit_fd[2];
|
| 21 | bool is_waitting;
|
| 22 | pthread_cond_t cond;
|
| 23 | pthread_mutex_t mutex;
|
| 24 |
|
| 25 | pthread_mutex_t send_mutex;
|
| 26 |
|
| 27 | // Temp response data.
|
| 28 | uint16 info_err;
|
| 29 | uint16 data_len;
|
| 30 | void *data;
|
| 31 |
|
| 32 | //mbtk wyq for server_ready_status add start
|
| 33 | char server_ready_status;
|
| 34 | //mbtk wyq for server_ready_status add end
|
| 35 |
|
| 36 | mbtk_info_callback_func net_state_cb;
|
| 37 | mbtk_info_callback_func call_state_cb;
|
| 38 | mbtk_info_callback_func sms_state_cb;
|
| 39 | mbtk_info_callback_func radio_state_cb;
|
| 40 | mbtk_info_callback_func sim_state_cb;
|
| 41 | mbtk_info_callback_func pdp_state_cb;
|
| 42 | //add signal by xr
|
| 43 | mbtk_info_callback_func signal_state_cb;
|
| 44 | } mbtk_info_handle_t;
|
| 45 |
|
| 46 | typedef struct
|
| 47 | {
|
| 48 | uint8 call_wait;
|
| 49 | uint8 dir1;
|
| 50 | uint8 dir;
|
| 51 | uint8 state;
|
| 52 | uint8 mode;
|
| 53 | uint8 mpty;
|
| 54 | char phone_number[100];
|
| 55 | uint8 type;
|
| 56 | uint8 pas;
|
| 57 | uint8 disconnected_id;
|
| 58 | uint8 end_reason[128];
|
| 59 | } __attribute__((packed)) mbtk_call_info_t;
|
| 60 |
|
| 61 | typedef enum {
|
| 62 | MBTK_CLCC = 1,
|
| 63 | MBTK_CPAS,
|
| 64 | MBTK_DISCONNECTED,
|
| 65 | } mbtk_call_enum;
|
| 66 |
|
| 67 | typedef enum {
|
| 68 | MBTK_CALL_RADY, //MT allows commands from TA/TE
|
| 69 | MBTK_CALL_UNAVAILABLE, //MT does not allow commands from TA/TE
|
| 70 | MBTK_CALL_UNKNOWN, //MT is not guaranteed to respond to instructions
|
| 71 | MBTK_CALL_RINGING, //MT is ready for commands from TA/TE, but the ringer is active
|
| 72 | MBTK_CALL_PROGRESS, //MT is ready for commands from TA/TE, but a call is in progress
|
| 73 | MBTK_CALL_ASLEEP, //MT is unable to process commands from TA/TE because it is in a low functionality state
|
| 74 | MBTK_CALL_ACTIVE,
|
| 75 | } mbtk_call_pas_enum;
|
| 76 |
|
| 77 |
|
| 78 | //----------------end_reason start------------
|
| 79 | //mbtk end_reason define
|
| 80 | #define MBTK_VOICE_END_REASON_UNKNOWN "0 "
|
| 81 | #define MBTK_VOICE_END_REASON_UNASSIGNED_NUMBER "1 "
|
| 82 | #define MBTK_VOICE_END_REASON_NO_ROUTE_DES "3 "
|
| 83 | #define MBTK_VOICE_END_REASON_CHANNEL_UNACCEPTABLE "6 "
|
| 84 | #define MBTK_VOICE_END_REASON_OPERATOR_DETERMINED_BARRING "8 "
|
| 85 | #define MBTK_VOICE_END_REASON_NORMAL_CALL_CLEARING "16 "
|
| 86 | #define MBTK_VOICE_END_REASON_USER_BUSY "17 "
|
| 87 | #define MBTK_VOICE_END_REASON_NO_USER_RESPONDING "18 "
|
| 88 | #define MBTK_VOICE_END_REASON_USER_ALERTING_NO_ANSWER "19 "
|
| 89 | #define MBTK_VOICE_END_REASON_CALL_REJECTED "21 "
|
| 90 | #define MBTK_VOICE_END_REASON_NUMBER_CHANGED "22 "
|
| 91 | #define MBTK_VOICE_END_REASON_PREEMPTION "25 "
|
| 92 | #define MBTK_VOICE_END_REASON_NON_SELECTED_USER_CLEARING "26 "
|
| 93 | #define MBTK_VOICE_END_REASON_DESTINATION_OUT_OF_ORDER "27 "
|
| 94 | #define MBTK_VOICE_END_REASON_INVALID_NUMBER_FORMAT "28 "
|
| 95 | #define MBTK_VOICE_END_REASON_FACILITY_REJECTED "29 "
|
| 96 | #define MBTK_VOICE_END_REASON_STATUS_ENQUIRY "30 "
|
| 97 | #define MBTK_VOICE_END_REASON_NORMAL_UNSPECIFIED "31 "
|
| 98 | #define MBTK_VOICE_END_REASON_NO_CIRCUIT_AVAILABLE "34 "
|
| 99 | #define MBTK_VOICE_END_REASON_NETWORK_OUT_OF_ORDER "38 "
|
| 100 | #define MBTK_VOICE_END_REASON_TEMPORARY_FAILURE "41 "
|
| 101 | #define MBTK_VOICE_END_REASON_SWITCHING_EQUIPMENT_CONGESTION "42 "
|
| 102 | #define MBTK_VOICE_END_REASON_ACCESS_INFORMATION_DISCARDED "43 "
|
| 103 | #define MBTK_VOICE_END_REASON_REQUESTED_CIRCUIT_UNAVAILABLE "44 "
|
| 104 | #define MBTK_VOICE_END_REASON_RESOURCE_UNAVAILABLE "47 "
|
| 105 | #define MBTK_VOICE_END_REASON_QOS_UNAVAILABLE "49 "
|
| 106 | #define MBTK_VOICE_END_REASON_REQUESTED_FACILITY_NOT_SUBSCRIBED "50 "
|
| 107 | #define MBTK_VOICE_END_REASON_INCOMING_CALLS_BARRED_WITHIN_CUG "55 "
|
| 108 | #define MBTK_VOICE_END_REASON_BEARER_CAPABILITY_NOT_AUTHORIZED "57 "
|
| 109 | #define MBTK_VOICE_END_REASON_BEARER_CAPABILITY_NOT_AVAILABLE "58 "
|
| 110 | #define MBTK_VOICE_END_REASON_SERVICE_NOT_AVAILABLE "63 "
|
| 111 | #define MBTK_VOICE_END_REASON_BEARER_SERVICE_NOT_IMPLEMENTED "65 "
|
| 112 | #define MBTK_VOICE_END_REASON_ACM_MAX_REACHED "68 "
|
| 113 | #define MBTK_VOICE_END_REASON_FACILITY_NOT_IMPLEMENTED "69 "
|
| 114 | #define MBTK_VOICE_END_REASON_ONLY_RDI_BEARER_CAPABILITY_AVAILABLE "70 "
|
| 115 | #define MBTK_VOICE_END_REASON_SERVICE_NOT_IMPLEMENTED "79 "
|
| 116 | #define MBTK_VOICE_END_REASON_INVALID_TRANSACTION_ID "81 "
|
| 117 | #define MBTK_VOICE_END_REASON_USER_NOT_MEMBER_OF_CUG "87 "
|
| 118 | #define MBTK_VOICE_END_REASON_INCOMPATIBLE_DESTINATION "88 "
|
| 119 | #define MBTK_VOICE_END_REASON_INVALID_TRANSIT_NETWORK_SELECTION "91 "
|
| 120 | #define MBTK_VOICE_END_REASON_INCORRECT_MESSAGE "95 "
|
| 121 | #define MBTK_VOICE_END_REASON_INVALID_MANDATORY_INFORMATION "96 "
|
| 122 | #define MBTK_VOICE_END_REASON_MESSAGE_TYPE_NON_EXISTENT "97 "
|
| 123 | #define MBTK_VOICE_END_REASON_MESSAGE_TYPE_WRONG_STATE "98 "
|
| 124 | #define MBTK_VOICE_END_REASON_INFORMATION_ELEMENT_NOT_EXISTENT "99 "
|
| 125 | #define MBTK_VOICE_END_REASON_CONDITIONAL_IE_ERROR "100 "
|
| 126 | #define MBTK_VOICE_END_REASON_MESSAGE_WRONG_STATE "101 "
|
| 127 | #define MBTK_VOICE_END_REASON_RECOVERY_AFTER_TIMER_EXPIRY "102 "
|
| 128 | #define MBTK_VOICE_END_REASON_PROTOCOL_ERROR_UNSPECIFIED "111 "
|
| 129 | #define MBTK_VOICE_END_REASON_INERWORKING_UNSPECIFIED "127 "
|
| 130 | #define MBTK_VOICE_END_REASON_CALL_BARRING "224 "
|
| 131 | #define MBTK_VOICE_END_REASON_FDN_BLOCKED "241 "
|
| 132 | #define MBTK_VOICE_END_REASON_END "end"
|
| 133 |
|
| 134 | typedef enum{
|
| 135 | GSW_LOCAL_END_NORMAL = 0,
|
| 136 | GSW_PEER_END_NORMAL,
|
| 137 | GSW_OTHER_END_NORMAL,
|
| 138 | GSW_END_ABNORMAL,
|
| 139 | } gsw_call_end_reason_enum;
|
| 140 |
|
q.huang | d934b6d | 2025-07-29 20:17:00 +0800 | [diff] [blame] | 141 | typedef struct {
|
| 142 | char mbtk_end_reason[64];
|
| 143 | gsw_call_end_reason_enum end_reason;
|
| 144 | }end_reason_map_t;
|
| 145 |
|
| 146 | end_reason_map_t g_end_reason_map[4] = {
|
| 147 | {MBTK_VOICE_END_REASON_NORMAL_CALL_CLEARING, GSW_OTHER_END_NORMAL},
|
| 148 | {MBTK_VOICE_END_REASON_NORMAL_UNSPECIFIED, GSW_OTHER_END_NORMAL},
|
| 149 | {MBTK_VOICE_END_REASON_USER_ALERTING_NO_ANSWER, GSW_PEER_END_NORMAL},
|
| 150 | {MBTK_VOICE_END_REASON_CALL_REJECTED, GSW_PEER_END_NORMAL},
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 151 | };
|
q.huang | d934b6d | 2025-07-29 20:17:00 +0800 | [diff] [blame] | 152 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 153 | int gsw_global_end_reason = GSW_OTHER_END_NORMAL;
|
| 154 |
|
| 155 | //----------------end_reason end------------
|
| 156 |
|
| 157 |
|
| 158 | typedef uint32_t voice_client_handle_type;
|
| 159 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 160 | static mbtk_info_handle_t* call_info_handle = NULL;
|
| 161 | static int level_call = 0;
|
| 162 | int gsw_voice_init_flag = 0;
|
| 163 | int auto_answer_flag = 0;
|
| 164 | voice_client_handle_type g_call_val = -1;
|
| 165 | CallStateInd gsw_voice_callback = NULL;
|
| 166 |
|
| 167 |
|
| 168 | int state_t = 0;
|
| 169 | char* phone_num_t = NULL;
|
| 170 | char* phone_num_t2 = NULL;
|
| 171 | int call_id_t = 0;
|
| 172 | int call_id_t2 = 0;
|
| 173 |
|
| 174 | #define lib_mbtk_path "/lib/libmbtk_lib.so"
|
| 175 | static void *dlHandle_mbtk;
|
| 176 |
|
| 177 | static mbtk_info_handle_t* (*mbtk_info_handle_get)(void);
|
| 178 | int (*mbtk_call_state_change_cb_reg)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb);
|
| 179 | int (*mbtk_call_start)(mbtk_info_handle_t* handle, char* phone_number);
|
| 180 | int (*mbtk_call_hang)(mbtk_info_handle_t* handle);
|
| 181 | int (*mbtk_a_call_hang)(mbtk_info_handle_t* handle, int phone_id);
|
| 182 | int (*mbtk_call_answer)(mbtk_info_handle_t* handle);
|
| 183 | int (*mbtk_call_reg_get)(mbtk_info_handle_t* handle, mbtk_call_info_t *reg);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 184 |
|
| 185 | /*rtp begin*/
|
| 186 | int (*mbtk_rtp_init)();
|
| 187 | int (*mbtk_rtp_deinit)();
|
| 188 | int (*mbtk_rtp_enable)(bool enable);
|
| 189 | int (*mbtk_rtp_remote_ip_set)(const char *ipv4);
|
| 190 | int (*mbtk_rtp_server_port_set)(int port);
|
| 191 | int (*mbtk_rtp_client_port_set)(int port);
|
| 192 | int (*mbtk_rtp_sample_rate_set)(int sample_rate);
|
| 193 | int (*mbtk_rtp_channel_set)(int channel);
|
q.huang | 020cc23 | 2025-06-06 19:06:18 +0800 | [diff] [blame] | 194 | int (*mbtk_rtp_vlan_set)(const char *vlan);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 195 | /*rtp end*/
|
| 196 |
|
| 197 |
|
l.yang | 6a42e4d | 2025-05-28 01:04:20 -0700 | [diff] [blame] | 198 | #define GSW_VOICE "[HAL][GSW_VOICE]"
|
| 199 |
|
q.huang | 50a0d85 | 2025-06-11 14:35:15 +0800 | [diff] [blame] | 200 | #define MODULE_INIT_CHECK(init_flag) \
|
| 201 | if(init_flag == 0) \
|
| 202 | { \
|
| 203 | return GSW_HAL_ERROR_GNSS_DATA_CALL_DEINIT; \
|
| 204 | }
|
| 205 |
|
| 206 | #define VOICE_MODULE_INIT_CHECK() MODULE_INIT_CHECK(gsw_voice_init_flag)
|
| 207 |
|
| 208 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 209 | static int mbtk_rtp_api_import()
|
| 210 | {
|
| 211 | mbtk_rtp_init = (int (*)(void))dlsym(dlHandle_mbtk, "mbtk_rtp_init");
|
| 212 | if (mbtk_rtp_init == NULL)
|
| 213 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 214 | LOGE(GSW_VOICE,"mbtk_rtp_init dlsym fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 215 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 216 | }
|
| 217 |
|
| 218 | mbtk_rtp_deinit = (int (*)(void))dlsym(dlHandle_mbtk, "mbtk_rtp_deinit");
|
| 219 | if (mbtk_rtp_deinit == NULL)
|
| 220 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 221 | LOGE(GSW_VOICE,"mbtk_rtp_deinit dlsym fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 222 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 223 | }
|
| 224 |
|
| 225 | mbtk_rtp_enable = (int (*)(bool enable))dlsym(dlHandle_mbtk, "mbtk_rtp_enable");
|
| 226 | if (mbtk_rtp_enable == NULL)
|
| 227 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 228 | LOGE(GSW_VOICE,"mbtk_rtp_enable dlsym fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 229 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 230 | }
|
| 231 |
|
| 232 | mbtk_rtp_remote_ip_set = (int (*)(const char *ipv4))dlsym(dlHandle_mbtk, "mbtk_rtp_remote_ip_set");
|
| 233 | if (mbtk_rtp_remote_ip_set == NULL)
|
| 234 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 235 | LOGE(GSW_VOICE,"mbtk_rtp_remote_ip_set dlsym fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 236 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 237 | }
|
| 238 |
|
| 239 | mbtk_rtp_server_port_set = (int (*)(int port))dlsym(dlHandle_mbtk, "mbtk_rtp_server_port_set");
|
| 240 | if (mbtk_rtp_server_port_set == NULL)
|
| 241 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 242 | LOGE(GSW_VOICE,"mbtk_rtp_server_port_set dlsym fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 243 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 244 | }
|
| 245 |
|
| 246 | mbtk_rtp_client_port_set = (int (*)(int port))dlsym(dlHandle_mbtk, "mbtk_rtp_client_port_set");
|
| 247 | if (mbtk_rtp_client_port_set == NULL)
|
| 248 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 249 | LOGE(GSW_VOICE,"mbtk_rtp_client_port_set dlsym fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 250 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 251 | }
|
| 252 |
|
| 253 | mbtk_rtp_sample_rate_set = (int (*)(int sample_rate))dlsym(dlHandle_mbtk, "mbtk_rtp_sample_rate_set");
|
| 254 | if (mbtk_rtp_sample_rate_set == NULL)
|
| 255 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 256 | LOGE(GSW_VOICE,"mbtk_rtp_sample_rate_set dlsym fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 257 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 258 | }
|
| 259 |
|
| 260 | mbtk_rtp_channel_set = (int (*)(int channel))dlsym(dlHandle_mbtk, "mbtk_rtp_channel_set");
|
| 261 | if (mbtk_rtp_channel_set == NULL)
|
| 262 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 263 | LOGE(GSW_VOICE,"mbtk_rtp_channel_set dlsym fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 264 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 265 | }
|
q.huang | 020cc23 | 2025-06-06 19:06:18 +0800 | [diff] [blame] | 266 |
|
| 267 | mbtk_rtp_vlan_set = (int (*)(const char *vlan))dlsym(dlHandle_mbtk, "mbtk_rtp_vlan_set");
|
| 268 | if (mbtk_rtp_vlan_set == NULL)
|
| 269 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 270 | LOGE(GSW_VOICE,"mbtk_rtp_vlan_set dlsym fail\n");
|
q.huang | 020cc23 | 2025-06-06 19:06:18 +0800 | [diff] [blame] | 271 | return GSW_HAL_NORMAL_FAIL;
|
| 272 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 273 |
|
| 274 | return GSW_HAL_SUCCESS;
|
| 275 | }
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 | static int mbtk_call_api_import()
|
| 280 | {
|
| 281 | dlHandle_mbtk = dlopen(lib_mbtk_path, RTLD_NOW);
|
| 282 | if (dlHandle_mbtk == NULL)
|
| 283 | {
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 284 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 285 | }
|
| 286 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 287 | mbtk_info_handle_get = (mbtk_info_handle_t* (*)(void))dlsym(dlHandle_mbtk, "mbtk_info_handle_get");
|
| 288 | if (mbtk_info_handle_get == NULL)
|
| 289 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 290 | LOGE(GSW_VOICE,"mbtk_info_handle_get dlsym fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 291 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 292 | }
|
| 293 |
|
| 294 | mbtk_call_state_change_cb_reg = (int (*)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb))dlsym(dlHandle_mbtk, "mbtk_call_state_change_cb_reg");
|
| 295 | if(mbtk_call_state_change_cb_reg == NULL)
|
| 296 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 297 | LOGE(GSW_VOICE,"mbtk_call_state_change_cb_reg dlsym fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 298 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 299 | }
|
| 300 |
|
| 301 | mbtk_call_start = (int (*)(mbtk_info_handle_t* handle, char* phone_number))dlsym(dlHandle_mbtk, "mbtk_call_start");
|
| 302 | if(mbtk_call_start == NULL)
|
| 303 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 304 | LOGE(GSW_VOICE,"mbtk_call_start dlsym fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 305 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 306 | }
|
| 307 |
|
| 308 | mbtk_call_answer = (int (*)(mbtk_info_handle_t* handle))dlsym(dlHandle_mbtk, "mbtk_call_answer");
|
| 309 | if(mbtk_call_answer == NULL)
|
| 310 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 311 | LOGE(GSW_VOICE,"mbtk_call_answer dlsym fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 312 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 313 | }
|
| 314 |
|
| 315 | mbtk_call_hang = (int (*)(mbtk_info_handle_t* handle))dlsym(dlHandle_mbtk, "mbtk_call_hang");
|
| 316 | if(mbtk_call_hang == NULL)
|
| 317 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 318 | LOGE(GSW_VOICE,"mbtk_call_hang dlsym fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 319 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 320 | }
|
| 321 |
|
| 322 | mbtk_a_call_hang = (int (*)(mbtk_info_handle_t* handle, int phone_id))dlsym(dlHandle_mbtk, "mbtk_a_call_hang");
|
| 323 | if(mbtk_a_call_hang == NULL)
|
| 324 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 325 | LOGE(GSW_VOICE,"mbtk_a_call_hang dlsym fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 326 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 327 | }
|
| 328 |
|
| 329 | mbtk_call_reg_get = (int (*)(mbtk_info_handle_t* handle, mbtk_call_info_t *reg))dlsym(dlHandle_mbtk, "mbtk_call_reg_get");
|
| 330 | if(mbtk_call_reg_get == NULL)
|
| 331 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 332 | LOGE(GSW_VOICE,"mbtk_call_reg_get dlsym fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 333 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 334 | }
|
| 335 |
|
| 336 | return mbtk_rtp_api_import();
|
| 337 | }
|
| 338 |
|
q.huang | 5461cfd | 2025-06-24 19:04:34 +0800 | [diff] [blame] | 339 | static void end_reason_mbtk_to_gsw(char* mbtk_reason)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 340 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 341 | LOGE(GSW_VOICE,"mbtk_reason:%s\n", mbtk_reason);
|
q.huang | 5461cfd | 2025-06-24 19:04:34 +0800 | [diff] [blame] | 342 | gsw_global_end_reason = GSW_END_ABNORMAL;
|
q.huang | d934b6d | 2025-07-29 20:17:00 +0800 | [diff] [blame] | 343 |
|
| 344 | int length=sizeof (g_end_reason_map)/ sizeof(g_end_reason_map[0]);
|
q.huang | 5461cfd | 2025-06-24 19:04:34 +0800 | [diff] [blame] | 345 | for(int i = 0; i<length; i++)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 346 | {
|
q.huang | d934b6d | 2025-07-29 20:17:00 +0800 | [diff] [blame] | 347 | if(0 == strncmp(mbtk_reason, g_end_reason_map[i].mbtk_end_reason, strlen(g_end_reason_map[i].mbtk_end_reason)))
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 348 | {
|
q.huang | d934b6d | 2025-07-29 20:17:00 +0800 | [diff] [blame] | 349 | gsw_global_end_reason = g_end_reason_map[i].end_reason;
|
| 350 | LOGE(GSW_VOICE,"mbtk call end reason %s gsw reason:%d\n", mbtk_reason,gsw_global_end_reason);
|
q.huang | 5461cfd | 2025-06-24 19:04:34 +0800 | [diff] [blame] | 351 | return;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 352 | }
|
| 353 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 354 | }
|
| 355 |
|
| 356 | void gsw_call_state_change_cb(const void *data, int data_len)
|
| 357 | {
|
| 358 | mbtk_call_info_t *reg = (mbtk_call_info_t *)data;
|
| 359 | switch (reg->call_wait)
|
| 360 | {
|
| 361 | case MBTK_CLCC:
|
| 362 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 363 | LOGD(GSW_VOICE,"RING : %d, %d, %d, %d, %d, %s, %d, %d, end_reason:%s", reg->dir1, reg->dir, reg->state, reg->mode, reg->mpty, reg->phone_number, reg->type, reg->disconnected_id, reg->end_reason);
|
| 364 | printf("RING : %d, %d, %d, %d, %d, %s, %d, %d, end_reason:%s\n", reg->dir1, reg->dir, reg->state, reg->mode, reg->mpty, reg->phone_number, reg->type, reg->disconnected_id, reg->end_reason);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 365 | switch(reg->state)
|
| 366 | {
|
| 367 | case 0:
|
| 368 | state_t = GSW_VOICE_CALL_CONNECTED;
|
| 369 | break;
|
| 370 | case 1:
|
| 371 | state_t = GSW_VOICE_CALL_HOLDING;
|
| 372 | break;
|
| 373 | case 2:
|
| 374 | state_t = GSW_VOICE_CALL_DIALING;
|
| 375 | break;
|
| 376 | case 3:
|
| 377 | state_t = GSW_VOICE_CALL_ALERTING;
|
| 378 | break;
|
| 379 | case 4:
|
| 380 | state_t = GSW_VOICE_CALL_INCOMING;
|
| 381 | break;
|
| 382 | case 5:
|
| 383 | state_t = GSW_VOICE_CALL_WAITING;
|
| 384 | break;
|
| 385 | case 6:
|
| 386 | {
|
| 387 | state_t = GSW_VOICE_CALL_END;
|
| 388 | call_id_t = reg->dir1;
|
| 389 | end_reason_mbtk_to_gsw((char *)reg->end_reason);
|
| 390 | break;
|
| 391 | }
|
| 392 |
|
| 393 | }
|
| 394 |
|
| 395 | if(gsw_voice_callback)
|
| 396 | {
|
| 397 | gsw_voice_callback(reg->dir1, state_t);
|
| 398 | }
|
| 399 |
|
| 400 | }
|
q.huang | 5461cfd | 2025-06-24 19:04:34 +0800 | [diff] [blame] | 401 | break;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 402 | case MBTK_DISCONNECTED:
|
| 403 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 404 | LOGD(GSW_VOICE,"RING : call dis connected!");
|
| 405 | LOGD(GSW_VOICE,"RING : %d, %d, %d, %d, %d, %s, %d, %d, end_reason:%s", reg->dir1, reg->dir, reg->state, reg->mode, reg->mpty, reg->phone_number, reg->type, reg->disconnected_id, reg->end_reason);
|
| 406 | printf("RING : %d, %d, %d, %d, %d, %s, %d, %d, end_reason:%s\n", reg->dir1, reg->dir, reg->state, reg->mode, reg->mpty, reg->phone_number, reg->type, reg->disconnected_id, reg->end_reason);
|
q.huang | 5461cfd | 2025-06-24 19:04:34 +0800 | [diff] [blame] | 407 | state_t = GSW_VOICE_CALL_END;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 408 | call_id_t = reg->dir1;
|
| 409 | end_reason_mbtk_to_gsw((char *)reg->end_reason);
|
q.huang | 5461cfd | 2025-06-24 19:04:34 +0800 | [diff] [blame] | 410 | if(gsw_voice_callback)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 411 | {
|
| 412 | gsw_voice_callback(reg->disconnected_id, state_t);
|
| 413 | }
|
| 414 | }
|
q.huang | 5461cfd | 2025-06-24 19:04:34 +0800 | [diff] [blame] | 415 | break;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 416 | case MBTK_CPAS:
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 417 | LOGD(GSW_VOICE,"CALL : Call state = %d", reg->pas);
|
q.huang | 5461cfd | 2025-06-24 19:04:34 +0800 | [diff] [blame] | 418 | switch (reg->pas)
|
| 419 | {
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 420 | case MBTK_CALL_RADY:
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 421 | LOGD(GSW_VOICE,"CALL: call READY");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 422 | break;
|
| 423 | case MBTK_CALL_UNAVAILABLE:
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 424 | LOGD(GSW_VOICE,"CALL: call unavaliable");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 425 | break;
|
| 426 | case MBTK_CALL_UNKNOWN:
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 427 | LOGD(GSW_VOICE,"CALL: call unknown");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 428 | break;
|
| 429 | case MBTK_CALL_RINGING:
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 430 | LOGD(GSW_VOICE,"CALL: call ringing");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 431 | break;
|
| 432 | case MBTK_CALL_PROGRESS:
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 433 | LOGD(GSW_VOICE,"CALL: call progress");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 434 | break;
|
| 435 | case MBTK_CALL_ASLEEP:
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 436 | LOGD(GSW_VOICE,"CALL: call asleep");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 437 | break;
|
| 438 | case MBTK_CALL_ACTIVE:
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 439 | LOGD(GSW_VOICE,"CALL: call active");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 440 | break;
|
| 441 | default:
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 442 | //LOGE(GSW_VOICE,"\r\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 443 | break;
|
q.huang | 5461cfd | 2025-06-24 19:04:34 +0800 | [diff] [blame] | 444 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 445 | break;
|
| 446 | default:
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 447 | LOGE(GSW_VOICE,"RING : None call_wait = %d", reg->call_wait);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 448 | break;
|
| 449 | }
|
| 450 | }
|
| 451 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 452 | /**
|
| 453 | * @brief init voice sdk,and register the status indicated callback function
|
| 454 | * @param [in] CallStateInd ind: status indicated callback function
|
| 455 | * @param [out] None
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 456 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 457 | */
|
| 458 | int32_t gsw_voice_sdk_init(CallStateInd ind)
|
| 459 | {
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 460 | if (gsw_voice_init_flag == 1 && call_info_handle != NULL)
|
| 461 | {
|
| 462 | return GSW_HAL_SUCCESS;
|
| 463 | }
|
| 464 |
|
| 465 | if(ind == NULL)
|
| 466 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 467 | LOGE(GSW_VOICE,"parameter is null\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 468 | return GSW_HAL_ARG_INVALID;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 469 | }
|
| 470 |
|
q.huang | d934b6d | 2025-07-29 20:17:00 +0800 | [diff] [blame] | 471 | int ret = mbtk_call_api_import();
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 472 | if(ret != 0)
|
| 473 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 474 | LOGE(GSW_VOICE,"[gsw_voice_sdk_init]mbtk_call_api_import fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 475 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 476 | }
|
| 477 |
|
q.huang | d934b6d | 2025-07-29 20:17:00 +0800 | [diff] [blame] | 478 |
|
| 479 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 480 | if(call_info_handle == NULL)
|
| 481 | {
|
| 482 | call_info_handle = mbtk_info_handle_get();
|
| 483 | if(call_info_handle != NULL)
|
| 484 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 485 | LOGE(GSW_VOICE,"create gsw_voice_sdk_init success\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 486 |
|
| 487 | ret = mbtk_call_state_change_cb_reg(call_info_handle, gsw_call_state_change_cb);
|
| 488 | if(ret)
|
| 489 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 490 | LOGE(GSW_VOICE,"mbtk_call_state_change_cb_reg fail,ret = %d\n",ret);
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 491 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 492 | }
|
| 493 | else
|
| 494 | {
|
| 495 | gsw_voice_init_flag = 1;
|
| 496 | gsw_voice_callback = ind;
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 497 | LOGE(GSW_VOICE,"create gsw_voice_sdk_init success\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 498 | return GSW_HAL_SUCCESS;
|
| 499 | }
|
| 500 |
|
| 501 | }
|
| 502 |
|
| 503 | else
|
| 504 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 505 | LOGE(GSW_VOICE,"create gsw_voice_sdk_init fail\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 506 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 507 | }
|
| 508 | }
|
| 509 |
|
| 510 | return GSW_HAL_SUCCESS;
|
| 511 | }
|
| 512 |
|
| 513 | /**
|
| 514 | * @brief set speaker_volume
|
| 515 | * @param [in] int32_t volume:1(Min)-7(Max)
|
| 516 | * @param [out] None
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 517 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 518 | */
|
| 519 | int32_t gsw_voice_set_speaker_volume(int32_t volume)
|
| 520 | {
|
| 521 | //UNUSED(volume);
|
| 522 |
|
q.huang | 50a0d85 | 2025-06-11 14:35:15 +0800 | [diff] [blame] | 523 | VOICE_MODULE_INIT_CHECK();
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 524 |
|
| 525 | char cmd[128] = {0};
|
| 526 | int lv = 0;
|
| 527 |
|
| 528 | memset(cmd ,0x00, sizeof(cmd));
|
| 529 |
|
| 530 | if(volume < 1 || volume > 7)
|
| 531 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 532 | LOGE(GSW_VOICE,"Error volume : %d", volume);
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 533 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 534 | }
|
| 535 | else
|
| 536 | {
|
| 537 | switch(volume)
|
| 538 | {
|
| 539 | case 1 :
|
| 540 | lv = -36;
|
| 541 | break;
|
| 542 | case 2 :
|
| 543 | lv = -36;
|
| 544 | break;
|
| 545 | case 3 :
|
| 546 | lv = -27;
|
| 547 | break;
|
| 548 | case 4 :
|
| 549 | lv = -18;
|
| 550 | break;
|
| 551 | case 5 :
|
| 552 | lv = -9;
|
| 553 | break;
|
| 554 | case 6 :
|
| 555 | lv = 0;
|
| 556 | break;
|
| 557 | case 7:
|
| 558 | lv = 12;
|
| 559 | break;
|
| 560 | default:
|
| 561 | break;
|
| 562 | }
|
| 563 | }
|
| 564 |
|
| 565 | sprintf(cmd, "ubus call audio_if config_dspgain \"{\'type\':%d,\'gain\':%d}\"", 1, lv);
|
| 566 | // sLOGE(cmd, "ubus call audio_if volume_set \'{\"param0\":%d}\'", lv);
|
| 567 | int err = system(cmd);
|
| 568 | if ((err != -1) && (err != 127))
|
| 569 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 570 | LOGE(GSW_VOICE,"Set success.");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 571 | level_call = volume;
|
| 572 | }
|
| 573 | else
|
| 574 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 575 | LOGE(GSW_VOICE,"Error : %d", err);
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 576 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 577 | }
|
| 578 |
|
| 579 | return GSW_HAL_SUCCESS;
|
| 580 | }
|
| 581 |
|
| 582 | /**
|
| 583 | * @brief start a voice call
|
| 584 | * @param [in] char *callNumber
|
| 585 | * @param [out] CallHandle *handle
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 586 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 587 | */
|
| 588 | int32_t gsw_voice_normal_voice_start(CallHandle *handle, const char *callNumber)
|
| 589 | {
|
q.huang | 50a0d85 | 2025-06-11 14:35:15 +0800 | [diff] [blame] | 590 | VOICE_MODULE_INIT_CHECK();
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 591 |
|
| 592 | mbtk_call_info_t reg = {0};
|
| 593 | int ret = -1;
|
| 594 |
|
| 595 |
|
| 596 | if(handle == NULL)
|
| 597 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 598 | LOGE(GSW_VOICE,"handle is null\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 599 | return GSW_HAL_ARG_INVALID;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 600 | }
|
| 601 |
|
| 602 | if(callNumber == NULL)
|
| 603 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 604 | LOGE(GSW_VOICE,"callNumber is null\n");
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 605 | return GSW_HAL_ARG_INVALID;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 606 | }
|
| 607 |
|
| 608 |
|
| 609 | ret = mbtk_call_start(call_info_handle, (char *)callNumber);
|
| 610 |
|
| 611 | if(ret != 0)
|
| 612 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 613 | LOGE(GSW_VOICE,"mbtk_call_start fail,ret = %d\n",ret);
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 614 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 615 | }
|
| 616 |
|
| 617 | //get call id
|
| 618 | mbtk_call_reg_get(call_info_handle, ®);
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 619 | LOGE(GSW_VOICE,"call id = %d\n",reg.dir1);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 620 | *handle = reg.dir1;
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 621 | LOGE(GSW_VOICE,"gsw_voice_normal_voice_start id = %d\n", (int)*handle);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 622 |
|
| 623 |
|
| 624 | return GSW_HAL_SUCCESS;
|
| 625 |
|
| 626 | }
|
| 627 |
|
| 628 | /**
|
| 629 | * @brief answer a voice call
|
| 630 | * @param [in] CallHandle handle
|
| 631 | * @param [out] None
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 632 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 633 | */
|
| 634 | int32_t gsw_voice_answer(CallHandle handle)
|
| 635 | {
|
q.huang | 50a0d85 | 2025-06-11 14:35:15 +0800 | [diff] [blame] | 636 | VOICE_MODULE_INIT_CHECK();
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 637 |
|
| 638 | int ret = -1;
|
| 639 |
|
| 640 |
|
| 641 | ret = mbtk_call_answer(call_info_handle);
|
| 642 |
|
| 643 | if(ret != 0)
|
| 644 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 645 | LOGE(GSW_VOICE,"mbtk_call_answer fail,ret = %d\n", ret);
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 646 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 647 | }
|
| 648 | else
|
| 649 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 650 | LOGE(GSW_VOICE,"mbtk_call_answer success\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 651 | }
|
| 652 |
|
| 653 | return GSW_HAL_SUCCESS;
|
| 654 | }
|
| 655 |
|
| 656 |
|
| 657 | /**
|
| 658 | * @brief hangup a voice call
|
| 659 | * @param [in] CallHandle handle
|
| 660 | * @param [out] None
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 661 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 662 | */
|
| 663 | int32_t gsw_voice_hangup(CallHandle handle)
|
| 664 | {
|
q.huang | 50a0d85 | 2025-06-11 14:35:15 +0800 | [diff] [blame] | 665 | VOICE_MODULE_INIT_CHECK();
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 666 |
|
| 667 | int ret = -1;
|
| 668 |
|
| 669 | ret = mbtk_a_call_hang(call_info_handle,handle);
|
| 670 |
|
| 671 | if(ret != 0)
|
| 672 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 673 | LOGE(GSW_VOICE,"mbtk_a_call_hang fail,ret = %d\n", ret);
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 674 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 675 | }
|
| 676 | else
|
| 677 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 678 | LOGE(GSW_VOICE,"mbtk_a_call_hang success\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 679 | }
|
| 680 |
|
| 681 | return GSW_HAL_SUCCESS;
|
| 682 | }
|
| 683 |
|
| 684 | /**
|
| 685 | * @brief set auto answer mode
|
| 686 | * @param [in] int32_t mode:0-1, 0:NO(close auto answer), 1:YES(auto answer)
|
| 687 | * @param [out] None
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 688 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 689 | */
|
| 690 | int32_t gsw_voice_set_auto_answer_mode(int32_t mode)
|
| 691 | {
|
q.huang | 50a0d85 | 2025-06-11 14:35:15 +0800 | [diff] [blame] | 692 | VOICE_MODULE_INIT_CHECK();
|
| 693 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 694 | if(mode == 1)
|
| 695 | {
|
| 696 | int ret = -1;
|
| 697 |
|
| 698 | ret = mbtk_call_answer(call_info_handle);
|
| 699 | if(ret != 0)
|
| 700 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 701 | LOGE(GSW_VOICE,"mbtk_call_answer fail,ret = %d\n", ret);
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 702 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 703 | }
|
| 704 | else
|
| 705 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame] | 706 | LOGE(GSW_VOICE,"mbtk_call_answer success\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 707 | }
|
| 708 | }
|
| 709 |
|
| 710 | return GSW_HAL_SUCCESS;
|
| 711 | }
|
| 712 |
|
| 713 | int32_t gsw_voice_get_current_call_end_reason(CallHandle handle)
|
| 714 | {
|
q.huang | 50a0d85 | 2025-06-11 14:35:15 +0800 | [diff] [blame] | 715 | VOICE_MODULE_INIT_CHECK();
|
q.huang | 5461cfd | 2025-06-24 19:04:34 +0800 | [diff] [blame] | 716 |
|
| 717 | return gsw_global_end_reason;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 718 | }
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 | /*##########################################rtp begin*/
|
| 723 | /**
|
| 724 | * @brief set audio mode
|
| 725 | * @param [in] AudioMode audioMode
|
| 726 | * @param [out] None
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 727 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 728 | */
|
| 729 | int32_t gsw_voice_set_audio_mode(AudioMode audioMode)
|
| 730 | {
|
q.huang | 50a0d85 | 2025-06-11 14:35:15 +0800 | [diff] [blame] | 731 | VOICE_MODULE_INIT_CHECK();
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 732 |
|
| 733 | int ret=mbtk_rtp_enable(audioMode);
|
| 734 | if(ret !=0 )
|
| 735 | {
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 736 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 737 | }
|
| 738 | return GSW_HAL_SUCCESS;
|
| 739 | }
|
| 740 |
|
| 741 | /**
|
| 742 | * @brief set rtp ip address of remote
|
| 743 | * @param [in] char *ip :ip address
|
| 744 | * @param [in] int32_t len: length
|
| 745 | * @param [out] None
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 746 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 747 | */
|
| 748 | int32_t gsw_voice_set_remote_rtp_ip(const char *ip, int32_t len)
|
| 749 | {
|
q.huang | 50a0d85 | 2025-06-11 14:35:15 +0800 | [diff] [blame] | 750 | VOICE_MODULE_INIT_CHECK();
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 751 |
|
| 752 | int ret=mbtk_rtp_remote_ip_set(ip);
|
| 753 | if(ret !=0 )
|
| 754 | {
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 755 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 756 | }
|
| 757 | return GSW_HAL_SUCCESS;
|
| 758 | }
|
| 759 |
|
| 760 | /**
|
| 761 | * @brief set rtp mode and port
|
| 762 | * @param [in] RTPMode rtpMode: rtp mode
|
| 763 | * @param [in] int32_t port:rtp port
|
| 764 | * @param [out] None
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 765 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 766 | */
|
| 767 | int32_t gsw_voice_set_rtp_port(RTPMode rtpMode, int32_t port)
|
| 768 | {
|
q.huang | 50a0d85 | 2025-06-11 14:35:15 +0800 | [diff] [blame] | 769 | VOICE_MODULE_INIT_CHECK();
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 770 |
|
| 771 | int ret;
|
| 772 | if(rtpMode==GSW_RTP_CLIENT)
|
| 773 | {
|
| 774 | ret = mbtk_rtp_client_port_set(port);
|
| 775 | }
|
| 776 | else
|
| 777 | {
|
| 778 | ret = mbtk_rtp_server_port_set(port);
|
| 779 | }
|
| 780 | if(ret !=0 )
|
| 781 | {
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 782 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 783 | }
|
| 784 | return GSW_HAL_SUCCESS;
|
| 785 | }
|
| 786 |
|
| 787 | /**
|
| 788 | * @brief set rtp mode and port
|
| 789 | * @param [in] int32_t clockRate: clock rate
|
| 790 | * @param [in] int32_t channel:channel
|
| 791 | * @param [in] int32_t latency:latency
|
| 792 | * @param [out] None
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 793 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 794 | */
|
| 795 | int32_t gsw_voice_set_rtp_param(int32_t clockRate, int32_t channel, int32_t latency)
|
| 796 | {
|
q.huang | 50a0d85 | 2025-06-11 14:35:15 +0800 | [diff] [blame] | 797 | VOICE_MODULE_INIT_CHECK();
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 798 |
|
| 799 | int ret=mbtk_rtp_channel_set(channel);
|
| 800 | if(ret==0)
|
| 801 | {
|
| 802 | ret=mbtk_rtp_sample_rate_set(clockRate);
|
| 803 | }
|
| 804 | if(ret !=0 )
|
| 805 | {
|
xy.he | cfb7d68 | 2025-05-28 21:39:12 +0800 | [diff] [blame] | 806 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 807 | }
|
| 808 | return GSW_HAL_SUCCESS;
|
| 809 | }
|
q.huang | 020cc23 | 2025-06-06 19:06:18 +0800 | [diff] [blame] | 810 |
|
| 811 | /**
|
| 812 | * @brief set rtp vlan
|
| 813 | * @param [in] interfaceName network interface name
|
| 814 | * @retval 0: success
|
| 815 | * @retval other: fail
|
| 816 | */
|
| 817 | int32_t gsw_voice_set_rtp_vlan_info(const char *interfaceName)
|
| 818 | {
|
q.huang | 50a0d85 | 2025-06-11 14:35:15 +0800 | [diff] [blame] | 819 | VOICE_MODULE_INIT_CHECK();
|
q.huang | 020cc23 | 2025-06-06 19:06:18 +0800 | [diff] [blame] | 820 |
|
| 821 | int ret=mbtk_rtp_vlan_set(interfaceName);
|
| 822 |
|
| 823 | if(ret !=0 )
|
| 824 | {
|
| 825 | return GSW_HAL_NORMAL_FAIL;
|
| 826 | }
|
| 827 | return GSW_HAL_SUCCESS;
|
| 828 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 829 | /*##########################################rtp end*/
|
| 830 |
|