<commit_before>#include "P2PClient_IOS.h"
#include "test.h"

#include <json/json.h>

bool InitZSipLib()
{
	Json::Value root;
	Json::FastWriter writer;

	root["TokenId"] = "<PASSWORD>";
	root["UsrId"] = "1654500";

	root["ClientIP"] = "0.0.0.0";
	root["ClientPort"] = "0";
#if FOR_TEST_SERVER
	//root["StunIP"] = "192.168.127.12";
	//root["StunPort"] = "8089";
	//root["ServerIP"] = "192.168.127.12";
	//root["ServerPort"] = "8089";

	root["StunIP"] = "172.18.32.19";
	root["StunPort"] = "8088";
	root["ServerIP"] = "172.18.32.19";
	root["ServerPort"] = "8088";
#endif

#if FOR_DEV_SERVER
	root["StunIP"] = "172.18.35.6";
	root["StunPort"] = "8088";
	root["ServerIP"] = "172.18.35.6";
	root["ServerPort"] = "8088";
#endif

#if FOR_USA_SERVER
	//root["StunIP"] = "register.zmodo.com";  //"192.168.127.12";
	//root["StunPort"] = "8088";
	//root["ServerIP"] =  "register.zmodo.com";  //"192.168.127.12";
	//root["ServerPort"] = "8088";

	root["StunIP"] = "192.168.127.12";  //"192.168.127.12";
	root["StunPort"] = "8088";
	root["ServerIP"] =  "192.168.127.12";  //"192.168.127.12";
	root["ServerPort"] = "8088";
#endif
	root["UsrType"] = "3";					// 0-ͻˣ3-upnpͻ
	root["ClientType"] = "0";				// 0-android1-ios

	// ʱ
	root["SipKeepAlive"] = "4000000";		// SIPʱ Ĭ4s
	root["SipReqTimeout"] = "5000000";		// SIPʱʱ䣬Ĭ5s

	root["P2PReqTimeout"] = "8000000";		// P2Pʱʱ Ĭ8s
	root["RegisterTimeout"] = "2000000";	// תעᳬʱʱ Ĭ2s
	root["LoginTimeout"] = "4000000";		// ½ʱʱ Ĭ2s

	root["StreamKeepAlive"] = "2000000";		// ֱ Ĭ2s
	root["StreamTimeout"] = "5000000";		// ݳʱ Ĭ5s

	std::string slParams = writer.write(root);

	return CP2PClient::InitZSip(slParams, ZSIP_MSG);
}

void ZSIP_MSG(int iType, int iStatus, char* data, int data_len)
{
	switch (iStatus)
	{
	case sipsMessage:
		printf("SIPϢ: \n %s \n", data);	// pText Ϊjsonַ Ҫϲ
		break;
	case sipsSessionTimeout:
		printf("sip֪ͨSessionʱ, µ½\n");
		break;
	case sipsUpdateDNS:
		printf("ãUpdateDNS!\n");
		break;
	}
}

void OnStatusReport(int iType, int iStatus, const char* pText, void * pCookie)
{
	printf("OnStatusReport : %d   %d\t", iType, iStatus);
	switch (iType)
	{
	case stSIP:
		switch (iStatus)
		{

		}
		break;
	case stStream:
		{
			switch (iStatus)
			{
			case ssUPNPConnectSucc:
				{
					printf("UPNPӳɹ\n");
					set_connect_status(upnp_status_connect_succ);
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(upnp_status_connect_succ));
					write_to_log(g_test);
				}
				break;
			case ssUPNPConnectFailed:
				{
					printf("UPNPʧ %s\n", pText);
					set_connect_status(upnp_status_connect_failed);
					set_wait_first_data_error();
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(upnp_status_connect_failed), pText);
					write_to_log(g_test);
				}
				break;
			case ssUPNPRecvFailed:
				{
					printf("UPNPմ %s\n", pText);
					set_same_error();
					set_connect_status(upnp_status_connect_failed);
					set_wait_first_data_error();
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(upnp_status_connect_failed), pText);
					write_to_log(g_test);
				}				
				break;

			case ssP2PConnectSucc:
				{
					printf("P2Pӳɹ\n");
					set_connect_status(p2p_status_connect_succ);
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_connect_succ));
					write_to_log(g_test);
				}
				break;
			case ssP2PConnectFailed:
				{
					printf("P2Pʧ %s\n", pText);
					set_connect_status(p2p_status_connect_failed);
					set_wait_first_data_error();
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_connect_failed), pText);
					write_to_log(g_test);
				}
				break;
			case ssP2PRecvFailed:
				{
					printf("P2Pմ %s\n", pText);
					set_same_error();
					set_connect_status(p2p_status_connect_failed);
					set_wait_first_data_error();
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_connect_failed), pText);
					write_to_log(g_test);
				}				
				break;

			case ssDeliverConnectSucc:
				{
					printf("תӳɹ\n");
					set_connect_status(transit_status_connect_succ);
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_connect_succ), pText);
					write_to_log(g_test);
				}
				break;
			case ssDeliverConnectFailed:
				{
					printf("תʧ %s\n", pText);
					set_connect_status(transit_status_connect_failed);
					set_wait_first_data_error();
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_connect_failed), pText);
					write_to_log(g_test);
				}
				break;
			case ssDeliverRecvFailed:
				{
					printf("תմ %s\n", pText);
					set_connect_status(transit_status_connect_failed);
					set_wait_first_data_error();
					char g_test[1024] = {0};

					if (strcmp("login timeout", pText) == 0)
						set_login_status(login_status_falied);
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_connect_failed), pText);
					write_to_log(g_test);
				}
				break;

			case ssPlayBackReqSucc:
				printf("طɹ\n");
				break;
			case ssPlayBackReqFailed:
				printf("طʧ\n");
				break;
			case ssPlayBackStop:
				printf("ǰطŽ\n");
				break;

			case ssChangeToQVGA:
				printf("ҪлΪQVGA\n");
				break;
			case ssChangeToVGA:
				printf("ҪлΪVGA\n");
				break;
			case ssOpenSoundSucc:
				printf("Ƶɹ\n");
				break;
			case ssOpenSoundFailed :
				printf("Ƶʧ\n");
				break;
			case ssCloseSoundSucc:
				printf("رƵɹ\n");
				break;
			case ssCloseSoundFailed:
				printf("رƵʧ\n");
				break;

			case ssOpenTalkSucc:
				printf("򿪶Խɹ\n");
				set_talk_status(talk_status_succ);
				break;
			case ssOpenTalkFailed:
				printf("򿪶Խʧ\n");
				set_talk_status(talk_status_failed);
				break;
			case ssCloseTalkSucc:
				printf("رնԽɹ\n");
				set_talk_status(talk_status_succ);
				break;
			case ssCloseTalkFailed:
				printf("رնԽʧ\n");
				set_talk_status(talk_status_failed);
				break;

			case ssChangeStreamSucc:
				printf("ɹ\n");
				set_change_stream_status(change_stream_status_succ);
				break;
			case ssChangeStreamFailed:
				printf("ʧ\n");
				set_change_stream_status(change_stream_status_failed);
				break;

			case ssPTZCfgSucc:
				printf("PTZóɹ\n");
				break;
			case ssPTZCfgFailed:
				printf("PTZʧ\n");
				break;
			case ssPTZGetPresetSucc:
				printf("PTZԤõȡɹ\n");
				break;
			case ssPTZGetPresetFailed:
				printf("PTZԤõȡʧ\n");
				break;

			case ssUnknownError:
			default:
				printf("δ֪\n");
				break;
			}
		}
		break;
	case stNatType :
		{
			printf("Ϣ֪ϲ\n");
		}
		break;
	case stUpnp:
		{
			switch (iStatus)
			{
			case upnpLoginSuper_0:
				{
					set_login_status(login_status_super_succ);
					printf("login super ok \n");

					char g_test[1024] = {0};
					if (is_p2p_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : Super %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_login_succ), pText);
					else if (is_transit_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : Super %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_login_succ), pText);
					write_to_log(g_test);
				}
				break;
			case upnpLoginNormal_0:
				{
					set_login_status(login_status_normal_succ);
					printf("login normal ok \n");

					char g_test[1024] = {0};
					if (is_p2p_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : Normal %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_login_succ), pText);
					else if (is_transit_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : Normal %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_login_succ), pText);
					write_to_log(g_test);
				}
				break;
			case upnpLoginfalied:
				{
					set_login_status(login_status_falied);
					printf("login failed \n");

					char g_test[1024] = {0};
					if (is_p2p_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_login_failed), pText);
					else if (is_transit_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_login_failed), pText);
					write_to_log(g_test);
				}
				break;
			case upnpChangePwdSucc:
				{
					printf("change pwd succ \n");

					set_change_pwd_status(change_pwd_status_succ);
					char g_test[1024] = {0};
					if (is_p2p_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_change_pwd_succ), pText);
					else if (is_transit_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_login_succ), pText);
					write_to_log(g_test);
				}
				break;
			case upnpChangePwdFailed:
				{
					printf("change pwd failed \n");

					set_change_pwd_status(change_pwd_status_failed);
					char g_test[1024] = {0};
					if (is_p2p_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_change_pwd_failed), pText);
					else if (is_transit_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_login_failed), pText);
					write_to_log(g_test);
				}
				break;
			case upnpQueryUpnpSucc:
				{
					if (pText == NULL)
					{
						printf("response null ");
					}
					printf("UPNP ѯɹ %s \n", pText);

					char g_test[1024] = {0};
					if (is_p2p_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_upnp_query_succ));
					else if (is_transit_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_upnp_query_succ));
					write_to_log(g_test);

					set_upnp_query_status(upnp_query_status_succ);
				}
				break;
			case upnpQueryUpnpFailed:
				{
					if (pText == NULL)
					{
						printf("response null ");
					}
					printf("UPNP ѯʧ \n");
					char g_test[1024] = {0};
					if (is_p2p_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_upnp_query_failed));
					else if (is_transit_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_upnp_query_failed));
					write_to_log(g_test);

					set_upnp_query_status(upnp_query_status_failed);
				}
				break;
			}
		}
		break;
	}
}

void OnFrameData(int iType, char* pData, int iSize, void * pCookie)
{
	// ش õ ->
	if (!is_recv_first_data())
	{
		set_recv_first_data(true);
		char g_test[1024] = {0};
		if (is_p2p_mode())
			sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_first_data));
		else if (is_transit_mode())
			sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_first_data));
		else if (is_upnp_mode())
			sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(upnp_status_first_data));

		write_to_log(g_test);
	}
	printf("*");

#if TEST_RECORD_FRAME_DATA
	//write_data_to_file(pData, iSize);
#endif
}

int main(int argc, char* argv[])
{
	////
	set_never_stop(true);
	set_connect_mode(P2P_MODE);

	if (!InitZSipLib())
	{
		printf("init zsip lib failed\n");
	}

	//getchar();
	
	if (!create_test_log())
	{
		printf("create test log failed\n");
	}

	//getchar();

	//test_p2p_transit_all();
	//return 0;
	//create_data_file();
	test_connect_device("1308001424", CHANNEL_0, 0, P2P_MODE);

	//test_connect_device("1308000803", CHANNEL_0, 0, UPNP_MODE);

	//create_data_file();
	//test_connect_device("1308001028", CHANNEL_0, 0, UPNP_MODE);
	return 0;

#if 0
	test_dvr_talk("1308000312", CHANNEL_0, 0, TRANSIT_MODE);
	return 0;
#endif

//
//#if 1
//	test_ptz("1207001011", TRANSIT_MODE);
//	return 0;
//#endif

#if TEST_PLAYBACK
	std::string strDateTime = "2014-03-03 03:27:43";
	test_play_back("1308001259", CHANNEL_1, P2P_MODE, strDateTime);
	return 0;
#endif

//#if TEST_UPDATE_DNS
//	test_update_dns();
//	return 0;
//#endif
//
#if TEST_SEND_TALK_DATA
	test_talk("1308001060", UPNP_MODE);
	return 0;
#endif 

//#if TEST_CHANAGE_STREAM
//	test_change_stream("1308000906", P2P_MODE);
//	return 0;
//#endif

//#if  TEST_UPNP_CHANGE_PWD
//	test_change_pwd("<PASSWORD>", P2P_MODE);
//	return 0;
//#endif

	//test_connect_device("9999999970", CHANNEL_3, 0, P2P_MODE);
	//test_connect_device("1308000916", CHANNEL_0, 0, P2P_MODE);

	test_p2p_transit_all();

	close_test_log();
	CP2PClient::ReleaseZSip();

	printf("\n\n\nPress any key to quit... \n");
	getchar();
	return 0;
}
<commit_msg>删除了多余数据<commit_after>#include "P2PClient_IOS.h"
#include "test.h"

#include <json/json.h>

bool InitZSipLib()
{
	Json::Value root;
	Json::FastWriter writer;

	root["TokenId"] = "<PASSWORD>";
	root["UsrId"] = "1654500";

	root["ClientIP"] = "0.0.0.0";
	root["ClientPort"] = "0";
#if FOR_TEST_SERVER
	//root["StunIP"] = "192.168.127.12";
	//root["StunPort"] = "8089";
	//root["ServerIP"] = "192.168.127.12";
	//root["ServerPort"] = "8089";

	root["StunIP"] = "172.18.32.19";
	root["StunPort"] = "8088";
	root["ServerIP"] = "172.18.32.19";
	root["ServerPort"] = "8088";
#endif

#if FOR_DEV_SERVER
	root["StunIP"] = "172.18.35.6";
	root["StunPort"] = "8088";
	root["ServerIP"] = "172.18.35.6";
	root["ServerPort"] = "8088";
#endif

#if FOR_USA_SERVER
	root["StunIP"] = "192.168.127.12";  //"192.168.127.12";
	root["StunPort"] = "8088";
	root["ServerIP"] =  "192.168.127.12";  //"192.168.127.12";
	root["ServerPort"] = "8088";
#endif
	root["UsrType"] = "3";					// 0-ͻˣ3-upnpͻ
	root["ClientType"] = "0";				// 0-android1-ios

	// ʱ
	root["SipKeepAlive"] = "4000000";		// SIPʱ Ĭ4s
	root["SipReqTimeout"] = "5000000";		// SIPʱʱ䣬Ĭ5s

	root["P2PReqTimeout"] = "8000000";		// P2Pʱʱ Ĭ8s
	root["RegisterTimeout"] = "2000000";	// תעᳬʱʱ Ĭ2s
	root["LoginTimeout"] = "4000000";		// ½ʱʱ Ĭ2s

	root["StreamKeepAlive"] = "2000000";		// ֱ Ĭ2s
	root["StreamTimeout"] = "5000000";		// ݳʱ Ĭ5s

	std::string slParams = writer.write(root);

	return CP2PClient::InitZSip(slParams, ZSIP_MSG);
}

void ZSIP_MSG(int iType, int iStatus, char* data, int data_len)
{
	switch (iStatus)
	{
	case sipsMessage:
		printf("SIPϢ: \n %s \n", data);	// pText Ϊjsonַ Ҫϲ
		break;
	case sipsSessionTimeout:
		printf("sip֪ͨSessionʱ, µ½\n");
		break;
	case sipsUpdateDNS:
		printf("ãUpdateDNS!\n");
		break;
	}
}

void OnStatusReport(int iType, int iStatus, const char* pText, void * pCookie)
{
	printf("OnStatusReport : %d   %d\t", iType, iStatus);
	switch (iType)
	{
	case stSIP:
		switch (iStatus)
		{

		}
		break;
	case stStream:
		{
			switch (iStatus)
			{
			case ssUPNPConnectSucc:
				{
					printf("UPNPӳɹ\n");
					set_connect_status(upnp_status_connect_succ);
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(upnp_status_connect_succ));
					write_to_log(g_test);
				}
				break;
			case ssUPNPConnectFailed:
				{
					printf("UPNPʧ %s\n", pText);
					set_connect_status(upnp_status_connect_failed);
					set_wait_first_data_error();
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(upnp_status_connect_failed), pText);
					write_to_log(g_test);
				}
				break;
			case ssUPNPRecvFailed:
				{
					printf("UPNPմ %s\n", pText);
					set_same_error();
					set_connect_status(upnp_status_connect_failed);
					set_wait_first_data_error();
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(upnp_status_connect_failed), pText);
					write_to_log(g_test);
				}				
				break;

			case ssP2PConnectSucc:
				{
					printf("P2Pӳɹ\n");
					set_connect_status(p2p_status_connect_succ);
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_connect_succ));
					write_to_log(g_test);
				}
				break;
			case ssP2PConnectFailed:
				{
					printf("P2Pʧ %s\n", pText);
					set_connect_status(p2p_status_connect_failed);
					set_wait_first_data_error();
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_connect_failed), pText);
					write_to_log(g_test);
				}
				break;
			case ssP2PRecvFailed:
				{
					printf("P2Pմ %s\n", pText);
					set_same_error();
					set_connect_status(p2p_status_connect_failed);
					set_wait_first_data_error();
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_connect_failed), pText);
					write_to_log(g_test);
				}				
				break;

			case ssDeliverConnectSucc:
				{
					printf("תӳɹ\n");
					set_connect_status(transit_status_connect_succ);
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_connect_succ), pText);
					write_to_log(g_test);
				}
				break;
			case ssDeliverConnectFailed:
				{
					printf("תʧ %s\n", pText);
					set_connect_status(transit_status_connect_failed);
					set_wait_first_data_error();
					char g_test[1024] = {0};
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_connect_failed), pText);
					write_to_log(g_test);
				}
				break;
			case ssDeliverRecvFailed:
				{
					printf("תմ %s\n", pText);
					set_connect_status(transit_status_connect_failed);
					set_wait_first_data_error();
					char g_test[1024] = {0};

					if (strcmp("login timeout", pText) == 0)
						set_login_status(login_status_falied);
					sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_connect_failed), pText);
					write_to_log(g_test);
				}
				break;

			case ssPlayBackReqSucc:
				printf("طɹ\n");
				break;
			case ssPlayBackReqFailed:
				printf("طʧ\n");
				break;
			case ssPlayBackStop:
				printf("ǰطŽ\n");
				break;

			case ssChangeToQVGA:
				printf("ҪлΪQVGA\n");
				break;
			case ssChangeToVGA:
				printf("ҪлΪVGA\n");
				break;
			case ssOpenSoundSucc:
				printf("Ƶɹ\n");
				break;
			case ssOpenSoundFailed :
				printf("Ƶʧ\n");
				break;
			case ssCloseSoundSucc:
				printf("رƵɹ\n");
				break;
			case ssCloseSoundFailed:
				printf("رƵʧ\n");
				break;

			case ssOpenTalkSucc:
				printf("򿪶Խɹ\n");
				set_talk_status(talk_status_succ);
				break;
			case ssOpenTalkFailed:
				printf("򿪶Խʧ\n");
				set_talk_status(talk_status_failed);
				break;
			case ssCloseTalkSucc:
				printf("رնԽɹ\n");
				set_talk_status(talk_status_succ);
				break;
			case ssCloseTalkFailed:
				printf("رնԽʧ\n");
				set_talk_status(talk_status_failed);
				break;

			case ssChangeStreamSucc:
				printf("ɹ\n");
				set_change_stream_status(change_stream_status_succ);
				break;
			case ssChangeStreamFailed:
				printf("ʧ\n");
				set_change_stream_status(change_stream_status_failed);
				break;

			case ssPTZCfgSucc:
				printf("PTZóɹ\n");
				break;
			case ssPTZCfgFailed:
				printf("PTZʧ\n");
				break;
			case ssPTZGetPresetSucc:
				printf("PTZԤõȡɹ\n");
				break;
			case ssPTZGetPresetFailed:
				printf("PTZԤõȡʧ\n");
				break;

			case ssUnknownError:
			default:
				printf("δ֪\n");
				break;
			}
		}
		break;
	case stNatType :
		{
			printf("Ϣ֪ϲ\n");
		}
		break;
	case stUpnp:
		{
			switch (iStatus)
			{
			case upnpLoginSuper_0:
				{
					set_login_status(login_status_super_succ);
					printf("login super ok \n");

					char g_test[1024] = {0};
					if (is_p2p_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : Super %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_login_succ), pText);
					else if (is_transit_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : Super %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_login_succ), pText);
					write_to_log(g_test);
				}
				break;
			case upnpLoginNormal_0:
				{
					set_login_status(login_status_normal_succ);
					printf("login normal ok \n");

					char g_test[1024] = {0};
					if (is_p2p_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : Normal %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_login_succ), pText);
					else if (is_transit_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : Normal %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_login_succ), pText);
					write_to_log(g_test);
				}
				break;
			case upnpLoginfalied:
				{
					set_login_status(login_status_falied);
					printf("login failed \n");

					char g_test[1024] = {0};
					if (is_p2p_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_login_failed), pText);
					else if (is_transit_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_login_failed), pText);
					write_to_log(g_test);
				}
				break;
			case upnpChangePwdSucc:
				{
					printf("change pwd succ \n");

					set_change_pwd_status(change_pwd_status_succ);
					char g_test[1024] = {0};
					if (is_p2p_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_change_pwd_succ), pText);
					else if (is_transit_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_login_succ), pText);
					write_to_log(g_test);
				}
				break;
			case upnpChangePwdFailed:
				{
					printf("change pwd failed \n");

					set_change_pwd_status(change_pwd_status_failed);
					char g_test[1024] = {0};
					if (is_p2p_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_change_pwd_failed), pText);
					else if (is_transit_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s %s\n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_login_failed), pText);
					write_to_log(g_test);
				}
				break;
			case upnpQueryUpnpSucc:
				{
					if (pText == NULL)
					{
						printf("response null ");
					}
					printf("UPNP ѯɹ %s \n", pText);

					char g_test[1024] = {0};
					if (is_p2p_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_upnp_query_succ));
					else if (is_transit_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_upnp_query_succ));
					write_to_log(g_test);

					set_upnp_query_status(upnp_query_status_succ);
				}
				break;
			case upnpQueryUpnpFailed:
				{
					if (pText == NULL)
					{
						printf("response null ");
					}
					printf("UPNP ѯʧ \n");
					char g_test[1024] = {0};
					if (is_p2p_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_upnp_query_failed));
					else if (is_transit_mode())
						sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_upnp_query_failed));
					write_to_log(g_test);

					set_upnp_query_status(upnp_query_status_failed);
				}
				break;
			}
		}
		break;
	}
}

void OnFrameData(int iType, char* pData, int iSize, void * pCookie)
{
	// ش õ ->
	if (!is_recv_first_data())
	{
		set_recv_first_data(true);
		char g_test[1024] = {0};
		if (is_p2p_mode())
			sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(p2p_status_first_data));
		else if (is_transit_mode())
			sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(transit_status_first_data));
		else if (is_upnp_mode())
			sprintf(g_test, "[%s] (%0.0f) {%s} : %s \n", GetCurTime(), GetWorkTime(), deviceList[g_device_index]._name, CONN_STATUS_STR(upnp_status_first_data));

		write_to_log(g_test);
	}
	printf("*");

#if TEST_RECORD_FRAME_DATA
	//write_data_to_file(pData, iSize);
#endif
}

int main(int argc, char* argv[])
{
	////
	set_never_stop(true);
	set_connect_mode(P2P_MODE);

	if (!InitZSipLib())
	{
		printf("init zsip lib failed\n");
	}

	//getchar();
	
	if (!create_test_log())
	{
		printf("create test log failed\n");
	}

	//getchar();

	//test_p2p_transit_all();
	//return 0;
	//create_data_file();
	test_connect_device("1308001424", CHANNEL_0, 0, P2P_MODE);

	//test_connect_device("1308000803", CHANNEL_0, 0, UPNP_MODE);

	//create_data_file();
	//test_connect_device("1308001028", CHANNEL_0, 0, UPNP_MODE);
	return 0;

#if 0
	test_dvr_talk("1308000312", CHANNEL_0, 0, TRANSIT_MODE);
	return 0;
#endif

//
//#if 1
//	test_ptz("1207001011", TRANSIT_MODE);
//	return 0;
//#endif

#if TEST_PLAYBACK
	std::string strDateTime = "2014-03-03 03:27:43";
	test_play_back("1308001259", CHANNEL_1, P2P_MODE, strDateTime);
	return 0;
#endif

//#if TEST_UPDATE_DNS
//	test_update_dns();
//	return 0;
//#endif
//
#if TEST_SEND_TALK_DATA
	test_talk("1308001060", UPNP_MODE);
	return 0;
#endif 

//#if TEST_CHANAGE_STREAM
//	test_change_stream("1308000906", P2P_MODE);
//	return 0;
//#endif

//#if  TEST_UPNP_CHANGE_PWD
//	test_change_pwd("<PASSWORD>", P2P_MODE);
//	return 0;
//#endif

	//test_connect_device("9999999970", CHANNEL_3, 0, P2P_MODE);
	//test_connect_device("1308000916", CHANNEL_0, 0, P2P_MODE);

	test_p2p_transit_all();

	close_test_log();
	CP2PClient::ReleaseZSip();

	printf("\n\n\nPress any key to quit... \n");
	getchar();
	return 0;
}

{'fraction_non_alphanumeric': 0.1693133202813429, 'fraction_numerical': 0.039300993401493726, 'mean_word_length': 4.025141191473857, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 24, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2216405', 'n_tokens_mistral': 14098, 'n_tokens_neox': 11610, 'n_words': 1852}