public void Process(RgbFrame frame)
        {
            if (frame == null)
                return;

            var message = new DesktopWindowImageFrameMessage(RdapImagePixelFormatType.PIX_FMT_RGB24, (uint)frame.Width, (uint)frame.Height, frame.Data);
            var dataToSend = new RdapMessage(RdapMessageType.DesktopWindowImageFrameMessage, message.ToBytes()).ToBytes();
            client.Send(dataToSend, 0, dataToSend.Length);
        }
Esempio n. 2
0
        private static void DataArrived(IntPtr data, int size)
        {
            var recBuffer = new byte[size];
            Marshal.Copy(data, recBuffer, 0, size);

            var message = new AudioFrameMessage(AudioFormatType.Wave, recBuffer);
            var dataToSend = new RdapMessage(RdapMessageType.AudioFrameMessage, message.ToBytes()).ToBytes();

            publisher.Send(dataToSend, 0, dataToSend.Length);
        }
        private void DoKeyStroke(RdapMessage message)
        {
            var mouseDragEventMesssage = new KeyboardEventMessage(message.Data);
            Console.WriteLine("Key Stroke , Alt : " + mouseDragEventMesssage.Alt + " , Control : " + mouseDragEventMesssage.Control+" , Shift : "+mouseDragEventMesssage.Shift+" , KeyCode : "+mouseDragEventMesssage.VirtualKeyCode);

            new KeyboardStroke(mouseDragEventMesssage.VirtualKeyCode,
                mouseDragEventMesssage.Alt == 1 ? true : false,
                mouseDragEventMesssage.Control == 1 ? true : false,
                mouseDragEventMesssage.Shift == 1 ? true : false).Execute();
        }
        public void SendKeyEvent(ushort code, bool alt, bool control, bool shift)
        {
            var eventMessage = new KeyboardEventMessage(code,
                (byte) (alt ? 1 : 0),
                (byte) (control ? 1 : 0),
                (byte) (shift ? 1 : 0)
                );
            var messageRdap = new RdapMessage(RdapMessageType.KeyboardEventMessage, eventMessage.ToBytes());
            var dataToSend = messageRdap.ToBytes();

            if (subscriber != null)
                subscriber.Send(dataToSend, 0, dataToSend.Length);
        }
        private void DoMouseClick(RdapMessage message)
        {
            var mouseClickEventMessage = new MouseClickEventMessage(message.Data);
            Console.WriteLine("Mouse Click , X : " + mouseClickEventMessage.XPosition+" , Y : "+mouseClickEventMessage.YPosition);

            switch (mouseClickEventMessage.EventType)
            {
                case MouseEventType.Left:
                    new MouseLeft((int) ((int) mouseClickEventMessage.XPosition*desktopCapture.WidthAspectRatio),
                                  (int) ((int) mouseClickEventMessage.YPosition*desktopCapture.HeightAspectRatio))
                        .Execute();
                    break;
                case MouseEventType.Right:
                    new MouseRight((int)((int)mouseClickEventMessage.XPosition * desktopCapture.WidthAspectRatio),
                                   (int)((int)mouseClickEventMessage.YPosition * desktopCapture.HeightAspectRatio))
                        .Execute();
                    break;
                default:
                    return;
            }
        }
 private void DoMouseDrag(RdapMessage message)
 {
     var mouseDragEventMesssage = new MouseDragEventMesssage(message.Data);
     switch (mouseDragEventMesssage.EventType)
     {
         case MouseEventType.Left:
             new MouseDrag((int) ((int)mouseDragEventMesssage.StartXPosition * desktopCapture.WidthAspectRatio),
                           (int) ((int)mouseDragEventMesssage.EndXPosition * desktopCapture.WidthAspectRatio),
                           (int) ((int)mouseDragEventMesssage.StartYPosition * desktopCapture.HeightAspectRatio),
                           (int) ((int)mouseDragEventMesssage.EndYPosition * desktopCapture.HeightAspectRatio),
                           0).Execute();
             break;
         case MouseEventType.Right:
             new MouseDrag((int) ((int)mouseDragEventMesssage.StartXPosition * desktopCapture.WidthAspectRatio),
                           (int) ((int)mouseDragEventMesssage.EndXPosition * desktopCapture.WidthAspectRatio),
                           (int) ((int)mouseDragEventMesssage.StartYPosition * desktopCapture.HeightAspectRatio),
                           (int) ((int)mouseDragEventMesssage.EndYPosition * desktopCapture.HeightAspectRatio),
                           1).Execute();
             break;
         default:
             return;
     }
 }
Esempio n. 7
0
        static void Main()
        {
            var publisher = new TcpSocketClient(8000);
            publisher.Connect(new IPEndPoint(IPAddress.Loopback, 5000));

            var cam = new VideoCapture(0, 15, 160, 120);
            cam.Start();

            Console.ReadLine();

            for (var i = 0; i < 200000000; i++)
            {
                var ip = cam.GetBitMap();
                var image = new Bitmap(cam.Width, cam.Height, cam.Stride, PixelFormat.Format24bppRgb, ip);
                image.RotateFlip(RotateFlipType.RotateNoneFlipY);
                var frame = RgbFrameFactory.CreateFrame(image);
                var message = new VideoFrameMessage(RdapImagePixelFormatType.PIX_FMT_RGB24, (uint)frame.Width, (uint)frame.Height, frame.Data);
                var dataToSend = new RdapMessage(RdapMessageType.VideoFrameMessage, message.ToBytes()).ToBytes();
                publisher.Send(dataToSend, 0, dataToSend.Length);
                image.Dispose();
            }

            Console.ReadLine();
        }
        private void OnMouseUp(object sender, MouseEventArgs e)
        {
            switch (e.Button)
            {
                case MouseButtons.Left:
                    dragEndMouseEventType = MouseEventType.Left;
                    break;
                case MouseButtons.Middle:
                    dragEndMouseEventType = MouseEventType.Middle;
                    break;
                case MouseButtons.Right:
                    dragEndMouseEventType = MouseEventType.Right;
                    break;
                default:
                    return;
            }

            dragEndX = e.X;
            dragEndY = e.Y;

            byte[] dataToSend;
            if (dragEndX == dragStartX && dragEndY == dragStartY)
            {
                var message = new MouseClickEventMessage(dragEndMouseEventType, (uint)e.X, (uint)e.Y);
                var messageRdap = new RdapMessage(RdapMessageType.MouseClickEventMessage, message.ToBytes());
                dataToSend = messageRdap.ToBytes();
            }
            else
            {
                var message = new MouseDragEventMesssage(dragEndMouseEventType, (uint)dragStartX, (uint)dragStartY, (uint)dragEndX, (uint)dragEndY);
                var messageRdap = new RdapMessage(RdapMessageType.MouseClickEventMessage, message.ToBytes());
                dataToSend = messageRdap.ToBytes();
            }

            if (subscriber != null)
                subscriber.Send(dataToSend, 0, dataToSend.Length);
        }