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