/// <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) { 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> public void Close() { try { aVcommunicationEx1.closeCommunication(); } catch (Exception) { } try { aVcommunicationEx1.sockUDP1.CloseSock(); } catch (Exception) { } if (this.VC != null) { if (VC != null) { VC.Close(); VC = null; } } if (VR!=null) { VR = null; } if (VE!=null) { VE.Close(); VE = null; } if (VD!=null) { VD.Close(); VD = null; } if (AC!=null) { AC = null; } if (AR!=null) { AR = null; } if (AE!=null) { AE = null; } }