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