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