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