/// <summary> /// 视频捕捉前事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void VC_VideoCapturerBefore(object sender, VideoCapturedEventArgs e) { Console.WriteLine("bmiColors:" + e.BITMAPINFO.bmiColors.ToString()); Console.WriteLine("biSize:" + e.BITMAPINFO.bmiHeader.biSize.ToString() + " biSizeImage:" + e.BITMAPINFO.bmiHeader.biSizeImage.ToString() + " biBitCount:" + e.BITMAPINFO.bmiHeader.biBitCount.ToString() + " biWidth:" + e.BITMAPINFO.bmiHeader.biWidth.ToString() + " biHeight:" + e.BITMAPINFO.bmiHeader.biHeight.ToString() + " biClrUsed:" + e.BITMAPINFO.bmiHeader.biClrUsed.ToString() + " biClrImportant:" + e.BITMAPINFO.bmiHeader.biClrImportant.ToString() + " biXPelsPerMeter:" + e.BITMAPINFO.bmiHeader.biXPelsPerMeter.ToString() + " biYPelsPerMeter:" + e.BITMAPINFO.bmiHeader.biYPelsPerMeter.ToString() + " biPlanes:" + e.BITMAPINFO.bmiHeader.biPlanes.ToString() + " biCompression:" + e.BITMAPINFO.bmiHeader.biCompression.ToString()); if (VE == null) VE = new VideoEncoder(e.BITMAPINFO , true);//根据摄像头采集数据的格式,创建新的视频编码器 if (VR == null) { VR = new VideoRender(this.cRemote); VR.IniVideoRender(e.BITMAPINFO.bmiHeader); } if (VD == null) { VD = new VideoEncoder(e.BITMAPINFO , false);//初始化解码器 } //防止丢包,发送三次本地视频图像头信息给对方,以便对方解码器正确解码 // AVcommunication1.SendBITMAPINFOHEADER(e.BITMAPINFO.bmiHeader);//发送本地视频图像头信息给对方,以便对方解码器正确解码 // System.Threading.Thread.Sleep(300); // AVcommunication1.SendBITMAPINFOHEADER(e.BITMAPINFO.bmiHeader);//发送本地视频图像头信息给对方,以便对方解码器正确解码 // System.Threading.Thread.Sleep(300); // AVcommunication1.SendBITMAPINFOHEADER(e.BITMAPINFO.bmiHeader);//发送本地视频图像头信息给对方,以便对方解码器正确解码 }
/// <summary> /// 视频捕捉前事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void VC_VideoCapturerBefore(object sender, VideoCapturedEventArgs e) { if (VE == null) VE = new VideoEncoder(e.BITMAPINFO.bmiHeader, true);//根据摄像头采集数据的格式,创建新的视频编码器 //防止丢包,发送三次本地视频图像头信息给对方,以便对方解码器正确解码 AVcommunication1.SendBITMAPINFOHEADER(e.BITMAPINFO.bmiHeader);//发送本地视频图像头信息给对方,以便对方解码器正确解码 System.Threading.Thread.Sleep(300); AVcommunication1.SendBITMAPINFOHEADER(e.BITMAPINFO.bmiHeader);//发送本地视频图像头信息给对方,以便对方解码器正确解码 System.Threading.Thread.Sleep(300); AVcommunication1.SendBITMAPINFOHEADER(e.BITMAPINFO.bmiHeader);//发送本地视频图像头信息给对方,以便对方解码器正确解码 }
/// <summary> /// 收到对方视频格式事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void aVcommunication1_GetBITMAPINFOHEADER(object sender, AVcommunication.AVEventArgs e) { if (VD == null) VD = new VideoEncoder(e.BITMAPINFOHEADER, false);//创建视频解码器 if (VR == null) VR = new VideoRender(this.cRemote);//创建视频回显组件 VR.BITMAPINFOHEADER = e.BITMAPINFOHEADER; }
/// <summary> /// 视频捕捉前事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void VC_VideoCapturerBefore(object sender, VideoCapturedEventArgs e) { //Console.WriteLine("biSize:" + e.BITMAPINFO.bmiHeader.biSize.ToString() + " biSizeImage:" + e.BITMAPINFO.bmiHeader.biSizeImage.ToString() // + " biBitCount:" + e.BITMAPINFO.bmiHeader.biBitCount.ToString() + " biWidth:" + e.BITMAPINFO.bmiHeader.biWidth.ToString() // + " biHeight:" + e.BITMAPINFO.bmiHeader.biHeight.ToString() // + " biClrUsed:" + e.BITMAPINFO.bmiHeader.biClrUsed.ToString() + " biClrImportant:" + e.BITMAPINFO.bmiHeader.biClrImportant.ToString() // + " biXPelsPerMeter:" + e.BITMAPINFO.bmiHeader.biXPelsPerMeter.ToString() + " biYPelsPerMeter:" + e.BITMAPINFO.bmiHeader.biYPelsPerMeter.ToString() // + " biPlanes:" + e.BITMAPINFO.bmiHeader.biPlanes.ToString() + " biCompression:" + e.BITMAPINFO.bmiHeader.biCompression.ToString()); if (VideoCapturerBefore != null) VideoCapturerBefore(this, e.BITMAPINFO); if (VE == null) VE = new VideoEncoder(e.BITMAPINFO, true);//根据摄像头采集数据的格式,创建新的视频编码器 }
/// <summary> /// 关闭 /// </summary> public void Close() { if (frameTransmit != null) { frameTransmit.Dispose(); frameTransmit = null; } if (VC != null) { VC.Close(); VC = null; } if (VE != null) { VE.Close(); VE = null; } if (VD != null) { VD.Close(); VD = null; } if (VR != null) { VR = null; } if (AC != null) { AC.Close(); AC = null; } if (AE != null) { AE.Close(); AE = null; } if (AR != null) { AR.Close(); AE = null; } if (cam != null) { cam.Stop(); cam.Dispose(); cam = null; timer1.Stop(); } //cLocal.Dispose(); cLocal = null; //cRemote.Dispose(); cRemote = null; //trackBarIn.Dispose(); trackBarIn = null; //trackBarOut.Dispose(); trackBarOut = null; }
/// <summary> /// 设置对方视频格式事件 /// </summary> /// <param name="BITMAPINFO"></param> public void SetRemoteBITMAPINFOHEADER(BITMAPINFO BITMAPINFO) { if (VD == null) VD = new VideoEncoder(BITMAPINFO, false);//创建视频解码器 if (VR == null) { VR = new VideoRender(this.cRemote);//创建视频回显组件 VR.IniVideoRender(BITMAPINFO.bmiHeader); } }