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