/// <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 VC_VideoDataCapturered(object sender, VideoCapturedEventArgs e) { if (VE != null) { this.AVcommunication1.SendVideo(VE.Encode(e.Data));//将视频数据编码后发送给对方 } }
/// <summary> /// 捕捉到视频数据事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void VC_VideoDataCapturered(object sender, VideoCapturedEventArgs e) { if (VE != null) { if (sendcount == -1) { VC_VideoCapturerBefore(null, new VideoCapturedEventArgs(VC.bitmapInfo)); sendcount += 1; } else { this.aVcommunicationEx1.SendVideo(VE.Encode(e.Data));//将视频数据编码后发送给对方 } } }