请详细解析下面函数中的参数的变化
LOCAL int local_connect_recv(TCP_CONNECTION_T *tcp_connection)
{
WEBRTC_ERROR("connect recv");
TPRTCSERVERSESSION *pSession = (TPRTCSERVERSESSION *) tcp_connection->param;
unsigned char RXBufferMemSpace[TPRTCSERVER_BUFFER_SIZE];
MBUFFERByteArray RXBuffer;
char sdpBuf[MAX_ANSWER_LEN] = {0};
char pcWhiteSpaces[4] = {'=', ' ', ';', ','};
memset(RXBufferMemSpace, 0, TPRTCSERVER_BUFFER_SIZE);
MBUFFERByteArrayInit(RXBufferMemSpace, 0, 0, TPRTCSERVER_BUFFER_SIZE, &RXBuffer);
MBUFFERByteArraySetWhiteSpaces(pcWhiteSpaces, 4, &RXBuffer);
S8 recv_buf[2048];
WEBRTC_REQUEST_INFO request_info;
memset(&request_info, 0, sizeof(WEBRTC_REQUEST_INFO));
RTC_WEBRTC_MSG *msg = NULL;
int ret = 0, err = 0;
/* 1.读取数据并缓存 */
ret = tcp_read_data(tcp_connection, (char *)recv_buf, 2048);
if (ret > 0)
{
WEBRTC_ERROR("recv buf = %s", recv_buf);
MBUFFERByteArrayPrintf(&RXBuffer, "%s\r\n", recv_buf);
MBUFFERByteConvert2ReadBuff(&RXBuffer);
if (MBUFFERByteArrayFindString((char *)"\r\n\r\n", &RXBuffer) == MBUFFER_EC_OK)
{
MBUFFERByteArrayGetStringBySeparator(sdpBuf, 2048, '\r', &RXBuffer);
JSON_OBJPTR sdpJson = jso_from_string(sdpBuf);
getRequestInfoFromSdp(sdpJson, &request_info);
handleRTCAnswer(pSession, &request_info, 0);
msg = (RTC_WEBRTC_MSG *) malloc (sizeof(RTC_WEBRTC_MSG));
if (msg == NULL)
{
goto reportRecvEnd;
}
char iip[P2P_IP_ADDR_LEN];
int iport = -1;
int sock = -1;
memset(iip, '\0', P2P_IP_ADDR_LEN);
extract_ip_and_port(request_info.sdp.candidate[0], iip, (char *) &iport);
strncpy(msg->remote_addr, iip, P2P_IP_ADDR_LEN);
msg->remote_port = (U16)iport;
getFdSockFromPeer(pSession->peer, iip, iport, &sock);
msg->fd_sock = sock;
WEBRTC_INFO("fd = %d, ip = %s, port = %d", msg->fd_sock, msg->remote_addr, msg->remote_port);
if (STATUS_SUCCESS != setDataSendingIceCandidatePair(pSession->peer, (WEBRTC_MSG*) msg, request_info.stream_type))
{
WEBRTC_ERROR("setDataSendingIceCandidatePair failed!");
pSession->check_failed_timer_id = webrtc_trans_add_timer(rtc_connect_change_state_failed, (S32)pSession, DEFAULT_TIMER_START_DELAY, EXECUTE_SINGLE, -1); // 10s后检测状态,参考webrtc ice状态机10s超时时间
goto reportRecvEnd;
}
pSession->check_failed_timer_id = webrtc_trans_add_timer(rtc_connect_change_state_failed, (S32)pSession, 20, EXECUTE_SINGLE, -1); // 10s后检测状态,参考webrtc ice状态机10s超时时间
if (-1 == pSession->check_failed_timer_id)
{
WEBRTC_ERROR("inet add rtc_connect_change_state_failed error");
goto reportRecvEnd;
}
if (msg != NULL)
{
free(msg);
msg = NULL;
}
rtc_connect_change_state(pSession);
}
}
/* 2.读数据错误处理 */
if (ret <= 0)
{
WEBRTC_ERROR("tcp_read_data() ret=%d!", ret);
err = -1;
goto reportRecvEnd;
}
return 0;
reportRecvEnd:
tcp_connection_free(tcp_connection);
return err;
}