AnyChat技术支持论坛
标题:
视频数据回调函数
[打印本页]
作者:
hk92
时间:
2015-12-13 11:13
标题:
视频数据回调函数
您好,能举个例子说明怎样通过客户端回调函数得到输出用户原始的视频采样帧数据YUV吗?
作者:
佰锐科技-李永星
时间:
2015-12-13 11:53
您好,请您参考视频回调API的说明,
/**
* 视频数据扩展回调(增加时间戳)
* @param dwUserid 用户ID号
* @param lpBuf 视频数据缓冲区
* @param dwLen 缓冲区大小
* @param bmiHeader 视频缓冲区的头信息,包含了视频的大小、颜色位数等信息
* @param dwTimeStamp 时间戳
*/
void CALLBACK OnAnyChatVideoDataExCallBack(DWORD dwUserid, LPVOID lpBuf, DWORD dwLen, BITMAPINFOHEADER bmiHeader, DWORD dwTimeStamp, LPVOID lpUserValue)
{
TRACE("VideoDataExCallBack: userid:%d, timestamp:%d\r\n", (int)dwUserid, dwTimeStamp);
CAnyChatInputVideoDlg* lpDlg = (CAnyChatInputVideoDlg*)lpUserValue;
CRect dispRect;
HWND hWnd;
if(lpDlg->m_dwRemoteUserId == dwUserid && dwUserid != -1) // 远程用户
{
hWnd = lpDlg->GetDlgItem(IDC_STATIC_REMOTEVIDEO)->GetSafeHwnd();
lpDlg->GetDlgItem(IDC_STATIC_REMOTEVIDEO)->GetClientRect(dispRect);
}
else // 本地用户
{
hWnd = lpDlg->GetDlgItem(IDC_STATIC_LOCALVIDEO)->GetSafeHwnd();
lpDlg->GetDlgItem(IDC_STATIC_LOCALVIDEO)->GetClientRect(dispRect);
}
//构建Bitmap
BITMAPINFOHEADER *lpbmi = (BITMAPINFOHEADER*)malloc(sizeof(BITMAPINFOHEADER)+dwLen);
ZeroMemory(lpbmi,sizeof(BITMAPINFOHEADER)+dwLen);
memcpy((LPBYTE)lpbmi,&bmiHeader,sizeof(BITMAPINFOHEADER));
memcpy(((LPBYTE)lpbmi+sizeof(BITMAPINFOHEADER)),lpBuf,dwLen);
HDC hdc = ::GetDC(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(hWnd,hdc);
free(lpbmi);
lpbmi = NULL;
}
复制代码
欢迎光临 AnyChat技术支持论坛 (http://bbs.anychat.cn/)
Powered by Discuz! X3