/// <summary> /// 视频双击放大缩小视频 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pic_MouseDoubleClick(object sender, MouseEventArgs e) { UCVideo video = sender as UCVideo; if (video != null) { if (video.VideoHandle >= 0) { if (video.Width < this.pnlVideo.Width) { video.Width = this.pnlVideo.Width; video.Height = this.pnlVideo.Height; video.Location = new Point(0, 0); int channel = Convert.ToInt32(video.Tag); //this.cmbYTChannel.Text = (channel + 1).ToString(); //this.cmbBZChannel.Text = (channel + 1).ToString(); foreach (Control ctrl in this.pnlVideo.Controls) { if (ctrl.GetType() == typeof(UCVideo)) { if (video.Tag != ctrl.Tag) { ctrl.Visible = false; } } } } else { JudgeVideo(this.pnlVideo, CameraCount); } } } }
/// <summary> /// 视频单击切换焦点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pic_MouseClick(object sender, MouseEventArgs e) { UCVideo videoWindow = sender as UCVideo; if (videoWindow != null) { int intWindIndex = Convert.ToInt32(videoWindow.Tag); //this.cmbYTChannel.Text = (intWindIndex + 1).ToString(); //this.cmbBZChannel.Text = (intWindIndex + 1).ToString(); ActivateVideo(listVideo, intWindIndex); } }
/// <summary> /// 关闭当前播放视频 /// </summary> private void CloseVideo(object sender) { UCVideo videoWindow = sender as UCVideo; if (videoWindow != null) { int intWindIndex = Convert.ToInt32(videoWindow.Tag); if (videoWindow.VideoHandle >= 0) { CHCNetSDK.NET_DVR_StopRealPlay(videoWindow.VideoHandle); videoWindow.VideoHandle = -1; } } }
private void PlayBackMouseDown(object sender, MouseEventArgs e) { if (CurVideo.CameraType == 4) { UCVideo video = sender as UCVideo; //int tag = Convert.ToInt32(video.Tag); EaglePalyBackVideo = video; m_strPlayBackPoint.x = (e.X - video.Pic.Left); m_strPlayBackPoint.y = (e.Y - video.Pic.Top); m_bEagleMoved = true; video.Focus(); video.Pic.Focus(); //ucVideoPlayBack.Focus(); } }
/// <summary> /// 激活视频 /// </summary> /// <param name="videoindex"></param> public void ActivateVideo(List <UCVideo> listvideo, int videoindex) { foreach (UCVideo video in listvideo) { if (Convert.ToInt16(video.Tag) == videoindex) {//激活 CurVideo = video; video.SetBorderColor(true); if (e_SelChannel != null) { e_SelChannel(video.ChannelNo); } } else { video.SetBorderColor(false); } } }
public void CalcVideoSizeAndPos(Control pan, int rowcount, int colcount) { int XPos1 = 0, YPos1 = 0; foreach (Control ctrl in pan.Controls) { if (ctrl.GetType() == typeof(UCVideo)) { UCVideo video = ctrl as UCVideo; video.Visible = true; int width = pan.Width, height = pan.Height; video.Width = width / colcount; video.Height = height / rowcount; int picTag = Convert.ToInt32(video.Tag); XPos1 = (picTag % colcount) * video.Width; YPos1 = (picTag / colcount) * video.Height; video.Location = new Point(XPos1, YPos1); } } }
private void PlayBack_e_EagleModeChange(UCVideo video) { int tag = Convert.ToInt32(video.Tag); if (m_PlayBackPort >= 0) { PlayCtrl.PLAYM4SRMODELMODE struParam = new PlayCtrl.PLAYM4SRMODELMODE(); struParam.emTextureMode = (uint)PlayCtrl.PLAYM4SRTEXTUREMODE.PLAYM4_TEXTURE_DOUBLE; struParam.ulDisplayType = PlayCtrl.PLAYM4_MODEL_SOLID; struParam.nTransformMode = 0; struParam.emModelType = (uint)PlayCtrl.PLAYM4SRMODELTYPE.PLAYM4_MODELTYPE_EAGLE_EYE; struParam.bModelMode = video.IsQJVideo; // true是碗装,false是块状 int dwSize = Marshal.SizeOf(struParam); IntPtr ptrDeviceCfg = Marshal.AllocHGlobal(dwSize); Marshal.StructureToPtr(struParam, ptrDeviceCfg, false); if (!PlayCtrl.PlayM4_SR_SetConfig(m_PlayBackPort, PlayCtrl.CFG_DISPLAY_MODEL_MODE, ptrDeviceCfg)) { Marshal.FreeHGlobal(ptrDeviceCfg); } } }
private void MouseDown(object sender, MouseEventArgs e) { UCVideo video = sender as UCVideo; int tag = Convert.ToInt32(video.Tag); int channelno = video.ChannelNo; if (dicChannelType.ContainsKey(channelno)) { if (dicChannelType[channelno] == EnumChannelType.EagleChannel) { EagleVideo = video; } else { EagleVideo = null; return; } } m_strPrePoint.x = (e.X - video.Pic.Left); m_strPrePoint.y = (e.Y - video.Pic.Top); m_bMoved = true; video.Focus(); }
/// <summary> /// 初始化视频图像句柄 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InitVideo(object sender, EventArgs e) { try { //DoubleBuffPanel pic = sender as DoubleBuffPanel; //if (pic != null) { //int videoCount = Convert.ToInt32(pic.Tag); int videoCount = Configurations.CameraCount; CameraCount = videoCount; m_lRealHandle = new int[CameraCount]; m_Channel = new int[CameraCount]; for (int i = 0; i < m_Channel.Length; i++) { m_Channel[i] = -1; } m_ptrRealHandle = new IntPtr[CameraCount]; for (int j = 0; j < videoCount; j++) { int channelno = j + StartDChan; m_lRealHandle[j] = -1; UCVideo video = new UCVideo(); video.Tag = j.ToString(); video.ChannelNo = j + StartDChan; video.Name = "PlayWnd" + (j + 1).ToString(); video.Pic.ContextMenuStrip = null; if (dicChannelType.ContainsKey(channelno)) { if (dicChannelType[channelno] == EnumChannelType.EagleChannel) {//鹰眼 //video.SetBorderColor(true); video.CameraType = 4; video.MouseDown += MouseDown; video.MouseUp += MouseUp; video.MouseMove += MouseMove; video.MouseWheel += MouseWheel; video.e_EagleModeChange += video_e_EagleModeChange; } else { video.CameraType = 0; } } else { video.CameraType = 0; } video.e_CloseVideo += CloseVideo; video.e_CapturePic += CapturePic; video.MouseClick += pic_MouseClick; video.MouseDoubleClick += pic_MouseDoubleClick; m_ptrRealHandle[j] = video.Pic.Handle; listVideo.Add(video); this.pnlVideo.Controls.Add(video); } JudgeVideo(this.pnlVideo, videoCount); } } catch (Exception ex) { //TXTWriteHelper.WriteException("InitVideo"+ex.ToString()); } }
private void PreviewVideo() { try { int channel = 0; //IntPtr picHandle = new IntPtr(); //picHandle = IntPtr.Zero; m_StreamPlayMode = 0; if (dicRealHandlerChannel != null && dicRealHandlerChannel.Count > 0) { dicRealHandlerChannel.Clear(); } foreach (Control ctrl in this.pnlVideo.Controls) { //if (Convert.ToInt16(ctrl.Tag) == 0) { if (ctrl.GetType() == typeof(UCVideo)) { int tag = Convert.ToInt32(ctrl.Tag); //if (tag > 0) // return; //if (tag == 0) { m_Channel[tag] = -1; if (m_lRealHandle[tag] < 0) { channel = tag + StartDChan; UCVideo RealPlayWnd = ctrl as UCVideo; CHCNetSDK.NET_DVR_PREVIEWINFO lpPreviewInfo = new CHCNetSDK.NET_DVR_PREVIEWINFO(); //lpPreviewInfo.hPlayWnd = RealPlayWnd.Pic.Handle;//预览窗口 利用回调播放库显示视频 lpPreviewInfo.lChannel = channel;//预te览的设备通道 //if(QJChannel!=null && QJChannel.Contains((channel%StartDChan+1).ToString())) // lpPreviewInfo.dwStreamType = 0;//码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推 //else // lpPreviewInfo.dwStreamType = 1; lpPreviewInfo.hPlayWnd = IntPtr.Zero; lpPreviewInfo.DisplayBufNum = 6; lpPreviewInfo.dwStreamType = 0; //初始预览用子码流 放大的时候用主码流 lpPreviewInfo.dwLinkMode = 0; //连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4-RTP/RTSP,5-RSTP/HTTP lpPreviewInfo.bBlocked = true; //0- 非阻塞取流,1- 阻塞取流 RealPlayWnd.HikPreViewInfo = lpPreviewInfo; RealPlayWnd.LUserID = m_lUserID; m_RealDataCallBack[tag] = new CHCNetSDK.REALDATACALLBACK(RealDataCallBack); //预览实时流回调函数 IsCallBack = true; IntPtr pUser = new IntPtr(); //用户数据 //打开预览 Start live view m_lRealHandle[tag] = CHCNetSDK.NET_DVR_RealPlay_V40(m_lUserID, ref lpPreviewInfo, m_RealDataCallBack[tag], pUser); if (!dicRealHandlerChannel.ContainsKey(m_lRealHandle[tag])) { dicRealHandlerChannel.Add(m_lRealHandle[tag], channel); } else { dicRealHandlerChannel[m_lRealHandle[tag]] = channel; } RealPlayWnd.VideoHandle = m_lRealHandle[tag]; //if (!dicPreviewInfo.ContainsKey(tag)) // dicPreviewInfo.Add(tag, lpPreviewInfo); //预览视频信息 if (m_lRealHandle[tag] < 0) {//预览失败 } else { //预览成功 IsPreviewing = true; //正在预览 } } else { } } } } } if (IsPreviewing == true) { this.pnlPreview.BackgroundImage = global::ToolsManage.Properties.Resources.停止; } } catch (Exception ex) { TXTWriteHelper.WriteException("UCHikVideo-PreviewVideo-" + ex.ToString()); } }
private void video_e_EagleModeChange(UCVideo video) { int tag = Convert.ToInt32(video.Tag); if (m_Channel[tag] >= 0) { PlayCtrl.PLAYM4SRMODELMODE struParam = new PlayCtrl.PLAYM4SRMODELMODE(); struParam.emTextureMode = (uint)PlayCtrl.PLAYM4SRTEXTUREMODE.PLAYM4_TEXTURE_DOUBLE; struParam.ulDisplayType = PlayCtrl.PLAYM4_MODEL_SOLID; struParam.nTransformMode = 0; struParam.emModelType = (uint)PlayCtrl.PLAYM4SRMODELTYPE.PLAYM4_MODELTYPE_EAGLE_EYE; struParam.bModelMode = video.IsQJVideo; // true是碗装,false是块状 int dwSize = Marshal.SizeOf(struParam); IntPtr ptrDeviceCfg = Marshal.AllocHGlobal(dwSize); Marshal.StructureToPtr(struParam, ptrDeviceCfg, false); if (!PlayCtrl.PlayM4_SR_SetConfig(m_Channel[tag], PlayCtrl.CFG_DISPLAY_MODEL_MODE, ptrDeviceCfg)) { Marshal.FreeHGlobal(ptrDeviceCfg); } } //if (tag >= 0) //{ // //先关闭预览 // if (m_Channel[tag] != -1) // { // if (!PlayCtrl.PlayM4_FEC_Disable(m_Channel[tag])) // { // iLastErr = PlayCtrl.PlayM4_GetLastError(m_Channel[tag]); // } // if (!PlayCtrl.PlayM4_Stop(m_Channel[tag])) // { // iLastErr = PlayCtrl.PlayM4_GetLastError(m_Channel[tag]); // } // if (!PlayCtrl.PlayM4_CloseStream(m_Channel[tag])) // { // iLastErr = PlayCtrl.PlayM4_GetLastError(m_Channel[tag]); // } // if (!PlayCtrl.PlayM4_CloseFile(m_Channel[tag])) // { // iLastErr = PlayCtrl.PlayM4_GetLastError(m_Channel[tag]); // } // if (!PlayCtrl.PlayM4_FreePort(m_Channel[tag])) // { // iLastErr = PlayCtrl.PlayM4_GetLastError(m_Channel[tag]); // } // m_Channel[tag] = -1; // } // if (m_lRealHandle[tag] >= 0) // { // bool isok= CHCNetSDK.NET_DVR_StopRealPlay(m_lRealHandle[tag]); // m_lRealHandle[tag] = -1; // m_RealDataCallBack[tag] = null; // } // IsEagleQJ = video.IsQJVideo; // //重新打开预览 // int channel = tag + StartDChan; // CHCNetSDK.NET_DVR_PREVIEWINFO lpPreviewInfo = new CHCNetSDK.NET_DVR_PREVIEWINFO(); // //lpPreviewInfo.hPlayWnd = RealPlayWnd.Pic.Handle;//预览窗口 利用回调播放库显示视频 // lpPreviewInfo.lChannel = channel;//预te览的设备通道 // //if(QJChannel!=null && QJChannel.Contains((channel%StartDChan+1).ToString())) // // lpPreviewInfo.dwStreamType = 0;//码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推 // //else // // lpPreviewInfo.dwStreamType = 1; // lpPreviewInfo.dwStreamType = 0; //初始预览用子码流 放大的时候用主码流 // lpPreviewInfo.dwLinkMode = 0;//连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4-RTP/RTSP,5-RSTP/HTTP // lpPreviewInfo.bBlocked = true; //0- 非阻塞取流,1- 阻塞取流 // video.HikPreViewInfo = lpPreviewInfo; // video.LUserID = m_lUserID; // m_RealDataCallBack[tag] = new CHCNetSDK.REALDATACALLBACK(RealDataCallBack);//预览实时流回调函数 // IsCallBack = true; // IntPtr pUser = new IntPtr();//用户数据 // //打开预览 Start live view // m_lRealHandle[tag] = CHCNetSDK.NET_DVR_RealPlay_V40(m_lUserID, ref lpPreviewInfo, m_RealDataCallBack[tag], pUser); // video.VideoHandle = m_lRealHandle[tag]; // //if (!dicPreviewInfo.ContainsKey(tag)) // // dicPreviewInfo.Add(tag, lpPreviewInfo); //预览视频信息 // if (m_lRealHandle[tag] < 0) // {//预览失败 // } // else // {//预览成功 // } //} }