Пример #1
0
//保存产品化相关信息
static int write_product_info(SysProductInfo *info)
{
	int ret = 0;
	char temp[256] = {0};
	char title[64] = {0};
	char *config_file = PRODUCT_CONFIG;

	MMPSysParam net_info ;
	//	struct in_addr int_addr;

	memset(&net_info, 0, sizeof(MMPSysParam));
	MMP_get_sysparam(0, &net_info, MAIN_MMP);

	memcpy(title, "product", 64);


	ret =  ConfigSetKey(config_file, title, "name", info->strName);

	if(ret != 0) {
		PRINTF("Failed to write version\n");
		return -1;
	}

	ret =  ConfigSetKey(config_file, title, "serialNum", info->serialNum);

	if(ret != 0) {
		PRINTF("Failed to write version\n");
		return -1;
	}

	sprintf(temp, "%d", info->producttype);
	ret =  ConfigSetKey(config_file, title, "type", temp);

	if(ret != 0) {
		PRINTF("Failed to write version\n");
		return -1;
	}

	sprintf(temp, "%d", info->bType);
	ret =  ConfigSetKey(config_file, title, "MMP_type", temp);

	if(ret != 0) {
		PRINTF("Failed to write version\n");
		return -1;
	}


	//write to factory.ini
	return 0;
}
Пример #2
0
void InitProtocalStatus()
{
	return 0;

#ifdef SAVE_TS_STATUS
	int ret = 0;
	char temp[512] = {0};
	struct in_addr          addr_ip;
	char config_file[64] = PROTOCALSTATUS;



	//-------------------------ts-----------------------------------------
	ret = ConfigGetKey(config_file, "ts", "ipaddr", temp);

	if(ret == 0) {
		memcpy(g_MidMultAddr[TS_STREAM].chIP, temp, 16);
		DEBUG(DL_FLOW, "ts ip : %s\n\n", g_MidMultAddr[TS_STREAM].chIP);
	}

	ret = ConfigGetKey(config_file, "ts", "port", temp);

	if(ret == 0) {
		g_MidMultAddr[TS_STREAM].nPort = atoi(temp);
		DEBUG(DL_FLOW, "ts port : %d\n\n", g_MidMultAddr[TS_STREAM].nPort);
	}

	ret = ConfigGetKey(config_file, "ts", "status", temp);

	if(ret == 0) {
		g_MidMultAddr[TS_STREAM].nStatus = atoi(temp);
		DEBUG(DL_FLOW, "ts onoff : %d\n\n", g_MidMultAddr[TS_STREAM].nStatus);
	}

	//-------------------------rtp-----------------------------------------
	ret = ConfigGetKey(config_file, "rtp", "ipaddr", temp);

	if(ret == 0) {
		memcpy(g_MidMultAddr[RTP_STREAM].chIP, temp, 16);
		DEBUG(DL_FLOW, "rtp ip : %s\n\n", g_MidMultAddr[RTP_STREAM].chIP);
	}

	ret = ConfigGetKey(config_file, "rtp", "port", temp);

	if(ret == 0) {
		g_MidMultAddr[RTP_STREAM].nPort = atoi(temp);
		DEBUG(DL_FLOW, "rtp port : %d\n\n", g_MidMultAddr[RTP_STREAM].nPort);
	}

	ret = ConfigGetKey(config_file, "rtp", "status", temp);

	if(ret == 0) {
		g_MidMultAddr[RTP_STREAM].nStatus = atoi(temp);
		DEBUG(DL_FLOW, "rtp onoff : %d\n\n", g_MidMultAddr[RTP_STREAM].nStatus);
	}


	//-------------------------rtsp-----------------------------------------
	memcpy(&addr_ip, &gSysParaT.sysPara.dwAddr, 4);
	memcpy(g_MidMultAddr[RTSP_STREAM].chIP, inet_ntoa(addr_ip), 16);
	memcpy(temp, inet_ntoa(addr_ip), 16);

	g_MidMultAddr[RTSP_STREAM].nPort = 554;
	ret = ConfigSetKey(config_file, "rtsp", "ipaddr", temp);

	if(ret == 0) {
		DEBUG(DL_FLOW, "rtsp ip : %s\n\n", g_MidMultAddr[RTSP_STREAM].chIP);
	}

	sprintf(temp, "%d", g_MidMultAddr[RTSP_STREAM].nPort);

	ret = ConfigSetKey(config_file, "rtsp", "port", temp);

	if(ret == 0) {
		DEBUG(DL_FLOW, "rtsp port : %d\n\n", g_MidMultAddr[RTSP_STREAM].nPort);
	}


	ret = ConfigGetKey(config_file, "rtsp", "status", temp);
	PRINTF("ret = %d,temp=%s\n", ret, temp);

	if(ret == 0) {
		g_MidMultAddr[RTSP_STREAM].nStatus = atoi(temp);
		DEBUG(DL_FLOW, "rtsp onoff : %d\n\n", g_MidMultAddr[RTSP_STREAM].nStatus);
	}


	//-------------------------rtmp-----------------------------------------
	memcpy(&addr_ip, &gSysParaT.sysPara.dwAddr, 4);
	memcpy(g_MidMultAddr[RTMP_STREAM].chIP, inet_ntoa(addr_ip), 16);
	memcpy(temp, inet_ntoa(addr_ip), 16);

	g_MidMultAddr[RTMP_STREAM].nPort = RTMP_LISTEN_PORT;
	ret = ConfigSetKey(config_file, "rtmp", "ipaddr", temp);

	if(ret == 0) {
		DEBUG(DL_FLOW, "rtmp ip : %s\n\n", g_MidMultAddr[RTMP_STREAM].chIP);
	}


	sprintf(temp, "%d", g_MidMultAddr[RTMP_STREAM].nPort);
	ret = ConfigSetKey(config_file, "rtmp", "port", temp);

	if(ret == 0) {
		DEBUG(DL_FLOW, "rtmp port : %d\n\n", g_MidMultAddr[RTMP_STREAM].nPort);
	}


	ret = ConfigGetKey(config_file, "rtmp", "status", temp);

	if(ret == 0) {
		g_MidMultAddr[RTMP_STREAM].nStatus = atoi(temp);
		DEBUG(DL_FLOW, "rtsp onoff : %d\n\n", g_MidMultAddr[RTMP_STREAM].nStatus);
	}

	//----------------------------------------------Build socket ------------------------------------------//
	if(MULT_START == g_MidMultAddr[TS_STREAM].nStatus) {
		DEBUG(DL_FLOW, "\n------------ TS START ------------\n\n");
		SetEStoTSMultPort(&g_MidMultAddr[TS_STREAM], TS_STREAM);
		TsSetUdp(g_UdpTSSocket[TS_STREAM], g_UdpTSAddr[TS_STREAM]);
		DEBUG(DL_FLOW, "------------ s_MultAddr[0].nStatus = %d ------------\n", g_MidMultAddr[0].nStatus);
	}

	if(MULT_START == g_MidMultAddr[RTP_STREAM].nStatus) {
		DEBUG(DL_FLOW, "\n------------ RTP START ------------\n\n");
		SetEStoTSMultPort(&g_MidMultAddr[RTP_STREAM], RTP_STREAM);
		RtpSetUdp(g_UdpTSSocket[RTP_STREAM], g_UdpTSAddr[RTP_STREAM], g_UdpaudioSocket, g_UdpaudioAddr);
		DEBUG(DL_FLOW, "------------ s_MultAddr[1].nStatus = %d ------------\n", g_MidMultAddr[RTP_STREAM].nStatus);

	}


	//------------------------------save params-----------------------------------------------//
	for(ret = 0; ret < MAX_PROTOCOL; ret++) {
		if(strlen(g_MidMultAddr[ret].chIP) != 0) {
			memcpy(&s_MultAddr[ret].chIP, &g_MidMultAddr[ret].chIP, sizeof(MultAddr));
		}

	}

#endif
	return ;
}
Пример #3
0
int SaveProtocalStatus(const MultAddr *port, int protocol)
{
#ifdef SAVE_TS_STATUS
	char temp[512] = {0};
	char config_file[64] = PROTOCALSTATUS;
	int ret = 0;
	memcpy(&g_MidMultAddr[protocol].chIP, port, sizeof(MultAddr));

	if(TS_STREAM == protocol) {
		memcpy(temp, port->chIP, 16);
		ret = ConfigSetKey(config_file, "ts", "ipaddr", temp);

		if(ret != 0) {
			DEBUG(DL_FLOW, "set ts ipaddr failed\n");
		}

		sprintf(temp, "%d", port->nPort);
		ret = ConfigSetKey(config_file, "ts", "port", temp);

		if(ret != 0) {
			DEBUG(DL_FLOW, "set ts port failed\n");
		}

		sprintf(temp, "%d", port->nStatus);
		ret = ConfigSetKey(config_file, "ts", "status", temp);

		if(ret != 0) {
			DEBUG(DL_FLOW, "set ts onoff status failed\n");
		}

	}

	if(RTP_STREAM == protocol) {
		memcpy(temp, port->chIP, 16);
		ret = ConfigSetKey(config_file, "rtp", "ipaddr", temp);

		if(ret != 0) {
			DEBUG(DL_FLOW, "set rtp ipaddr failed\n");
		}

		sprintf(temp, "%d", port->nPort);
		ret = ConfigSetKey(config_file, "rtp", "port", temp);

		if(ret != 0) {
			DEBUG(DL_FLOW, "set rtp port failed\n");
		}

		sprintf(temp, "%d", port->nStatus);
		ret = ConfigSetKey(config_file, "rtp", "status", temp);

		if(ret != 0) {
			DEBUG(DL_FLOW, "set ts onoff status failed\n");
		}
	}

	if(RTSP_STREAM == protocol) {
		sprintf(temp, "%d", port->nStatus);
		PRINTF("port->nStatus =%d,\n", port->nStatus);
		ret = ConfigSetKey(config_file, "rtsp", "status", temp);

		if(ret != 0) {
			DEBUG(DL_FLOW, "set rtsp onoff status failed\n");
		}
	}

	if(RTMP_STREAM == protocol) {
		sprintf(temp, "%d", port->nStatus);
		ret = ConfigSetKey(config_file, "rtmp", "status", temp);

		if(ret != 0) {
			DEBUG(DL_FLOW, "set rtmp onoff status failed\n");
		}
	}

#endif
	return 0;
}
Пример #4
0
int write_mp_config()
{
	char temp[64] = {0};
	int ret  = 0 ;
	int i = 0 ;
	int input = SIGNAL_INPUT_MP;
	int layout = 1;
	int  audio_input = SIGNAL_INPUT_1;
	const char config_file[64] = MP_CONFIG ;

	int mp_status = get_mp_status();
	sprintf(temp, "%d", mp_status);
	ret =  ConfigSetKey((char *)config_file, "MP", "mp", temp);

	if(ret != 0) {
		ERR_PRN("Failed to Set mp \n");
		return -1;
	}

	input_get_audio_input(input, &audio_input);
	sprintf(temp, "%d", audio_input);
	ret =  ConfigSetKey((char *)config_file, "MP", "audio_input", temp);

	if(ret != 0) {
		ERR_PRN("Failed to Set audio_input \n");
		return -1;
	}

	layout = get_mp_layout();
	sprintf(temp, "%d", layout);
	ret =  ConfigSetKey((char *)config_file, "MP", "layout", temp);

	if(ret != 0) {
		ERR_PRN("Failed to Set layout \n");
		return -1;
	}

	for(i = MP_LAYOUT_1; i < MP_LAYOUT_MAX; i++) {
		char title[16] = {0};
		int win1 = SIGNAL_INPUT_1, win2 = SIGNAL_INPUT_2;
		app_get_swap_layout(i, &win1, &win2);

		sprintf(title, "layout=%d", i);
		sprintf(temp, "%d", win1);
		ret =  ConfigSetKey((char *)config_file, title, "win1", temp);

		if(ret != 0) {
			ERR_PRN("Failed to Set win1 \n");
			return -1;
		}

		sprintf(temp, "%d", win2);
		ret =  ConfigSetKey((char *)config_file, title, "win2", temp);

		if(ret != 0) {
			ERR_PRN("Failed to Set win2 \n");
			return -1;
		}
	}

	PRINTF("mp_status=%d,layout=%d,audio_input=%d\n", mp_status, layout, audio_input);
	return ret;
}
Пример #5
0
int writeOutputVideoParam(void)
{
	//	return 0;
	PRINTF("begin \n");

	int total = 0;
	int ret = 0;
	//int value = 0;
	int i = 0;
	char bak_name[512] = {0};
	char section[256] = {0};
	char cmd[512] = {0};
	char temp[64] = {0};
	OutputVideoInfo videoinfo;
	memset(&videoinfo, 0, sizeof(OutputVideoInfo));

	pthread_mutex_lock(&gSetP_m.save_sys_m);
	memcpy(&videoinfo, &g_outputparam, sizeof(OutputVideoInfo));
	pthread_mutex_unlock(&gSetP_m.save_sys_m);

	sprintf(bak_name, "%s.bak", VIDEOENCODE_FILE);




	sprintf(temp, "%d", videoinfo.resolution);

	ret = ConfigSetKey(bak_name, "video", "resolution", temp);

	if(ret != 0) {
		PRINTF("write resolution failed resolution:%d\n", videoinfo.resolution);
		goto EXIT;
	}

	PRINTF("write outputparam.resizeMode %d before ....\n", videoinfo.resizeMode);
	sprintf(temp, "%d", videoinfo.resizeMode);
	ret = ConfigSetKey(bak_name, "video", "resizemode", temp);
	PRINTF("write outputparam.resizeMode after ....\n");

	if(ret != 0) {
		PRINTF("write resizeMode failed resolution:%d\n", videoinfo.resizeMode);
		goto EXIT;
	}

	sprintf(temp, "%d", videoinfo.encodelevel);
	ret = ConfigSetKey(bak_name, "video", "encodelv", temp);

	if(ret != 0) {
		PRINTF("write encodelevel failed resolution:%d\n", videoinfo.encodelevel);
		goto EXIT;
	}

	sprintf(temp, "%d", videoinfo.preset);
	ret = ConfigSetKey(bak_name, "video", "scene", temp);

	if(ret != 0) {
		PRINTF("write scene failed resolution:%d\n", videoinfo.preset);
		goto EXIT;
	}

	PRINTF("set nFramerate rize value : %d \n", videoinfo.nFrameRate);
	sprintf(temp, "%d", videoinfo.nFrameRate);
	ret = ConfigSetKey(bak_name, "video", "frame", temp);

	if(ret != 0) {
		PRINTF("write nFrameRate failed resolution:%d\n", videoinfo.nFrameRate);
		goto EXIT;
	}

	sprintf(temp, "%d", videoinfo.IFrameinterval);
	ret = ConfigSetKey(bak_name, "video", "Iframeinterval", temp);

	if(ret != 0) {
		PRINTF("write IFrameinterval failed resolution:%d\n", videoinfo.IFrameinterval);
		goto EXIT;
	}

	PRINTF("write sBitrate :%d\n", videoinfo.sBitrate);
	sprintf(temp, "%d", videoinfo.sBitrate);
	ret = ConfigSetKey(bak_name, "video", "bitrate", temp);

	if(ret != 0) {
		PRINTF("write sBitrate failed resolution:%d\n", videoinfo.sBitrate);
		goto EXIT;
	}


	//	sprintf(temp, "%d", getShowLogoTextFlag());
	//	ret = ConfigSetKey(bak_name, "video", "logotext", temp);

	//	if(ret != 0) {
	//		PRINTF("write getShowLogoTextFlag failed resolution:%d\n", getShowLogoTextFlag());
	//		goto EXIT;
	//	}

	sprintf(temp, "%d", app_get_logoshow_flag());
	ret = ConfigSetKey(bak_name, "video", "logo_show", temp);

	if(ret != 0) {
		PRINTF("write logo show failed resolution:%d\n", app_get_logoshow_flag());
		goto EXIT;
	}

	sprintf(temp, "%d", app_get_textshow_flag());
	ret = ConfigSetKey(bak_name, "video", "text_show", temp);

	if(ret != 0) {
		PRINTF("write text show failed resolution:%d\n", app_get_textshow_flag());
		goto EXIT;
	}



	/*拷贝bak文件到ini*/
	if(ret != -1) {
		sprintf(cmd, "cp -rf %s %s;rm -rf %s", bak_name, VIDEOENCODE_FILE, bak_name);
		system(cmd);
		PRINTF("i will run cmd:%s\n", cmd);
	}

EXIT:
	PRINTF("end \n");
	return ret;
}
Пример #6
0
static int write_network_info()
{
	char 			temp[512] = {0};
	int 			ret  = 0 ;
	//	int 			enable = 0;
	int 			rst = -1;
	const char config_file[64] = NETWORK_CONFIG;
	//pthread_mutex_lock(&gSetP_m.save_sys_m);
	char    title[20] = "system";
	MMPSysParam net_info ;
	struct in_addr int_addr;

	memset(&net_info, 0, sizeof(MMPSysParam));
	MMP_get_sysparam(0, &net_info, MAIN_MMP);
	memcpy(&int_addr, &(net_info.dwAddr), 4);

	PRINTF("eth0:ip=%s\n", inet_ntoa(int_addr));
	ret =  ConfigSetKey((char *)config_file, title, "eth0_ip", inet_ntoa(int_addr));

	if(ret != 0) {
		PRINTF("Failed to write eth0 ip\n");
		goto EXIT;
	}

	memset(&int_addr, 0, sizeof(int_addr));
	memcpy(&int_addr, &(net_info.dwNetMask), 4);
	PRINTF("eth0:mark=%s\n", inet_ntoa(int_addr));
	ret =  ConfigSetKey((char *)config_file, title, "eth0_mark", inet_ntoa(int_addr));

	if(ret != 0) {
		PRINTF("Failed to write eth0 mark\n");
		goto EXIT;
	}

	memset(&int_addr, 0, sizeof(int_addr));
	memcpy(&int_addr, &(net_info.dwGateWay), 4);
	PRINTF("eth0:gateway=%s\n", inet_ntoa(int_addr));
	ret =  ConfigSetKey((char *)config_file, title, "eth0_gateway", inet_ntoa(int_addr));

	if(ret != 0) {
		PRINTF("Failed to write eth0 gateway\n");
		goto EXIT;
	}

	JoinMacAddr(temp, net_info.szMacAddr, 8);
	PRINTF("eth0:MAC=%s\n", temp);
	ret =  ConfigSetKey((char *)config_file, title, "eth0_Mac", temp);

	if(ret != 0) {
		PRINTF("Failed to eth0 mac\n");
		goto EXIT;
	}


	memset(&net_info, 0, sizeof(MMPSysParam));
	MMP_get_sysparam(1, &net_info, SECOND_MMP);
	memcpy(&int_addr, &(net_info.dwAddr), 4);
	PRINTF("eth1:ip=%s\n", inet_ntoa(int_addr));
	ret =  ConfigSetKey((char *)config_file, title, "eth1_ip", inet_ntoa(int_addr));

	if(ret != 0) {
		PRINTF("Failed to write eth1 ip\n");
		goto EXIT;
	}

	memset(&int_addr, 0, sizeof(int_addr));
	memcpy(&int_addr, &(net_info.dwNetMask), 4);
	PRINTF("eth1:mark=%s\n", inet_ntoa(int_addr));
	ret =  ConfigSetKey((char *)config_file, title, "eth1_mark", inet_ntoa(int_addr));

	if(ret != 0) {
		PRINTF("Failed to write eth1 mark!\n");
		goto EXIT;
	}

	memset(&int_addr, 0, sizeof(int_addr));
	memcpy(&int_addr, &(net_info.dwGateWay), 4);
	PRINTF("eth1:gateway=%s\n", inet_ntoa(int_addr));
	ret =  ConfigSetKey((char *)config_file, title, "eth1_gateway", inet_ntoa(int_addr));

	if(ret != 0) {
		PRINTF("Failed to write eth1 gateway!\n");
		goto EXIT;
	}


	JoinMacAddr(temp, net_info.szMacAddr, 8);
	PRINTF("eth1:MAC=%s\n", temp);
	ret =  ConfigSetKey((char *)config_file, title, "eth1_Mac", temp);

	if(ret != 0) {
		PRINTF("Failed to eth1  mac!\n");
		goto EXIT;
	}

	rst = 1;
EXIT:
	return rst;
}
Пример #7
0
static int write_version_info(Version_Info *curr, Version_Info *prev)
{
	char title[64] ;
	//	char temp[512] = {0};
	int ret  = 0 ;
	const char config_file[64] = VERSION_CONFIG;

	memcpy(title, "current", 20);

	ret =  ConfigSetKey((char *)config_file, title, "app", curr->app_version);

	if(ret != 0) {
		PRINTF("Failed to write version\n");
		return -1;
	}

	ret =  ConfigSetKey((char *)config_file, title, "kernel", curr->kernel_version);

	if(ret != 0) {
		PRINTF("Failed to write version\n");
		return -1;
	}

	ret =  ConfigSetKey((char *)config_file, title, "fpag", curr->fpga_version);

	if(ret != 0) {
		PRINTF("Failed to write version\n");
		return -1;
	}

#if 0
	ret =  ConfigSetKey((char *)config_file, title, "built_time", curr->built_time);

	if(ret != 0) {
		PRINTF("Failed to write version\n");
		return -1;
	}

#endif


	memcpy(title, "previous", 20);


	ret =  ConfigSetKey((char *)config_file, title, "app", prev->app_version);

	if(ret != 0) {
		PRINTF("Failed to write version\n");
		return -1;
	}

	ret =  ConfigSetKey((char *)config_file, title, "kernel", prev->kernel_version);

	if(ret != 0) {
		PRINTF("Failed to write version\n");
		return -1;
	}

	ret =  ConfigSetKey((char *)config_file, title, "fpag", prev->fpga_version);

	if(ret != 0) {
		PRINTF("Failed to write version\n");
		return -1;
	}

#if 0
	ret =  ConfigSetKey((char *)config_file, title, "built_time", prev->built_time);

	if(ret != 0) {
		PRINTF("Failed to write version\n");
		return -1;
	}

#endif
	return 0;
}