//捕获视频回调
        private void VideoDataCaptureCallBack(UInt64 time, IntPtr data, UInt32 size, UInt32 width, UInt32 height, string json_extension)
        {
            Action action = () =>
            {
                MainForm.VideoFrame frame = new MainForm.VideoFrame(data, (int)width, (int)height, (int)size, (long)time);
                ShowVideoFrame(_multiVChatFormGraphics_pb01, pb_multivchat_01.Width, pb_multivchat_01.Height, frame);
            };

            this.Invoke(action);
        }
Beispiel #2
0
 //收到视频帧回调函数
 private static void VideoDataRecHandler(UInt64 time, IntPtr data, UInt32 size, UInt32 width, UInt32 height, string json_extension)
 {
     MainForm.VideoFrame frame = new MainForm.VideoFrame(data, (int)width, (int)height, (int)size, (long)time);
     try
     {
         if (ReceiveVideoFrameHandler != null)
         {
             ReceiveVideoFrameHandler(_ownerFriendsListForm, new MainForm.VideoEventAgrs(frame));
         }
     }
     catch
     {
         return;
     }
 }
        //收到视频数据回调
        private void VideoDataReceiveCallBack(UInt64 time, IntPtr data, UInt32 size, UInt32 width, UInt32 height, string json_extension)
        {
            MainForm.VideoFrame frame = new MainForm.VideoFrame(data, (int)width, (int)height, (int)size, (long)time);
            string account            = ParseCbJsonExtension(json_extension);

            if (_multichatlist.Keys.Contains(account))
            {
                Debug.Assert(_multichatlist[account] != null);
                Action action = () =>
                {
                    ShowVideoFrame(_multichatlist[account], pb_multivchat_02.Width, pb_multivchat_02.Height, frame);
                };
                this.Invoke(action);
            }
            else
            {
                if (_multichatlist.Count < 4)
                {
                    Graphics g = null;
                    //if (!_multichatlist.Values.Contains(_multiVChatFormGraphics_pb01))
                    //{
                    //    g = _multiVChatFormGraphics_pb01;
                    //}
                    //else
                    if (!_multichatlist.Values.Contains(_multiVChatFormGraphics_pb02))
                    {
                        g = _multiVChatFormGraphics_pb02;
                    }
                    else if (!_multichatlist.Values.Contains(_multiVChatFormGraphics_pb03))
                    {
                        g = _multiVChatFormGraphics_pb03;
                    }
                    else if (!_multichatlist.Values.Contains(_multiVChatFormGraphics_pb04))
                    {
                        g = _multiVChatFormGraphics_pb04;
                    }
                    if (g != null)
                    {
                        _multichatlist.Add(account, g);
                        Action action = () =>
                        {
                            ShowVideoFrame(_multichatlist[account], pb_multivchat_02.Width, pb_multivchat_02.Height, frame);
                        };
                        this.Invoke(action);
                    }
                }
            }
        }
        public void ShowVideoFrame(MainForm.VideoFrame frame)
        {
            int w = pb_livingstream.Width;
            int h = pb_livingstream.Height;

            graphics.CompositingMode    = CompositingMode.SourceCopy;
            graphics.CompositingQuality = CompositingQuality.Default;
            var    stream = frame.GetBmpStream();
            Bitmap img    = new Bitmap(stream);
            //等比例缩放
            float sa        = (float)w / frame.Width;
            float sb        = (float)h / frame.Height;
            var   scale     = Math.Min(sa, sb);
            var   newWidth  = frame.Width * scale;
            var   newHeight = frame.Height * scale;

            stream.Dispose();
            graphics.DrawImage(img, new Rectangle((int)(w - newWidth) / 2, (int)(h - newHeight) / 2, (int)newWidth, (int)newHeight),
                               new Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel);
            img.Dispose();
        }
Beispiel #5
0
 public VideoEventAgrs(VideoFrame frame)
 {
     Frame = frame;
 }