Example #1
0
static int load_pic_info(PIC_INFO* p_pic_info,char *serviceID,char *service_id)
{
	//////load pic info
	// there are 4 cases here ,
	// 1:there is a record in the db,and the pic exists; 			 deal:normal
	// 2:there is a record in the db,but the pic doesn't exist 		deal:only section header
	// 3:there is no record in the db  							deal:only section header
	// 4:there is an empty record after 7 seconds 				deal:only section header

	printf("@@@正在从数据库中读取排期信息......\n");
	int num;
	char data_img[10][DATA_MAX_FIELD_NUM][DATA_MAX_REC_LEN];
	char pic_dir[256];
	read_config("pic_dir", pic_dir);

	sprintf(sql,"select imgurl,scheduleid,xposition,yposition,width,height,showtime,style,position,length,channelcode,id from xepg_ad where service_id=%s and NOW() >= start_time and NOW() <  end_time",serviceID);
	num=mysql_get_data(&mysql, sql,data_img);
	if(num)
	{



		//set dtbflag=1
		sprintf(sql,"update xepg_ad set dtbflag=1 where id='%s' ",data_img[0][11]);
		mysql_exec(&mysql, sql);


		
		//get pic_name 
		
		strcpy(p_pic_info->name,pic_dir);
		strcat(p_pic_info->name,data_img[0][0]);
		//printf("pic:%s\n",pic_info[j].name);

		//get antifake,x,y,width,height,period.stype
		p_pic_info->schedule_id=atoi(data_img[0][1]);
		p_pic_info->x=atoi(data_img[0][2]);
		p_pic_info->y=atoi(data_img[0][3]);
		p_pic_info->width=atoi(data_img[0][4]);
		p_pic_info->height=atoi(data_img[0][5]);
		p_pic_info->period=atoi(data_img[0][6]);
		p_pic_info->style=atoi(data_img[0][7]);
		p_pic_info->m_position=atoi(data_img[0][8]);
		p_pic_info->m_len=atoi(data_img[0][9]);
		p_pic_info->file_sub_id=atoi(data_img[0][10]);//channelcode

		
		//get file stream
		if(get_file_stream(p_pic_info)==-1)
		{
			return -1;
		}
		return 0;
	
	}
	else
	{
		printf("@@@没有当前的排期信息!\n");
		return -1;
	}
	


}
Example #2
0
const WCHAR *FileNameEnc::Convert() {

	if (!m_tried) {

		m_tried = true;

		try {
			if (m_con->GetConfig()->m_reverse) {
				if (rt_is_config_file(m_con, m_plain_path.c_str())) {
					m_enc_path = m_con->GetConfig()->m_basedir + L"\\";
					m_enc_path += REVERSE_CONFIG_NAME;
				} else if (rt_is_virtual_file(m_con, m_plain_path.c_str())) {
					wstring dirpath;
					if (!get_file_directory(m_plain_path.c_str(), dirpath))
						throw(-1);
					if (!decrypt_path(m_con, &dirpath[0], m_enc_path))
						throw(-1);
					m_enc_path += L"\\";
					wstring filename;
					if (!get_bare_filename(m_plain_path.c_str(), filename))
						throw(-1);
					m_enc_path += filename;
				} else {
					if (!decrypt_path(m_con, m_plain_path.c_str(), m_enc_path)) {
						throw(-1);
					}
				}
			} else {

				LPCWSTR plain_path = m_plain_path.c_str();
				int cache_status = CASE_CACHE_NOTUSED;
				if (m_con->IsCaseInsensitive()) {
					cache_status = m_con->m_case_cache.lookup(
						m_plain_path.c_str(), m_correct_case_path,
						m_force_case_cache_notfound);
					if (cache_status == CASE_CACHE_FOUND ||
						cache_status == CASE_CACHE_NOT_FOUND) {
						m_file_existed = cache_status == CASE_CACHE_FOUND;
						plain_path = m_correct_case_path.c_str();
					} else if (cache_status == CASE_CACHE_MISS) {
						if (m_con->m_case_cache.load_dir(m_plain_path.c_str())) {
							cache_status = m_con->m_case_cache.lookup(
								m_plain_path.c_str(), m_correct_case_path,
								m_force_case_cache_notfound);
							if (cache_status == CASE_CACHE_FOUND ||
								cache_status == CASE_CACHE_NOT_FOUND) {
								m_file_existed = cache_status == CASE_CACHE_FOUND;
								plain_path = m_correct_case_path.c_str();
							}
						}
					}
					wstring stream;
					wstring file_without_stream;
					bool have_stream =
						get_file_stream(plain_path, &file_without_stream, &stream);
					if (have_stream) {
						unordered_map<wstring, wstring> streams_map;
						wstring stream_without_type;
						wstring type;

						if (!remove_stream_type(stream.c_str(), stream_without_type,
							type)) {
							throw(-1);
						}

						if (CryptFindStreamsInternal(
							file_without_stream.c_str(), NULL, m_dokan_file_info,
							CryptCaseStreamsCallback, &streams_map) == 0) {

							wstring uc_stream;

							if (!touppercase(stream_without_type.c_str(), uc_stream))
								throw(-1);

							auto it = streams_map.find(uc_stream);

							if (it != streams_map.end()) {
								m_correct_case_path = file_without_stream + it->second + type;
								plain_path = m_correct_case_path.c_str();
								DbgPrint(L"stream found %s -> %s\n", m_plain_path, plain_path);
							} else {
								DbgPrint(L"stream not found %s -> %s\n", m_plain_path,
									plain_path);
							}
						}
					}
				}
				if (!encrypt_path(m_con, plain_path, m_enc_path, m_actual_encrypted)) {
					throw(-1);
				}
			}
		} catch (...) {
			m_failed = true;
		}
	}

	const WCHAR *rs = !m_failed ? &m_enc_path[0] : NULL;

	if (rs) {
		DbgPrint(L"\tconverted filename %s => %s\n", m_plain_path.c_str(), rs);
	} else {
		DbgPrint(L"\terror converting filename %s\n", m_plain_path.c_str());
	}

	return rs;
}
Example #3
0
static CreateOneTable_FTT(unsigned char table_id,SEC_BUFFER_INFO *p_sbi, char *streamID,char *stream_id)
{
	//actual AD or other AD or actual AE or other AE,one of them
	printf("creating table 0x%x\n",table_id);
	
	PIC_INFO pic_info;
	char temp[128];
	unsigned int service_num=0;
	unsigned int num=0;
	int section_number=0;
	int table_section_number=0;
	int max_one_pic_section_number=0;
	int i,j;
	char ret=0;
	char data_service[100][DATA_MAX_FIELD_NUM][DATA_MAX_REC_LEN];
	char data_img[10][DATA_MAX_FIELD_NUM][DATA_MAX_REC_LEN];

	//get all services in this stream
	sprintf(sql,"SELECT id,service_id  from xepg_sdt_extension where transport_stream_id=%s",streamID);
	service_num=mysql_get_data(&mysql, sql,data_service);
	printf("service_num:%d\n",service_num);

	/*
	//get version_number of this table
	unsigned char version_number=0;
	version_number=get_version_number_task(table_id, baseid, streamID);
	*/
	
	//get ...
	char pic_table[32];
	char field_name[32];
	char table_type=0;

	int null_pic_section_flag=0;

	if(table_id==tableid_ad)
	{
		strcpy(pic_table,"xepg_ad");
		strcpy(field_name,"epgad_file_sub_id");
		table_type=1;
	}
	else if(table_id==tableid_ce)
	{
		strcpy(pic_table,"xepg_poster");
		strcpy(field_name,"poster_file_sub_id");
		table_type=2;
	}

	for(i=0;i<service_num;i++)// cirle of sub table 
	{
		printf("########serviceID:%d:%s########\n",i,data_service[i][1]);
		sprintf(logbuf,"ts[%s]tb[0x%x]sv[%s]",stream_id,table_id,data_service[i][1]);

		memset(&pic_info,0,sizeof(PIC_INFO));
		
		//////load pic info
		// there are 4 cases here ,
		// 1:there is a record in the db,and the pic exists; 			 deal:normal
		// 2:there is a record in the db,but the pic doesn't exist 		deal:only section header
		// 3:there is no record in the db  							deal:only section header
		// 4:there is an empty record after 7 seconds 				deal:only section header
		null_pic_section_flag=0;

		if(table_type==1)//only epg-ad do this
		{
			//check if it's empty record after 7 seconds
			sprintf(sql,"select *  from %s where dtbflag!=-1  and service_id=%s and (imgurl=NULL or imgurl is NULL or imgurl='')\
and(( NOW() + interval 7 second  between start_time and end_time )  or (NOW() >= start_time and NOW() < end_time ) )",pic_table,data_service[i][0]);
			num=mysql_get_data(&mysql, sql,data);
			if(num)
			{
				printf("next record is forbidden period, sending null section!\n");
				null_pic_section_flag=1;
				strcat(logbuf,"pic[fbd]");
				goto l;
			}
		}
		
		
		
		sprintf(sql,"select imgurl,antifake,xposition,yposition,width,height,showtime,style from %s where dtbflag!=-1  and service_id=%s and NOW() >= start_time and NOW() <  end_time",pic_table,data_service[i][0]);
		num=mysql_get_data(&mysql, sql,data_img);
		if(num)
		{
		
			//get pic_name 
			strcpy(pic_info.name,"/opt/tomcat/webapps/xepg");
			strcat(pic_info.name,data_img[0][0]);
			//printf("pic:%s\n",pic_info[j].name);

			//get antifake,x,y,width,height,period.stype
			strcpy(pic_info.antifake,data_img[0][1]);
			pic_info.x=atoi(data_img[0][2]);
			pic_info.y=atoi(data_img[0][3]);
			pic_info.width=atoi(data_img[0][4]);
			pic_info.height=atoi(data_img[0][5]);
			pic_info.period=atoi(data_img[0][6]);
			pic_info.style=atoi(data_img[0][7]);
			

		

			//get file_sub_id
			sprintf(sql,"select %s from xepg_pdt_extension where serviceid='%s'",field_name,data_service[i][0]);
			mysql_get_data(&mysql, sql,data);
			pic_info.file_sub_id=atoi(data[0][0]);
			
			//get file stream
			if(get_file_stream(&pic_info,table_type)==-1)
			{
				null_pic_section_flag=1;
				printf("get_file_stream failed !\n");
				strcat(logbuf,"pic[failed]");
				goto l;
			}


			sprintf(temp,"pic[%s]streamlen[%d]size[%d]anti[%s]x[%d]y[%d]width[%d]height[%d]period[%d]style[%d]",pic_info.name,pic_info.stream_len,pic_info.size,pic_info.antifake,pic_info.x,pic_info.y,pic_info.width,pic_info.height,pic_info.period,pic_info.style);
			strcat(logbuf,temp);
		
		}
		else
		{
			null_pic_section_flag=1;
			strcat(logbuf,"pic[empty]");
			goto l;
		}




	l:	
		if(null_pic_section_flag)//there are no rec in poster or ad table
		{
			pic_info.file_sub_id=htons(0);
			pic_info.size=0;
			pic_info.stream_len=0;
			printf("sending empty pic section!\n");
		}
		
		//creating sections of this sub table
		section_number=0;
		while(1)
		{
			p_sbi[table_section_number].pic_id=i;
			p_sbi[table_section_number].sec_id=section_number;
			ret=CreateFTS(table_id, &pic_info,section_number,&p_sbi[table_section_number],version_number);
			section_number++;
			table_section_number++;
			
			if(!ret)
				break;
		}

		/* update last section number of every section of this sub table */
		
		for(j=0;j<section_number;j++)
		{
			*(unsigned char *)(p_sbi[table_section_number-section_number+j].buffer+7)=section_number-1;
			get_CRC(p_sbi[table_section_number-section_number+j].buffer,p_sbi[table_section_number-section_number+j].len-4);
		}
		sprintf(temp,"sec[%d]",section_number);
		strcat(logbuf,temp);
		if(section_number > max_one_pic_section_number)
			max_one_pic_section_number=section_number;
		/*
		//update dtbflag
		sprintf(sql,"update %s set dtbflag=1 where id='%s'",pic_table,data[0][1]);
		mysql_query(&mysql,sql);
		*/
		
	
		////////////
		//strcat(logbuf,"\n");
		proclog(logfd,mdname,logbuf);
	}