// CaptureDlg.cpp : 实现文件
//

#include "stdafx.h"
#include "By5000Asiplay Demo.h"
#include "CaptureDlg.h"
#include ".\capturedlg.h"
#include "By5000asiplay.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CCaptureDlg 对话框

IMPLEMENT_DYNAMIC(CCaptureDlg, CDialog)
CCaptureDlg::CCaptureDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CCaptureDlg::IDD, pParent)
	, m_uiCardNumber(0)
{
	m_bCh1IsOpened = FALSE;
}

CCaptureDlg::~CCaptureDlg()
{
//	KillTimer(m_nIDTimer);
}

void CCaptureDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST_TSTOPS, m_ListCtrlTsServiceTable);
	DDX_Control(pDX, IDC_EDITR_RECORDER_FILE, m_RecorderFileDir);
	DDX_Control(pDX, IDC_SCROLLBAR_CONTRAST, m_scrollbar_contrast);
	DDX_Control(pDX, IDC_SCROLLBAR_LIGHT, m_scrollbar_light);
	DDX_Control(pDX, IDC_SCROLLBAR_HUE, m_scrollbar_hue);
	DDX_Control(pDX, IDC_SCROLLBAR_SATUATION, m_scrollbar_satuation);
}


BEGIN_MESSAGE_MAP(CCaptureDlg, CDialog)
	ON_BN_CLICKED(IDOK, OnBnClickedOk)
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_BUTTON_WINPOS_SET_CAPTURE, OnBnClickedButtonWinposSetCapture)
	ON_CBN_SELCHANGE(IDC_COMBO_RECORDER_PIX_FMT, OnCbnSelchangeComboRecorderPixFmt)
	ON_CBN_SELCHANGE(IDC_COMBO_RECORDER_SOURCE, OnCbnSelchangeComboRecorderSource)
	ON_BN_CLICKED(IDC_BUTTON_RECORDER_CONFIG, OnBnClickedButtonRecorderConfig)
	ON_BN_CLICKED(IDC_BUTTON_RECORDER_BROWS, OnBnClickedButtonRecorderBrows)
	ON_BN_CLICKED(IDC_BUTTON_RECORDER_START, OnBnClickedButtonRecorderStart)
	ON_BN_CLICKED(IDC_BUTTON_RECORDER_STOP, OnBnClickedButtonRecorderStop)
	ON_BN_CLICKED(IDC_CHECK_RECORDER_CG, OnBnClickedCheckRecorderCg)
	ON_WM_HSCROLL()
	ON_BN_CLICKED(IDC_BUTTON_PSPATH_SAVEFILE_ONE, OnBnClickedButtonPspathSavefileOne)
	ON_BN_CLICKED(IDC_BUTTON_PSPATH_SAVEFILE_TWO, OnBnClickedButtonPspathSavefileTwo)
	ON_BN_CLICKED(IDC_BUTTON_PSPATH_SAVEFILE_THREE, OnBnClickedButtonPspathSavefileThree)
	ON_BN_CLICKED(IDC_BUTTON_PSPATH_SAVEFILE_FOUR, OnBnClickedButtonPspathSavefileFour)
	ON_BN_CLICKED(IDC_BUTTON_PSPATH_SAVEFILE_FIVE, OnBnClickedButtonPspathSavefileFive)
	ON_BN_CLICKED(IDC_BUTTON_PSPATH_SAVEFILE_SIX, OnBnClickedButtonPspathSavefileSix)
	ON_BN_CLICKED(IDC_BUTTON_BIGEN, OnBnClickedButtonBigen)
	ON_BN_CLICKED(IDC_BUTTON_BIGEN2, OnBnClickedButtonBigen2)
	ON_BN_CLICKED(IDC_BUTTON_BIGEN3, OnBnClickedButtonBigen3)
	ON_BN_CLICKED(IDC_BUTTON_BIGEN4, OnBnClickedButtonBigen4)
	ON_BN_CLICKED(IDC_BUTTON_BIGEN5, OnBnClickedButtonBigen5)
	ON_BN_CLICKED(IDC_BUTTON_BIGEN6, OnBnClickedButtonBigen6)
	ON_CBN_SELCHANGE(IDC_COMBO_RECORDER_FORMAT, OnCbnSelchangeComboRecorderFormat)
END_MESSAGE_MAP()


// CCaptureDlg 消息处理程序

void CCaptureDlg::OnBnClickedOk()
{
	// TODO: 在此添加控件通知处理程序代码
//	OnOK();
}

void CCaptureDlg::OnBnClickedButtonWinposSetCapture()
{
	// TODO: 在此添加控件通知处理程序代码
	CString strText;
	UINT uiXStart,uiYStart,uiWidth,uiHeight;
	uiXStart=uiYStart=uiWidth=uiHeight = 0;
	Seekfit_By5000asiplay_CapturedStreamEnablePlaybackDve(m_uiCardNumber);
	((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_SRCX))->GetWindowText(strText);
#ifdef _UNICODE
	swscanf_s(strText,_T("%d"),&uiXStart);

#else
	sscanf_s(strText,_T("%d"),&uiXStart);
#endif
	((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_SRCY))->GetWindowText(strText);
#ifdef _UNICODE
	swscanf_s(strText,_T("%d"),&uiYStart);

#else
	sscanf_s(strText,_T("%d"),&uiYStart);
#endif
	((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_SRC_WIDTH))->GetWindowText(strText);
#ifdef _UNICODE
	swscanf_s(strText,_T("%d"),&uiWidth);

#else
	sscanf_s(strText,_T("%d"),&uiWidth);
#endif
	((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_SRC_HEIGHT))->GetWindowText(strText);
#ifdef _UNICODE
	swscanf_s(strText,_T("%d"),&uiHeight);

#else
	sscanf_s(strText,_T("%d"),&uiHeight);
#endif
	Seekfit_By5000asiplay_CapturedStreamSetDveSourceWindow(uiXStart,uiYStart,uiWidth,uiHeight,m_uiCardNumber);

	((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_DSTX))->GetWindowText(strText);
#ifdef _UNICODE
	swscanf_s(strText,_T("%d"),&uiXStart);

#else
	sscanf_s(strText,_T("%d"),&uiXStart);
#endif
	((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_DSTY))->GetWindowText(strText);
#ifdef _UNICODE
	swscanf_s(strText,_T("%d"),&uiYStart);

#else
	sscanf_s(strText,_T("%d"),&uiYStart);
#endif
	((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_DST_WIDTH))->GetWindowText(strText);
#ifdef _UNICODE
	swscanf_s(strText,_T("%d"),&uiWidth);

#else
	sscanf_s(strText,_T("%d"),&uiWidth);
#endif
	((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_DST_HEIGHT))->GetWindowText(strText);
#ifdef _UNICODE
	swscanf_s(strText,_T("%d"),&uiHeight);

#else
	sscanf_s(strText,_T("%d"),&uiHeight);
#endif
	Seekfit_By5000asiplay_CapturedStreamSetDveDestWindow(uiXStart,uiYStart,uiWidth,uiHeight,m_uiCardNumber);
}


void CCaptureDlg::OnCbnSelchangeComboRecorderPixFmt()
{
	// TODO: 在此添加控件通知处理程序代码
}

void CCaptureDlg::OnCbnSelchangeComboRecorderSource()
{
	// TODO: 在此添加控件通知处理程序代码
}

void CCaptureDlg::OnBnClickedButtonRecorderConfig()
{
	// TODO: 在此添加控件通知处理程序代码
	RECORDER_ENCODER_PARAM EncoderParam;
	INT nBitRate = 0;
	INT nQuailty = 0;
	CString str;
	((CEdit *)GetDlgItem(IDC_EDIT_RECORDER_BIT_RATE))->GetWindowText(str);
#ifdef _UNICODE
	swscanf_s(str,_T("%d"),&nBitRate);

#else
	sscanf_s(str,_T("%d"),&nBitRate);
#endif
	EncoderParam.uiBitRate = nBitRate;

	((CEdit *)GetDlgItem(IDC_EDIT_RECORDER_VIDEO_QUAILTY))->GetWindowText(str);
#ifdef _UNICODE
	swscanf_s(str,_T("%d"),&nQuailty);

#else
	sscanf_s(str,_T("%d"),&nQuailty);
#endif
	EncoderParam.uiVbrQuality = nQuailty;
	INT nEffectIndex = ((CComboBox*)GetDlgItem(IDC_COMBO_RECORDER_PIX_FMT))->GetCurSel();
	switch (nEffectIndex)
	{
	case 0:
		EncoderParam.uiPixelFormat = FMT_YUV420;
		break;
	case 1:
		EncoderParam.uiPixelFormat = FMT_YUV422;
		break;
	}

	INT nIndexFAT = ((CComboBox*)GetDlgItem(IDC_COMBO_RECORDER_FORMAT))->GetCurSel();
	switch (nIndexFAT)
	{
	case 0:
		EncoderParam.uiFileType = RECORDER_FILE_TYPE_MPEG;
		break;
	case 1:
		EncoderParam.uiFileType = RECORDER_FILE_TYPE_WMV;
		break;
	}
	
	INT nIndex = ((CComboBox*)GetDlgItem(IDC_COMBO_RECORDER_SOURCE))->GetCurSel();
	if(nIndex == 0)
	{
		m_uiRecorderSource = RECORDER_CAPTURE_STREAM;
	}
	else if(nIndex == 1)
	{
		m_uiRecorderSource = RECORDER_PLAYBACK_STREAM;
	}
	else
	{
		m_uiRecorderSource = RECORDER_CAPTURE_TS_STREAM;
	}
	RECORDER_PROGRAM_INFO rplProgramInfo;
	rplProgramInfo.nProgramId = 0;
	m_RecorderFileDir.GetWindowText(str);
	if (str.IsEmpty())
	{
		rplProgramInfo.szRecorderFileName = NULL;
	}
	//EncoderParam.uiFileType = RECORDER_FILE_TYPE_WMV/*RECORDER_FILE_TYPE_MPEG*/;
	EncoderParam.uiVideoAspect = VIDEO_ASPECT_RATIO_4_3;
	EncoderParam.uiVideoHeight =288 ;
	EncoderParam.uiVideoWidth =360 ;
	BOOL res = Seekfit_By5000asiplay_RecorderConfig(m_uiRecorderSource,rplProgramInfo,(LPVOID)(&EncoderParam),m_uiCardNumber);
}

void CCaptureDlg::OnBnClickedButtonRecorderBrows()
{
	// TODO: 在此添加控件通知处理程序代码
	TCHAR szFilter[] = _T("Media Files (*.mpg ;*.wmv)|*.mpg; *wmv|All Files(*.*)|*.*||");
	CFileDialog DlgFile(FALSE, NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter);
	DlgFile.m_ofn.lpstrTitle = _T("视频采集文件");
	BOOL bResult;
	if(m_bCh1IsOpened)
		return;
	CString strRecorderFileName;
	if( DlgFile.DoModal() == IDOK)
	{
		strRecorderFileName = DlgFile.GetPathName();
		m_RecorderFileDir.SetWindowText(LPCTSTR(strRecorderFileName));
	}
	INT nIndex = ((CComboBox*)GetDlgItem(IDC_COMBO_RECORDER_SOURCE))->GetCurSel();
	if(nIndex == 0)
	{
		m_uiRecorderSource = RECORDER_CAPTURE_STREAM;
	}
	else if(nIndex == 1)
	{
		m_uiRecorderSource = RECORDER_PLAYBACK_STREAM;
	}
	else if(nIndex == 2)
	{
		m_uiRecorderSource = RECORDER_CAPTURE_TS_STREAM;
	}

	//
	if(m_uiRecorderSource == RECORDER_CAPTURE_TS_STREAM)
	{
		//临时测试，要通过列表框选中来决定。
		m_rplProgramInfo.nProgramId = 1041;//
		m_rplProgramInfo.szRecorderFileName = (LPCTSTR)strRecorderFileName;
	}
	else
	{
		m_rplProgramInfo.nProgramId = 0;//
		m_rplProgramInfo.szRecorderFileName = (LPCTSTR)strRecorderFileName;
	}
	BOOL bRes = Seekfit_By5000asiplay_RecorderOpen(m_uiRecorderSource, m_rplProgramInfo, m_uiCardNumber);
	if(!bRes)
	{		
		AfxMessageBox(_T("打开视频采集失败！"));
		return;
	}
	m_bCh1IsOpened = TRUE;

}

void CCaptureDlg::OnBnClickedButtonRecorderStart()
{
	// TODO: 在此添加控件通知处理程序代码
	if(!m_bCh1IsOpened)
		return;
	INT nIndex = ((CComboBox*)GetDlgItem(IDC_COMBO_RECORDER_SOURCE))->GetCurSel();
	if(nIndex == 0)
	{
		m_uiRecorderSource = RECORDER_CAPTURE_STREAM;
	}
	else if(nIndex == 1)
	{
		m_uiRecorderSource = RECORDER_PLAYBACK_STREAM;
	}
	else
	{
		m_uiRecorderSource = RECORDER_CAPTURE_TS_STREAM;
	}

	BOOL bRes = Seekfit_By5000asiplay_RecorderStart(m_uiRecorderSource, m_rplProgramInfo,m_uiCardNumber);
}

void CCaptureDlg::OnBnClickedButtonRecorderStop()
{
	// TODO: 在此添加控件通知处理程序代码
	if(!m_bCh1IsOpened)
		return;
	INT nIndex = ((CComboBox*)GetDlgItem(IDC_COMBO_RECORDER_SOURCE))->GetCurSel();
	if(nIndex == 0)
	{
		m_uiRecorderSource = RECORDER_CAPTURE_STREAM;
	}
	else if(nIndex == 1)
	{
		m_uiRecorderSource = RECORDER_PLAYBACK_STREAM;
	}
	else
	{
		m_uiRecorderSource = RECORDER_CAPTURE_TS_STREAM;
	}
	BOOL bRes = Seekfit_By5000asiplay_RecorderStop(m_uiRecorderSource,m_rplProgramInfo,m_uiCardNumber);
	m_bCh1IsOpened = FALSE;
}

void CCaptureDlg::OnBnClickedCheckRecorderCg()
{
	// TODO: 在此添加控件通知处理程序代码
	CButton * Check;

	Check = (CButton *)GetDlgItem(IDC_CHECK_RECORDER_CG);
	if (Check->GetCheck() == BST_UNCHECKED)
		Seekfit_By5000asiplay_RecorderCgEnable(0,0);
	else
		Seekfit_By5000asiplay_RecorderCgEnable(1,0);
}

void CCaptureDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	int nCustomPos;
	CString str;
	if( pScrollBar ->m_hWnd == m_scrollbar_contrast.m_hWnd )
	{
		nCustomPos = m_scrollbar_contrast.GetScrollPos();
		if( nSBCode == SB_LINELEFT )
			nCustomPos--;
		else
			if( nSBCode == SB_LINERIGHT )
				nCustomPos++;
			else
				if( nSBCode == SB_PAGELEFT )
					nCustomPos -= 10;
				else
					if( nSBCode == SB_PAGERIGHT )
						nCustomPos += 10;

		if( nCustomPos <= 0 )
			nCustomPos = 0;
		else
			if( nCustomPos >= CONTRAST_RANGE - 1 )
				nCustomPos = CONTRAST_RANGE - 1;

		Seekfit_By5000asiplay_SetVideoInputContrast( nCustomPos, m_uiCardNumber );

		m_scrollbar_contrast.SetScrollPos(nCustomPos);

		str.Format(_T("C:%d"),nCustomPos);

		GetDlgItem(IDC_STATIC_CONTRAST)->SetWindowText(str);

	}
	else if( pScrollBar ->m_hWnd == m_scrollbar_light.m_hWnd )
	{
		nCustomPos = m_scrollbar_light.GetScrollPos();
		if( nSBCode == SB_LINELEFT )
			nCustomPos--;
		else
			if( nSBCode == SB_LINERIGHT )
				nCustomPos++;
			else
				if( nSBCode == SB_PAGELEFT )
					nCustomPos -= 10;
				else
					if( nSBCode == SB_PAGERIGHT )
						nCustomPos += 10;

		if( nCustomPos <= 0 )
			nCustomPos = 0;
		else
			if( nCustomPos >= LIGHT_RANGE - 1 )
				nCustomPos = LIGHT_RANGE - 1;

		Seekfit_By5000asiplay_SetVideoInputBrightness( nCustomPos, m_uiCardNumber );

		m_scrollbar_light.SetScrollPos(nCustomPos);

		str.Format(_T("L:%d"),nCustomPos);

		GetDlgItem(IDC_STATIC_LIGHT)->SetWindowText(str);

	}
	else if( pScrollBar ->m_hWnd == m_scrollbar_hue.m_hWnd )
	{
		nCustomPos = m_scrollbar_hue.GetScrollPos();
		if( nSBCode == SB_LINELEFT )
			nCustomPos--;
		else
			if( nSBCode == SB_LINERIGHT )
				nCustomPos++;
			else
				if( nSBCode == SB_PAGELEFT )
					nCustomPos -= 10;
				else
					if( nSBCode == SB_PAGERIGHT )
						nCustomPos += 10;

		if( nCustomPos <= 0 )
			nCustomPos = 0;
		else
			if( nCustomPos >= HUE_RANGE - 1 )
				nCustomPos = HUE_RANGE - 1;

		Seekfit_By5000asiplay_SetVideoInputHue( nCustomPos, m_uiCardNumber );

		m_scrollbar_hue.SetScrollPos(nCustomPos);

		str.Format(_T("H:%d"),nCustomPos);

		GetDlgItem(IDC_STATIC_HUE)->SetWindowText(str);

	}
	else if( pScrollBar ->m_hWnd == m_scrollbar_satuation.m_hWnd )
	{
		nCustomPos = m_scrollbar_satuation.GetScrollPos();
		if( nSBCode == SB_LINELEFT )
			nCustomPos--;
		else
			if( nSBCode == SB_LINERIGHT )
				nCustomPos++;
			else
				if( nSBCode == SB_PAGELEFT )
					nCustomPos -= 10;
				else
					if( nSBCode == SB_PAGERIGHT )
						nCustomPos += 10;

		if( nCustomPos <= 0 )
			nCustomPos = 0;
		else
			if( nCustomPos >= SATUATION_RANGE - 1 )
				nCustomPos = SATUATION_RANGE - 1;

		if (m_uiCardType == SEEKFIT_CARD_TYPE_By5000ASIPROPLAY)
		{
			Seekfit_By5000asiplay_SetVideoInputSubSaturation( nCustomPos, BY5000ASIPLAY_VIDEO_SATURATION_CB_ID,m_uiCardNumber );
		}
		else
			Seekfit_By5000asiplay_SetVideoInputSaturation( nCustomPos, m_uiCardNumber );

		m_scrollbar_satuation.SetScrollPos(nCustomPos);

		str.Format(_T("S:%d"),nCustomPos);

		GetDlgItem(IDC_STATIC_SATUATION)->SetWindowText(str);

	}
	CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}

BOOL CCaptureDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here

	memset((void *)&m_rplProgramInfo,0,sizeof(m_rplProgramInfo));
	((CEdit *)GetDlgItem(IDC_EDIT_RECORDER_BIT_RATE))->SetWindowText(_T("4200"));
	((CComboBox *)GetDlgItem(IDC_COMBO_RECORDER_PIX_FMT))->AddString(_T("YUV420"));
	((CComboBox *)GetDlgItem(IDC_COMBO_RECORDER_PIX_FMT))->AddString(_T("YUV422"));
	((CComboBox *)GetDlgItem(IDC_COMBO_RECORDER_PIX_FMT))->SetCurSel(0);

	((CComboBox *)GetDlgItem(IDC_COMBO_RECORDER_SOURCE))->AddString(_T("模拟输入"));
	((CComboBox *)GetDlgItem(IDC_COMBO_RECORDER_SOURCE))->AddString(_T("输出"));
	((CComboBox *)GetDlgItem(IDC_COMBO_RECORDER_SOURCE))->AddString(_T("TS输入"));
	((CComboBox *)GetDlgItem(IDC_COMBO_RECORDER_SOURCE))->SetCurSel(0);

	((CComboBox *)GetDlgItem(IDC_COMBO_RECORDER_FORMAT))->AddString(_T("MPEG"));
	((CComboBox *)GetDlgItem(IDC_COMBO_RECORDER_FORMAT))->AddString(_T("WMV"));
	((CComboBox *)GetDlgItem(IDC_COMBO_RECORDER_FORMAT))->SetCurSel(0);
	((CEdit*)GetDlgItem(IDC_EDIT_RECORDER_VIDEO_QUAILTY))->EnableWindow(FALSE);
	((CStatic*)GetDlgItem(IDC_STATIC_QU))->EnableWindow(FALSE);
	((CEdit*)GetDlgItem(IDC_EDIT_RECORDER_VIDEO_QUAILTY))->SetWindowText(_T("80"));

	m_uiRecorderSource = RECORDER_PLAYBACK_STREAM;

	UINT uiTemp;
	Seekfit_By5000asiplay_GetVideoMode(uiTemp, m_uiCardNumber);
	m_uiVideoMode = uiTemp;

	((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_SRCX))->SetWindowText(_T("0"));
	((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_SRCY))->SetWindowText(_T("0"));
	((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_SRC_WIDTH))->SetWindowText(_T("720"));
	if (m_uiVideoMode == VIDEO_MODE_PAL)
		((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_SRC_HEIGHT))->SetWindowText(_T("576"));
	else 
		((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_SRC_HEIGHT))->SetWindowText(_T("480"));

	((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_DSTX))->SetWindowText(_T("0"));
	((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_DSTY))->SetWindowText(_T("0"));
	((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_DST_WIDTH))->SetWindowText(_T("720"));
	if (m_uiVideoMode == VIDEO_MODE_PAL)
		((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_DST_HEIGHT))->SetWindowText(_T("576"));
	else
		((CEdit *)GetDlgItem(IDC_EDIT_CAPTURE_DST_HEIGHT))->SetWindowText(_T("480"));

	CString strItem;
	UINT m_contrast,m_light,m_hue,m_satuation,m_subcarrier; 
	Seekfit_By5000asiplay_GetVideoInputContrast( m_contrast, m_uiCardNumber );
	m_scrollbar_contrast.SetScrollRange( 0, CONTRAST_RANGE - 1);
	m_scrollbar_contrast.SetScrollPos( m_contrast );
	strItem.Format(_T("C:%d"),m_contrast);
	GetDlgItem(IDC_STATIC_CONTRAST)->SetWindowText(strItem);

	Seekfit_By5000asiplay_GetVideoInputBrightness( m_light, m_uiCardNumber );
	m_scrollbar_light.SetScrollRange( 0, LIGHT_RANGE - 1);
	m_scrollbar_light.SetScrollPos( m_light );
	strItem.Format(_T("L:%d"),m_light);
	GetDlgItem(IDC_STATIC_LIGHT)->SetWindowText(strItem);

	Seekfit_By5000asiplay_GetVideoInputHue( m_hue, m_uiCardNumber );
	m_scrollbar_hue.SetScrollRange( 0, HUE_RANGE - 1);
	m_scrollbar_hue.SetScrollPos( m_hue );
	strItem.Format(_T("H:%d"),m_hue);
	GetDlgItem(IDC_STATIC_HUE)->SetWindowText(strItem);

	if (m_uiCardType == SEEKFIT_CARD_TYPE_By5000ASIPROPLAY)
	{
		Seekfit_By5000asiplay_GetVideoInputSubSaturation(m_satuation, BY5000ASIPLAY_VIDEO_SATURATION_CB_ID,m_uiCardNumber );
	}
	else
		Seekfit_By5000asiplay_GetVideoInputSaturation( m_satuation, m_uiCardNumber );
	m_scrollbar_satuation.SetScrollRange( 0, SATUATION_RANGE - 1);
	m_scrollbar_satuation.SetScrollPos( m_satuation );
	strItem.Format(_T("S:%d"),m_satuation);
	GetDlgItem(IDC_STATIC_SATUATION)->SetWindowText(strItem);


	m_ListCtrlTsServiceTable.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
	m_ListCtrlTsServiceTable.InsertColumn(0, _T("ID"),LVCFMT_LEFT,50);
	m_ListCtrlTsServiceTable.InsertColumn(1, _T("NAME"),LVCFMT_LEFT,100);
	((CButton *)GetDlgItem(IDC_CHECK_RECORDER_CG))->SetCheck(1);

	SetTimer(1, 20, NULL);

	

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

void CCaptureDlg::OnBnClickedButtonPspathSavefileOne()
{
	// TODO: 在此添加控件通知处理程序代码
	CString strText;

	TCHAR szFilter[] = _T("Media Files (*.mpg)| *.mpg|All Files(*.*)|*.*||");
	CFileDialog fdlg(FALSE,_T(".mpg"),NULL,OFN_ENABLESIZING,szFilter);

	fdlg.m_ofn.lpstrTitle = _T("选择文件存放路径");
	if (fdlg.DoModal() == IDOK)
	{
		m_strMPEGFilePath[0] = fdlg.GetPathName();
		SetDlgItemText(IDC_EDIT_TSTOPS_FILE,m_strMPEGFilePath[0]);
		//m_programnum++;
	}
	((CEdit *)GetDlgItem(IDC_EDIT_PRO_ONE))->GetWindowText(strText);

}

void CCaptureDlg::OnBnClickedButtonPspathSavefileTwo()
{
	// TODO: 在此添加控件通知处理程序代码
	CString strText;

	TCHAR szFilter[] = _T("Media Files (*.mpg)| *.mpg|All Files(*.*)|*.*||");
	CFileDialog fdlg(FALSE,_T(".mpg"),NULL,OFN_ENABLESIZING,szFilter);

	fdlg.m_ofn.lpstrTitle = _T("选择文件存放路径");
	if (fdlg.DoModal() == IDOK)
	{
		m_strMPEGFilePath[1] = fdlg.GetPathName();
		SetDlgItemText(IDC_EDIT_TSTOPS_FILE2,m_strMPEGFilePath[1]);
		//m_programnum++;
	}
	((CEdit *)GetDlgItem(IDC_EDIT_PRO_TWO))->GetWindowText(strText);
}

void CCaptureDlg::OnBnClickedButtonPspathSavefileThree()
{
	// TODO: 在此添加控件通知处理程序代码
	CString strText;

	TCHAR szFilter[] = _T("Media Files (*.mpg)| *.mpg|All Files(*.*)|*.*||");
	CFileDialog fdlg(FALSE,_T(".mpg"),NULL,OFN_ENABLESIZING,szFilter);

	fdlg.m_ofn.lpstrTitle = _T("选择文件存放路径");
	if (fdlg.DoModal() == IDOK)
	{
		m_strMPEGFilePath[2] = fdlg.GetPathName();
		SetDlgItemText(IDC_EDIT_TSTOPS_FILE3,m_strMPEGFilePath[2]);
		//m_programnum++;
	}
	((CEdit *)GetDlgItem(IDC_EDIT_PRO_THREE))->GetWindowText(strText);
}

void CCaptureDlg::OnBnClickedButtonPspathSavefileFour()
{
	// TODO: 在此添加控件通知处理程序代码
	CString strText;

	TCHAR szFilter[] = _T("Media Files (*.mpg)| *.mpg|All Files(*.*)|*.*||");
	CFileDialog fdlg(FALSE,_T(".mpg"),NULL,OFN_ENABLESIZING,szFilter);

	fdlg.m_ofn.lpstrTitle = _T("选择文件存放路径");
	if (fdlg.DoModal() == IDOK)
	{
		m_strMPEGFilePath[3] = fdlg.GetPathName();
		SetDlgItemText(IDC_EDIT_TSTOPS_FILE4,m_strMPEGFilePath[3]);
		//m_programnum++;
	}
	((CEdit *)GetDlgItem(IDC_EDIT_PRO_FOUR))->GetWindowText(strText);
}

void CCaptureDlg::OnBnClickedButtonPspathSavefileFive()
{
	// TODO: 在此添加控件通知处理程序代码
	CString strText;

	TCHAR szFilter[] = _T("Media Files (*.mpg)| *.mpg|All Files(*.*)|*.*||");
	CFileDialog fdlg(FALSE,_T(".mpg"),NULL,OFN_ENABLESIZING,szFilter);

	fdlg.m_ofn.lpstrTitle = _T("选择文件存放路径");
	if (fdlg.DoModal() == IDOK)
	{
		m_strMPEGFilePath[4] = fdlg.GetPathName();
		SetDlgItemText(IDC_EDIT_TSTOPS_FILE5,m_strMPEGFilePath[4]);
		//m_programnum++;
	}
	((CEdit *)GetDlgItem(IDC_EDIT_PRO_FIVE))->GetWindowText(strText);
}

void CCaptureDlg::OnBnClickedButtonPspathSavefileSix()
{
	// TODO: 在此添加控件通知处理程序代码
	CString strText;

	TCHAR szFilter[] = _T("Media Files (*.mpg)| *.mpg|All Files(*.*)|*.*||");
	CFileDialog fdlg(FALSE,_T(".mpg"),NULL,OFN_ENABLESIZING,szFilter);

	fdlg.m_ofn.lpstrTitle = _T("选择文件存放路径");
	if (fdlg.DoModal() == IDOK)
	{
		m_strMPEGFilePath[5] = fdlg.GetPathName();
		SetDlgItemText(IDC_EDIT_TSTOPS_FILE6,m_strMPEGFilePath[5]);
		//m_programnum++;
	}
	((CEdit *)GetDlgItem(IDC_EDIT_PRO_SIX))->GetWindowText(strText);
}

void CCaptureDlg::OnBnClickedButtonBigen()
{
	// TODO: 在此添加控件通知处理程序代码

	CString strText ;
	RECORDER_PROGRAM_INFO rplTsToMpgPrograminfo;
	((CButton *)GetDlgItem(IDC_BUTTON_BIGEN))->GetWindowText(strText);

	if (strText == "Start")
	{
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_ONE))->GetWindowText(strText);
		if (!strText.IsEmpty())
		{
			if (m_strMPEGFilePath[0].IsEmpty())
			{
				AfxMessageBox(_T(" program one mpeg file path is NULL!!!"));
				return;
			}
			else
			{
#ifdef UNICODE
				rplTsToMpgPrograminfo.nProgramId = _wtoi(strText);
#else
				rplTsToMpgPrograminfo.nProgramId = atoi(strText);

#endif // _DEBUG	
				rplTsToMpgPrograminfo.szRecorderFileName = m_strMPEGFilePath[0];
				m_programnum++;
			}

		}
		else
		{
			AfxMessageBox(_T("program PID is NULL!!!"));
			return ;
		}
		if(Seekfit_By5000asiplay_RecorderStart(RECORDER_CAPTURE_TS_STREAM,rplTsToMpgPrograminfo,m_uiCardNumber))		
			((CButton *)GetDlgItem(IDC_BUTTON_BIGEN))->SetWindowText(_T("Stop"));
	}
	else
	{
		//m_programnum--;
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_ONE))->GetWindowText(strText);
#ifdef UNICODE
		rplTsToMpgPrograminfo.nProgramId = _wtoi(strText);
#else
		rplTsToMpgPrograminfo.nProgramId = atoi(strText);

#endif // _DEBUG	
		
		//rplTsToMpgPrograminfo.nProgramId = atoi(strText);
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_ONE))->SetWindowText(_T(""));
		m_strMPEGFilePath[0].Empty();
		SetDlgItemText(IDC_EDIT_TSTOPS_FILE,m_strMPEGFilePath[0]);
		if(Seekfit_By5000asiplay_RecorderStop(RECORDER_CAPTURE_TS_STREAM,rplTsToMpgPrograminfo, m_uiCardNumber))
			((CButton *)GetDlgItem(IDC_BUTTON_BIGEN))->SetWindowText(_T("Start"));
	}


}

void CCaptureDlg::OnBnClickedButtonBigen2()
{
	// TODO: 在此添加控件通知处理程序代码
	CString strText ;
	RECORDER_PROGRAM_INFO rplTsToMpgPrograminfo;
	((CButton *)GetDlgItem(IDC_BUTTON_BIGEN2))->GetWindowText(strText);

	if (strText == "Start")
	{
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_TWO))->GetWindowText(strText);
		if (!strText.IsEmpty())
		{
			if (m_strMPEGFilePath[1].IsEmpty())
			{
				AfxMessageBox(_T(" program one mpeg file path is NULL!!!"));
				return;
			}
			else
			{
#ifdef UNICODE
				rplTsToMpgPrograminfo.nProgramId = _wtoi(strText);
#else
				rplTsToMpgPrograminfo.nProgramId = atoi(strText);

#endif // _DEBUG	
				//rplTsToMpgPrograminfo.nProgramId = atoi(strText);
				rplTsToMpgPrograminfo.szRecorderFileName = m_strMPEGFilePath[1];
				m_programnum++;
			}

		}
		else
		{
			AfxMessageBox(_T("program PID is NULL!!!"));
			return ;
		}
		if(Seekfit_By5000asiplay_RecorderStart(RECORDER_CAPTURE_TS_STREAM,rplTsToMpgPrograminfo,m_uiCardNumber))		
			((CButton *)GetDlgItem(IDC_BUTTON_BIGEN2))->SetWindowText(_T("Stop"));
	}
	else
	{
		//m_programnum--;
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_TWO))->GetWindowText(strText);
#ifdef UNICODE
		rplTsToMpgPrograminfo.nProgramId = _wtoi(strText);
#else
		rplTsToMpgPrograminfo.nProgramId = atoi(strText);

#endif // _DEBUG	
		//rplTsToMpgPrograminfo.nProgramId = atoi(strText);
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_TWO))->SetWindowText(_T(""));
		m_strMPEGFilePath[1].Empty();
		SetDlgItemText(IDC_EDIT_TSTOPS_FILE2,m_strMPEGFilePath[1]);
		if(Seekfit_By5000asiplay_RecorderStop(RECORDER_CAPTURE_TS_STREAM,rplTsToMpgPrograminfo, m_uiCardNumber))
			((CButton *)GetDlgItem(IDC_BUTTON_BIGEN2))->SetWindowText(_T("Start"));
	}

}

void CCaptureDlg::OnBnClickedButtonBigen3()
{
	// TODO: 在此添加控件通知处理程序代码
	CString strText ;
	RECORDER_PROGRAM_INFO rplTsToMpgPrograminfo;
	((CButton *)GetDlgItem(IDC_BUTTON_BIGEN3))->GetWindowText(strText);

	if (strText == "Start")
	{
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_THREE))->GetWindowText(strText);
		if (!strText.IsEmpty())
		{
			if (m_strMPEGFilePath[2].IsEmpty())
			{
				AfxMessageBox(_T(" program one mpeg file path is NULL!!!"));
				return;
			}
			else
			{
#ifdef UNICODE
				rplTsToMpgPrograminfo.nProgramId = _wtoi(strText);
#else
				rplTsToMpgPrograminfo.nProgramId = atoi(strText);

#endif // _DEBUG	
				//rplTsToMpgPrograminfo.nProgramId = atoi(strText);
				rplTsToMpgPrograminfo.szRecorderFileName = m_strMPEGFilePath[2];
				m_programnum++;
			}

		}
		else
		{
			AfxMessageBox(_T("program PID is NULL!!!"));
			return ;
		}
		if(Seekfit_By5000asiplay_RecorderStart(RECORDER_CAPTURE_TS_STREAM,rplTsToMpgPrograminfo,m_uiCardNumber))		
			((CButton *)GetDlgItem(IDC_BUTTON_BIGEN3))->SetWindowText(_T("Stop"));
	}
	else
	{
		//m_programnum--;
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_THREE))->GetWindowText(strText);
#ifdef UNICODE
		rplTsToMpgPrograminfo.nProgramId = _wtoi(strText);
#else
		rplTsToMpgPrograminfo.nProgramId = atoi(strText);

#endif // _DEBUG	
		//rplTsToMpgPrograminfo.nProgramId = atoi(strText);
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_THREE))->SetWindowText(_T(""));
		m_strMPEGFilePath[2].Empty();
		SetDlgItemText(IDC_EDIT_TSTOPS_FILE3,m_strMPEGFilePath[2]);
		if(Seekfit_By5000asiplay_RecorderStop(RECORDER_CAPTURE_TS_STREAM,rplTsToMpgPrograminfo, m_uiCardNumber))
			((CButton *)GetDlgItem(IDC_BUTTON_BIGEN3))->SetWindowText(_T("Start"));
	}

}

void CCaptureDlg::OnBnClickedButtonBigen4()
{
	// TODO: 在此添加控件通知处理程序代码
	CString strText ;
	RECORDER_PROGRAM_INFO rplTsToMpgPrograminfo;
	((CButton *)GetDlgItem(IDC_BUTTON_BIGEN4))->GetWindowText(strText);

	if (strText == "Start")
	{
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_FOUR))->GetWindowText(strText);
		if (!strText.IsEmpty())
		{
			if (m_strMPEGFilePath[3].IsEmpty())
			{
				AfxMessageBox(_T(" program one mpeg file path is NULL!!!"));
				return;
			}
			else
			{
#ifdef UNICODE
				rplTsToMpgPrograminfo.nProgramId = _wtoi(strText);
#else
				rplTsToMpgPrograminfo.nProgramId = atoi(strText);

#endif // _DEBUG	
				//rplTsToMpgPrograminfo.nProgramId = atoi(strText);
				rplTsToMpgPrograminfo.szRecorderFileName = m_strMPEGFilePath[3];
				m_programnum++;
			}

		}
		else
		{
			AfxMessageBox(_T("program PID is NULL!!!"));
			return ;
		}
		if(Seekfit_By5000asiplay_RecorderStart(RECORDER_CAPTURE_TS_STREAM,rplTsToMpgPrograminfo,m_uiCardNumber))		
			((CButton *)GetDlgItem(IDC_BUTTON_BIGEN4))->SetWindowText(_T("Stop"));
	}
	else
	{
		//m_programnum--;
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_FOUR))->GetWindowText(strText);
#ifdef UNICODE
		rplTsToMpgPrograminfo.nProgramId = _wtoi(strText);
#else
		rplTsToMpgPrograminfo.nProgramId = atoi(strText);

#endif // _DEBUG	
		
		//rplTsToMpgPrograminfo.nProgramId = atoi(strText);
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_FOUR))->SetWindowText(_T(""));
		m_strMPEGFilePath[3].Empty();
		SetDlgItemText(IDC_EDIT_TSTOPS_FILE4,m_strMPEGFilePath[3]);
		if(Seekfit_By5000asiplay_RecorderStop(RECORDER_CAPTURE_TS_STREAM,rplTsToMpgPrograminfo, m_uiCardNumber))
			((CButton *)GetDlgItem(IDC_BUTTON_BIGEN4))->SetWindowText(_T("Start"));
	}

}

void CCaptureDlg::OnBnClickedButtonBigen5()
{
	// TODO: 在此添加控件通知处理程序代码
	CString strText ;
	RECORDER_PROGRAM_INFO rplTsToMpgPrograminfo;
	((CButton *)GetDlgItem(IDC_BUTTON_BIGEN5))->GetWindowText(strText);

	if (strText == "Start")
	{
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_FIVE))->GetWindowText(strText);
		if (!strText.IsEmpty())
		{
			if (m_strMPEGFilePath[4].IsEmpty())
			{
				AfxMessageBox(_T(" program one mpeg file path is NULL!!!"));
				return;
			}
			else
			{
#ifdef UNICODE
				rplTsToMpgPrograminfo.nProgramId = _wtoi(strText);
#else
				rplTsToMpgPrograminfo.nProgramId = atoi(strText);

#endif // _DEBUG	
				//rplTsToMpgPrograminfo.nProgramId = atoi(strText);
				rplTsToMpgPrograminfo.szRecorderFileName = m_strMPEGFilePath[4];
				m_programnum++;
			}

		}
		else
		{
			AfxMessageBox(_T("program PID is NULL!!!"));
			return ;
		}
		if(Seekfit_By5000asiplay_RecorderStart(RECORDER_CAPTURE_TS_STREAM,rplTsToMpgPrograminfo,m_uiCardNumber))		
			((CButton *)GetDlgItem(IDC_BUTTON_BIGEN5))->SetWindowText(_T("Stop"));
	}
	else
	{
		//m_programnum--;
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_FIVE))->GetWindowText(strText);
#ifdef UNICODE
		rplTsToMpgPrograminfo.nProgramId = _wtoi(strText);
#else
		rplTsToMpgPrograminfo.nProgramId = atoi(strText);

#endif // _DEBUG	
		//rplTsToMpgPrograminfo.nProgramId = atoi(strText);
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_FIVE))->SetWindowText(_T(""));
		m_strMPEGFilePath[4].Empty();
		SetDlgItemText(IDC_EDIT_TSTOPS_FILE5,m_strMPEGFilePath[4]);
		if(Seekfit_By5000asiplay_RecorderStop(RECORDER_CAPTURE_TS_STREAM,rplTsToMpgPrograminfo, m_uiCardNumber))
			((CButton *)GetDlgItem(IDC_BUTTON_BIGEN5))->SetWindowText(_T("Start"));
	}

}

void CCaptureDlg::OnBnClickedButtonBigen6()
{
	// TODO: 在此添加控件通知处理程序代码
	CString strText ;
	RECORDER_PROGRAM_INFO rplTsToMpgPrograminfo;
	((CButton *)GetDlgItem(IDC_BUTTON_BIGEN6))->GetWindowText(strText);

	if (strText == "Start")
	{
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_SIX))->GetWindowText(strText);
		if (!strText.IsEmpty())
		{
			if (m_strMPEGFilePath[5].IsEmpty())
			{
				AfxMessageBox(_T(" program one mpeg file path is NULL!!!"));
				return;
			}
			else
			{
#ifdef UNICODE
				rplTsToMpgPrograminfo.nProgramId = _wtoi(strText);
#else
				rplTsToMpgPrograminfo.nProgramId = atoi(strText);

#endif // _DEBUG	
				//rplTsToMpgPrograminfo.nProgramId = atoi(strText);
				rplTsToMpgPrograminfo.szRecorderFileName = m_strMPEGFilePath[5];
				m_programnum++;
			}

		}
		else
		{
			AfxMessageBox(_T("program PID is NULL!!!"));
			return ;
		}
		if(Seekfit_By5000asiplay_RecorderStart(RECORDER_CAPTURE_TS_STREAM,rplTsToMpgPrograminfo,m_uiCardNumber))		
			((CButton *)GetDlgItem(IDC_BUTTON_BIGEN6))->SetWindowText(_T("Stop"));
	}
	else
	{
		//m_programnum--;
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_SIX))->GetWindowText(strText);
#ifdef UNICODE
		rplTsToMpgPrograminfo.nProgramId = _wtoi(strText);
#else
		rplTsToMpgPrograminfo.nProgramId = atoi(strText);

#endif // _DEBUG	
		//rplTsToMpgPrograminfo.nProgramId = atoi(strText);
		((CEdit *)GetDlgItem(IDC_EDIT_PRO_SIX))->SetWindowText(_T(""));
		m_strMPEGFilePath[5].Empty();
		SetDlgItemText(IDC_EDIT_TSTOPS_FILE6,m_strMPEGFilePath[5]);
		if(Seekfit_By5000asiplay_RecorderStop(RECORDER_CAPTURE_TS_STREAM,rplTsToMpgPrograminfo, m_uiCardNumber))
			((CButton *)GetDlgItem(IDC_BUTTON_BIGEN6))->SetWindowText(_T("Start"));
	}

}

void CCaptureDlg::OnTimer(UINT nIDEvent)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	CString strText;
	CString str;
	INT nLastServiceId = -1;
	INT nCurServiceId = -1;
	UINT strtoint = 0;
	RECORDER_PROGRAM_INFO m_rplInfo;
	memset(&m_CurrteTime,0,sizeof(MEDIA_TIME_CODE)*TSTOPS_MAX_SERVICE_NUMBER);
	Seekfit_By5000asiplay_TsCaptureGetProgramInformation(TsProgramInfo, m_nTsSearchProgramStatus, m_uiCardNumber);
	if(m_nTsSearchProgramStatus == TS_SEARCH_PROGRAM_OK)
	{
		INT nChannelsNum = TsProgramInfo.sdtServiceTable.nMaxServiceInfoNum;
		for(INT i = 0;i< nChannelsNum;i++)
		{
			if(m_ListCtrlTsServiceTable.GetItemCount() < (i+1))
			{
				//inset item
				str.Format(_T("%d"), TsProgramInfo.sdtServiceTable.aServiceInfo[i].nServiceId);
				m_ListCtrlTsServiceTable.InsertItem(i,LPCTSTR(str));
				m_ListCtrlTsServiceTable.SetItemText(i,1,(LPCTSTR)(LPTSTR)TsProgramInfo.sdtServiceTable.aServiceInfo[i].aServiceName);
			}
			else
			{
				//update item
				str = m_ListCtrlTsServiceTable.GetItemText(i,0);
#ifdef UNICODE
				swscanf(str,_T("%d"),&nLastServiceId);
#else
				sscanf_s(str,"%d",&nLastServiceId);
#endif		
				
				nCurServiceId = TsProgramInfo.sdtServiceTable.aServiceInfo[i].nServiceId;
				if(nCurServiceId != nLastServiceId)
				{
					str.Format(_T("%d"), TsProgramInfo.sdtServiceTable.aServiceInfo[i].nServiceId);
					m_ListCtrlTsServiceTable.SetItemText(i,0,LPCTSTR(str));
					m_ListCtrlTsServiceTable.SetItemText(i,1,(LPCTSTR)(LPTSTR)TsProgramInfo.sdtServiceTable.aServiceInfo[i].aServiceName);
				}
			}
		}
	}

	((CEdit *)GetDlgItem(IDC_EDIT_PRO_ONE))->GetWindowText(strText);
#ifdef UNICODE 
		strtoint = _wtoi(strText);
#else
		strtoint = atoi(strText);
#endif
	if (strtoint>0)
	{
		m_rplInfo.nProgramId = strtoint;
		Seekfit_By5000asiplay_RecorderGetCurrentFileLength(RECORDER_CAPTURE_TS_STREAM,m_rplInfo,m_CurrteTime[0],m_uiCardNumber);
		str.Format(_T("%02d:%02d:%02d:%02d"),m_CurrteTime[0].uiHour, m_CurrteTime[0].uiMinute, m_CurrteTime[0].uiSecond, m_CurrteTime[0].uiFrame);
		SetDlgItemText(IDC_STATIC_TSTOPSTIMESTAMP,str);
	}
	else
	{
		str.Format(_T("%02d:%02d:%02d:%02d"),0, 0, 0, 0);
		SetDlgItemText(IDC_STATIC_TSTOPSTIMESTAMP,str);
	}
	((CEdit *)GetDlgItem(IDC_EDIT_PRO_TWO))->GetWindowText(strText);
#ifdef UNICODE 
	strtoint = _wtoi(strText);
#else
	strtoint = atoi(strText);
#endif
	if (strtoint>0)
	{
		m_rplInfo.nProgramId = strtoint;
		Seekfit_By5000asiplay_RecorderGetCurrentFileLength(RECORDER_CAPTURE_TS_STREAM,m_rplInfo,m_CurrteTime[1],m_uiCardNumber);
		str.Format(_T("%02d:%02d:%02d:%02d"),m_CurrteTime[1].uiHour, m_CurrteTime[1].uiMinute, m_CurrteTime[1].uiSecond, m_CurrteTime[1].uiFrame);
		SetDlgItemText(IDC_STATIC_TSTOPSTIMESTAMP2,str);
	}
	else
	{
		str.Format(_T("%02d:%02d:%02d:%02d"),0, 0, 0, 0);
		SetDlgItemText(IDC_STATIC_TSTOPSTIMESTAMP2,str);
	}
	((CEdit *)GetDlgItem(IDC_EDIT_PRO_THREE))->GetWindowText(strText);
#ifdef UNICODE 
	strtoint = _wtoi(strText);
#else
	strtoint = atoi(strText);
#endif
	if (strtoint>0)
	{
		m_rplInfo.nProgramId = strtoint;
		Seekfit_By5000asiplay_RecorderGetCurrentFileLength(RECORDER_CAPTURE_TS_STREAM,m_rplInfo,m_CurrteTime[2],m_uiCardNumber);
		str.Format(_T("%02d:%02d:%02d:%02d"),m_CurrteTime[2].uiHour, m_CurrteTime[2].uiMinute, m_CurrteTime[2].uiSecond, m_CurrteTime[2].uiFrame);
		SetDlgItemText(IDC_STATIC_TSTOPSTIMESTAMP3,str);
	}
	else
	{
		str.Format(_T("%02d:%02d:%02d:%02d"),0, 0, 0, 0);
		SetDlgItemText(IDC_STATIC_TSTOPSTIMESTAMP3,str);
	}
	((CEdit *)GetDlgItem(IDC_EDIT_PRO_FOUR))->GetWindowText(strText);
#ifdef UNICODE 
	strtoint = _wtoi(strText);
#else
	strtoint = atoi(strText);
#endif
	if (strtoint>0)
	{
		m_rplInfo.nProgramId = strtoint;
		Seekfit_By5000asiplay_RecorderGetCurrentFileLength(RECORDER_CAPTURE_TS_STREAM,m_rplInfo,m_CurrteTime[3],m_uiCardNumber);
		str.Format(_T("%02d:%02d:%02d:%02d"),m_CurrteTime[3].uiHour, m_CurrteTime[3].uiMinute, m_CurrteTime[3].uiSecond, m_CurrteTime[3].uiFrame);
		SetDlgItemText(IDC_STATIC_TSTOPSTIMESTAMP4,str);
	}
	else
	{
		str.Format(_T("%02d:%02d:%02d:%02d"),0, 0, 0, 0);
		SetDlgItemText(IDC_STATIC_TSTOPSTIMESTAMP4,str);
	}
	((CEdit *)GetDlgItem(IDC_EDIT_PRO_FIVE))->GetWindowText(strText);
#ifdef UNICODE 
	strtoint = _wtoi(strText);
#else
	strtoint = atoi(strText);
#endif
	if (strtoint>0)
	{
		m_rplInfo.nProgramId = strtoint;
		Seekfit_By5000asiplay_RecorderGetCurrentFileLength(RECORDER_CAPTURE_TS_STREAM,m_rplInfo,m_CurrteTime[4],m_uiCardNumber);
		str.Format(_T("%02d:%02d:%02d:%02d"),m_CurrteTime[4].uiHour, m_CurrteTime[4].uiMinute, m_CurrteTime[4].uiSecond, m_CurrteTime[4].uiFrame);
		SetDlgItemText(IDC_STATIC_TSTOPSTIMESTAMP5,str);
	}
	else
	{
		str.Format(_T("%02d:%02d:%02d:%02d"),0, 0, 0, 0);
		SetDlgItemText(IDC_STATIC_TSTOPSTIMESTAMP5,str);
	}
	((CEdit *)GetDlgItem(IDC_EDIT_PRO_SIX))->GetWindowText(strText);
#ifdef UNICODE 
	strtoint = _wtoi(strText);
#else
	strtoint = atoi(strText);
#endif
	if (strtoint>0)
	{
		m_rplInfo.nProgramId = strtoint;
		Seekfit_By5000asiplay_RecorderGetCurrentFileLength(RECORDER_CAPTURE_TS_STREAM,m_rplInfo,m_CurrteTime[5],m_uiCardNumber);
		str.Format(_T("%02d:%02d:%02d:%02d"),m_CurrteTime[5].uiHour, m_CurrteTime[5].uiMinute, m_CurrteTime[5].uiSecond, m_CurrteTime[5].uiFrame);
		SetDlgItemText(IDC_STATIC_TSTOPSTIMESTAMP6,str);
	}
	else
	{
		str.Format(_T("%02d:%02d:%02d:%02d"),0, 0, 0, 0);
		SetDlgItemText(IDC_STATIC_TSTOPSTIMESTAMP6,str);
	}
	
//	CString str;
	UINT uiHour;
	UINT uiMinute;
	UINT uiSecond;
	UINT uiFrame;
	ULONG ulTime;
	struct MEDIA_TIME_CODE mtcTimeCode;
	if(m_bCh1IsOpened)
	{
		Seekfit_By5000asiplay_RecorderGetCurrentFileLength(m_uiRecorderSource,m_rplProgramInfo,mtcTimeCode, m_uiCardNumber);
		uiHour = mtcTimeCode.uiHour;
		uiMinute = mtcTimeCode.uiMinute;
		uiSecond = mtcTimeCode.uiSecond;
		uiFrame = mtcTimeCode.uiFrame;
		str.Format(_T("%02d:%02d:%02d:%02d"), uiHour, uiMinute, uiSecond, uiFrame);
		GetDlgItem(IDC_STATIC_RECORDER_LENGTH)->SetWindowText(str);
	}
	TSTOPS_ETR_290_ERROR ccc;
	((CEdit *)GetDlgItem(IDC_EDIT_PRO_ONE))->GetWindowText(strText);
#ifdef UNICODE 
	strtoint = _wtoi(strText);
#else
	strtoint = atoi(strText);
#endif
	m_rplInfo.nProgramId = strtoint;
	Seekfit_By5000asiplay_RecorderGetTsTransformStatus(RECORDER_CAPTURE_TS_STREAM,m_rplInfo,ccc,m_uiCardNumber);
	CDialog::OnTimer(nIDEvent);
}


void CCaptureDlg::OnCbnSelchangeComboRecorderFormat()
{
	// TODO: 在此添加控件通知处理程序代码
	INT nIndexFAT = ((CComboBox*)GetDlgItem(IDC_COMBO_RECORDER_FORMAT))->GetCurSel();
	switch (nIndexFAT)
	{
	case 0:
		((CEdit*)GetDlgItem(IDC_EDIT_RECORDER_VIDEO_QUAILTY))->EnableWindow(FALSE);
		((CStatic*)GetDlgItem(IDC_STATIC_QU))->EnableWindow(FALSE);
		break;
	case 1:
	
		((CEdit*)GetDlgItem(IDC_EDIT_RECORDER_VIDEO_QUAILTY))->EnableWindow(TRUE);
		((CStatic*)GetDlgItem(IDC_STATIC_QU))->EnableWindow(TRUE);
		break;
	}
}
