📄 tccmmbdlg.cpp
字号:
ON_BN_CLICKED(IDC_BTN_SCAN, OnBtnScan)
ON_WM_LBUTTONDOWN()
ON_WM_TIMER()
ON_CBN_SELCHANGE(IDC_COMB_FREQ, OnSelchangeCombFreq)
ON_BN_CLICKED(IDC_CHECKFULLSCREEN, OnCheckfullscreen)
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTcCMMBDlg message handlers
BOOL CTcCMMBDlg::OnInitDialog()
{
CWnd* pTaskBar = CWnd::FindWindow(_T("HHTaskBar"), _T(""));
if(pTaskBar && ::IsWindow(*pTaskBar))
pTaskBar->ShowWindow(SW_HIDE);
SetBKBitmapID(IDB_MAIN);
SetCTLInfo(main_ui);
CSkinDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
DisplayCurrentBattery();
InitButtons();
SetWindowText(L"TCCCMMB");
m_fullScreen = FALSE;
m_videoWindow.left = VIDEO_WINDOW_LEFT;
m_videoWindow.top = VIDEO_WINDOW_TOP;
m_videoWindow.right = VIDEO_WINDOW_RIGHT;
m_videoWindow.bottom = VIDEO_WINDOW_BOTTOM;
memset(ChannelArray,0,sizeof(PROGRAMINFOITEM)*20);
GetScannedInfo();
CString buffer;
for(int i=0; i<68; i++)
{
buffer.Format(_T("%d MHz"), freqPoint[i]);
m_combofreq.AddString(buffer);
}
RECT rect;
rect.left=180;
rect.top=223;
rect.right=317;
rect.bottom=240;
m_combofreq.MoveWindow(&rect,TRUE);
rect.left=321;
rect.top=223;
rect.right=338;
rect.bottom=240;
m_allscreen.MoveWindow(&rect,TRUE);
mstr_status.Format(_T("Select FreqPoint"));
m_freq=-1;
m_status=0;
BOOL result=FALSE;
RawAudioQueue=new CDataQueue(sizeof(RawAudioPacket)*128,&result);
if(result==FALSE)
return FALSE;
RawVideoQueue=new CDataQueue(sizeof(RawVideoPacket)*512,&result);
if(result==FALSE)
{
delete RawAudioQueue;
return FALSE;
}
AudioQueue=new CDataQueue(sizeof(AudioPacket)*128,&result);
if(result==FALSE)
{
delete RawAudioQueue;
delete RawVideoQueue;
return FALSE;
}
InitH264Dec();
InitVideoRender();
InitEAACDec();
InitializeCriticalSection(&Timer_section);
InitializeCriticalSection(&Video_section);
mhTsif =NULL;
InitINNO();
StartRunHandle=CreateThread(NULL, 0, StartRun,this,0,NULL);
// mSignalStrengthTimer=SetTimer(TMR_SINGAL, 2000, NULL);
m_SignalStrength=-127;
return TRUE; // return TRUE unless you set the focus to a control
}
BOOL CTcCMMBDlg::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
ReleasePlayer();
ReleaseINNO();
if(RawVideoQueue)
delete RawVideoQueue;
if(RawAudioQueue)
delete RawAudioQueue;
if(AudioQueue)
delete AudioQueue;
if(m_pH264Dec){
m_pH264Dec->TCC_CODEC_H264Dec_Close();
delete m_pH264Dec;
m_pH264Dec = NULL;
}
if(m_pVideoRender){
delete m_pVideoRender;
m_pVideoRender = NULL;
}
if(m_pEAACPDec){
delete m_pEAACPDec;
m_pEAACPDec = NULL;
}
DeleteCriticalSection(&Timer_section);
DeleteCriticalSection(&Video_section);
if (mSignalStrengthTimer) {
KillTimer(mSignalStrengthTimer);
mSignalStrengthTimer = NULL;
}
// -- Show the task bar
CWnd* pTaskBar = CWnd::FindWindow(_T("HHTaskBar"), _T(""));
if(pTaskBar && ::IsWindow(*pTaskBar))
pTaskBar->ShowWindow(SW_SHOW);
return CSkinDialog::DestroyWindow();
}
void CTcCMMBDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CBrush nBrush(RGB(16,0,16)); // chroma key of TCCVrenderer
dc.FillRect(&m_videoWindow, &nBrush);
ViewOSD();
// Do not call CDialog::OnPaint() for painting messages
}
void CTcCMMBDlg::OnBtnExit()
{
// TODO: Add your control notification handler code here
CSkinDialog::OnOK();
}
void CTcCMMBDlg::OnBtnNext()
{
// TODO: Add your control notification handler code here
if(m_status<3)
return;
int result=0,i=0,tmp=0;
VideoPacket * getItem;
RawVideoQueue->Clear();
EnterCriticalSection(&Video_section);
while(VideoFirst)
{
getItem=VideoFirst;
VideoFirst = VideoFirst->Next;
VideoCount--;
delete getItem;
getItem = NULL;
}
VideoFirst=VideoLast=NULL;
LeaveCriticalSection(&Video_section);
RawAudioQueue->Clear();
AudioQueue->Clear();
Sleep(10);
if(m_pVideoRender)
m_pVideoRender->DisableLayer0();
Sleep(100);
tmp=channelpointer;
channelpointer++;
if(channelpointer>=ChannelSum)
channelpointer=0;
printf("%d,%d\n",ChannelArray[tmp].freqPoint,ChannelArray[channelpointer].freqPoint);
if((ChannelArray[tmp].freqPoint!=ChannelArray[channelpointer].freqPoint)||freqfail)
{
for(i=0;i<3;i++)
{
result=tpTvSetFreq(ChannelArray[channelpointer].freqPoint);
printf("OnBtnNext::tpTvSetFreq %d=%d\n",ChannelArray[channelpointer].freqPoint,result);
if(result==0)
break;
}
if(result!=0)
{
freqfail=1;
mstr_status.Format(_T("FreqPoint Fail"));
InvalidateRect(&INFO,TRUE);
return;
}
freqfail=0;
}
result=tpTvSelectService(channelpointer);
printf("++++OnBtnnext::tpTvSelectService=%d\n",result);
mstr_status.Format(_T("%d"),ChannelArray[channelpointer].ServerID);
InvalidateRect(&INFO,TRUE);
}
void CTcCMMBDlg::OnBtnPip()
{
// TODO: Add your control notification handler code here
ReleasePlayer();
ReleaseINNO();
KillTimer(mSignalStrengthTimer);
if(m_pVideoRender)
m_pVideoRender->DisableLayer0();
Sleep(100);
COption dlg(NULL);
dlg.DoModal();
mhTsif =NULL;
InitINNO();
// mSignalStrengthTimer=SetTimer(TMR_SINGAL, 5000, NULL);
mstr_status.Format(_T("Select FreqPoint"));
m_freq=-1;
m_status=0;
InvalidateRect(&INFO,TRUE);
m_combofreq.SetCurSel(-1);
GetScannedInfo();
StartRunHandle=CreateThread(NULL, 0, StartRun,this,0,NULL);
}
void CTcCMMBDlg::OnBtnPrev()
{
// TODO: Add your control notification handler code here
if(m_status<3)
return;
int result=0,i=0,tmp=0;
VideoPacket * getItem;
RawVideoQueue->Clear();
EnterCriticalSection(&Video_section);
while(VideoFirst)
{
getItem=VideoFirst;
VideoFirst = VideoFirst->Next;
VideoCount--;
delete getItem;
getItem = NULL;
}
VideoFirst=VideoLast=NULL;
LeaveCriticalSection(&Video_section);
RawAudioQueue->Clear();
AudioQueue->Clear();
Sleep(10);
if(m_pVideoRender)
m_pVideoRender->DisableLayer0();
Sleep(100);
tmp=channelpointer;
channelpointer--;
if(channelpointer<0)
channelpointer=ChannelSum-1;
if((ChannelArray[tmp].freqPoint!=ChannelArray[channelpointer].freqPoint)||freqfail)
{
for(i=0;i<3;i++)
{
result=tpTvSetFreq(ChannelArray[channelpointer].freqPoint);
printf("OnBtnNext::tpTvSetFreq %d=%d\n",ChannelArray[channelpointer].freqPoint,result);
if(result==0)
break;
}
if(result!=0)
{
freqfail=1;
mstr_status.Format(_T("FreqPoint Fail"));
InvalidateRect(&INFO,TRUE);
return;
}
freqfail=0;
}
result=tpTvSelectService(channelpointer);
printf("++++OnBtnnext::tpTvSelectService=%d\n",result);
mstr_status.Format(_T("%d"),ChannelArray[channelpointer].ServerID);
InvalidateRect(&INFO,TRUE);
}
void CTcCMMBDlg::OnBtnScan()
{
// InitPlayer();
// return;
// TODO: Add your control notification handler code here
if(m_status<1)
return;
int result=0;
if(m_status==1)
InitPlayer();
for(int i=0;i<5;i++)
{
ChannelSum=0;
result=tpTvGetServiceInfo();
printf("++++tpTvGetServiceInfo=%d\n",result);
if(result==0)
{
memset(ChannelArray,0,sizeof(PROGRAMINFOITEM)*20);
break;
}else{
}
Sleep(3000);
}
if(result==0)
{
mstr_status.Format(_T("Scan OK"));
m_status=2;
InvalidateRect(&INFO,TRUE);
}
else{
mstr_status.Format(_T("Scan Fail"));
InvalidateRect(&INFO,TRUE);
return ;
}
Sleep(4000);
printf("\n*******ChannelSum=%d\n",ChannelSum);
if(ChannelSum>0)
{
channelpointer=0;
result=tpTvSelectService(channelpointer);
printf("++++tpTvSelectService=%d\n",result);
m_status=3;
if(result==0)
{
mstr_status.Format(_T("%d"),ChannelArray[channelpointer].ServerID);
InvalidateRect(&INFO,TRUE);
}
}else{
mstr_status.Format(_T("NO Scan!"));
InvalidateRect(&INFO,TRUE);
}
}
void CTcCMMBDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SwitchFullScreen();
RECT s = {0,VIDEO_WINDOW_BOTTOM,LCD_WIDTH,LCD_HEIGHT};
InvalidateRect(&s,true);
CSkinDialog::OnLButtonDown(nFlags, point);
}
void CTcCMMBDlg::InitButtons()
{
m_batt.MoveWindow(BTN_BATT_LEFT, BTN_BATT_TOP, BTN_BATT_FULL_WIDTH, BTN_BATT_FULL_HEIGHT);
AttachBitmapToButton(IDB_BTN_PREV_OFF, IDB_BTN_PREV_ON, &m_btn_prev);
AttachBitmapToButton(IDB_BTN_NEXT_OFF, IDB_BTN_NEXT_ON, &m_btn_next);
AttachBitmapToButton(IDB_BTN_SCAN_OFF, IDB_BTN_SCAN_ON, &m_btn_scan);
AttachBitmapToButton(IDB_BTN_EXIT_OFF, IDB_BTN_EXIT_ON, &m_btn_exit);
AttachBitmapToButton(IDB_BTN_PIP_OFF, IDB_BTN_PIP_ON, &m_btn_pip);
}
void CTcCMMBDlg::SwitchFullScreen()
{
if (m_fullScreen)
{
m_videoWindow.left = VIDEO_WINDOW_LEFT;
m_videoWindow.top = VIDEO_WINDOW_TOP;
m_videoWindow.right = VIDEO_WINDOW_RIGHT;
m_videoWindow.bottom = VIDEO_WINDOW_BOTTOM;
DisplayAllControls(TRUE);
}
else // Full screen
{
// if not playing, full-screen mode is not allowed
m_videoWindow.left = 0;
m_videoWindow.top = 0;
m_videoWindow.right = LCD_WIDTH;
m_videoWindow.bottom = LCD_HEIGHT;
DisplayAllControls(FALSE);
}
m_fullScreen = !m_fullScreen;
}
void CTcCMMBDlg::DisplayCurrentBattery()
{
SYSTEM_POWER_STATUS_EX2 sps;
RECT r = {BTN_BATT_LEFT, BTN_BATT_TOP, BTN_BATT_LEFT+BTN_BATT_FULL_WIDTH, BTN_BATT_TOP+BTN_BATT_FULL_HEIGHT};
// set the battery level & update the button
GetSystemPowerStatusEx2(&sps,sizeof(sps),TRUE);
m_batt.SetBatteryLevel(sps.BatteryLifePercent);
}
void CTcCMMBDlg::DisplayAllControls(BOOL flag)
{
unsigned int n_switch;
if (flag == TRUE)
n_switch = SW_SHOW;
else
n_switch = SW_HIDE;
// buttons
m_btn_prev.ShowWindow(n_switch);
m_btn_next.ShowWindow(n_switch);
m_btn_scan.ShowWindow(n_switch);
m_btn_exit.ShowWindow(n_switch);
m_btn_pip.ShowWindow(n_switch);
m_combofreq.ShowWindow(n_switch);
m_allscreen.ShowWindow(n_switch);
m_batt.ShowWindow(n_switch);
}
DWORD DecodeThread(void *para)
{
unsigned char buf[512]={0};
printf("starting...........\n");
/*
fd = fopen("/nand/szsignal.mfs","rb");
if (fd < 0)
{
printf("open file error!\n");
return -1;
}
//*/
while(dataend)
// while(!feof(fd))
{
DWORD bytes;
ReadFile(mhTsif, g_FrameBuffer, 0xfc00, &bytes, 0);//先读取帧头,判断帧总长度
// bytes = fread(g_FrameBuffer, 1, 0xfc00, fd);
// if(ferror(fd))
// break;
if(bytes<=0)
{
// printf(". ");
// fd = fopen("/nand/szsignal.mfs","ab+");
// fwrite(g_FrameBuffer, 1,bytes, fd);
// fclose(fd);
// break;
continue;
}else{
// fd = fopen("/nand/IFsignal.mfs","ab+");
// fwrite(g_FrameBuffer, 1,bytes, fd);
// fclose(fd);
}
mfx.Demultiplex(g_FrameBuffer, bytes);
Sleep(3);
}
// fclose(fd);
printf("Decode SubMultiplex Frame SUCCESS!!!!!\n");
return 1;
}
void InitH264Dec()
{
m_pH264Dec = NULL;
m_pH264Dec = new CH264DEC;
if(m_pH264Dec){
//// DECODER PHYSICAL MEMORY SETTING -defined in Common/Virtual.h ////
#if defined(__TCC79XX_WINCE__)
unsigned int decPhysicalMemStart = HW_MEM_BASE_TCC79X;
HKEY hk = NULL;
DWORD dwStatus;
DWORD dwSize,dwType;
dwStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Drivers\\TCC79X\\CONFIG", 0, 0, &hk);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -