1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348 |
- // 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);
- }
|