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