日期:2014-05-18 浏览次数:21282 次
m_PictureBox = p_PictureBox; m_PictureHandle = p_PictureBox.Handle; CHCNetSDK.NET_DVR_CLIENTINFO lpClientInfo = new CHCNetSDK.NET_DVR_CLIENTINFO(); lpClientInfo.hPlayWnd = IntPtr.Zero; lpClientInfo.lChannel = 1; lpClientInfo.lLinkMode = 0; lpClientInfo.sMultiCastIP = null; this.m_nBagCount = nBagCount; m_Reviewhandle = CHCNetSDK.NET_DVR_RealPlay_V30(m_UserID, ref lpClientInfo, m_RealData, IntPtr.Zero, 1); if (m_Reviewhandle == -1) { nBagCount = -1; uint _Error = CHCNetSDK.NET_DVR_GetLastError(); if (_Error > 0) YTLog.Error("预览视频失败!错误代码为:" + _Error.ToString() + ";错误信息:" + GetErrStr(_Error)); return false; } //播放回调 private void RealDataCallBack(Int32 lRealHandle, UInt32 dwDataType, ref byte pBuffer, UInt32 dwBufSize, IntPtr pUser) { switch (dwDataType) { case CHCNetSDK.NET_DVR_SYSHEAD: if (m_lPort < 0) { if (!HKPlayCtrl.PlayM4_GetPort(ref m_lPort)) { YTLog.Error("获取播放库端口失败!错误代码为:"); } } if (dwBufSize > 0) { if (!HKPlayCtrl.PlayM4_SetStreamOpenMode(m_lPort, HKPlayCtrl.STREAME_REALTIME)) { break; } if (!HKPlayCtrl.PlayM4_OpenStream(m_lPort, ref pBuffer, dwBufSize, 1024 * 1024)) { break; } if (!HKPlayCtrl.PlayM4_SetDisplayBuf(m_lPort, 100)) { break; } //解码回调 if (!HKPlayCtrl.PlayM4_SetDecCallBackEx(m_lPort, m_DECCBFUN, IntPtr.Zero, 0)) { break; } //画图回调 if (!HKPlayCtrl.PlayM4_RegisterDrawFun(m_lPort, m_Play_DrawFun, 0)) { break; } if (!HKPlayCtrl.PlayM4_Play(m_lPort, m_PictureHandle)) { break; } if (!HKPlayCtrl.PlayM4_SetOverlayMode(m_lPort, 0, 0/* COLORREF(0)*/))//play off screen // todo!!! { break; } } break; case CHCNetSDK.NET_DVR_STREAMDATA: // video stream data if (dwBufSize > 0 && m_lPort != -1) { for (int i = 0; i < 10; ++i) { if (HKPlayCtrl.PlayM4_InputData(m_lPort, ref pBuffer, dwBufSize)) { break; } Thread.Sleep(5); } //while (HKPlayCtrl.PlayM4_InputData(m_lPort, ref pBuffer, dwBufSize) == false) //{ // Thread.Sleep(5); //} } break; default: break; }