/// <summary> /// 设置对方视频位图信息,构造解码器 /// </summary> /// <param name="bitmapinfo"></param> public void SetVideoBitmapinfo(IMLibrary.AV.BITMAPINFO bitmapinfo) { if (AVC != null) { AVC.SetRemoteBITMAPINFOHEADER(bitmapinfo); } }
/// <summary> /// 设置对方视频位图信息,以便构造解码器 /// </summary> /// <param name="msg"></param> public void SetVideoBitmapinfo(IMLibrary3.Protocol.AVMsg msg) { IMLibrary.AV.BITMAPINFO bitmapinfo = new IMLibrary.AV.BITMAPINFO(); bitmapinfo.bmiHeader.biBitCount = msg.biBitCount; bitmapinfo.bmiHeader.biClrImportant = msg.biClrImportant; bitmapinfo.bmiHeader.biClrUsed = msg.biClrUsed; bitmapinfo.bmiHeader.biCompression = msg.biCompression; bitmapinfo.bmiHeader.biHeight = msg.biHeight; bitmapinfo.bmiHeader.biPlanes = msg.biPlanes; bitmapinfo.bmiHeader.biSize = msg.biSize; bitmapinfo.bmiHeader.biSizeImage = msg.biSizeImage; bitmapinfo.bmiHeader.biWidth = msg.biWidth; bitmapinfo.bmiHeader.biXPelsPerMeter = msg.biXPelsPerMeter; bitmapinfo.bmiHeader.biYPelsPerMeter = msg.biYPelsPerMeter; video1.SetVideoBitmapinfo(bitmapinfo); }
//视频位图信息捕获事件 void video1_VideoCapturerBefore(object sender, IMLibrary.AV.BITMAPINFO bitmapinfo) { IMLibrary3.Protocol.AVMsg msg = new IMLibrary3.Protocol.AVMsg(); msg.type = IMLibrary3.Protocol.type.Else;//其他信息 msg.biBitCount = bitmapinfo.bmiHeader.biBitCount; msg.biClrImportant = bitmapinfo.bmiHeader.biClrImportant; msg.biClrUsed = bitmapinfo.bmiHeader.biClrUsed; msg.biCompression = bitmapinfo.bmiHeader.biCompression; msg.biHeight = bitmapinfo.bmiHeader.biHeight; msg.biPlanes = bitmapinfo.bmiHeader.biPlanes; msg.biSize = bitmapinfo.bmiHeader.biSize; msg.biSizeImage = bitmapinfo.bmiHeader.biSizeImage; msg.biWidth = bitmapinfo.bmiHeader.biWidth; msg.biXPelsPerMeter = bitmapinfo.bmiHeader.biXPelsPerMeter; msg.biYPelsPerMeter = bitmapinfo.bmiHeader.biYPelsPerMeter; if (SendMsgToUser != null)//触发消息发送事件 { SendMsgToUser(msg, User); } }
/// <summary> /// 开始视频捕获 /// </summary> private void StartVideoCapture() { ///先将本地视频初始化为CapturerSize的高与宽 this.vCapturer = new IMLibrary.AV.VideoCapturer(this.panel, 0); this.vCapturer.ConnectDevice(); IMLibrary.AV.CaptureParms cp = this.vCapturer.CaptureParms; cp.fAbortLeftMouse = cp.fAbortRightMouse = false; cp.fYield = true; this.vCapturer.CaptureParms = cp; IMLibrary.AV.BITMAPINFO h = this.vCapturer.BITMAPINFO; //如果当前摄像头不为CapturerSize,先将本地视频初始化为CapturerSize if (!(h.bmiHeader.biWidth == this.CapturerSize.Width && h.bmiHeader.biHeight == this.CapturerSize.Height)) { h.bmiHeader.biWidth = this.CapturerSize.Width; h.bmiHeader.biHeight = this.CapturerSize.Height; this.vCapturer.BITMAPINFO = h; } this.vCapturer.VideoCaptured += new VideoCaptureEventHandler(vc_VideoCaptured); this.vCapturer.SetPreviewRate(11); this.vCapturer.Preview = true; this.vCapturer.CaptureWithOutFile(); this.bitmapInfo = vCapturer.BITMAPINFO; if (this.VideoCapturerBefore != null) { this.VideoCapturerBefore(this, new VideoCapturedEventArgs(this.bitmapInfo));//触发视频捕获前事件 } //Console.WriteLine("biSize:" + bitmapInfo.bmiHeader.biSize.ToString() + " biSizeImage:" + bitmapInfo.bmiHeader.biSizeImage.ToString() // + " biBitCount:" + bitmapInfo.bmiHeader.biBitCount.ToString() + " biWidth:" + bitmapInfo.bmiHeader.biWidth.ToString() // + " biHeight:" + bitmapInfo.bmiHeader.biHeight.ToString() // + " biClrUsed:" + bitmapInfo.bmiHeader.biClrUsed.ToString() + " biClrImportant:" + bitmapInfo.bmiHeader.biClrImportant.ToString() // + " biXPelsPerMeter:" + bitmapInfo.bmiHeader.biXPelsPerMeter.ToString() + " biYPelsPerMeter:" + bitmapInfo.bmiHeader.biYPelsPerMeter.ToString() // + " biPlanes:" + bitmapInfo.bmiHeader.biPlanes.ToString() + " biCompression:" + bitmapInfo.bmiHeader.biCompression.ToString()); IniVideoRender(); }