12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346 |
- // clientdemoDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "clientdemo.h"
- #include "clientdemoDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #define WM_MYCOMMAND WM_USER+1
- #define DEFAULTVAL 64
- //#define RECORD_ONLY
- int count;
- HWND hWnd1,hWnd2,hWnd3,hWnd4,hWnd5,hWnd6,hWnd7,hWnd8;
- //int filecount=20;
- DWORD num1;
- UINT timers;
- int ipos=0;
- BOOL bpos=FALSE;
- RECT rinit;
- CRect m_OldRect;
- int filecount=0;
- UINT filetimer=0;
- int capcount=0;
- CRect orirc;
- BOOL blarged=FALSE;
- WORD testnum=0;
- BOOL bmode=FALSE;
- BOOL g_bCapPic=FALSE;
- UINT remains=0;
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
- // Implementation
- protected:
- //{{AFX_MSG(CAboutDlg)
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CClientdemoDlg dialog
- CClientdemoDlg::CClientdemoDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CClientdemoDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CClientdemoDlg)
- m_linktype = 0;
- m_ipadd = _T("192.168.1.247");
- m_shownum = 1;
- m_delaytype = -1;
- m_showmode = -1;
- m_bframenum = -1;
- m_frameshow = _T("");
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- void CClientdemoDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CClientdemoDlg)
- DDX_Control(pDX, IDC_SLIDER4, m_hue);
- DDX_Control(pDX, IDC_SLIDER3, m_saturation);
- DDX_Control(pDX, IDC_SLIDER2, m_contrast);
- DDX_Control(pDX, IDC_SLIDER1, m_brightness);
- DDX_Control(pDX, IDC_COMBO1, m_windowCtrl);
- DDX_Control(pDX, IDC_STATIC8, m_video8);
- DDX_Control(pDX, IDC_STATIC7, m_video7);
- DDX_Control(pDX, IDC_STATIC6, m_video6);
- DDX_Control(pDX, IDC_STATIC5, m_video5);
- DDX_Radio(pDX, IDC_TCP, m_linktype);
- DDX_Text(pDX, IDC_IPADDRESS, m_ipadd);
- DDX_Text(pDX, IDC_SHOWNUM, m_shownum);
- DDX_Radio(pDX, IDC_DELAY1, m_delaytype);
- DDX_Radio(pDX, IDC_SHOWMODE1, m_showmode);
- DDX_Radio(pDX, IDC_RADIOBFRAM0, m_bframenum);
- DDX_Text(pDX, IDC_STATICFRAME, m_frameshow);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CClientdemoDlg, CDialog)
- //ON_MESSAGE(WM_MYCOMMAND,OnMyCommand)
- //{{AFX_MSG_MAP(CClientdemoDlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
- ON_WM_TIMER()
- ON_BN_CLICKED(IDC_STATIC5, OnStatic5)
- ON_BN_CLICKED(IDC_STATIC7, OnStatic7)
- ON_BN_CLICKED(IDC_STATIC6, OnStatic6)
- ON_BN_CLICKED(IDC_STATIC8, OnStatic8)
- ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
- ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
- ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
- ON_WM_DESTROY()
- ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
- ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
- ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
- ON_WM_HSCROLL()
- ON_WM_CTLCOLOR()
- ON_BN_CLICKED(IDC_SHOWMODE2, OnShowmode2)
- ON_BN_CLICKED(IDC_SHOWMODE1, OnShowmode1)
- ON_BN_CLICKED(IDC_BUTTON10, OnButton10)
- ON_BN_CLICKED(IDC_RADIOBFRAM0, OnRadiobfram0)
- ON_BN_CLICKED(IDC_RADIOBFRAM1, OnRadiobfram1)
- ON_BN_CLICKED(IDC_RADIOBFRAM2, OnRadiobfram2)
- ON_BN_CLICKED(IDC_BUTTON_CLEAN_BUFFER, OnButtonCleanBuffer)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
- ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER1, OnReleasedcaptureSlider1)
- ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER2, OnReleasedcaptureSlider2)
- ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER3, OnReleasedcaptureSlider3)
- ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER4, OnReleasedcaptureSlider4)
- ON_CONTROL(STN_DBLCLK,IDC_STATIC5,OnDbStatic1)
- ON_CONTROL(STN_DBLCLK,IDC_STATIC6,OnDbStatic2)
- ON_CONTROL(STN_DBLCLK,IDC_STATIC7,OnDbStatic3)
- ON_CONTROL(STN_DBLCLK,IDC_STATIC8,OnDbStatic4)
- ON_BN_CLICKED(IDC_BUTTONDEFAULT, OnButtondefault)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CClientdemoDlg message handlers
- void CALLBACK DrawFun(LONG StockHandle,HDC hDc,LONG nUser)
- {
- // if (StockHandle == 0)
- {
- //直接写
- // TextOut(hDc,5,5,"abcdef",5);
- }
- }
- void CALLBACK CapPicFun(long nPort,\
- char * pBuf,long nSize,\
- long nWidth,long nHeight,\
- long nStamp,long nType,long nReceaved)
- {
- if(!((g_bCapPic) && (nPort == ipos)))
- return;
- CString csFile;
- switch(nType)
- {
- case T_UYVY:
- csFile="c:\\uyvy.bmp";
- break;
- case T_YV12:
- csFile="c:\\yv12.bmp";
- break;
- case T_RGB32:
- csFile="c:\\rgb.bmp";
- break;
- default:
- return ;
- }
- MP4_ClientSavePicFile(pBuf,nSize,nWidth,nHeight,nType,csFile.GetBuffer(csFile.GetLength()));
- g_bCapPic=FALSE;
-
- }
- BOOL CClientdemoDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // Add "About..." menu item to system menu.
- // IDM_ABOUTBOX must be in the system command range.
- ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
- ASSERT(IDM_ABOUTBOX < 0xF000);
- CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
- CString strAboutMenu;
- strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty())
- {
- pSysMenu->AppendMenu(MF_SEPARATOR);
- pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
- }
- }
- // 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
- MP4_ClientSetNetPort(5050,6050);
- MP4_ClientStartup(WM_MYCOMMAND,this->m_hWnd);
- // m_playtryl.SetRange(1,100,TRUE);
- m_delaytype =3;
- m_showmode = 0;
- m_bframenum = 2;
- UpdateData(FALSE);
- nn1=nn2=nn3=nn4=-1;
- m_iWndNum = -1;
- m_windowCtrl.SetCurSel(m_iWndNum);
- m_brightness.SetRange(0, 128,TRUE);
- m_contrast.SetRange(0, 128,TRUE);
- m_saturation.SetRange(0, 128,TRUE);
- m_hue.SetRange(0, 128,TRUE);
- m_brightness.SetPos(DEFAULTVAL);
- m_contrast.SetPos(DEFAULTVAL);
- m_saturation.SetPos(DEFAULTVAL);
- m_hue.SetPos(DEFAULTVAL);
- // TODO: Add extra initialization here
-
- return TRUE; // return TRUE unless you set the focus to a control
- }
- void CClientdemoDlg::OnSysCommand(UINT nID, LPARAM lParam)
- {
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- }
- else
- {
- CDialog::OnSysCommand(nID, lParam);
- }
- }
- // If you add a minimize button to your dialog, you will need the code below
- // to draw the icon. For MFC applications using the document/view model,
- // this is automatically done for you by the framework.
- void CClientdemoDlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
- // The system calls this to obtain the cursor to display while the user drags
- // the minimized window.
- HCURSOR CClientdemoDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
- void CALLBACK ReadDataCallBack(DWORD nPort,UCHAR *pPacketBuffer,DWORD nPacketSize)
- {
- TRACE("%d\n",nPacketSize);
- }
- void CClientdemoDlg::OnButton1()
- {
- CWnd* pButton1;
- CString csFile;
- pButton1 = (CButton*)GetDlgItem(IDC_BUTTON1);
- pButton1->EnableWindow(FALSE);
- UpdateData(TRUE);
- if (m_showmode == 0)
- {
- MP4_ClientSetShowMode(NORMALMODE,0);
- }
- else
- {
- MP4_ClientSetShowMode(OVERLAYMODE,COLORREF(0xff00ff));
- }
- nn1=nn2=nn3=nn4 = -1;
- int itemp = m_shownum;
- char ips[256];
-
- sprintf(ips,"%s",m_ipadd);
-
- hWnd5 = m_video5.GetSafeHwnd();//
- aa5.m_bRemoteChannel = 0;
- switch(m_linktype)
- {
- case 0:
- aa5.m_bSendMode = TCPMODE;
- break;
- case 1:
- aa5.m_bSendMode = UDPMODE;
- break;
- case 2:
- aa5.m_bSendMode = MULTIMODE;
- break;
- case 3:
- aa5.m_bSendMode = DIALING;
- break;
- case 4:
- aa5.m_bSendMode = AUDIODETACH;
- break;
- default:
- aa5.m_bSendMode = TCPMODE;
- break;
- }
- aa5.m_sIPAddress = ips;
- //2003.12.2
- //如果想只录像,而不进行解码,可以将m_hShowVideo设置成NULL
- //If you just want to record without decode on client side,
- //please set m_hShowVideo as NULL
- #if defined RECORD_ONLY
- aa5.m_hShowVideo = NULL;
- #else
- aa5.m_hShowVideo = hWnd5;
- #endif
- // add 2003.12.2
- //m_nImgFormat 指明想要获取的图像格式
- //依赖服务器端的设置。如果不设置,获取的是服务器的缺省格式
- //m_nImgFormat indicates the picture format you get on the client side,
- //It depends on the setting of Server side.
- aa5.m_nImgFormat = 0; // request CIF format
- // aa5.m_nImgFormat = 1; // request QCIF format
- aa5.m_sUserName = "123";
- aa5.m_sUserPassword="w";
- aa5.m_bUserCheck = TRUE;
-
- MP4_ClientSetTTL(64);
- nn1 = MP4_ClientStart(&aa5,ReadDataCallBack);
- if (nn1 == -1)
- {
- MessageBox("error");
- return;
- }
- //
- BOOL breturn;
- breturn = MP4_ClientRigisterDrawFun(nn1,DrawFun,0);
- switch(m_delaytype)
- {
- case 0:
- MP4_ClientSetBufferNum(nn1,40);
- MP4_ClientSetPlayDelay(nn1,580);
- break;
- case 1:
- MP4_ClientSetBufferNum(nn1,15);
- MP4_ClientSetPlayDelay(nn1,40);
- break;
- case 2:
- MP4_ClientSetBufferNum(nn1,15);
- MP4_ClientSetPlayDelay(nn1,0);
- break;
- case 3:
- MP4_ClientSetBufferNum(nn1,0);
- MP4_ClientSetPlayDelay(nn1,0);
- break;
- }
- // MP4_ClientThrowBFrame(nn1,m_bframenum);
- MP4_ClientSetCapPicCallBack(nn1,CapPicFun);
- itemp --;
- if (itemp<=0)
- goto GOTOEND;
- if (m_showmode == 1)
- {
- goto GOTOEND;
- }
- Sleep(200);
- hWnd6 = m_video6.GetSafeHwnd();//
- aa6.m_bRemoteChannel =1;
- switch(m_linktype)
- {
- case 0:
- aa6.m_bSendMode = TCPMODE;
- break;
- case 1:
- aa6.m_bSendMode = UDPMODE;
- break;
- case 2:
- aa6.m_bSendMode = MULTIMODE;
- break;
- case 3:
- aa6.m_bSendMode = DIALING;
- break;
- case 4:
- aa6.m_bSendMode = AUDIODETACH;
- break;
- default:
- aa6.m_bSendMode = TCPMODE;
- break;
- }
- aa6.m_sIPAddress = ips;
- #if defined RECORD_ONLY
- aa6.m_hShowVideo = NULL;
- #else
- aa6.m_hShowVideo = hWnd6;
- #endif
-
- aa6.m_nImgFormat = 0;
- aa6.m_sUserName = "123";
- aa6.m_sUserPassword="w";
- aa6.m_bUserCheck = TRUE;
- MP4_ClientSetTTL(32);
- nn2 = MP4_ClientStart(&aa6,NULL);
- if (nn2 == -1)
- {
- MessageBox("error");
- return;
- }
- switch(m_delaytype)
- {
- case 0:
- MP4_ClientSetBufferNum(nn2,40);
- MP4_ClientSetPlayDelay(nn2,580);
- break;
- case 1:
- MP4_ClientSetBufferNum(nn2,15);
- MP4_ClientSetPlayDelay(nn2,30);
-
-
- break;
- case 2:
- MP4_ClientSetBufferNum(nn2,15);
- MP4_ClientSetPlayDelay(nn2,0);
- break;
- case 3:
- MP4_ClientSetBufferNum(nn2,0);
- MP4_ClientSetPlayDelay(nn2,0);
- break;
- }
- // MP4_ClientThrowBFrame(nn2,m_bframenum);
- MP4_ClientSetCapPicCallBack(nn2,CapPicFun);
- itemp --;
- if (itemp<=0)
- goto GOTOEND;
- Sleep(200);
- hWnd7 = m_video7.GetSafeHwnd();//
- aa7.m_bRemoteChannel = 2;
- switch(m_linktype)
- {
- case 0:
- aa7.m_bSendMode = TCPMODE;
- break;
- case 1:
- aa7.m_bSendMode = UDPMODE;
- break;
- case 2:
- aa7.m_bSendMode = MULTIMODE;
- break;
- case 3:
- aa7.m_bSendMode = DIALING;
- break;
- case 4:
- aa7.m_bSendMode = AUDIODETACH;
- break;
- default:
- aa7.m_bSendMode = TCPMODE;
- break;
- }
- aa7.m_sIPAddress = ips;
- #if defined RECORD_ONLY
- aa7.m_hShowVideo = NULL;
- #else
- aa7.m_hShowVideo = hWnd7;
- #endif
- aa7.m_nImgFormat = 0;
- aa7.m_sUserName = "123";
- aa7.m_sUserPassword="w";
- aa7.m_bUserCheck = TRUE;
- MP4_ClientSetTTL(64);
- nn3 = MP4_ClientStart(&aa7,NULL);
- if (nn3 == -1)
- {
- MessageBox("error");
- return;
- }
- switch(m_delaytype)
- {
- case 0:
- MP4_ClientSetBufferNum(nn3,40);
- MP4_ClientSetPlayDelay(nn3,580);
- break;
- case 1:
- MP4_ClientSetBufferNum(nn3,15);
- MP4_ClientSetPlayDelay(nn3,30);
-
- break;
- case 2:
- MP4_ClientSetBufferNum(nn3,15);
- MP4_ClientSetPlayDelay(nn3,0);
- break;
- case 3:
- MP4_ClientSetBufferNum(nn3,0);
- MP4_ClientSetPlayDelay(nn3,0);
- break;
- }
- // MP4_ClientThrowBFrame(nn3,m_bframenum);
- MP4_ClientSetCapPicCallBack(nn3,CapPicFun);
- itemp --;
- if (itemp<=0)
- goto GOTOEND;
- Sleep(200);
- hWnd8 = m_video8.GetSafeHwnd();//
- aa8.m_bRemoteChannel = 3;
- switch(m_linktype)
- {
- case 0:
- aa8.m_bSendMode = TCPMODE;
- break;
- case 1:
- aa8.m_bSendMode = UDPMODE;
- break;
- case 2:
- aa8.m_bSendMode = MULTIMODE;
- break;
- case 3:
- aa8.m_bSendMode = DIALING;
- break;
- case 4:
- aa8.m_bSendMode = AUDIODETACH;
- break;
- default:
- aa8.m_bSendMode = TCPMODE;
- break;
- }
- aa8.m_sIPAddress = ips;
- #if defined RECORD_ONLY
- aa8.m_hShowVideo = NULL;
- #else
- aa8.m_hShowVideo = hWnd8;
- #endif
- aa8.m_nImgFormat = 0;
- aa8.m_sUserName = "123";
- aa8.m_sUserPassword="w";
- aa8.m_bUserCheck = TRUE;
- MP4_ClientSetTTL(64);
- nn4 = MP4_ClientStart(&aa8,NULL);
- if (nn4 == -1)
- {
- MessageBox("Error");
- return;
- }
- switch(m_delaytype)
- {
- case 0:
- MP4_ClientSetBufferNum(nn4,40);
- MP4_ClientSetPlayDelay(nn4,580);
- break;
- case 1:
- MP4_ClientSetBufferNum(nn4,15);
- MP4_ClientSetPlayDelay(nn4,30);
- break;
- case 2:
- MP4_ClientSetBufferNum(nn4,15);
- MP4_ClientSetPlayDelay(nn4,0);
- break;
- case 3:
- MP4_ClientSetBufferNum(nn4,0);
- MP4_ClientSetPlayDelay(nn4,0);
- break;
- }
- // MP4_ClientThrowBFrame(nn4,m_bframenum);
- MP4_ClientSetCapPicCallBack(nn4,CapPicFun);
- GOTOEND:
- // remains=SetTimer(10,1000,NULL);
- pButton1 = (CButton*)GetDlgItem(IDC_BUTTON2);
- pButton1->EnableWindow(TRUE);
- if(nn1 >= 0)
- {
- m_iWndNum = 1;
- m_windowCtrl.SetCurSel(m_iWndNum-1);
- OnSelchangeCombo1();
- }
- }
- void CClientdemoDlg::OnButton2()
- {
- CWnd* pButton1;
- /*
- if (remains)
- {
- remains = 0;
- KillTimer(remains);
- }
- */
- pButton1 = (CButton*)GetDlgItem(IDC_BUTTON2);
- pButton1->EnableWindow(FALSE);
- if (filetimer)
- {
- KillTimer(filetimer);
- filetimer = 0;
- }
- if (nn1 >= 0)
- {
- MP4_ClientStopCapture(nn1);
- MP4_ClientStop(nn1);
- }
- nn1=-1;
- Sleep(100);
- if (nn2 >= 0)
- {
- MP4_ClientStopCapture(nn2);
- MP4_ClientStop(nn2);
- }
- Sleep(100);
- nn2=-1;
- if (nn3 >= 0)
- {
- MP4_ClientStopCapture(nn3);
- MP4_ClientStop(nn3);
- }
- Sleep(100);
- nn3=-1;
- if (nn4 >= 0)
- {
- MP4_ClientStopCapture(nn4);
- MP4_ClientStop(nn4);
- }
- Sleep(100);
- nn4=-1;
- m_video5.Invalidate(TRUE);
- m_video6.Invalidate(TRUE);
- m_video7.Invalidate(TRUE);
- m_video8.Invalidate(TRUE);
- UpdateData(FALSE);
-
- pButton1 = (CButton*)GetDlgItem(IDC_BUTTON1);
- pButton1->EnableWindow(TRUE);
- MessageBox("End!");
-
- }
- void CClientdemoDlg::OnTimer(UINT nIDEvent)
- {
- if (nIDEvent == 1)
- {
- }
- else if (nIDEvent == 10)
- {
- if (nn1>=0)
- {
- m_frameshow.Format("nowframenum:%ld",MP4_ClientGetFrameNum(nn1));
- UpdateData(FALSE);
- }
- }
- CDialog::OnTimer(nIDEvent);
- }
- void CClientdemoDlg::OnStatic5()
- {
- // TODO: Add your control notification handler code here
- ipos = 0;
- }
- void CClientdemoDlg::OnStatic7()
- {
- ipos = 2;
- }
- void CClientdemoDlg::OnStatic6()
- {
- ipos = 1;
- }
- void CClientdemoDlg::OnStatic8()
- {
- ipos = 3;
- }
- void CClientdemoDlg::OnButton4()
- {
- CWnd* pButton1;
- if (nn1>=0)
- MP4_ClientStopCapture(nn1);
- if (nn2>=0)
- MP4_ClientStopCapture(nn2);
- if (nn3>=0)
- MP4_ClientStopCapture(nn3);
- if (nn4>=0)
- MP4_ClientStopCapture(nn4);
- pButton1 = (CButton*)GetDlgItem(IDC_BUTTON4);
- pButton1->EnableWindow(FALSE);
- pButton1 = (CButton*)GetDlgItem(IDC_BUTTON8);
- pButton1->EnableWindow(TRUE);
- }
- void CClientdemoDlg::OnButton3()
- {
- char ctemp[256];
- char ips[256];
- WORD wtemp;
- UpdateData(TRUE);
- sprintf(ips,"%s",m_ipadd);
- wtemp = MP4_ClientGetServerChanNum(ips);
- sprintf(ctemp,"%d",wtemp);
- MessageBox(ctemp);
- }
- void CClientdemoDlg::OnButton6()
- {
- char ctemp[256];
- char sendcont[500];
- CString firstco;
- firstco = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
- MP4_ClientSetWait(3000,10);
- // for(int i=0;i<100;i++)
- {
- memset(sendcont,0,500);
- UpdateData(TRUE);
- sprintf(ctemp,"%s",m_ipadd);
- sprintf(sendcont,"%s send content %d",firstco,testnum);
- testnum++;
- if (testnum > 200)
- testnum=0;
- MP4_ClientCommandtoServer((LPCTSTR)ctemp,sendcont,400);
- Sleep(100);
- }
- }
- void CClientdemoDlg::OnMyCommand(WPARAM wParam, LPARAM lParam)
- {
- char ctemp[1000];
- switch((BYTE)wParam)
- {
- case RECDATAERR:
- {
- CTime time;
- time = CTime::GetCurrentTime();
- sprintf(ctemp,"%d index%d,receive error",time.GetHour(),(BYTE)lParam);
- break;
- }
- case PLAYERR:
- {
- CTime time;
- time = CTime::GetCurrentTime();
- sprintf(ctemp,"%d index%d,play error",time.GetHour(),(BYTE)lParam);
- break;
- }
- case REFUSED:
- {
- CTime time;
- time = CTime::GetCurrentTime();
- sprintf(ctemp,"%d index%d,no permission",time.GetHour(),(BYTE)lParam);
- break;
- }
- case VERSIONERR:
- {
- CTime time;
- time = CTime::GetCurrentTime();
- sprintf(ctemp,"%d index%d,version error",time.GetHour(),(BYTE)lParam);
- break;
- }
- case GETSTRING:
- {
- WORD tlen;
- char ips[30];
- memset(ctemp,0,1000);
- MP4_ClientReadLastMessage(ips,ctemp,&tlen);
- sprintf(&(ctemp[tlen]),"\r\n");
- // TRACE(ctemp);
- break;
- }
- default:
- {
- sprintf(ctemp,"index%d,message%d",(BYTE)lParam,(BYTE)wParam);
- break;
- }
- }
- MessageBox(ctemp);
- }
- void CClientdemoDlg::OnDestroy()
- {
- if (nn1 >= 0)
- {
- MP4_ClientStopCapture(nn1);
- // ClientStopPlay(nn5);
- MP4_ClientStop(nn1);
- }
- if (nn2 >= 0)
- {
- MP4_ClientStopCapture(nn2);
- // ClientStopPlay(nn5);
- MP4_ClientStop(nn2);
- }
- if (nn3 >= 0)
- {
- MP4_ClientStopCapture(nn3);
- // ClientStopPlay(nn5);
- MP4_ClientStop(nn3);
- }
- if (nn4 >= 0)
- {
- MP4_ClientStopCapture(nn4);
- // ClientStopPlay(nn5);
- MP4_ClientStop(nn4);
- }
- MP4_ClientCleanup();
- CDialog::OnDestroy();
- }
- void CClientdemoDlg::OnButton5()
- {
- char ctemp[256];
- UpdateData(TRUE);
- sprintf(ctemp,"%s",m_ipadd);
- MP4_ClientShut((LPCTSTR)ctemp,0);
- }
- void CClientdemoDlg::OnButton7()
- {
- MP4_ClientAudioStop();
- }
- void CClientdemoDlg::OnDbStatic1()
- {
- if (nn1 >= 0 )
- {
- MP4_ClientAudioStart(nn1);
- MP4_ClientAudioVolume(0xfff0);
- }
- if (blarged)
- {
- ScreenToClient((LPPOINT)&orirc);
- ScreenToClient((LPPOINT)&orirc+1);
- m_video5.MoveWindow(orirc,TRUE);
- m_video6.ShowWindow(SW_SHOW);
- m_video7.ShowWindow(SW_SHOW);
- m_video8.ShowWindow(SW_SHOW);
- blarged = FALSE;
- }
- else
- {
- m_video6.ShowWindow(SW_HIDE);
- m_video7.ShowWindow(SW_HIDE);
- m_video8.ShowWindow(SW_HIDE);
- m_video5.GetWindowRect(&orirc);
- m_video5.MoveWindow(10,10,(int)(352*1.6),(int)(288*1.6),TRUE);
- blarged = TRUE;
- }
- }
- void CClientdemoDlg::OnDbStatic2()
- {
- if (nn2 >=0 )
- {
- MP4_ClientAudioStart(nn2);
- MP4_ClientAudioVolume(0xfff0);
- }
- }
- void CClientdemoDlg::OnDbStatic3()
- {
- if (nn3 >=0 )
- {
- MP4_ClientAudioStart(nn3);
- MP4_ClientAudioVolume(0xfff0);
- }
- }
- void CClientdemoDlg::OnDbStatic4()
- {
- if (nn4 >=0 )
- {
- MP4_ClientAudioStart(nn4);
- MP4_ClientAudioVolume(0xfff0);
- }
- }
- BOOL CClientdemoDlg::DestroyWindow()
- {
- return CDialog::DestroyWindow();
- }
- void CClientdemoDlg::OnButton8()
- {
- char filename[256];
- CWnd* pButton1;
- if (nn1 >= 0)
- {
- sprintf(filename,"d:\\mp4test1_%d.mp4",capcount);
- MP4_ClientStartCaptureFile(nn1,filename);
- //MP4_ClientStartCapture(nn1);
- }
- if (nn2 >= 0)
- {
- sprintf(filename,"d:\\mp4test2_%d.mp4",capcount);
- MP4_ClientStartCaptureFile(nn2,filename);
- }
- if (nn3 >= 0)
- {
- sprintf(filename,"d:\\mp4test3_%d.mp4",capcount);
- MP4_ClientStartCaptureFile(nn3,filename);
- }
- if (nn4 >= 0)
- {
- sprintf(filename,"d:\\mp4test4_%d.mp4",capcount);
- MP4_ClientStartCaptureFile(nn4,filename);
- }
- capcount++;
- pButton1 = (CButton*)GetDlgItem(IDC_BUTTON4);
- pButton1->EnableWindow(TRUE);
- pButton1 = (CButton*)GetDlgItem(IDC_BUTTON8);
- pButton1->EnableWindow(FALSE);
- //
- }
- void CClientdemoDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- //
- // char cpos;
- // cpos = (char)(m_playtryl.GetPos());
-
- CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
- }
- HBRUSH CClientdemoDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
- // TODO: Return a different brush if the default is not desired
- if (bmode)
- {
- CWnd*pSubWnd=GetDlgItem(IDC_STATIC5);
- if(pWnd->m_hWnd==pSubWnd->m_hWnd)
- {
- pDC->SetBkColor(RGB(255,0,255));
- HBRUSH hBrush=::CreateSolidBrush(COLORREF(0xff00ff));
- return hBrush;
- }
- }
- return hbr;
- }
- void CClientdemoDlg::OnShowmode2()
- {
- bmode = TRUE;
- GetDlgItem(IDC_STATIC5)->Invalidate(TRUE);
-
- }
- void CClientdemoDlg::OnShowmode1()
- {
- bmode = FALSE;
- GetDlgItem(IDC_STATIC5)->Invalidate(TRUE);
- }
- void CClientdemoDlg::OnButton10()
- {
- g_bCapPic = TRUE;
- }
- void CClientdemoDlg::OnRadiobfram0()
- {
- if (nn1>=0)
- {
- // MP4_ClientThrowBFrame(nn1,0);
- }
- if (nn2>=0)
- {
- // MP4_ClientThrowBFrame(nn2,0);
- }
- if (nn3>=0)
- {
- // MP4_ClientThrowBFrame(nn3,0);
- }
- if (nn4>=0)
- {
- // MP4_ClientThrowBFrame(nn4,0);
- }
-
- }
- void CClientdemoDlg::OnRadiobfram1()
- {
- if (nn1>=0)
- {
- // MP4_ClientThrowBFrame(nn1,1);
- }
- if (nn2>=0)
- {
- // MP4_ClientThrowBFrame(nn2,1);
- }
- if (nn3>=0)
- {
- // MP4_ClientThrowBFrame(nn3,1);
- }
- if (nn4>=0)
- {
- // MP4_ClientThrowBFrame(nn4,1);
- }
-
- }
- void CClientdemoDlg::OnRadiobfram2()
- {
- if (nn1>=0)
- {
- // MP4_ClientThrowBFrame(nn1,2);
- }
- if (nn2>=0)
- {
- // MP4_ClientThrowBFrame(nn2,2);
- }
- if (nn3>=0)
- {
- // MP4_ClientThrowBFrame(nn3,2);
- }
- if (nn4>=0)
- {
- // MP4_ClientThrowBFrame(nn4,2);
- }
-
- }
- void CClientdemoDlg::OnButtonCleanBuffer()
- {
- // clean client buffer
- //if ( nn1 != -1 )
- // MP4_ClientCleanBuffer(nn1,0);
- // clean server buffer
- //if ( nn1 != - 1)
- // MP4_ClientCleanBuffer(nn1,1);
- // clean server/client buffer
- if ( nn1 != -1 )
- MP4_ClientCleanBuffer(nn1,2);
- }
- void CClientdemoDlg::OnSelchangeCombo1()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- m_iWndNum = m_windowCtrl.GetCurSel()+1;
- switch(m_iWndNum) {
- case 1:
- if(nn1 >= 0)
- {
- if(MP4_ClientGetVideoPara(nn1, 0, &m_iBrightness, &m_iContrast, &m_iSaturation, &m_iHue))
- {
- m_brightness.SetPos(m_iBrightness);
- m_contrast.SetPos(m_iContrast);
- m_saturation.SetPos(m_iSaturation);
- m_hue.SetPos(m_iHue);
- return;
- }
- }
- break;
- case 2:
- if(nn2 >= 0)
- {
- if(MP4_ClientGetVideoPara(nn2, 0, &m_iBrightness, &m_iContrast, &m_iSaturation, &m_iHue))
- {
- m_brightness.SetPos(m_iBrightness);
- m_contrast.SetPos(m_iContrast);
- m_saturation.SetPos(m_iSaturation);
- m_hue.SetPos(m_iHue);
- return;
- }
- }
- break;
- case 3:
- if(nn3 >= 0)
- {
- if(MP4_ClientGetVideoPara(nn3, 0, &m_iBrightness, &m_iContrast, &m_iSaturation, &m_iHue))
- {
- m_brightness.SetPos(m_iBrightness);
- m_contrast.SetPos(m_iContrast);
- m_saturation.SetPos(m_iSaturation);
- m_hue.SetPos(m_iHue);
- return;
- }
- }
- break;
- case 4:
- if(nn4 >= 0)
- {
- if(MP4_ClientGetVideoPara(nn4, 0, &m_iBrightness, &m_iContrast, &m_iSaturation, &m_iHue))
- {
- m_brightness.SetPos(m_iBrightness);
- m_contrast.SetPos(m_iContrast);
- m_saturation.SetPos(m_iSaturation);
- m_hue.SetPos(m_iHue);
- return;
- }
- }
- break;
- default:
- break;
- }
- // AfxMessageBox("Get Video Parameter Failed!");
- m_iBrightness = m_iContrast = m_iSaturation = m_iHue = DEFAULTVAL;
- m_brightness.SetPos(DEFAULTVAL);
- m_contrast.SetPos(DEFAULTVAL);
- m_saturation.SetPos(DEFAULTVAL);
- m_hue.SetPos(DEFAULTVAL);
- }
- void CClientdemoDlg::OnReleasedcaptureSlider1(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- m_iBrightness = m_brightness.GetPos();
- SliderContral();
- *pResult = 0;
- }
- void CClientdemoDlg::OnReleasedcaptureSlider2(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- m_iContrast = m_contrast.GetPos();
- SliderContral();
- *pResult = 0;
- }
- void CClientdemoDlg::OnReleasedcaptureSlider3(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- m_iSaturation = m_saturation.GetPos();
- SliderContral();
- *pResult = 0;
- }
- void CClientdemoDlg::OnReleasedcaptureSlider4(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- m_iHue = m_hue.GetPos();
- SliderContral();
- *pResult = 0;
- }
- BOOL CClientdemoDlg::SliderContral()
- {
- switch(m_iWndNum) {
- case 1:
- if(nn1 >= 0)
- {
- if(!MP4_ClientSetVideoPara(nn1, 0, m_iBrightness, m_iContrast, m_iSaturation, m_iHue))
- {
- AfxMessageBox("Set Video Parameter Failed!");
- }
- }
- break;
- case 2:
- if(nn2 >= 0)
- {
- if(!MP4_ClientSetVideoPara(nn2, 0, m_iBrightness, m_iContrast, m_iSaturation, m_iHue))
- {
- AfxMessageBox("Set Video Parameter Failed!");
- }
- }
- break;
- case 3:
- if(nn3 >= 0)
- {
- if(!MP4_ClientSetVideoPara(nn3, 0, m_iBrightness, m_iContrast, m_iSaturation, m_iHue))
- {
- AfxMessageBox("Set Video Parameter Failed!");
- }
- }
- break;
- case 4:
- if(nn4 >= 0)
- {
- if(!MP4_ClientSetVideoPara(nn4, 0, m_iBrightness, m_iContrast, m_iSaturation, m_iHue))
- {
- AfxMessageBox("Set Video Parameter Failed!");
- }
- }
- break;
- default:
- break;
- }
- return TRUE;
- }
- void CClientdemoDlg::OnButtondefault()
- {
- // TODO: Add your control notification handler code here
- m_iBrightness = m_iContrast = m_iSaturation = m_iHue = DEFAULTVAL;
- SliderContral();
- m_brightness.SetPos(m_iBrightness);
- m_contrast.SetPos(m_iContrast);
- m_saturation.SetPos(m_iSaturation);
- m_hue.SetPos(m_iHue);
- }
|