ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 2 | #include <stdio.h>
|
| 3 | #include <sys/types.h>
|
| 4 | #include <sys/socket.h>
|
| 5 | #include <arpa/inet.h>
|
| 6 | #include <fcntl.h>
|
| 7 | #include <string.h>
|
| 8 | #include <stdlib.h>
|
| 9 | #include <unistd.h>
|
| 10 | #include <binder/Parcel.h>
|
| 11 | #include <log/log.h>
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 12 | #include <cutils/jstring.h>
|
| 13 | #include <pthread.h>
|
| 14 | #include "liblog/lynq_deflog.h"
|
lh | 228a7b8 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 15 | #include <sys/time.h>
|
lh | 59e0d00 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 16 | #include <string.h>
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 17 | #include <vendor-ril/telephony/ril.h>
|
| 18 | #include <vendor-ril/telephony/mtk_ril_sp.h>
|
| 19 | #include <vendor-ril/telephony/mtk_ril_ivt.h>
|
| 20 | #include "lynq_call.h"
|
| 21 |
|
| 22 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 23 | #define LYNQ_SERVICE_PORT 8088
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 24 | #define DSET_IP_ADDRESS "127.0.0.1"
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 25 | #define LYNQ_URC_SERVICE_PORT 8086
|
| 26 | #define LYNQ_REC_BUF 8192
|
| 27 | #define LYNQ_REQUEST_PARAM_BUF 8192
|
| 28 | #define LYQN_SEDN_BUF 1024*8+sizeof(int)*3
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 29 | #define INVALID_ID (-1)
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 30 | #define RTP_FROM_CMD "gst-launch-1.0 -v udpsrc port=%d caps=\'application/x-rtp, media=(string)audio, clock-rate=(int)%d, channels=(int)%d\' ! rtpjitterbuffer latency=%d ! rtppcmadepay ! alawdec ! audioresample ! audioconvert ! alsasink device=\'hw:0,2\'"
|
| 31 | #define RTP_TO_CMD "gst-launch-1.0 -v alsasrc device=\'hw:0,6\' ! audioconvert ! audioresample ! alawenc ! rtppcmapay ! udpsink host=%s auto-multicast=true port=%d"
|
| 32 | #define MAX_IP_LENGTH 128
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 33 | #define USER_LOG_TAG "LYNQ_CALL"
|
| 34 |
|
| 35 | using ::android::Parcel;
|
| 36 | typedef enum {
|
| 37 | LYNQ_CALL_ACTIVE = 0,
|
| 38 | LYNQ_CALL_HOLDING = 1,
|
| 39 | LYNQ_CALL_DIALING = 2, /* MO call only */
|
| 40 | LYNQ_CALL_ALERTING = 3, /* MO call only */
|
| 41 | LYNQ_CALL_INCOMING = 4, /* MT call only */
|
lh | 8657e74 | 2022-04-26 00:45:44 -0700 | [diff] [blame] | 42 | LYNQ_CALL_WAITING = 5, /* MT call only */
|
| 43 | /*warren add for T800 platform 2022/04/26 start*/
|
| 44 | LYNQ_CALL_END = 6, /*CALL END*/
|
| 45 | /*warren add for T800 platform 2022/04/26 end*/
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 46 | }lynq_call_state_t;
|
| 47 |
|
| 48 | typedef struct{
|
| 49 | int uToken;
|
| 50 | int request;
|
| 51 | int paramLen;
|
| 52 | char param[LYNQ_REQUEST_PARAM_BUF];
|
| 53 | }lynq_client_t;
|
| 54 | typedef struct
|
| 55 | {
|
| 56 | int used;
|
| 57 | int call_id;
|
| 58 | int call_state;
|
| 59 | int toa;
|
| 60 | int direction;/*0: MO call,1:MT call*/
|
| 61 | char addr[LYNQ_PHONE_NUMBER_MAX];
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 62 | }lynq_call_list_e_t;
|
| 63 | typedef struct
|
| 64 | {
|
| 65 | int call_id;
|
| 66 | int call_state;
|
| 67 | int toa;
|
| 68 | int direction;/*0: MO call,1:MT call*/
|
| 69 | char addr[LYNQ_PHONE_NUMBER_MAX];
|
| 70 | }lynq_call_list_t;
|
| 71 |
|
| 72 | lynq_call_list_e_t lynq_call_lists[LYNQ_CALL_MAX]={};
|
| 73 | static pthread_mutex_t call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 74 | static pthread_cond_t call_state_change_cond = PTHREAD_COND_INITIALIZER;
|
ll | c81b4d5 | 2022-07-13 09:39:44 +0000 | [diff] [blame] | 75 | static pthread_mutex_t *s_urc_call_state_change_mutex = NULL;
|
| 76 | static pthread_cond_t *s_urc_call_state_change_cond = NULL;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 77 | static pthread_mutex_t s_incoming_call_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 78 | static pthread_cond_t s_incoming_call_cond = PTHREAD_COND_INITIALIZER;
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 79 | static pthread_mutex_t g_lynq_call_sendto_mutex;
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 80 | pthread_t lynq_call_urc_tid = -1;
|
| 81 | pthread_t lynq_call_list_loop_tid = -1;
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 82 |
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 83 | /*lei add*/
|
| 84 | /* socket文件描述符 */
|
| 85 | int len_addr_serv;
|
| 86 | struct sockaddr_in addr_serv;
|
| 87 | lynq_client_t client_t;
|
| 88 | int client_size = 0;
|
| 89 | /*lei add*/
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 90 |
|
ll | c81b4d5 | 2022-07-13 09:39:44 +0000 | [diff] [blame] | 91 | int s_call_urc_event_complete = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 92 |
|
| 93 | enum{
|
| 94 | CALL_OFF=0,
|
| 95 | CALL_ON=1
|
| 96 | }call_state;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 97 | typedef enum{
|
| 98 | LYNQ_E_CARDSTATE_ERROR=8000,
|
| 99 | /* The voice service state is out of service*/
|
| 100 | LYNQ_E_STATE_OUT_OF_SERVICE=8001,
|
| 101 | /* The voice service state is EMERGENCY_ONLY*/
|
| 102 | LYNQ_E_STATE_EMERGENCY_ONLY=8002,
|
| 103 | /* The radio power is power off*/
|
| 104 | LYNQ_E_STATE_POWER_OFF=8003,
|
| 105 | LYNQ_E_TIME_OUT=8004,
|
| 106 | /*create or open sms DB fail */
|
| 107 | LYNQ_E_SMS_DB_FAIL=8005,
|
| 108 | /*Failed to execute sql statement*/
|
| 109 | LYNQ_E_SMS_SQL_FAIL = 8006,
|
| 110 | LYNQ_E_SMS_NOT_FIND = 8007,
|
| 111 | /* The logic conflict*/
|
| 112 | LYNQ_E_CONFLICT=9000,
|
| 113 | /*Null anomaly*/
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 114 | LYNQ_E_NULL_ANONALY=9001,
|
| 115 | /*Invalid id anomaly*/
|
| 116 | LYNQ_E_INVALID_ID_ANONALY=9002,
|
| 117 | #ifdef ECALL_SUPPORT
|
| 118 | LYNQ_E_ECALL_BEING_RUNNING =9003,
|
| 119 | LYNQ_E_ECALL_MSD_LENGTH_ERROR =9004,
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame] | 120 | LYNQ_E_ECALL_DAILING_NO_ANSWER =9005,
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 121 | #endif
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 122 | }LYNQ_E;
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 123 | typedef enum{
|
| 124 | LYNQ_E_VOLUMN_SET_DTMF,
|
| 125 | LYNQ_E_VOLUMN_SET_SPEECH
|
| 126 | }LYNQ_E_VOLUMN_SET;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 127 |
|
| 128 | int lynq_call_state =CALL_OFF;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 129 | int lynq_call_client_sockfd = 0;
|
| 130 | int Global_uToken_call = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 131 | int global_call_count =0;
|
| 132 | int global_call_auto_answer = 0;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 133 | bool urc_call_recive_status = 1;
|
ll | c81b4d5 | 2022-07-13 09:39:44 +0000 | [diff] [blame] | 134 | bool call_list_loop = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 135 | int isDial = 0;
|
| 136 | int lynqIncomingCallId = 0;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 137 |
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 138 | /*rtp begin*/
|
| 139 | typedef struct
|
| 140 | {
|
| 141 | char ip[MAX_IP_LENGTH];
|
| 142 | int port;
|
| 143 | }lynq_rtp_server_info;
|
| 144 |
|
| 145 | typedef struct
|
| 146 | {
|
| 147 | int port;
|
| 148 | int clockrate;
|
| 149 | int latency;
|
| 150 | int channels;
|
| 151 | }lynq_rtp_client_info;
|
| 152 |
|
| 153 | static lynq_rtp_client_info g_rtp_client_info;
|
| 154 | static lynq_rtp_server_info g_rtp_server_info;
|
| 155 |
|
| 156 | static pthread_t g_rtp_thread[RTP_MODE_MAX];
|
| 157 | static bool g_rtp_thread_valid[RTP_MODE_MAX];
|
| 158 |
|
| 159 | /*rtp end*/
|
| 160 |
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 161 | #ifdef ECALL_SUPPORT
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 162 | int lynq_set_common_request(int request_id, int argc, const char* format,...);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 163 | int g_ecallId = INVALID_ID;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 164 | typedef enum{
|
| 165 | LYNQ_ECALL_TYPE_TEST = 0, /* Test eCall */
|
| 166 | LYNQ_ECALL_TYPE_RECONFIG = 1, /* Reconfiguration eCall */
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 167 | LYNQ_ECALL_MANUAL_EMERGENCY = 2, /*Manual Emergency eCall */
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame] | 168 | LYNQ_ECALL_TYPE_AUTO_EMERGENCY = 3, /* Automatic Emergency eCall */
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 169 | }LYNQ_ECall_Type;
|
| 170 |
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame] | 171 | typedef enum{
|
| 172 | LYNQ_ECALL_DAILING_STATE_NONE =0,
|
| 173 | LYNQ_ECALL_DAILING_STATE_STARTED = 1,
|
| 174 | LYNQ_ECALL_DAILING_STATE_ANSWERED = 2,
|
| 175 | }LYNQ_ECall_Dailing_State;
|
| 176 |
|
| 177 | LYNQ_ECall_Dailing_State is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 178 | char e_call_addr[LYNQ_ECALL_VAR_MAX][LYNQ_PHONE_NUMBER_MAX]={"test_ecall","emergency_ecall","reconf_ecall"};
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 179 |
|
| 180 | static pthread_mutex_t s_incoming_e_call_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 181 | static pthread_cond_t s_incoming_e_call_cond = PTHREAD_COND_INITIALIZER;
|
| 182 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 183 | LYNQ_ECall_Indication g_lynqIncomingEcallIndication;
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame] | 184 | int g_lynqIncomingEcallId;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 185 |
|
| 186 | void sendSignalIncomingECallEvent()
|
| 187 | {
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 188 | LYINFLOG("send incoming ecall event signal");
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 189 | pthread_mutex_lock(&s_incoming_e_call_mutex);
|
| 190 | pthread_cond_signal(&s_incoming_e_call_cond);
|
| 191 | pthread_mutex_unlock(&s_incoming_e_call_mutex);
|
| 192 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 193 |
|
| 194 | int lynq_is_msd_suc(LYNQ_ECall_Indication lynqIncomingEcallIndication)
|
| 195 | {
|
| 196 | if(LYNQ_ECALL_LLACK_RECEIVED == lynqIncomingEcallIndication ||
|
| 197 | LYNQ_ECALL_ALACK_POSITIVE_RECEIVED == lynqIncomingEcallIndication ||
|
| 198 | LYNQ_ECALL_ALACK_CLEARDOWN_RECEIVED == lynqIncomingEcallIndication ||
|
| 199 | LYNQ_ECALL_T5_TIMER_OUT == lynqIncomingEcallIndication ||
|
| 200 | LYNQ_ECALL_T6_TIMER_OUT == lynqIncomingEcallIndication ||
|
| 201 | LYNQ_ECALL_T7_TIMER_OUT == lynqIncomingEcallIndication)
|
| 202 | {
|
| 203 | return 1;
|
| 204 | }
|
| 205 |
|
| 206 | return 0;
|
| 207 | }
|
| 208 |
|
| 209 | int lynq_ecall_is_running()
|
| 210 | {
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame] | 211 | return (is_ecall_dial!=LYNQ_ECALL_DAILING_STATE_NONE) || (g_ecallId !=INVALID_ID);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 212 | }
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 213 | #endif
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 214 |
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 215 | /**
|
| 216 | * @brief mark call initialization state
|
| 217 | * 0: deinit state
|
| 218 | * 1: init state
|
| 219 | */
|
| 220 | int g_lynq_call_init_flag = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 221 |
|
| 222 | int JumpHeader(Parcel &p,int *resp_type,int *request,int *slot_id,int *error)
|
| 223 | {
|
| 224 | if(p.dataAvail() > 0)
|
| 225 | {
|
| 226 | p.readInt32(resp_type);
|
| 227 | p.readInt32(request);
|
| 228 | p.readInt32(slot_id);
|
| 229 | p.readInt32(error);
|
| 230 | return 0;
|
| 231 | }
|
| 232 | else
|
| 233 | {
|
| 234 | return -1;
|
| 235 | }
|
| 236 | }
|
| 237 | int send_request(int sockfd,lynq_client_t *client_tmp)
|
| 238 | {
|
| 239 | int ret=0;
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 240 | ret = sendto(sockfd, client_tmp, client_size, 0, (struct sockaddr *)&addr_serv, len_addr_serv);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 241 | if(ret==-1)
|
| 242 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 243 | LYERRLOG("sendto error");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 244 | return -1;
|
| 245 | }
|
| 246 | return 0;
|
| 247 | }
|
| 248 |
|
| 249 | int get_response(int sockfd,Parcel &p)
|
| 250 | {
|
| 251 | int len = 0;
|
| 252 | char recvline[LYNQ_REC_BUF];
|
| 253 | bzero(recvline,LYNQ_REC_BUF);
|
| 254 | /* receive data from server */
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 255 | len = recvfrom(sockfd,recvline,LYNQ_REC_BUF, 0, (struct sockaddr *)&addr_serv,(socklen_t*)&len_addr_serv);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 256 | if(len == -1)
|
| 257 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 258 | LYERRLOG("recvfrom error");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 259 | return -1;
|
| 260 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 261 | if (recvline != NULL) {
|
| 262 | p.setData((uint8_t *)recvline,len); // p.setData((uint8_t *) buffer, buflen);
|
| 263 | p.setDataPosition(0);
|
| 264 | }
|
| 265 | return 0;
|
| 266 | }
|
| 267 | static char *strdupReadString(Parcel &p) {
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 268 | size_t stringlen;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 269 | const char16_t *s16;
|
| 270 | s16 = p.readString16Inplace(&stringlen);
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 271 | return strndup16to8(s16, stringlen);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 272 | }
|
| 273 |
|
| 274 | int lynq_get_current_call_list(lynq_call_list_t call_list[LYNQ_CALL_MAX])
|
| 275 | {
|
| 276 | Parcel p;
|
| 277 | lynq_client_t client;
|
| 278 | int resp_type = -1;
|
| 279 | int request = -1;
|
| 280 | int slot_id = -1;
|
| 281 | int error = -1;
|
| 282 | int call_num = 0;
|
| 283 | int temp = 0;
|
| 284 | char *remote_phoneNum = NULL;
|
| 285 | char *remote_name= NULL;
|
| 286 | char *uusData = NULL;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 287 | client.uToken = Global_uToken_call;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 288 | client.request = 9;//RIL_REQUEST_GET_CURRENT_CALLS
|
| 289 | client.paramLen = 0;
|
| 290 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 291 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 292 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 293 | {
|
| 294 | LYERRLOG("send request fail");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 295 | return -1;
|
| 296 | }
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 297 | get_response(lynq_call_client_sockfd,p);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 298 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 299 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 300 | if(error == 0)
|
| 301 | {
|
| 302 | p.readInt32(&call_num);
|
| 303 | global_call_count = call_num;
|
| 304 | if(call_num<=0)
|
| 305 | {
|
| 306 | lynq_call_state = CALL_OFF;
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 307 | LYINFLOG("lynq_call_state:%d",lynq_call_state);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 308 | return 0;
|
| 309 | }
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 310 | lynq_call_state = CALL_ON;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 311 | LYINFLOG("lynq_call_state:%d, call num is %d ",lynq_call_state,call_num);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 312 | for(int i = 0;i < call_num;i++)
|
| 313 | {
|
| 314 | p.readInt32(&temp);
|
| 315 | call_list[i].call_state = temp;
|
| 316 | p.readInt32(&call_list[i].call_id);
|
| 317 | p.readInt32(&call_list[i].toa);
|
| 318 | p.readInt32(&temp);
|
| 319 | p.readInt32(&temp);
|
| 320 | call_list[i].direction = temp;
|
| 321 | p.readInt32(&temp);
|
| 322 | p.readInt32(&temp);
|
| 323 | p.readInt32(&temp);
|
| 324 | remote_phoneNum = strdupReadString(p);
|
| 325 | memcpy(call_list[i].addr,remote_phoneNum,strlen(remote_phoneNum));
|
| 326 | LYINFLOG("call_id=%d,call_state=%d,direction=%d,addr=%s,toa=%d",call_list[i].call_id,call_list[i].call_state,
|
| 327 | call_list[i].direction,call_list[i].addr,call_list[i].toa);
|
| 328 | p.readInt32(&temp);
|
| 329 | remote_name = strdupReadString(p);
|
| 330 | p.readInt32(&temp);
|
| 331 | p.readInt32(&temp);
|
| 332 | if(temp==0)
|
| 333 | {
|
| 334 | continue;
|
| 335 | }
|
| 336 | p.readInt32(&temp); /* UUS Information is present */
|
| 337 | p.readInt32(&temp);
|
| 338 | p.readInt32(&temp);
|
| 339 | p.read(uusData,temp);
|
| 340 | }
|
| 341 | }
|
| 342 | return 0;
|
| 343 | }
|
| 344 |
|
| 345 | void cleanCallList(int lynq_call_id)
|
| 346 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 347 | LYINFLOG("cleanCall local idx is %d, id is %d",lynq_call_id,lynq_call_lists[lynq_call_id].call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 348 | lynq_call_lists[lynq_call_id].call_id = 0;
|
lh | 8657e74 | 2022-04-26 00:45:44 -0700 | [diff] [blame] | 349 | lynq_call_lists[lynq_call_id].call_state = (int)LYNQ_CALL_END;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 350 | lynq_call_lists[lynq_call_id].toa = 0;
|
| 351 | lynq_call_lists[lynq_call_id].direction = 0;
|
| 352 | lynq_call_lists[lynq_call_id].used = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 353 | memset(lynq_call_lists[lynq_call_id].addr,0,sizeof(lynq_call_lists[lynq_call_id].addr));
|
| 354 | }
|
| 355 | int getUnusedElement()
|
| 356 | {
|
| 357 | for(int i=0;i < LYNQ_CALL_MAX; i++)
|
| 358 | {
|
| 359 | if(lynq_call_lists[i].used!=1)
|
| 360 | {
|
| 361 | return i;
|
| 362 | }
|
| 363 | }
|
| 364 | return -1;
|
| 365 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 366 | int addAddr(char addr[])
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 367 | {
|
| 368 | int ret = 0;
|
| 369 | ret = getUnusedElement();
|
| 370 | memcpy(lynq_call_lists[ret].addr,addr,strlen(addr)+1);
|
| 371 | lynq_call_lists[ret].used = 1;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 372 | LYINFLOG("add local idx is %d addr is %s",ret,addr);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 373 | return ret;
|
| 374 | }
|
| 375 | void updateCallList(lynq_call_list_e_t *callList, int call_id,int call_state,int toa,int direction)
|
| 376 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 377 | LYINFLOG("Update original local id is %d, new local id is %d",callList->call_id,call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 378 | callList->call_id = call_id;
|
| 379 | callList->call_state = call_state;
|
| 380 | callList->toa = toa;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 381 | callList->direction = direction;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 382 | return;
|
| 383 | }
|
| 384 | int waitCallstateChange(int mtime)
|
| 385 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 386 | LYINFLOG("wait Call state Change");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 387 | int ret = 0;
|
| 388 | int sec = 0;
|
| 389 | int usec = 0;
|
lh | 228a7b8 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 390 | struct timeval now;
|
| 391 | struct timespec timeout;
|
| 392 | gettimeofday(&now,NULL);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 393 | sec = mtime/1000;
|
| 394 | usec = mtime%1000;
|
lh | 228a7b8 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 395 | timeout.tv_sec = now.tv_sec+sec;
|
| 396 | timeout.tv_nsec = now.tv_usec*1000+usec*1000000;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 397 | pthread_mutex_lock(&call_state_change_mutex);
|
lh | 228a7b8 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 398 | ret = pthread_cond_timedwait(&call_state_change_cond,&call_state_change_mutex,&timeout);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 399 | pthread_mutex_unlock(&call_state_change_mutex);
|
| 400 | return ret;
|
| 401 | }
|
| 402 | int waitIncomingCall()
|
| 403 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 404 | LYINFLOG("wait incming call");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 405 | int ret = 0;
|
| 406 | pthread_mutex_lock(&s_incoming_call_mutex);
|
| 407 | ret = pthread_cond_wait(&s_incoming_call_cond,&s_incoming_call_mutex);
|
| 408 | pthread_mutex_unlock(&s_incoming_call_mutex);
|
| 409 | return ret;
|
| 410 | }
|
| 411 | int checkHasCall(char addr[])
|
| 412 | {
|
| 413 | for(int i = 0;i<LYNQ_CALL_MAX;i++)
|
| 414 | {
|
| 415 | if(strcmp(lynq_call_lists[i].addr,addr)==0)
|
| 416 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 417 | LYINFLOG("checkHasCall addr is %s idx is %d id is %d",addr,i,lynq_call_lists[i].call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 418 | return 1;
|
| 419 | }
|
| 420 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 421 | LYINFLOG("checkHasCall addr is %s , no idx is found",addr);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 422 | return 0;
|
| 423 | }
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 424 | int find_call_id_with_addr(char *addr)
|
| 425 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 426 | for(int id = 0; id < LYNQ_CALL_MAX; id++)
|
| 427 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 428 | if(lynq_call_lists[id].used && (strcmp(lynq_call_lists[id].addr,addr) == 0))
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 429 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 430 | LYINFLOG("find addr %s in local list, local idx is %d id is %d",addr,id,lynq_call_lists[id].call_id);
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 431 | return id;
|
| 432 | }
|
| 433 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 434 | LYINFLOG("find addr %s in local list , not found",addr);
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 435 | return -1;
|
| 436 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 437 | int find_call_id_with_call_id(int call_id)
|
| 438 | {
|
| 439 | for(int id = 0; id < LYNQ_CALL_MAX; id++)
|
| 440 | {
|
| 441 | if(lynq_call_lists[id].used && (lynq_call_lists[id].call_id == call_id))
|
| 442 | {
|
| 443 | LYINFLOG("find id %d in local list, local idx is %d, addr is %s",call_id,id,lynq_call_lists[id].addr);
|
| 444 | return id;
|
| 445 | }
|
| 446 | }
|
| 447 | LYINFLOG("find id %d in local list , not found",call_id);
|
| 448 | return INVALID_ID;
|
| 449 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 450 | void sendSignalToWaitCallStateChange()
|
| 451 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 452 | LYINFLOG("send Signal To Wait Call State Change");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 453 | pthread_mutex_lock(&call_state_change_mutex);
|
| 454 | pthread_cond_signal(&call_state_change_cond);
|
| 455 | pthread_mutex_unlock(&call_state_change_mutex);
|
| 456 | }
|
| 457 | void sendSignalIncomingCall()
|
| 458 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 459 | LYINFLOG("send incoming call signal");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 460 | pthread_mutex_lock(&s_incoming_call_mutex);
|
| 461 | pthread_cond_signal(&s_incoming_call_cond);
|
| 462 | pthread_mutex_unlock(&s_incoming_call_mutex);
|
| 463 | }
|
| 464 |
|
| 465 | void addCallListToLynqCallList(lynq_call_list_e_t *callList, int call_id,int call_state,int toa,int direction,char addr[LYNQ_PHONE_NUMBER_MAX])
|
| 466 | {
|
| 467 | callList->call_id = call_id;
|
| 468 | callList->call_state = call_state;
|
| 469 | callList->toa = toa;
|
| 470 | callList->direction = direction;
|
| 471 | memcpy(callList->addr,addr,strlen(addr)+1);
|
| 472 | callList->used = 1;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 473 | return;
|
| 474 | }
|
| 475 |
|
| 476 | void *triggerGetCallList(void *parg)
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 477 | {
|
| 478 | int ret=0;
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 479 | bool call_end;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 480 | lynq_call_list_t call_list[LYNQ_CALL_MAX];
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 481 | int update=0;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 482 | int cnt;
|
| 483 | int i,n;
|
| 484 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 485 | while(call_list_loop)
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 486 | {
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 487 | update=0;
|
ll | c81b4d5 | 2022-07-13 09:39:44 +0000 | [diff] [blame] | 488 | pthread_mutex_lock(s_urc_call_state_change_mutex);
|
| 489 | pthread_cond_wait(s_urc_call_state_change_cond, s_urc_call_state_change_mutex);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 490 | LYDBGLOG("triggerGetCallList event!!!");
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 491 | memset(call_list,0,sizeof(call_list));
|
| 492 | ret = lynq_get_current_call_list(call_list);
|
| 493 | if(ret != 0)
|
| 494 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 495 | LYDBGLOG("get current call list failure!!!");
|
ll | 2210140 | 2022-04-11 05:49:51 +0000 | [diff] [blame] | 496 | continue;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 497 | }
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 498 | LYINFLOG("++++++++++++++triggerGetCallList++++++++++++++");
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 499 | LYINFLOG("clear local index begin");
|
| 500 | cnt=0;
|
| 501 | for(i = 0;i < LYNQ_CALL_MAX;i++)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 502 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 503 | if(lynq_call_lists[i].used ==0)
|
| 504 | {
|
| 505 | continue;
|
| 506 | }
|
| 507 | cnt++;
|
| 508 | LYINFLOG("local idx is %d id is %d addr is %s state is %d direction is %d",i,lynq_call_lists[i].call_id,lynq_call_lists[i].addr,lynq_call_lists[i].call_state,lynq_call_lists[i].direction);
|
| 509 |
|
| 510 | if(lynq_call_lists[i].call_id > 0)
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 511 | {
|
| 512 | call_end = 0;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 513 | for(n = 0; n < LYNQ_CALL_MAX; n++)
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 514 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 515 | if(call_list[n].call_id == lynq_call_lists[i].call_id)
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 516 | {
|
| 517 | call_end = 1;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 518 | LYINFLOG("find lynq call local idx %d, service idx %d id is %d!!!",i,n,lynq_call_lists[i].call_id);
|
| 519 | break;
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 520 | }
|
| 521 | }
|
| 522 | if(call_end == 0)
|
| 523 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 524 | LYINFLOG("MT hungup,then clean call info local idx is %d id is %d",i, lynq_call_lists[i].call_id);
|
| 525 | cleanCallList(i);
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 526 | }
|
| 527 | } //fix bug API-54
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 528 | else
|
| 529 | {
|
| 530 | LYINFLOG("local id is 0");
|
| 531 | }
|
| 532 | }
|
| 533 | LYINFLOG("clear local index end, local used cnt is %d", cnt);
|
| 534 |
|
| 535 | LYINFLOG("add or update local index begin ");
|
| 536 | for (i = 0;i < LYNQ_CALL_MAX;i++)
|
| 537 | {
|
| 538 | if(call_list[i].call_id==0)
|
| 539 | {
|
| 540 | break;
|
| 541 | }
|
| 542 |
|
| 543 | LYINFLOG("servie idx %d begin: call_id=%d, call_state=%d, direction=%d, addr=%s, toa=%d",i,call_list[i].call_id, call_list[i].call_state,
|
| 544 | call_list[i].direction,call_list[i].addr,call_list[i].toa);
|
| 545 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 546 | if(call_list[i].direction == 1)//MT call
|
| 547 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 548 | LYINFLOG("This is a MT CALL");
|
lh | 4256e1b | 2022-05-13 03:02:19 -0700 | [diff] [blame] | 549 | /*MT CALL state code
|
| 550 | **LYNQ_CALL_INCOMING = 4,
|
| 551 | **LYNQ_CALL_WAITING = 5,
|
| 552 | */
|
| 553 | if((call_list[i].call_state ==4) || (call_list[i].call_state ==5))
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 554 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 555 | #ifdef ECALL_SUPPORT
|
| 556 | if(lynq_ecall_is_running())
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 557 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 558 | lynq_call_hungup(&(call_list[i].call_id));
|
| 559 | continue;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 560 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 561 | #endif
|
| 562 | }
|
| 563 | /*you call me, and i call you,One party failed to dial*/
|
| 564 | n = find_call_id_with_addr(call_list[i].addr);
|
| 565 | if(n ==INVALID_ID)
|
| 566 | {
|
| 567 | n = addAddr(call_list[i].addr);
|
| 568 | updateCallList(&lynq_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);
|
| 569 | lynqIncomingCallId = call_list[i].call_id;
|
| 570 | sendSignalIncomingCall();
|
| 571 | }
|
| 572 | else if(lynq_call_lists[n].call_state == call_list[i].call_state)
|
| 573 | {
|
| 574 | LYINFLOG("state not changed, state is %d ",call_list[i].call_state);
|
| 575 | if(call_list[i].call_state ==4 || call_list[i].call_state ==5)
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 576 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 577 | /*if call state not change,Maybe this call was ignored, so we need to continue to inform the user of
|
| 578 | **an incoming call until the status changes.
|
| 579 | **fix bug API-54
|
| 580 | */
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 581 | LYINFLOG("resend incoming call signal");
|
| 582 | sendSignalIncomingCall();
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 583 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 584 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 585 | else
|
ll | 45d3ea9 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 586 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 587 | LYINFLOG("state changed from %d to %d",lynq_call_lists[n].call_state,call_list[i].call_state);
|
| 588 |
|
| 589 | updateCallList(&lynq_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);
|
| 590 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 591 | }
|
| 592 | else
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 593 | {
|
| 594 | LYINFLOG("This is a MO CALL");
|
| 595 | call_end = 0;
|
| 596 | for(n = 0 ; n < LYNQ_CALL_MAX; n++)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 597 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 598 | if(lynq_call_lists[n].used && ((strcmp(call_list[i].addr,lynq_call_lists[n].addr)==0)||(call_list[i].call_id==lynq_call_lists[n].call_id)))
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 599 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 600 | if(lynq_call_lists[n].call_id==0)
|
| 601 | {
|
| 602 | LYINFLOG("add a call id");
|
| 603 | update=1;
|
| 604 | }
|
| 605 | LYINFLOG("local idx %d updated, original call id is %d origial addr is %s original state is %d",n,lynq_call_lists[n].call_id,lynq_call_lists[n].addr,lynq_call_lists[n].call_state);
|
| 606 | updateCallList(&lynq_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);
|
| 607 | call_end = 1;
|
| 608 | break;
|
| 609 | }
|
| 610 | }
|
| 611 |
|
| 612 | if(call_end == 0)
|
| 613 | {
|
| 614 | LYINFLOG("need to hangup id %d", call_list[i].call_id);
|
| 615 | #ifdef ECALL_SUPPORT
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame] | 616 | if(is_ecall_dial != LYNQ_ECALL_DAILING_STATE_NONE)
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 617 | {
|
| 618 | LYINFLOG("ecall is dialing, for the timebeing, don't huangup");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 619 | continue;
|
| 620 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 621 | #endif
|
| 622 | LYINFLOG("hang up service call id %d",call_list[i].call_id);
|
| 623 | lynq_call_hungup(&(call_list[i].call_id));
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 624 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 625 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 626 | LYDBGLOG("servie idx %d end",i);
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 627 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 628 | LYINFLOG("add or update local index end ");
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 629 | s_call_urc_event_complete = 1;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 630 | if(isDial==1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 631 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 632 | LYINFLOG("now is dialing");
|
| 633 | if(update==1)
|
| 634 | {
|
| 635 | LYINFLOG("find added call");
|
| 636 | sendSignalToWaitCallStateChange();
|
| 637 | isDial = 0;
|
| 638 | }
|
| 639 | else
|
| 640 | {
|
| 641 | LYINFLOG("not find added call");
|
| 642 | }
|
| 643 | }
|
| 644 | else
|
| 645 | {
|
| 646 | LYINFLOG("now is not dialing");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 647 | }
|
ll | c81b4d5 | 2022-07-13 09:39:44 +0000 | [diff] [blame] | 648 | pthread_mutex_unlock(s_urc_call_state_change_mutex);
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 649 | }
|
| 650 | return NULL;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 651 | }
|
| 652 |
|
| 653 | void lynqRespWatingEvent()
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 654 | {
|
| 655 | if(s_call_urc_event_complete==1)
|
| 656 | {
|
ll | c81b4d5 | 2022-07-13 09:39:44 +0000 | [diff] [blame] | 657 | pthread_mutex_lock(s_urc_call_state_change_mutex);
|
| 658 | pthread_cond_signal(s_urc_call_state_change_cond);
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 659 | s_call_urc_event_complete = 0;
|
ll | c81b4d5 | 2022-07-13 09:39:44 +0000 | [diff] [blame] | 660 | pthread_mutex_unlock(s_urc_call_state_change_mutex);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 661 | }
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 662 | return;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 663 | }
|
| 664 |
|
| 665 | /*Warren add for T800 platform 2021/11/19 start*/
|
| 666 | int lynq_socket_client_start()
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 667 | {
|
| 668 | #if 0
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 669 | struct sockaddr_in lynq_socket_server_addr;
|
| 670 | /* init lynq_socket_server_addr */
|
| 671 | bzero(&lynq_socket_server_addr, sizeof(lynq_socket_server_addr));
|
| 672 | lynq_socket_server_addr.sin_family = AF_INET;
|
| 673 | lynq_socket_server_addr.sin_port = htons(LYNQ_SERVICE_PORT);
|
| 674 | lynq_socket_server_addr.sin_addr.s_addr = htons(INADDR_ANY);
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 675 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 676 | /*
|
| 677 | if(inet_pton(AF_INET,"127.0.0.1", &lynq_socket_server_addr.sin_addr) <= 0)
|
| 678 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 679 | LYDBGLOG("[%s] is not a valid IPaddress", argv[1]);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 680 | exit(1);
|
| 681 | }
|
| 682 | */
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 683 | lynq_call_client_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
| 684 | if(connect(lynq_call_client_sockfd, (struct sockaddr *)&lynq_socket_server_addr, sizeof(lynq_socket_server_addr)) == -1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 685 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 686 | LYERRLOG("connect error");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 687 | return -1;
|
| 688 | }
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 689 | #endif
|
| 690 | lynq_call_client_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
| 691 | if (-1 == lynq_call_client_sockfd)
|
| 692 | {
|
| 693 | return lynq_call_client_sockfd;
|
| 694 | }
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 695 | struct timeval timeOut;
|
| 696 | timeOut.tv_sec = 60;
|
| 697 | timeOut.tv_usec = 0;
|
| 698 | if (setsockopt(lynq_call_client_sockfd, SOL_SOCKET, SO_RCVTIMEO, &timeOut, sizeof(timeOut)) < 0)
|
| 699 | {
|
| 700 | RLOGD("time out setting failed\n");
|
| 701 | return -1;
|
| 702 | }
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 703 | /* 设置address */
|
| 704 | memset(&addr_serv, 0, sizeof(addr_serv));
|
| 705 | addr_serv.sin_family = AF_INET;
|
| 706 | addr_serv.sin_addr.s_addr = inet_addr(DSET_IP_ADDRESS);
|
| 707 | addr_serv.sin_port = htons(LYNQ_SERVICE_PORT);
|
| 708 | len_addr_serv = sizeof(addr_serv);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 709 | return 0;
|
| 710 | }
|
| 711 | int lynq_update_call_list_loop()
|
| 712 | {
|
| 713 | int ret = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 714 | pthread_attr_t attr;
|
| 715 | pthread_attr_init(&attr);
|
| 716 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 717 | ret = pthread_create(&lynq_call_list_loop_tid,&attr,triggerGetCallList,NULL);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 718 | if(ret < 0)
|
| 719 | {
|
| 720 | LYERRLOG("lynq_update_call_list_loop fail!!!");
|
| 721 | return -1;
|
| 722 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 723 | LYDBGLOG("lynq_update_call_list_loop success!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 724 | return 0;
|
| 725 |
|
| 726 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 727 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 728 | void *thread_urc_recv(void *parg)
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 729 | {
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 730 | int socket_fd = (int64_t)parg;
|
| 731 | int len=0;
|
| 732 | socklen_t addr_len=0;
|
| 733 | uint8_t *dataLength = NULL;
|
| 734 | char urc_data[LYNQ_REC_BUF];
|
| 735 | int slot_id = -1;
|
| 736 | int resp_type = -1;
|
| 737 | int urcid = -1;
|
| 738 | Parcel *p = NULL;
|
| 739 | struct sockaddr_in dest_addr;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 740 | #ifdef ECALL_SUPPORT
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 741 | int ecall_ind;
|
| 742 | int ecallId;
|
| 743 | int unused_callid;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 744 | #endif
|
| 745 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 746 | LYINFLOG("thread_urc_recv in running....");
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 747 | while(urc_call_recive_status)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 748 | {
|
| 749 | bzero(urc_data,LYNQ_REC_BUF);
|
| 750 | //get data msg
|
| 751 | len = recvfrom(socket_fd,urc_data,LYNQ_REC_BUF,0,(struct sockaddr *)&dest_addr,&addr_len);
|
| 752 | if(len <= 0)
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 753 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 754 | LYERRLOG("thread_urc_recv step2 fail");
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 755 | break;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 756 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 757 | LYDBGLOG("=====>urc data len<=====:%d",len);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 758 | p = new Parcel();
|
| 759 | if(p==NULL)
|
| 760 | {
|
lh | 59e0d00 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 761 | LYERRLOG("new parcel failure!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 762 | break;
|
| 763 | }
|
| 764 | p->setData((uint8_t *)urc_data,len); // p.setData((uint8_t *) buffer, buflen);
|
| 765 | p->setDataPosition(0);
|
| 766 | if(p->dataAvail() > 0)
|
| 767 | {
|
| 768 | p->readInt32(&resp_type);
|
| 769 | p->readInt32(&urcid);
|
| 770 | p->readInt32(&slot_id);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 771 | //LYDBGLOG("*******Warren test*******:resp_type=%d,urcid=%d,slot_id=%d",resp_type,urcid,slot_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 772 | switch (urcid)
|
| 773 | {
|
| 774 | case 1001://RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED
|
| 775 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 776 | LYINFLOG("**************:resp_type=%d,urcid=%d,slot_id=%d",resp_type,urcid,slot_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 777 | lynqRespWatingEvent();
|
| 778 | break;
|
| 779 | }
|
| 780 | case 1018://RIL_UNSOL_CALL_RING
|
| 781 | {
|
| 782 | if(global_call_auto_answer==1)
|
| 783 | {
|
| 784 | lynq_call_answer();
|
| 785 | }
|
| 786 | break;
|
| 787 | }
|
| 788 | case 1029://RIL_UNSOL_RINGBACK_TONE
|
| 789 | case 3049://RIL_UNSOL_CALL_INFO_INDICATION
|
| 790 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 791 | LYINFLOG("**************:resp_type=%d,urcid=%d,slot_id=%d",resp_type,urcid,slot_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 792 | break;
|
| 793 | }
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 794 | #ifdef ECALL_SUPPORT
|
| 795 | case RIL_UNSOL_ECALL_INDICATIONS:
|
| 796 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 797 | p->readInt32(&ecall_ind);
|
| 798 | g_lynqIncomingEcallIndication = ecall_ind;
|
| 799 | p->readInt32(&ecallId);
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame] | 800 | g_lynqIncomingEcallId = ecallId;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 801 | LYINFLOG("**************:RIL_UNSOL_ECALL_INDICATIONS ,Id %d, ind %d, ecall dialing is %d, normal dialing is %d, local ecall id is %d",ecallId,ecall_ind,is_ecall_dial,isDial,g_ecallId);
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame] | 802 | switch (g_lynqIncomingEcallIndication)
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 803 | {
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame] | 804 | case LYNQ_ECALL_ACTIVE:
|
| 805 | if(is_ecall_dial)
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 806 | {
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame] | 807 | is_ecall_dial = LYNQ_ECALL_DAILING_STATE_ANSWERED;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 808 | }
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame] | 809 | break;
|
| 810 | case LYNQ_ECALL_LLACK_RECEIVED:
|
| 811 | case LYNQ_ECALL_ALACK_POSITIVE_RECEIVED:
|
| 812 | case LYNQ_ECALL_ALACK_CLEARDOWN_RECEIVED:
|
| 813 | case LYNQ_ECALL_T5_TIMER_OUT:
|
| 814 | case LYNQ_ECALL_T6_TIMER_OUT:
|
| 815 | case LYNQ_ECALL_T7_TIMER_OUT:
|
| 816 | if(is_ecall_dial)
|
| 817 | {
|
| 818 | LYINFLOG("ecall is dialing, recv suc indication");
|
| 819 | is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
|
| 820 | if(ecallId >0 && find_call_id_with_call_id(ecallId)==INVALID_ID)
|
| 821 | {
|
| 822 | LYINFLOG("add ecall in loacl list");
|
| 823 | g_ecallId = ecallId;
|
| 824 | unused_callid=addAddr("ecall");
|
| 825 | lynq_call_lists[unused_callid].call_id=g_ecallId;
|
| 826 | }
|
| 827 | sendSignalToWaitCallStateChange();
|
| 828 | }
|
| 829 | else if(ecallId >0 && (find_call_id_with_call_id(ecallId)==INVALID_ID))
|
| 830 | {
|
| 831 | LYERRLOG("ecall is not in dialing and first recv suc indication, hangup");
|
| 832 | lynq_call_hungup(&ecallId);
|
| 833 | }
|
| 834 | else
|
| 835 | {
|
| 836 | LYERRLOG("ecall is not in dialing and not first recv suc indication");
|
| 837 | }
|
| 838 | break;
|
| 839 | case LYNQ_ECALL_PSAP_CALLBACK_START:
|
| 840 | if(lynq_ecall_is_running()==0)
|
| 841 | {
|
| 842 | LYINFLOG("ecall is not running, recv psap call back msd start, set ecall in dialing");
|
| 843 | if(find_call_id_with_call_id(ecallId)!=INVALID_ID)
|
| 844 | {
|
| 845 | g_ecallId = ecallId;
|
| 846 | if(isDial)
|
| 847 | {
|
| 848 | LYINFLOG("stop normal dial");
|
| 849 | sendSignalToWaitCallStateChange();
|
| 850 | }
|
| 851 | else
|
| 852 | {
|
| 853 | LYINFLOG("no normal dial");
|
| 854 | }
|
| 855 | }
|
| 856 | else
|
| 857 | {
|
| 858 | LYERRLOG("can't find ecall id in local list");
|
| 859 | }
|
| 860 | }
|
| 861 | else
|
| 862 | {
|
| 863 | LYERRLOG("ecall is running, recv psap call back msd start");
|
| 864 | }
|
| 865 | break;
|
| 866 | case LYNQ_ECALL_ABNORMAL_HANGUP:
|
| 867 | if(is_ecall_dial == LYNQ_ECALL_DAILING_STATE_NONE)
|
| 868 | {
|
| 869 | LYERRLOG("ecall is not in dialing , recv abnormal hangup");
|
| 870 | g_ecallId = INVALID_ID;
|
| 871 | }
|
| 872 | else if (is_ecall_dial == LYNQ_ECALL_DAILING_STATE_STARTED)
|
| 873 | {
|
| 874 | LYERRLOG("ecall is in dialing state, recv no answer, recv abnormal hangup, dont' redial");
|
| 875 | g_ecallId = INVALID_ID;
|
| 876 | sendSignalToWaitCallStateChange();
|
| 877 | }
|
| 878 | else {
|
| 879 | LYINFLOG("ecall is in dialing and recv answer, recv abnormal hangup");
|
| 880 | }
|
| 881 | break;
|
| 882 | case LYNQ_ECALL_DISCONNECTED:
|
| 883 | case LYNQ_ECALL_REDIAL_TIMER_OUT:
|
| 884 | case LYNQ_ECALL_T2_TIMER_OUT :
|
| 885 | case LYNQ_ECALL_IMS_DISCONNECTED:
|
| 886 | g_ecallId = INVALID_ID;
|
| 887 | if(is_ecall_dial != LYNQ_ECALL_DAILING_STATE_NONE)
|
| 888 | {
|
| 889 | LYERRLOG("ecall is in dialing, recv like disconnect indication");
|
| 890 | is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
|
| 891 | sendSignalToWaitCallStateChange();
|
| 892 | }
|
| 893 | else
|
| 894 | {
|
| 895 | LYINFLOG("ecall is not in dialing, recv like disconnect indication");
|
| 896 | }
|
| 897 | break;
|
| 898 | default:
|
| 899 | LYINFLOG("not special indication");
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 900 | }
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 901 | sendSignalIncomingECallEvent();
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 902 | LYINFLOG("**************:RIL_UNSOL_ECALL_INDICATIONS, local ecall id is %d", g_ecallId);
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 903 | break;
|
| 904 | }
|
| 905 | #endif
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 906 | default:
|
| 907 | break;
|
| 908 | }
|
| 909 | }
|
| 910 | delete p;
|
| 911 | p = NULL;
|
| 912 | }
|
| 913 | close(socket_fd);
|
| 914 | }
|
| 915 | int lynq_socket_urc_start()
|
| 916 | {
|
| 917 | int socket_fd=0;
|
| 918 | int rt=0;
|
| 919 | int len=0;
|
| 920 | int on=1;
|
| 921 | struct sockaddr_in urc_local_addr;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 922 | pthread_attr_t attr;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 923 | socket_fd = socket(AF_INET,SOCK_DGRAM,0);
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 924 | if(socket_fd < 0)
|
| 925 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 926 | LYERRLOG("creaet socket for udp fail");
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 927 | return -1;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 928 | }
|
| 929 | urc_local_addr.sin_family = AF_INET;
|
| 930 | urc_local_addr.sin_port = htons(LYNQ_URC_SERVICE_PORT);
|
| 931 | urc_local_addr.sin_addr.s_addr = htons(INADDR_ANY);
|
| 932 | /* Set socket to allow reuse of address and port, SO_REUSEADDR value is 2*/
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 933 | rt = setsockopt(socket_fd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on);
|
| 934 | if(rt<0)
|
| 935 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 936 | LYERRLOG("SO_REUSEADDR fail");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 937 | return -1;
|
| 938 | }
|
| 939 | rt = bind(socket_fd ,(struct sockaddr*)&urc_local_addr, sizeof(urc_local_addr));
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 940 | if (rt == -1)
|
| 941 | {
|
lh | 59e0d00 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 942 | LYERRLOG("bind failed");
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 943 | return -1;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 944 | }
|
| 945 | pthread_attr_init(&attr);
|
| 946 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 947 | rt = pthread_create(&lynq_call_urc_tid,&attr,thread_urc_recv,(void *)socket_fd);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 948 | if(rt < 0)
|
| 949 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 950 | LYERRLOG("urc loop failure!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 951 | return -1;
|
| 952 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 953 | LYDBGLOG("urc loop success!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 954 | return 0;
|
| 955 | }
|
| 956 | int getSelfElement(char addr[])
|
| 957 | {
|
| 958 | for(int i=0;i < LYNQ_CALL_MAX; i++)
|
| 959 | {
|
| 960 | if(lynq_call_lists[i].used==1)
|
| 961 | {
|
| 962 | if(strcmp(lynq_call_lists[i].addr,addr)==0)
|
| 963 | {
|
| 964 | return i;
|
| 965 | }
|
| 966 |
|
| 967 | }
|
| 968 | }
|
| 969 | return -1;
|
| 970 | }
|
| 971 |
|
| 972 | void lynq_call_state_change_test(int soc_id)
|
| 973 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 974 | LYDBGLOG("call state change,sim:%d",soc_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 975 | }
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 976 |
|
| 977 | void lynq_init_rtp()
|
| 978 | {
|
| 979 | memset(&g_rtp_client_info,0,sizeof(g_rtp_client_info));
|
| 980 | memset(&g_rtp_server_info,0,sizeof(g_rtp_server_info));
|
| 981 |
|
| 982 |
|
| 983 | lynq_set_rtp_param(8000,1,400);
|
| 984 |
|
| 985 | for(int i=0;i<RTP_MODE_MAX;i++)
|
| 986 | {
|
q.huang | 301f2a6 | 2022-06-30 09:55:45 +0800 | [diff] [blame] | 987 | lynq_set_rtp_port(i,6666);
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 988 | g_rtp_thread_valid[i] = 0;
|
| 989 | }
|
| 990 |
|
| 991 | LYDBGLOG("lynq init rtp success!!!");
|
| 992 | return;
|
| 993 | }
|
| 994 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 995 | int lynq_init_call(int uToken)
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 996 | {
|
| 997 | if(g_lynq_call_init_flag == 1){
|
| 998 | LYDBGLOG("lynq init call failed!!!");
|
| 999 | return -1;
|
| 1000 | }
|
| 1001 | g_lynq_call_init_flag = 1;
|
ll | c81b4d5 | 2022-07-13 09:39:44 +0000 | [diff] [blame] | 1002 | s_call_urc_event_complete = 1;
|
| 1003 | call_list_loop = 1;
|
| 1004 | LYINFLOG("liulei call_list_loop %d\n", call_list_loop);
|
| 1005 | s_urc_call_state_change_mutex = new pthread_mutex_t;
|
| 1006 | pthread_mutex_init(s_urc_call_state_change_mutex, NULL);
|
| 1007 | s_urc_call_state_change_cond = new pthread_cond_t;
|
| 1008 | LYINFLOG("liulei s_urc_call_state_change_mutex\n");
|
| 1009 | pthread_cond_init(s_urc_call_state_change_cond, NULL);
|
| 1010 | LYINFLOG("liulei s_urc_call_state_change_cond\n");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1011 | int result = 0;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1012 | Global_uToken_call = uToken;
|
lh | 59e0d00 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 1013 | urc_call_recive_status = 1;
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 1014 | client_size = sizeof(client_t);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1015 | LYLOGSET(LOG_INFO);
|
| 1016 | LYLOGEINIT(USER_LOG_TAG);
|
| 1017 | result = lynq_socket_client_start();
|
| 1018 | if(result!=0)
|
| 1019 | {
|
| 1020 | return -1;
|
| 1021 | }
|
| 1022 | result = lynq_socket_urc_start();
|
| 1023 | if(result!=0)
|
| 1024 | {
|
| 1025 | return -1;
|
| 1026 | }
|
| 1027 | result = lynq_update_call_list_loop();
|
| 1028 | if(result!=0)
|
| 1029 | {
|
| 1030 | return -1;
|
| 1031 | }
|
| 1032 | memset(lynq_call_lists,0,sizeof(lynq_call_lists));
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 1033 |
|
| 1034 | lynq_init_rtp();
|
| 1035 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1036 | LYDBGLOG("lynq init call success!!!");
|
| 1037 | return 0;
|
| 1038 | }
|
| 1039 | int lynq_deinit_call()
|
| 1040 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1041 | int ret;
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 1042 | if(g_lynq_call_init_flag == 0)
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 1043 | {
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 1044 | LYDBGLOG("lynq_deinit_call failed!!!");
|
| 1045 | return -1;
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 1046 | }
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 1047 | else
|
ll | c81b4d5 | 2022-07-13 09:39:44 +0000 | [diff] [blame] | 1048 | {
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 1049 | g_lynq_call_init_flag = 0;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1050 | lynq_call_hungup_all();
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 1051 | if(lynq_call_client_sockfd>0)
|
| 1052 | {
|
| 1053 | close(lynq_call_client_sockfd);
|
| 1054 | }
|
| 1055 | urc_call_recive_status = 0;
|
| 1056 | call_list_loop = 0;
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 1057 | lynq_set_voice_audio_mode(AUDIO_MODE_CODEC);
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 1058 | if(lynq_call_urc_tid == -1 || lynq_call_list_loop_tid == -1)
|
| 1059 | {
|
| 1060 | return -1;
|
| 1061 | }
|
| 1062 | ret = pthread_cancel(lynq_call_urc_tid);
|
| 1063 | LYDBGLOG("pthread cancel ret = %d",ret);
|
| 1064 | ret = pthread_cancel(lynq_call_list_loop_tid);
|
| 1065 | LYDBGLOG("pthread cancel ret = %d",ret);
|
| 1066 | ret = pthread_join(lynq_call_urc_tid,NULL);
|
| 1067 | LYDBGLOG("pthread join ret = %d",ret);
|
| 1068 | ret = pthread_join(lynq_call_list_loop_tid,NULL);
|
| 1069 | LYDBGLOG("pthread join ret = %d",ret);
|
ll | c81b4d5 | 2022-07-13 09:39:44 +0000 | [diff] [blame] | 1070 | pthread_mutex_destroy(s_urc_call_state_change_mutex);
|
| 1071 | pthread_cond_destroy(s_urc_call_state_change_cond);
|
| 1072 | delete s_urc_call_state_change_mutex;
|
| 1073 | //s_urc_call_state_change_mutex = NULL;
|
| 1074 | delete s_urc_call_state_change_cond;
|
| 1075 | //s_urc_call_state_change_cond = NULL;
|
| 1076 |
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 1077 | return 0;
|
| 1078 | }
|
rita | 47debb9 | 2022-04-07 06:08:13 -0400 | [diff] [blame] | 1079 | }
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1080 |
|
| 1081 | int lynq_set_common_request(int request_id, int argc, const char* format,...)
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1082 | {
|
| 1083 | Parcel p;
|
| 1084 | lynq_client_t client;
|
| 1085 | int resp_type = -1;
|
| 1086 | int request = -1;
|
| 1087 | int slot_id = -1;
|
| 1088 | int error = -1;
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1089 |
|
| 1090 | client.uToken = Global_uToken_call;
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1091 | client.request = request_id;
|
| 1092 | client.paramLen = argc;
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1093 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1094 | if(argc!=0)
|
| 1095 | {
|
| 1096 | va_list args;
|
| 1097 | va_start(args, format);
|
| 1098 | vsnprintf(client.param, LYNQ_REQUEST_PARAM_BUF, format, args);
|
| 1099 | va_end(args);
|
| 1100 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1101 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1102 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 1103 | {
|
| 1104 | LYERRLOG("send request fail");
|
| 1105 | return -1;
|
| 1106 | }
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1107 | if(get_response(lynq_call_client_sockfd,p)==0)
|
| 1108 | {
|
| 1109 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1110 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1111 | }
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1112 | return error;
|
| 1113 | }
|
| 1114 |
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1115 | int lynq_get_common_request(int request_id, int* status)
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1116 | {
|
| 1117 | Parcel p;
|
| 1118 | lynq_client_t client;
|
| 1119 | int resp_type = -1;
|
| 1120 | int request = -1;
|
| 1121 | int slot_id = -1;
|
| 1122 | int error = -1;
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1123 | if(status==NULL)
|
| 1124 | {
|
| 1125 | LYERRLOG("status is null");
|
| 1126 | return -1;
|
| 1127 | }
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1128 | client.uToken = Global_uToken_call;
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1129 | client.request = request_id;
|
| 1130 | client.paramLen = 0;
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1131 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1132 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1133 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 1134 | {
|
| 1135 | LYERRLOG("send request fail");
|
| 1136 | return -1;
|
| 1137 | }
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1138 | if(get_response(lynq_call_client_sockfd,p)==0)
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1139 | {
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1140 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1141 | p.readInt32(status);
|
| 1142 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1143 | }
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1144 | return error;
|
| 1145 | }
|
| 1146 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1147 | int lynq_call(int* handle,char addr[])
|
| 1148 | {
|
| 1149 | Parcel p;
|
| 1150 | lynq_client_t client;
|
| 1151 | int resp_type = -1;
|
| 1152 | int request = -1;
|
| 1153 | int slot_id = -1;
|
| 1154 | int error = -1;
|
| 1155 | int lynq_call_id = -1;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1156 |
|
| 1157 | LYINFLOG("lynq_call begin addr %s",addr);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1158 | if(addr==NULL)
|
| 1159 | {
|
| 1160 | LYERRLOG("Phone num is null!!!");
|
| 1161 | return -1;
|
| 1162 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1163 |
|
| 1164 | if(find_call_id_with_addr(addr)!=INVALID_ID)
|
| 1165 | {
|
| 1166 | LYERRLOG("addr %s exists",addr);
|
| 1167 | return LYNQ_E_CONFLICT;
|
| 1168 | }
|
| 1169 |
|
| 1170 | #ifdef ECALL_SUPPORT
|
| 1171 | if(lynq_ecall_is_running())
|
| 1172 | {
|
| 1173 | LYERRLOG("lynq_fast_ecall ecall is running");
|
| 1174 | return LYNQ_E_ECALL_BEING_RUNNING;
|
| 1175 | }
|
| 1176 | #endif
|
| 1177 |
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1178 | client.uToken = Global_uToken_call;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1179 | client.request = 10;//RIL_REQUEST_DIAL
|
| 1180 | client.paramLen = 2;
|
| 1181 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 1182 | memcpy(client.param,addr,strlen(addr)+1);
|
| 1183 | strcat(client.param," 0");
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1184 | lynq_call_id = addAddr(addr);
|
| 1185 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1186 | pthread_mutex_lock(&g_lynq_call_sendto_mutex);
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1187 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1188 | {
|
| 1189 | LYERRLOG("send request fail");
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1190 | cleanCallList(lynq_call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1191 | return -1;
|
| 1192 | }
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1193 | get_response(lynq_call_client_sockfd,p);
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1194 | pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1195 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1196 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1197 | if(error==0)
|
| 1198 | {
|
| 1199 | isDial = 1;
|
ll | 45d3ea9 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1200 | if(waitCallstateChange(6000)==ETIMEDOUT)//6000ms
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1201 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 1202 | //if timeout,this call need destroy.
|
| 1203 | isDial = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1204 | error = LYNQ_E_TIME_OUT;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1205 | LYERRLOG("lynq_call timeout:wait Call state fail!!! clear local idx %d",lynq_call_id);
|
| 1206 | cleanCallList(lynq_call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1207 | return error;
|
| 1208 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1209 | isDial = 0;
|
| 1210 | *handle = lynq_call_lists[lynq_call_id].call_id;
|
| 1211 | if(*handle > 0)
|
| 1212 | {
|
| 1213 | LYINFLOG("lynq_call dial addr %s suc, id is %d",addr,*handle);
|
| 1214 | return 0;
|
| 1215 | }
|
| 1216 | else
|
| 1217 | {
|
| 1218 | LYERRLOG("lynq_call dial addr %s fail, invalid id",addr);
|
| 1219 | cleanCallList(lynq_call_id);
|
| 1220 | return LYNQ_E_INVALID_ID_ANONALY;
|
| 1221 | }
|
| 1222 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1223 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1224 | LYERRLOG("lynq_call dial addr %s fail, service error %d",addr, error);
|
| 1225 | cleanCallList(lynq_call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1226 | return error;
|
| 1227 | }
|
| 1228 | int lynq_call_answer()
|
| 1229 | {
|
| 1230 | Parcel p;
|
| 1231 | lynq_client_t client;
|
| 1232 | int resp_type = -1;
|
| 1233 | int request = -1;
|
| 1234 | int slot_id = -1;
|
| 1235 | int error = -1;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1236 | client.uToken = Global_uToken_call;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1237 | client.request = 40;//RIL_REQUEST_DIAL
|
| 1238 | client.paramLen = 0;
|
| 1239 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1240 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1241 | pthread_mutex_lock(&g_lynq_call_sendto_mutex);
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1242 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1243 | {
|
| 1244 | LYERRLOG("send request fail");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1245 | return -1;
|
| 1246 | }
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1247 | get_response(lynq_call_client_sockfd,p);
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1248 | pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1249 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1250 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1251 | return error;
|
| 1252 | }
|
| 1253 | int lynq_call_hungup(int* handle)
|
| 1254 | {
|
| 1255 | Parcel p;
|
| 1256 | lynq_client_t client;
|
| 1257 | int resp_type = -1;
|
| 1258 | int request = -1;
|
| 1259 | int slot_id = -1;
|
| 1260 | int error = -1;
|
| 1261 | int call_id = 0;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1262 | int lynq_call_id;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1263 | if(handle==NULL||!((*handle>=0)&&(*handle<10)))
|
| 1264 | {
|
| 1265 | LYERRLOG("[%s] illegal input!!!!",__FUNCTION__);
|
| 1266 | return LYNQ_E_CONFLICT;
|
| 1267 | }
|
| 1268 | client.uToken = Global_uToken_call;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1269 | client.request = 12;//RIL_REQUEST_HUNGUP
|
| 1270 | client.paramLen = 1;
|
| 1271 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1272 | call_id = *handle;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1273 | sprintf(client.param,"%d",call_id);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1274 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1275 | pthread_mutex_lock(&g_lynq_call_sendto_mutex);
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1276 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1277 | {
|
| 1278 | LYERRLOG("send request fail");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1279 | return -1;
|
| 1280 | }
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1281 | get_response(lynq_call_client_sockfd,p);
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1282 | pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1283 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1284 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1285 | if(error==0)
|
| 1286 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1287 | lynq_call_id=find_call_id_with_call_id(call_id);
|
| 1288 | if(lynq_call_id!=INVALID_ID)
|
| 1289 | {
|
| 1290 | cleanCallList(lynq_call_id);
|
| 1291 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1292 | }
|
| 1293 | return error;
|
| 1294 | }
|
| 1295 | int lynq_call_hungup_all()
|
| 1296 | {
|
| 1297 | Parcel p;
|
| 1298 | lynq_client_t client;
|
| 1299 | int resp_type = -1;
|
| 1300 | int request = -1;
|
| 1301 | int slot_id = -1;
|
| 1302 | int error = -1;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1303 | client.uToken = Global_uToken_call;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1304 | client.request = 17;//RIL_REQUEST_UDUB
|
| 1305 | client.paramLen = 0;
|
| 1306 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1307 | LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1308 | pthread_mutex_lock(&g_lynq_call_sendto_mutex);
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1309 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1310 | {
|
| 1311 | LYERRLOG("send request fail");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1312 | return -1;
|
| 1313 | }
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1314 | get_response(lynq_call_client_sockfd,p);
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1315 | pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1316 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1317 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1318 | return error;
|
| 1319 | }
|
| 1320 | int lynq_wait_incoming_call(int *handle)
|
| 1321 | {
|
| 1322 | waitIncomingCall();
|
| 1323 | *handle = lynqIncomingCallId;
|
| 1324 | LYINFLOG("lynq incoming call id:%d",lynqIncomingCallId);
|
| 1325 | return 0;
|
| 1326 | }
|
| 1327 |
|
| 1328 | int lynq_set_auto_answercall(const int mode)
|
| 1329 | {
|
| 1330 | global_call_auto_answer = mode;
|
| 1331 | LYINFLOG("auto answer call mode =%d",mode);
|
| 1332 | return 0;
|
| 1333 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1334 | int lynq_get_current_call_state(int *handle, int *call_state,int *toa,int *direction,char addr[])
|
| 1335 | {
|
| 1336 | int lynq_call_id = 0;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1337 | LYINFLOG("lynq_get_current_call_state begin ");
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1338 | if(handle==NULL)
|
| 1339 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1340 | LYERRLOG("handle is NULL");
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1341 | return LYNQ_E_NULL_ANONALY;
|
| 1342 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1343 | lynq_call_id = find_call_id_with_call_id(*handle);
|
| 1344 | if(lynq_call_id==INVALID_ID)
|
| 1345 | {
|
| 1346 | return LYNQ_E_INVALID_ID_ANONALY;
|
| 1347 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1348 | *call_state = lynq_call_lists[lynq_call_id].call_state;
|
| 1349 | *toa = lynq_call_lists[lynq_call_id].toa;
|
| 1350 | *direction = lynq_call_lists[lynq_call_id].direction;
|
| 1351 | memcpy(addr,lynq_call_lists[lynq_call_id].addr,strlen(lynq_call_lists[lynq_call_id].addr)+1);
|
| 1352 | return 0;
|
| 1353 | }
|
| 1354 |
|
| 1355 | /*audio begin*/
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1356 | static int judge_mic(const int enable){
|
ll | c603006 | 2022-02-14 08:58:16 +0000 | [diff] [blame] | 1357 | switch(enable){
|
| 1358 | case 0:
|
| 1359 | return 1;
|
| 1360 | case 1:
|
| 1361 | return 1;
|
| 1362 | default:
|
| 1363 | return 0;
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1364 | }
|
| 1365 | }
|
| 1366 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1367 | int lynq_set_mute_mic(const int enable)
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1368 | {
|
| 1369 | if(!judge_mic(enable)){
|
| 1370 | return LYNQ_E_CONFLICT;
|
| 1371 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1372 | return lynq_set_common_request(53,1,"%d",enable); //RIL_REQUEST_SET_MUTE
|
| 1373 | }
|
| 1374 | int lynq_get_mute_mic(int *status)
|
| 1375 | {
|
| 1376 | return lynq_get_common_request(54,status);//RIL_REQUEST_GET_MUTE
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1377 | }
|
ll | 45d3ea9 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1378 |
|
| 1379 | /**
|
| 1380 | * @brief Check whether DTMF is valid
|
| 1381 | *
|
| 1382 | * @param callnum dtmf eg:0-9 * #
|
| 1383 | * @return int
|
| 1384 | */
|
| 1385 | static int judge_dtmf(const char callnum)
|
| 1386 | {
|
| 1387 | if(callnum == '#')
|
| 1388 | {
|
| 1389 | return 1;
|
| 1390 | }
|
| 1391 | if(callnum == '*')
|
| 1392 | {
|
| 1393 | return 1;
|
| 1394 | }
|
| 1395 | if(callnum >= '0'&& callnum <= '9')
|
| 1396 | {
|
| 1397 | return 1;
|
| 1398 | }
|
| 1399 | return 0;
|
| 1400 | }
|
| 1401 |
|
ll | a043832 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1402 | int lynq_switch_waiting_or_holding_and_active(void)
|
| 1403 | {
|
| 1404 | Parcel p;
|
| 1405 | lynq_client_t client;
|
| 1406 | int resp_type = -1;
|
| 1407 | int request = -1;
|
| 1408 | int slot_id = -1;
|
| 1409 | int error = -1;
|
| 1410 | client.uToken = Global_uToken_call;
|
| 1411 | client.request = RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE;
|
| 1412 | client.paramLen = 0;
|
| 1413 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 1414 | LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1415 | pthread_mutex_lock(&g_lynq_call_sendto_mutex);
|
ll | a043832 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1416 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 1417 | {
|
| 1418 | LYERRLOG("send request fail");
|
| 1419 | return -1;
|
| 1420 | }
|
| 1421 | get_response(lynq_call_client_sockfd,p);
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1422 | pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
|
ll | a043832 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1423 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1424 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1425 | return error;
|
| 1426 | }
|
| 1427 |
|
| 1428 | int lynq_hangup_waiting_or_background(void)
|
| 1429 | {
|
| 1430 | Parcel p;
|
| 1431 | lynq_client_t client;
|
| 1432 | int resp_type = -1;
|
| 1433 | int request = -1;
|
| 1434 | int slot_id = -1;
|
| 1435 | int error = -1;
|
| 1436 | client.uToken = Global_uToken_call;
|
| 1437 | client.request = RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND;
|
| 1438 | client.paramLen = 0;
|
| 1439 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 1440 | LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1441 | pthread_mutex_lock(&g_lynq_call_sendto_mutex);
|
ll | a043832 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1442 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 1443 | {
|
| 1444 | LYERRLOG("send request fail");
|
| 1445 | return -1;
|
| 1446 | }
|
| 1447 | get_response(lynq_call_client_sockfd,p);
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1448 | pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
|
ll | a043832 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1449 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1450 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1451 | return error;
|
| 1452 | }
|
| 1453 |
|
| 1454 | int lynq_hangup_foreground_resume_background(void)
|
| 1455 | {
|
| 1456 | Parcel p;
|
| 1457 | lynq_client_t client;
|
| 1458 | int resp_type = -1;
|
| 1459 | int request = -1;
|
| 1460 | int slot_id = -1;
|
| 1461 | int error = -1;
|
| 1462 | client.uToken = Global_uToken_call;
|
| 1463 | client.request = RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND;
|
| 1464 | client.paramLen = 0;
|
| 1465 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 1466 | LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1467 | pthread_mutex_lock(&g_lynq_call_sendto_mutex);
|
ll | a043832 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1468 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 1469 | {
|
| 1470 | LYERRLOG("send request fail");
|
| 1471 | return -1;
|
| 1472 | }
|
| 1473 | get_response(lynq_call_client_sockfd,p);
|
ll | afa36b4 | 2022-07-25 05:52:14 +0000 | [diff] [blame] | 1474 | pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
|
ll | a043832 | 2022-07-20 09:30:19 +0000 | [diff] [blame] | 1475 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1476 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1477 | return error;
|
| 1478 | }
|
| 1479 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1480 | int lynq_set_DTMF(const char callnum)
|
| 1481 | {
|
ll | 45d3ea9 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1482 | if(!judge_dtmf(callnum))
|
| 1483 | {
|
| 1484 | return LYNQ_E_CONFLICT;
|
| 1485 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1486 | if(!lynq_call_state)
|
| 1487 | {
|
| 1488 | LYERRLOG("LYNQ_E_CONFLICT");
|
| 1489 | return LYNQ_E_CONFLICT;
|
| 1490 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1491 | return lynq_set_common_request(24,1,"%c",callnum); //RIL_REQUEST_DTMF
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1492 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1493 | static int judge_volume(LYNQ_E_VOLUMN_SET set,const int volume){
|
| 1494 | if(set==LYNQ_E_VOLUMN_SET_DTMF){
|
| 1495 | if(volume < 0 ||volume >36){
|
| 1496 | return 0;
|
| 1497 | }
|
| 1498 | }
|
| 1499 | else if (set==LYNQ_E_VOLUMN_SET_SPEECH)
|
| 1500 | {
|
| 1501 | if(volume < 1 ||volume >7){
|
| 1502 | return 0;
|
| 1503 | }
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1504 | }
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 1505 | return 1;
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1506 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1507 | int lynq_set_DTMF_volume(const int volume)
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1508 | {
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1509 | if(!judge_volume(LYNQ_E_VOLUMN_SET_DTMF,volume)){
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1510 | return LYNQ_E_CONFLICT;
|
| 1511 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1512 | return lynq_set_common_request(8003,1,"%d",volume);//LYNQ_REQUEST_SET_DTMF_VOLUME
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1513 | }
|
q.huang | 9ee6d5b | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1514 | int lynq_set_speech_volume(const int volume)//mixer_set_volume
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1515 | {
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1516 | if(!judge_volume(LYNQ_E_VOLUMN_SET_SPEECH,volume))
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1517 | {
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1518 | return LYNQ_E_CONFLICT;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1519 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1520 | return lynq_set_common_request(8009,1,"%d",volume); //LYNQ_REQUEST_SET_SPEECH_VOLUME
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1521 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1522 | int lynq_get_speech_volume(int* volumn)//mixer_get_volume
|
| 1523 | {
|
| 1524 | return lynq_get_common_request(8010,volumn);//LYNQ_REQUEST_GET_SPEECH_VOLUME
|
| 1525 | }
|
q.huang | 9ee6d5b | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1526 | int lynq_incall_record_start(const char* file_path)
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1527 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1528 | return lynq_set_common_request(8011,2,"%s %s","1",file_path); //LYNQ_REQUEST_RECORD
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1529 | }
|
| 1530 | int lynq_incall_record_stop()
|
| 1531 | {
|
q.huang | 9ee6d5b | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1532 | const char* unused_file="just_ocuupy_paramter_postion";
|
| 1533 | return lynq_set_common_request(8011,2,"%s %s","0",unused_file); //LYNQ_REQUEST_RECORD
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1534 | }
|
| 1535 | /*audio end*/
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1536 |
|
| 1537 | #ifdef ECALL_SUPPORT
|
| 1538 | LYNQ_ECall_Variant lynq_get_lynq_ecall_variant_from_lynq_type(LYNQ_ECall_Type type)
|
| 1539 | {
|
| 1540 | switch(type)
|
| 1541 | {
|
| 1542 | case LYNQ_ECALL_TYPE_TEST:
|
| 1543 | return LYNQ_ECALL_TEST;
|
| 1544 | case LYNQ_ECALL_TYPE_RECONFIG:
|
| 1545 | return LYNQ_ECALL_RECONFIG;
|
| 1546 | default:
|
| 1547 | return LYNQ_ECALL_EMERGENCY;
|
| 1548 | }
|
| 1549 | }
|
| 1550 |
|
| 1551 | RIL_ECall_Variant lynq_get_ril_ecall_variant_from_lynq_variant(LYNQ_ECall_Variant type)
|
| 1552 | {
|
| 1553 | switch(type)
|
| 1554 | {
|
| 1555 | case LYNQ_ECALL_TEST:
|
| 1556 | return ECALL_TEST;
|
| 1557 | case LYNQ_ECALL_RECONFIG:
|
| 1558 | return ECALL_RECONFIG;
|
| 1559 | default:
|
| 1560 | return ECALL_EMERGENCY;
|
| 1561 | }
|
| 1562 | }
|
| 1563 |
|
| 1564 | RIL_ECall_Category lynq_get_ril_ecall_cat_from_lynq_cat(LYNQ_ECall_Category cat)
|
| 1565 | {
|
| 1566 | switch(cat)
|
| 1567 | {
|
| 1568 | case LYNQ_EMER_CAT_MANUAL_ECALL:
|
| 1569 | return EMER_CAT_MANUAL_ECALL;
|
| 1570 | default:
|
| 1571 | return EMER_CAT_AUTO_ECALL;
|
| 1572 | }
|
| 1573 | }
|
| 1574 |
|
| 1575 |
|
| 1576 | int lynq_set_test_num(LYNQ_ECall_Set_Type type, const char *test_num, int test_num_length)
|
| 1577 | {
|
| 1578 | int error;
|
| 1579 |
|
| 1580 | if(test_num==NULL || test_num_length > LYNQ_PHONE_NUMBER_MAX )
|
| 1581 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1582 | LYERRLOG("test_num is null or test_num_length %d s greater than %d ",test_num_length,LYNQ_PHONE_NUMBER_MAX);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1583 | return -1;
|
| 1584 | }
|
| 1585 |
|
| 1586 | error=lynq_set_common_request(RIL_REQUEST_ECALL_SET_TEST_NUM,2,"%d %s",type,test_num);
|
| 1587 |
|
| 1588 | if(error==0)
|
| 1589 | {
|
| 1590 | snprintf(e_call_addr[LYNQ_ECALL_TEST],LYNQ_PHONE_NUMBER_MAX,"%s",test_num);
|
| 1591 | }
|
| 1592 |
|
| 1593 | return error;
|
| 1594 | }
|
| 1595 |
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1596 | int lynq_fast_ecall(int* handle, LYNQ_ECall_Category lynq_ecall_cat, LYNQ_ECall_Variant lynq_ecall_variant, const char *addr, int addr_length, const unsigned char *msd_data,int msd_length)
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1597 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1598 | int error;
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1599 | RIL_ECall_Variant ril_ecall_variant = lynq_get_ril_ecall_variant_from_lynq_variant (lynq_ecall_variant);
|
q.huang | 9a9b876 | 2022-04-19 05:20:12 -0400 | [diff] [blame] | 1600 | RIL_ECall_Category ril_ecall_cat = lynq_get_ril_ecall_cat_from_lynq_cat(lynq_ecall_cat);
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1601 | char lynq_msd_data[MSD_MAX_LENGTH*2+1]={0};
|
| 1602 | unsigned int i;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1603 | if(lynq_ecall_is_running())
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1604 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1605 | LYERRLOG("lynq_fast_ecall ecall is running");
|
| 1606 | return LYNQ_E_ECALL_BEING_RUNNING;
|
| 1607 | }
|
| 1608 |
|
| 1609 | if(msd_length > MSD_MAX_LENGTH || msd_length <=0)
|
| 1610 | {
|
| 1611 | LYERRLOG("lynq_fast_ecall msd_length %d is greater than %d or <= 0, parameter error",msd_length,MSD_MAX_LENGTH);
|
| 1612 | return LYNQ_E_ECALL_MSD_LENGTH_ERROR;
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1613 | }
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1614 |
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1615 | for(i =0; i<msd_length;i++)
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1616 | {
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1617 | sprintf(&(lynq_msd_data[i<<1]),"%02x",msd_data[i]);
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1618 | }
|
| 1619 |
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1620 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1621 | LYINFLOG("lynq_fast_ecall addr is %s",e_call_addr[lynq_ecall_variant]);
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1622 |
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1623 | error=lynq_set_common_request(RIL_REQUEST_ECALL_FAST_MAKE_ECALL,4,"%d %d %s %s",ril_ecall_cat, ril_ecall_variant, "null", lynq_msd_data);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1624 |
|
| 1625 | if(error==0)
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1626 | {
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame] | 1627 | is_ecall_dial = LYNQ_ECALL_DAILING_STATE_STARTED;
|
q.huang | 415e21d | 2022-07-01 11:38:26 +0800 | [diff] [blame] | 1628 | if(waitCallstateChange(270000)==ETIMEDOUT)//4.5 min, dailing 1 min, alerting 1 min, sending msd 30s, redial 2min
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1629 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1630 | LYERRLOG("lynq_fast_ecall timeout:wait Call state time out!!!");
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame] | 1631 | is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1632 | lynqRespWatingEvent();
|
| 1633 | return LYNQ_E_TIME_OUT;
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1634 | }
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame] | 1635 | if(is_ecall_dial == LYNQ_ECALL_DAILING_STATE_STARTED)
|
| 1636 | {
|
| 1637 | /*just dail, no recv answer*/
|
| 1638 | LYERRLOG("lynq_fast_ecall, no answer!");
|
| 1639 | is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
|
| 1640 | lynqRespWatingEvent();
|
| 1641 | return LYNQ_E_ECALL_DAILING_NO_ANSWER;
|
| 1642 | }
|
| 1643 |
|
| 1644 | is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1645 | lynqRespWatingEvent();
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1646 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1647 | if(g_ecallId != INVALID_ID)
|
| 1648 | {
|
| 1649 | *handle=g_ecallId;
|
| 1650 | LYINFLOG("lynq_fast_ecall id is %d",g_ecallId);
|
| 1651 | return 0;
|
| 1652 | }
|
| 1653 | else
|
| 1654 | {
|
| 1655 | LYERRLOG("lynq_fast_ecall service return fail");
|
| 1656 | return LYNQ_E_INVALID_ID_ANONALY;
|
| 1657 | }
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1658 | }
|
| 1659 |
|
| 1660 | return error;
|
| 1661 | }
|
| 1662 |
|
| 1663 | int lynq_set_psap(int enable)
|
| 1664 | {
|
| 1665 | return lynq_set_common_request(RIL_REQUEST_ECALL_SET_PSAP,1,"%d",enable);
|
| 1666 | }
|
| 1667 |
|
| 1668 | int lynq_psap_pull_msd()
|
| 1669 | {
|
| 1670 | return lynq_set_common_request(RIL_REQUEST_ECALL_PSAP_PULL_MSD,0,"");
|
| 1671 | }
|
| 1672 |
|
| 1673 | int lynq_make_ecall(int* handle, LYNQ_ECall_Type type)
|
| 1674 | {
|
| 1675 | LYNQ_ECall_Variant lynq_ecall_variant;
|
| 1676 | int error = -1;
|
| 1677 | int lynq_call_id = -1;
|
| 1678 |
|
| 1679 | if(handle==NULL)
|
| 1680 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1681 | LYERRLOG("handle is NULL, parameter error ");
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1682 | return -1;
|
| 1683 | }
|
| 1684 |
|
| 1685 | error=lynq_set_common_request(RIL_REQUEST_ECALL_MAKE_ECALL,1,"%d",type);
|
| 1686 |
|
| 1687 | if(error==0)
|
| 1688 | {
|
| 1689 | lynq_ecall_variant=lynq_get_lynq_ecall_variant_from_lynq_type(type);
|
| 1690 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1691 | lynq_call_id = addAddr(e_call_addr[lynq_ecall_variant]);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1692 | isDial = 1;
|
| 1693 | if(waitCallstateChange(10000)==ETIMEDOUT)//10000ms
|
| 1694 | {
|
| 1695 | error = LYNQ_E_TIME_OUT;
|
| 1696 | LYERRLOG("timeout:wait Call state fail!!!");
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1697 | return error;
|
| 1698 | }
|
| 1699 |
|
| 1700 | *handle = lynq_call_id;
|
| 1701 | }
|
| 1702 |
|
| 1703 | return error;
|
| 1704 | }
|
| 1705 |
|
| 1706 |
|
q.huang | bd6a306 | 2022-05-10 20:49:46 +0800 | [diff] [blame] | 1707 | int lynq_set_msd(int* handle, const unsigned char *msd_data, int msd_length)
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1708 | {
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1709 | char lynq_msd_data[MSD_MAX_LENGTH*2+1]={0};
|
| 1710 | unsigned int i;
|
| 1711 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1712 | if(handle==NULL || ((*handle) >= LYNQ_CALL_MAX) || msd_length > MSD_MAX_LENGTH || msd_length == 0 || msd_data ==NULL)
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1713 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1714 | LYERRLOG("lynq_set_msd handle is NULL or *handle %d is greater or equeal to %d or msd_length %d is greater than %d or msd_data %s is NULL, parameter error",*handle,LYNQ_CALL_MAX,msd_length,MSD_MAX_LENGTH, msd_data);
|
q.huang | bd6a306 | 2022-05-10 20:49:46 +0800 | [diff] [blame] | 1715 | return -1;
|
| 1716 | }
|
q.huang | bd6a306 | 2022-05-10 20:49:46 +0800 | [diff] [blame] | 1717 |
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1718 | for(i=0; i<msd_length;i++)
|
q.huang | bd6a306 | 2022-05-10 20:49:46 +0800 | [diff] [blame] | 1719 | {
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1720 | sprintf(&(lynq_msd_data[i<<1]),"%02x",msd_data[i]);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1721 | }
|
| 1722 |
|
| 1723 | LYINFLOG("lynq_set_msd ");
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1724 |
|
q.huang | bd6a306 | 2022-05-10 20:49:46 +0800 | [diff] [blame] | 1725 | return lynq_set_common_request(RIL_REQUEST_ECALL_SET_MSD,2,"%d %s",lynq_call_lists[(*handle)].call_id,lynq_msd_data);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1726 | }
|
| 1727 |
|
| 1728 | int lynq_set_ivs(int enable)
|
| 1729 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1730 | if(enable<0)
|
| 1731 | {
|
| 1732 | lynq_set_common_request(RIL_REQUEST_ECALL_SET_IVS,1,"%d",enable);
|
| 1733 | return 0;
|
| 1734 | }
|
| 1735 |
|
| 1736 | return lynq_set_common_request(RIL_REQUEST_ECALL_SET_IVS,1,"%d",enable);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1737 | }
|
| 1738 |
|
| 1739 | int lynq_reset_ivs()
|
| 1740 | {
|
| 1741 | return lynq_set_common_request(RIL_REQUEST_ECALL_RESET_IVS,0,"");
|
| 1742 | }
|
| 1743 |
|
| 1744 | int lynq_ivs_push_msd()
|
| 1745 | {
|
| 1746 | return lynq_set_common_request(RIL_REQUEST_ECALL_IVS_PUSH_MSD,0,"");
|
| 1747 | }
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1748 |
|
| 1749 | int wait_ecall_event()
|
| 1750 | {
|
| 1751 | int ret = 0;
|
| 1752 | pthread_mutex_lock(&s_incoming_e_call_mutex);
|
| 1753 | ret = pthread_cond_wait(&s_incoming_e_call_cond,&s_incoming_e_call_mutex);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1754 | pthread_mutex_unlock(&s_incoming_e_call_mutex);
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1755 | return ret;
|
| 1756 | }
|
| 1757 |
|
q.huang | 2b60c48 | 2022-06-30 19:39:20 +0800 | [diff] [blame] | 1758 | int lynq_wait_ecall_indication(int* handle, LYNQ_ECall_Indication *eCall_Indication)
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1759 | {
|
| 1760 | wait_ecall_event();
|
q.huang | 2b60c48 | 2022-06-30 19:39:20 +0800 | [diff] [blame] | 1761 | *handle = g_lynqIncomingEcallId;
|
q.huang | 40f5e32 | 2022-06-21 14:57:02 +0800 | [diff] [blame] | 1762 | *eCall_Indication = g_lynqIncomingEcallIndication;
|
q.huang | 2b60c48 | 2022-06-30 19:39:20 +0800 | [diff] [blame] | 1763 | LYINFLOG("lynq_wait_ecall_indication handle %d, Ind id: %d", *handle, *eCall_Indication);
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1764 | return 0;
|
| 1765 | }
|
| 1766 |
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1767 | #endif
|
| 1768 |
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1769 | /*Audio Path setting begin*/
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 1770 | /*sub function*/
|
| 1771 | void lynq_set_rtp_mixer_ctrl(int enable_rtp)
|
| 1772 | {
|
| 1773 | char cmd[256];
|
| 1774 | LYINFLOG("set_rtp_mixer_ctrl %d", enable_rtp);
|
| 1775 | if(enable_rtp)
|
| 1776 | {
|
| 1777 | sprintf(cmd, "amixer -D mtk_phonecall cset name=\"Speech_on\" %d", 0);
|
| 1778 | system(cmd);
|
| 1779 | sprintf(cmd, "amixer -D mtk_phonecall cset name=\"M2M_Speech_on\" %d", 1);
|
| 1780 | system(cmd);
|
| 1781 | sprintf(cmd, "amixer -c0 cset name=\"PCM_2_PB_CH1 DL2_CH1\" %d", 1);
|
| 1782 | system(cmd);
|
| 1783 | sprintf(cmd, "amixer -c0 cset name=\"PCM_2_PB_CH2 DL2_CH2\" %d", 1);
|
| 1784 | system(cmd);
|
| 1785 | sprintf(cmd, "amixer -c0 cset name=\"UL2_CH1 PCM_2_CAP_CH1\" %d", 1);
|
| 1786 | system(cmd);
|
| 1787 | sprintf(cmd, "amixer -c0 cset name=\"UL2_CH2 PCM_2_CAP_CH1\" %d", 1);
|
| 1788 | system(cmd);
|
| 1789 | }
|
| 1790 | else
|
| 1791 | {
|
| 1792 | sprintf(cmd, "amixer -D mtk_phonecall cset name=\"Speech_on\" %d", 1);
|
| 1793 | system(cmd);
|
| 1794 | sprintf(cmd, "amixer -D mtk_phonecall cset name=\"M2M_Speech_on\" %d", 0);
|
| 1795 | system(cmd);
|
| 1796 | sprintf(cmd, "amixer -c0 cset name=\"PCM_2_PB_CH1 DL2_CH1\" %d", 0);
|
| 1797 | system(cmd);
|
| 1798 | sprintf(cmd, "amixer -c0 cset name=\"PCM_2_PB_CH2 DL2_CH2\" %d", 0);
|
| 1799 | system(cmd);
|
| 1800 | sprintf(cmd, "amixer -c0 cset name=\"UL2_CH1 PCM_2_CAP_CH1\" %d", 0);
|
| 1801 | system(cmd);
|
| 1802 | sprintf(cmd, "amixer -c0 cset name=\"UL2_CH2 PCM_2_CAP_CH1\" %d", 0);
|
| 1803 | system(cmd);
|
| 1804 | }
|
| 1805 | }
|
| 1806 |
|
| 1807 | void* lynq_start_rtp_cmd(void *arg)
|
| 1808 | {
|
| 1809 | int* rtp_mode= (int*) arg;
|
| 1810 | char cmd[384];
|
| 1811 | LYINFLOG("lynq_start_rtp_cmd: rtp_mode is %d",(*rtp_mode));
|
| 1812 | if ((*rtp_mode) == RTP_CLIENT)
|
| 1813 | {
|
| 1814 | sprintf(cmd,RTP_FROM_CMD, \
|
| 1815 | g_rtp_client_info.port,g_rtp_client_info.clockrate,g_rtp_client_info.channels, \
|
| 1816 | g_rtp_client_info.latency);
|
| 1817 | LYINFLOG("start from rtp play: cmd is %s",cmd);
|
| 1818 | system(cmd);
|
| 1819 | }
|
| 1820 | else if ((*rtp_mode) == RTP_SERVER)
|
| 1821 | {
|
| 1822 | sprintf(cmd,RTP_TO_CMD, \
|
| 1823 | g_rtp_server_info.ip,g_rtp_server_info.port);
|
| 1824 | LYINFLOG("start to rtp play: cmd is %s",cmd);
|
| 1825 | system(cmd);
|
| 1826 | }
|
| 1827 | return NULL;
|
| 1828 | }
|
| 1829 |
|
| 1830 | int lynq_start_rtp_thread(int rtp_mode)
|
| 1831 | {
|
| 1832 | int ret;
|
| 1833 | pthread_attr_t attr;
|
| 1834 | static int start_mode[RTP_MODE_MAX]={0,1};
|
| 1835 |
|
| 1836 | pthread_attr_init(&attr);
|
| 1837 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
| 1838 | ret = pthread_create(&(g_rtp_thread[rtp_mode]),&attr,lynq_start_rtp_cmd,&(start_mode[rtp_mode]));
|
| 1839 | if(ret != 0)
|
| 1840 | {
|
| 1841 | g_rtp_thread_valid[rtp_mode]=0;
|
| 1842 | LYERRLOG("rtp create %d pthread error, ret is %d",rtp_mode, ret);
|
| 1843 | return ret;
|
| 1844 | }
|
| 1845 | g_rtp_thread_valid[rtp_mode]=1;
|
| 1846 | return 0;
|
| 1847 | }
|
| 1848 |
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1849 | /*set*/
|
| 1850 | int lynq_set_voice_audio_mode(const LYNQ_Audio_Mode audio_mode)
|
| 1851 | {
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 1852 | int ret;
|
| 1853 | int i;
|
| 1854 |
|
| 1855 | if(audio_mode==AUDIO_MODE_RTP)
|
| 1856 | {
|
| 1857 | lynq_set_rtp_mixer_ctrl(1);
|
| 1858 | for(i=0;i<RTP_MODE_MAX;i++)
|
| 1859 | {
|
| 1860 | if(!g_rtp_thread_valid[i])
|
| 1861 | {
|
| 1862 | if(lynq_start_rtp_thread(i)!= 0)
|
| 1863 | {
|
| 1864 | LYERRLOG("start rtp %d fail",i);
|
| 1865 | break;
|
| 1866 | }
|
| 1867 | else
|
| 1868 | {
|
| 1869 | LYINFLOG("start rtp %d suc",i);
|
| 1870 | }
|
| 1871 | }
|
| 1872 | else
|
| 1873 | {
|
| 1874 | LYERRLOG("rtp %d needn't start",i);
|
| 1875 | }
|
| 1876 | }
|
| 1877 | if(i!= RTP_MODE_MAX)
|
| 1878 | {
|
| 1879 | LYERRLOG("start rtp whole fail");
|
| 1880 | lynq_set_voice_audio_mode(AUDIO_MODE_CODEC);
|
| 1881 | return 1;
|
| 1882 | }
|
| 1883 | LYINFLOG("start rtp whole suc");
|
| 1884 | return 0;
|
| 1885 | }
|
| 1886 | else if(audio_mode==AUDIO_MODE_CODEC)
|
| 1887 | {
|
| 1888 | for(i=0;i<RTP_MODE_MAX;i++)
|
| 1889 | {
|
| 1890 | if(g_rtp_thread_valid[i])
|
| 1891 | {
|
| 1892 | ret = pthread_cancel(g_rtp_thread[i]);
|
| 1893 | LYINFLOG("pthread cancel rtp %d ret = %d",i,ret);
|
| 1894 | ret = pthread_join(g_rtp_thread[i],NULL);
|
| 1895 | LYINFLOG("pthread join rtp %d ret = %d",i,ret);
|
| 1896 | g_rtp_thread_valid[i] = 0;
|
| 1897 | }
|
| 1898 | else
|
| 1899 | {
|
| 1900 | LYINFLOG("rtp %d needn't stop",i);
|
| 1901 | }
|
| 1902 | }
|
| 1903 | lynq_set_rtp_mixer_ctrl(0);
|
| 1904 | LYINFLOG("stop rtp suc");
|
| 1905 | }
|
| 1906 | return 0;
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1907 | }
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 1908 | int lynq_set_remote_rtp_ip(const char* ip, const int ip_length)
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1909 | {
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 1910 | if (NULL == ip)
|
| 1911 | {
|
| 1912 | LYERRLOG("ip is NULL!!!");
|
| 1913 | return -1;
|
| 1914 | }
|
| 1915 | if ((ip_length < strlen(ip)+1) || (ip_length > MAX_IP_LENGTH))
|
| 1916 | {
|
| 1917 | LYERRLOG("incoming ip length error %d", ip_length);
|
| 1918 | return -1;
|
| 1919 | }
|
| 1920 |
|
| 1921 | bzero(g_rtp_server_info.ip,MAX_IP_LENGTH);
|
| 1922 | strcpy(g_rtp_server_info.ip,ip);
|
| 1923 |
|
| 1924 | LYINFLOG("lynq_set_remote_rtp_ip suc: ip is %s, length is %d", ip,ip_length);
|
| 1925 |
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1926 | return 0;
|
| 1927 | }
|
q.huang | 65033cb | 2022-06-06 20:23:15 +0800 | [diff] [blame] | 1928 | int lynq_set_rtp_port(const LYNQ_Rtp_Mode rtp_mode, const int port)
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1929 | {
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 1930 | if (port < 0)
|
| 1931 | {
|
| 1932 | LYERRLOG("invalid port number %d", port);
|
| 1933 | return -1;
|
| 1934 | }
|
| 1935 | if (rtp_mode == 0)
|
| 1936 | {
|
| 1937 | g_rtp_client_info.port = port;
|
| 1938 | }
|
| 1939 | else if (rtp_mode == 1)
|
| 1940 | {
|
| 1941 | g_rtp_server_info.port = port;
|
| 1942 | }
|
| 1943 | LYINFLOG("lynq_set_rtp_port suc: LYNQ_Rtp_Mode is %d, port is %d", rtp_mode, port);
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1944 | return 0;
|
| 1945 | }
|
| 1946 | int lynq_set_rtp_param(const int clock_rate,const int channels,const int latency) //only for client mode
|
| 1947 | {
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 1948 | g_rtp_client_info.clockrate = clock_rate;
|
| 1949 | g_rtp_client_info.channels = channels;
|
| 1950 | g_rtp_client_info.latency = latency;
|
| 1951 | LYINFLOG("lynq_set_rtp_param suc: clockrate is %d, channels is %d, latency is %d", clock_rate, channels, latency);
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1952 | return 0;
|
| 1953 | }
|
| 1954 | /*get*/
|
| 1955 | LYNQ_Audio_Mode lynq_get_voice_audio_mode()
|
| 1956 | {
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 1957 | if(g_rtp_thread_valid[0])
|
| 1958 | {
|
| 1959 | return AUDIO_MODE_RTP;
|
| 1960 | }
|
| 1961 | else
|
| 1962 | {
|
| 1963 | return AUDIO_MODE_CODEC;
|
| 1964 | }
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1965 | }
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 1966 | int lynq_get_remote_rtp_ip(char* ip, const int ip_length)
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1967 | {
|
| 1968 | if(ip==NULL)
|
| 1969 | {
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 1970 | LYERRLOG("ip is NULL");
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1971 | return 1;
|
| 1972 | }
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 1973 |
|
| 1974 | if(ip_length < strlen(g_rtp_server_info.ip)+1)
|
| 1975 | {
|
| 1976 | LYERRLOG("ip lenght %d is shorter than saved ip length %d",ip_length,strlen(g_rtp_server_info.ip)+1);
|
| 1977 | return 1;
|
| 1978 | }
|
| 1979 | bzero(ip,ip_length);
|
| 1980 | strcpy(ip,g_rtp_server_info.ip);
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1981 | return 0;
|
| 1982 | }
|
| 1983 | int lynq_get_rtp_port(const LYNQ_Rtp_Mode rtp_mode, int* port)
|
| 1984 | {
|
| 1985 | if(port==NULL)
|
| 1986 | {
|
| 1987 | return 1;
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 1988 | }
|
| 1989 | if (rtp_mode == 0)
|
| 1990 | {
|
| 1991 | *port = g_rtp_client_info.port;
|
| 1992 | }
|
| 1993 | else if (rtp_mode == 1)
|
| 1994 | {
|
| 1995 | *port = g_rtp_server_info.port;
|
| 1996 | }
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1997 | return 0;
|
| 1998 | }
|
| 1999 | int lynq_get_rtp_param(int* clock_rate, int* channels, int* latency)//only for client mode
|
| 2000 | {
|
| 2001 | if(clock_rate == NULL || channels ==NULL || latency ==NULL)
|
| 2002 | {
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 2003 | LYERRLOG("input parameter is NULL");
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 2004 | return 1;
|
| 2005 | }
|
| 2006 |
|
q.huang | 3e76170 | 2022-06-28 20:12:01 +0800 | [diff] [blame] | 2007 | *clock_rate = g_rtp_client_info.clockrate;
|
| 2008 | *channels = g_rtp_client_info.channels ;
|
| 2009 | *latency = g_rtp_client_info.latency;
|
| 2010 |
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 2011 | return 0;
|
| 2012 | }
|
| 2013 | /*Audio Path setting end*/
|
| 2014 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 2015 | #if 0
|
| 2016 | int main(int argc,char **argv)
|
| 2017 | {
|
| 2018 | int n = 0;
|
| 2019 | n = lynq_init_call(lynq_call_state_change_test,2222);
|
| 2020 | if(n<0)
|
| 2021 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 2022 | LYDBGLOG("lynq init call fail!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 2023 | return -1;
|
| 2024 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 2025 | LYDBGLOG("lynq call init success!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 2026 | char phoneNum[LYNQ_PHONE_NUMBER_MAX];
|
| 2027 | sprintf(phoneNum,"18180053406 0",strlen("18180053406 0")+1);
|
| 2028 | lynq_call(phoneNum);
|
| 2029 | while(1)
|
| 2030 | {
|
| 2031 | sleep(1);
|
| 2032 | }
|
| 2033 | return 0;
|
| 2034 | }
|
| 2035 | #endif
|
| 2036 | /*Warren add for T800 platform 2021/11/19 end*/
|