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