首页 > 代码库 > 视频通讯 demo源码下载
视频通讯 demo源码下载
以下为视频通讯系统中的部分回调函数源码:
具体可以在
http://download.csdn.net/detail/little_rui/7969285
下载
- /**
- * 视频数据回调函数
- */
- void CALLBACK VideoData_CallBack(DWORD dwUserid, LPVOID lpBuf, DWORD dwLen, BITMAPINFOHEADER bmiHeader, LPVOID lpUserValue)
- {
- CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
- if(pDemoDlg)
- pDemoDlg->DrawUserVideo(dwUserid,lpBuf,dwLen,bmiHeader);
- }
- /**
- * 音频数据回调函数
- */
- void CALLBACK AudioData_CallBack(DWORD dwUserid, LPVOID lpBuf, DWORD dwLen, WAVEFORMATEX waveFormatEx, LPVOID lpUserValue)
- {
- CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
- if(pDemoDlg)
- {
- // do something ...
- }
- }
- /**
- * 音量更改回调函数
- */
- void CALLBACK VolumeChange_CallBack(BRAC_AudioDevice device, DWORD dwCurrentVolume, LPVOID lpUserValue)
- {
- CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
- if(pDemoDlg)
- {
- if(device == BRAC_AD_WAVEIN)
- pDemoDlg->OnWaveInVolumeChange(dwCurrentVolume);
- else
- pDemoDlg->OnWaveOutVolumeChange(dwCurrentVolume);
- }
- }
- // 透明通道数据回调函数定义
- void CALLBACK TransBuffer_CallBack(DWORD dwUserid, LPBYTE lpBuf, DWORD dwLen, LPVOID lpUserValue)
- {
- CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
- if(pDemoDlg)
- {
- CString strNotify;
- strNotify.Format("TransBuffer_CallBack:dwUserid-%d, bufSize-%d",dwUserid,dwLen);
- pDemoDlg->AppendLogString(strNotify);
- }
- }
- // 透明通道数据扩展回调函数定义
- void CALLBACK TransBufferEx_CallBack(DWORD dwUserid, LPBYTE lpBuf, DWORD dwLen, DWORD wParam, DWORD lParam, DWORD dwTaskId, LPVOID lpUserValue)
- {
- CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
- if(pDemoDlg)
- {
- BOOL bSuccess = FALSE;
- if(dwLen > 1000)
- {
- bSuccess = lpBuf[1000] == ‘Y‘ ? TRUE : FALSE;
- }
- CString strNotify;
- strNotify.Format("TransBufferEx_CallBack:dwUserid-%d, bufSize-%d,verify:%s",dwUserid,dwLen,bSuccess ? "Success" : "Fail");
- pDemoDlg->AppendLogString(strNotify);
- }
- }
- // 文件传输回调函数定义
- void CALLBACK TransFile_CallBack(DWORD dwUserid, LPCTSTR lpFileName, LPCTSTR lpTempFilePath, DWORD dwFileLength, DWORD wParam, DWORD lParam, DWORD dwTaskId, LPVOID lpUserValue)
- {
- CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
- if(pDemoDlg)
- {
- CString strNotify;
- strNotify.Format("TransFile_CallBack:dwUserid-%d, lpFileName-%s, lpTempFilePath-%s",dwUserid,lpFileName,lpTempFilePath);
- pDemoDlg->AppendLogString(strNotify);
- }
- }
- // 录像、快照任务完成回调函数定义
- void CALLBACK RecordSnapShot_CallBack(DWORD dwUserid, LPCTSTR lpFileName, DWORD dwParam, BOOL bRecordType, LPVOID lpUserValue)
- {
- CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
- if(pDemoDlg)
- {
- CString strNotify;
- strNotify.Format("%s CallBack:dwUserid-%d, FilePathName-%s",bRecordType?"Record":"SnapShot",(int)dwUserid,lpFileName);
- pDemoDlg->AppendLogString(strNotify);
- }
- }
- // SDK Filter 通信数据回调函数定义
- void CALLBACK SDKFilterData_CallBack(LPBYTE lpBuf, DWORD dwLen, LPVOID lpUserValue)
- {
- CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
- if(pDemoDlg)
- {
- CString strNotify;
- strNotify.Format("SDK Filter CallBack:%s",lpBuf);
- pDemoDlg->AppendLogString(strNotify);
- }
- }
- /**
- * 绘制用户视频
- * 数据来源于回调函数
- * @param dwUserid 用户ID号
- * @param lpBuf 视频数据缓冲区
- * @param dwLen 缓冲区大小
- * @param bmiHeader 视频缓冲区的头信息,包含了视频的大小、颜色位数等信息
- */
- void CBRAnyChatSDKDemoDlg::DrawUserVideo(DWORD dwUserid, LPVOID lpBuf, DWORD dwLen, BITMAPINFOHEADER bmiHeader)
- {
- // 根据用户ID号找到合适的显示区域
- DWORD dwSite = -1;
- for(INT i=0; i<DEMO_SHOW_USER_NUM; i++)
- {
- if(m_iUserID[i] == (INT)dwUserid)
- {
- dwSite = i;
- break;
- }
- }
- if(dwSite == -1)
- return;
- CRect dispRect = m_UserRect[dwSite];
- //构建Bitmap
- BITMAPINFOHEADER *lpbmi = (BITMAPINFOHEADER*)malloc(sizeof(BITMAPINFOHEADER)+dwLen);
- ZeroMemory(lpbmi,sizeof(BITMAPINFOHEADER)+dwLen);
- memcpy((LPBYTE)lpbmi,&bmiHeader,sizeof(bmiHeader));
- memcpy(((LPBYTE)lpbmi+sizeof(BITMAPINFOHEADER)),lpBuf,dwLen);
- HDC hdc = ::GetDC(m_hWnd);
- HDC dcMem = ::CreateCompatibleDC(hdc);
- HBITMAP hBitmap = CreateDIBitmap(hdc,lpbmi,CBM_INIT,(LPBYTE)lpbmi+sizeof(BITMAPINFOHEADER),(LPBITMAPINFO)lpbmi,DIB_RGB_COLORS);
- //绘图
- HBITMAP holdbm = (HBITMAP)SelectObject(dcMem,hBitmap);
- ::SetStretchBltMode(hdc,COLORONCOLOR);
- ::StretchBlt(hdc,dispRect.left,dispRect.top,dispRect.Width(),dispRect.Height(),dcMem,0,0,bmiHeader.biWidth,bmiHeader.biHeight,SRCCOPY);
- SelectObject(dcMem,holdbm);
- ::DeleteDC(dcMem);
- ::DeleteObject(hBitmap);
- ::ReleaseDC(m_hWnd,hdc);
- free(lpbmi);
- lpbmi = NULL;
- }
- BOOL CBRAnyChatSDKDemoDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // 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);
- }
- }
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
- // 初始化每个视频显示位置信息
- GetDlgItem(IDC_STATIC_USER0)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_STATIC_USER0)->GetClientRect(m_UserRect[0]);
- GetDlgItem(IDC_STATIC_USER0)->ClientToScreen(m_UserRect[0]);
- ScreenToClient(m_UserRect[0]);
- GetDlgItem(IDC_STATIC_USER1)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_STATIC_USER1)->GetClientRect(m_UserRect[1]);
- GetDlgItem(IDC_STATIC_USER1)->ClientToScreen(m_UserRect[1]);
- ScreenToClient(m_UserRect[1]);
- GetDlgItem(IDC_STATIC_USER2)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_STATIC_USER2)->GetClientRect(m_UserRect[2]);
- GetDlgItem(IDC_STATIC_USER2)->ClientToScreen(m_UserRect[2]);
- ScreenToClient(m_UserRect[2]);
- GetDlgItem(IDC_STATIC_USER3)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_STATIC_USER3)->GetClientRect(m_UserRect[3]);
- GetDlgItem(IDC_STATIC_USER3)->ClientToScreen(m_UserRect[3]);
- ScreenToClient(m_UserRect[3]);
- // 隐藏录像状态标志
- GetDlgItem(IDC_STATIC_RECORDSTATE0)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_STATIC_RECORDSTATE1)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_STATIC_RECORDSTATE2)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_STATIC_RECORDSTATE3)->ShowWindow(SW_HIDE);
- for(INT i=0; i<DEMO_SHOW_USER_NUM; i++)
- {
- m_iUserID[i] = -1;
- }
- m_dwTransTaskId = -1;
- m_iPort = 8906;
- m_iRoomId = 1;
- SetDlgItemText(IDC_IPADDRESS_SERVER,"demo.anychat.cn");
- SetDlgItemText(IDC_EDIT_USERNAME,"AnyChat5");
- UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- }
- void CBRAnyChatSDKDemoDlg::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.
视频通讯 demo源码下载
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。