⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rdcp.c

📁 dvr
💻 C
📖 第 1 页 / 共 4 页
字号:
					}
					
					for(j=0;j<6;j++)
						end_time[j] = evt_node.evt_timed[j];

					if(HDD_EventLog_Get(i, &event_offset, EVTREQ_PAST, &evt_node))
					{
#ifdef DEBUG_PLAYSEARCH
						printf("\r\n[Event Get] Incomplete Pair");
#endif
						if(Val_EPROM_WRAPPING_FLAG[i])
						{
							HDD_EventLog_FixLast(i);
							event_offset = event_off_save;

							if(first_round_flag <63){
#ifdef DEBUG_PLAYSEARCH
								printf(" --> Scan more");
#endif
								goto DOIT_AGAIN;
							}
						}
						else
						{
#ifdef DEBUG_PLAYSEARCH
							printf("\n\r --> Don't need to Fix Last Event");
#endif
						}
						break;
					}
					first_round_flag++;
#ifdef DEBUG_PLAYSEARCH
					printf("\r\n[Event Get] Event %s %d [buffIndex: %u]",i?"Slave":"Master",
						(int)first_round_flag,(u16)buffIndex);
#endif
					mark_event(i, evt_node.evt_type=='S'? LIST_TYPE_TIME:LIST_TYPE_SENSOR, 
						evt_node.evt_lba, evt_node.evt_timed, end_time, &buffIndex);
				}

				if(buffIndex >= 238)
				{
#ifdef DEBUG_PLAYSEARCH
					printf("\r\n[Event Get] Shoot - buffIndex: %u, gv_txbuf[1]: %u",(u16)buffIndex,(u16)gv_txbuf[1]);
#endif
					gv_txlen = buffIndex;
					gv_txbuf[1] = gv_txlen - HDSZ;
					lan_send_control_packet();
					buffIndex = HDSZ;
				}

			}
			
			if(buffIndex>HDSZ)
			{
#ifdef DEBUG_PLAYSEARCH
				printf("\r\n[Event Get] Shoot - buffIndex: %u, gv_txbuf[1]: %u",(u16)buffIndex,(u16)gv_txbuf[1]);
#endif
				gv_txlen = buffIndex;
				gv_txbuf[1] = gv_txlen - HDSZ;
				lan_send_control_packet();
				buffIndex = HDSZ;
			}
		}
	}

	//printf("\r\nplay search completed!!!\r\n");
	EXIT_PLAY_SEARCH:
	gv_txlen = HDSZ;
#ifdef DEBUG_PLAYSEARCH
	printf("\n\rPlaySearch_Request -- end");
#endif
	return 0;
}
//###############################################################################
// Rx payload : start time (6 bytes)
//###############################################################################
static u8 Proc_CmdPlayStart_Request(void)
{
	u8 i;

	//===========================================================
	//if the payload length is 5 [1 hdd, 4 lba]
	//	1. copy hdd id to gv_HDD_play_hdd_index
	//	1. copy the lba to gv_RCurrent_LBA[gv_HDD_play_hdd_index]
	//	2. gv_skip_search_block to 1
	//if the payload length is 7 [1 hdd id, 6 time]
	//	1. same
	//===========================================================

	if(gv_rxbuf[FIELD_LEN]==0) // Resume playback
	{
		play_job(X_PLAY);
	}
	else if(gv_rxbuf[FIELD_LEN] == 5) // play with input starting point
	{	// lba start
		gv_HDD_play_hdd_index = gv_rxbuf[HDSZ];
		if((Val_EPROM_WRAPPING_FLAG[gv_HDD_play_hdd_index]==0) && (gv_WCurrent_LBA[gv_HDD_play_hdd_index]==0))
		{ // no data to play
			gv_reason_code = RDCP_ERR_HDD_EMPTY;
			return 1;
		}
		gv_RCurrent_LBA[gv_HDD_play_hdd_index] = 0;

		for(i=0;i<4;i++)
		{
			gv_RCurrent_LBA[gv_HDD_play_hdd_index] |= ((u32)gv_rxbuf[4+i])<<(8*(3-i));
		}
		gv_skip_search_block = 1;

#ifdef DEBUG_STEVE
		printf("\r\n start LBA   : %lu [0x%08lx]",
			(u32)gv_RCurrent_LBA[gv_HDD_play_hdd_index],
			(u32)gv_RCurrent_LBA[gv_HDD_play_hdd_index]);
#endif
		gv_lba_start = gv_RCurrent_LBA[gv_HDD_play_hdd_index];
		gv_rdcp_rec_stop_request = 3;
	}
	else if(gv_rxbuf[FIELD_LEN] == 7) // play with input target time
	{// time start
		gv_HDD_play_hdd_index = gv_rxbuf[HDSZ];
		if((Val_EPROM_WRAPPING_FLAG[gv_HDD_play_hdd_index]==0) && (gv_WCurrent_LBA[gv_HDD_play_hdd_index]==0))
		{ // no data to play
			gv_reason_code = RDCP_ERR_HDD_EMPTY;
			return 1;
		}
		for(i=0;i<6;i++) gv_rdcp_stime[i] = gv_rxbuf[4+i];	// copy start time to play
		gv_rdcp_rec_stop_request = 4;
	}
	else
	{// unknown error
		gv_reason_code = RDCP_ERR_INVALID_PARAM;
		return 2;
	}

	return 0;
}
//###############################################################################
//
//###############################################################################
static u8 Proc_CmdPlayStop_Request(void)
{
	gv_rdcp_play_job_req = 1;
	gv_rdcp_play_job = X_STOP;
	return 0;
}
//###############################################################################
//
//###############################################################################
static u8 Proc_CmdPlayPause_Request(void)
{
	gv_rdcp_play_job_req = 1;
	gv_rdcp_play_job = X_PAUSE;
	return 0;
}
//###############################################################################
//
//###############################################################################
static u8 Proc_CmdPlayFastForward_Request(void)
{
	gv_rdcp_play_job_req = 1;
	gv_rdcp_play_job = X_FFAST;
	return 0;
}
//###############################################################################
//
//###############################################################################
static u8 Proc_CmdPlayRewind_Request(void)
{
	gv_rdcp_play_job_req = 1;
	gv_rdcp_play_job = X_RFAST;
	return 0;
}
//###############################################################################
//
//###############################################################################
static u8 Proc_CmdRez0(void)
{
	return 0;
}
//###############################################################################
// Tx payload : vy_dvr_info_runtime (8 bytes)
//###############################################################################
static u8 Proc_CmdGetState_Request(void)
{
	_fill_state(gv_txbuf, &gv_txlen);
	
	return 0;
}

//###############################################################################
// Set the current DVR view channel
//###############################################################################
u8 key_map[4] = { X_CH4, X_CH3, X_CH2, X_CH1 };
static u8 Proc_CmdSetChannel_Request(void)
{
	u8 ch;
	u8 i;
	
	ch = gv_rxbuf[HDSZ];
	if(ch==0x10) // quad button
	{
		gv_soft_key = X_CHALL;
	}
	else
	{
		for(i=0;i<4;i++)
		{
			if(ch&0x01)
				break;
			ch = ch >> 1;
		}
		if(i>=4)
		{
			gv_reason_code = RDCP_ERR_INVALID_PARAM;
			return 1;
		}
		gv_soft_key = key_map[i];
	}
	gv_soft_key_flag = 1;
	
	return 0;
}

//###############################################################################
// G1PP Config Information
//###############################################################################
static u8 Proc_CmdGetNetConfigRequest(void)
{
	
	gv_txbuf[HDSZ+0] = (vBFREG_SETUP&BFS_CIF) >>5;	// video resolution
	gv_txbuf[HDSZ+1] = (vBFREG_SETUP&BFS_AEN) >>3;	// audio recording enable bits
	gv_txbuf[HDSZ+2] = (vBFREG_SETUP&BFS_RCEN)>>2;	// rate control bits
	gv_txbuf[HDSZ+3] = vBFREG_RC_DFR;
	gv_txbuf[HDSZ+4] = vBFREG_ENC_DCTH;	// DC Net Threshold
	gv_txbuf[HDSZ+5] = vBFREG_ENC_ACTH;	// AC Net Threshold
	gv_txbuf[HDSZ+6] = vBFREG_RC_DQL;	// Frame Combination(4bits) + Default Q Level (4 bits) 
	gv_txbuf[HDSZ+7] = vBFREG_RC_PQL0;	// Quantize Up(4bits) + Quantize Down (4bits) 
	gv_txbuf[HDSZ+8] = vBFREG_RC_PQL1;	// Compress Quantize Up (4bits) + Compress Quantize Down (4bits)
	
	gv_txlen += 9;
	return 0;
}
//###############################################################################
//
//###############################################################################
static u8 Proc_CmdSetVideoResolution_Request(void)
{
	u8 cif;
	
	cif = gv_rxbuf[HDSZ];
	if(cif)	vBFREG_SETUP |= BFS_CIF;
	else	vBFREG_SETUP &= ~BFS_CIF;
	bfpga_update_setup(vBFREG_SETUP);
	return 0;
}

//###############################################################################
//
//###############################################################################
static u8 Proc_CmdSetAudioTransfer_Request(void)
{
	u8 ae;
	
	ae = gv_rxbuf[HDSZ];
	if(ae)	vBFREG_SETUP |= BFS_AEN;
	else	vBFREG_SETUP &= ~BFS_AEN;
	bfpga_update_setup(vBFREG_SETUP);
	return 0;
}
//###############################################################################
//
//###############################################################################
static u8 Proc_CmdEnableRateControl_Request(void)
{
	u8 rc; // rate control bit
	
	rc = gv_rxbuf[HDSZ];
	if(rc)	vBFREG_SETUP |= BFS_RCEN;
	else	vBFREG_SETUP &= ~BFS_RCEN;
	bfpga_update_setup(vBFREG_SETUP);
	return 0;
}
//###############################################################################
//
//###############################################################################
static u8 Proc_CmdSetThreshold_Request(void)
{
	vBFREG_ENC_DCTH = gv_rxbuf[HDSZ];
	vBFREG_ENC_ACTH = gv_rxbuf[HDSZ+1];
	
	bfpga_update_regs(BFREGOFF_ENC_DCTH, vBFREG_ENC_DCTH);
	bfpga_update_regs(BFREGOFF_ENC_ACTH, vBFREG_ENC_ACTH);
	return 0;
}
//###############################################################################
//
//###############################################################################
static u8 Proc_CmdSetDefaultFrameRate_Request(void)
{
	vBFREG_RC_DFR = gv_rxbuf[HDSZ];
	bfpga_update_regs(BFREGOFF_RC_DFR, vBFREG_RC_DFR);
	return 0;
}
//###############################################################################
//
//###############################################################################
static u8 Proc_CmdSetFrameRateConfig_Request(void)
{
	vBFREG_RC_DQL = gv_rxbuf[HDSZ];
	bfpga_update_regs(BFREGOFF_RC_DQL, vBFREG_RC_DQL);
	return 0;
}
//###############################################################################
//
//###############################################################################
static u8 Proc_CmdSetQ_Level_Request(void)
{
	vBFREG_RC_PQL0 = gv_rxbuf[HDSZ];
	vBFREG_RC_PQL1 = gv_rxbuf[HDSZ+1];
	
	bfpga_update_regs(BFREGOFF_RC_PQL0, vBFREG_RC_PQL0);
	bfpga_update_regs(BFREGOFF_RC_PQL1, vBFREG_RC_PQL1);
	return 0;
}
//###############################################################################
//
//###############################################################################
static u8 Proc_CmdPoll_Request(void)
{
	gv_rdcp_poll_live=0;

	gv_txbuf[HDSZ] = gv_rxbuf[HDSZ];	// copy sequence number
	gv_txlen ++;
	
	return 0;
}

//###############################################################################
//
//###############################################################################
static u8 Proc_CmdGetMdInfo_Request(void)
{
#ifdef VY_MD
	BYTE i,j,k;
	
	for(i=0;i<4;i++)	// four channel
	{
		gv_txbuf[gv_txlen++] = mdgv_md_sensitivity_levels[i];
		for(j=0;j<2;j++)// two blocks
		{
			for(k=0;k<4;k++)
			{
				gv_txbuf[gv_txlen++] = mdgv_md_areas[i][j][k];
			}
		}
	}
#endif
	return 0;
}
//###############################################################################
//
//###############################################################################
static u8 Proc_CmdSetMdInfo_Request(void)
{
#ifdef VY_MD
	BYTE i,j,k,p=HDSZ;

	for(k=0;k<4;k++)
	{
		mdgv_md_sensitivity_levels[k] = gv_rxbuf[p++];
		for(i=0;i<2;i++)
		{
			for(j=0;j<4;j++)
			{
				mdgv_md_areas[k][i][j]=gv_rxbuf[p++];
			}
		}
		md_eprom_write(k);
		md_reg_set_area(k);
	}
#endif
	return 0;
}


/* EOF */

#endif //NOT_JUNK

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -