Ejemplo n.º 1
0
 private void ConnectUSBCamera_Click(object sender, RoutedEventArgs e)
 {
     _webCamera = new WebCamera();
     _mediaConnector.Connect(_webCamera.VideoChannel, _imageProvider);
     _videoViewer.SetImageProvider(_imageProvider);
     _webCamera.Start();
     _videoViewer.Start();
 }
Ejemplo n.º 2
0
        private void connectBtn_Click(object sender, EventArgs e)
        {
            _webCamera = new WebCamera();

            if (_webCamera != null)
            {
                _mediaConnector.Connect(_webCamera.VideoChannel, _imageProvider);
                _videoViewer.SetImageProvider(_imageProvider);
                _webCamera.Start();
                _videoViewer.Start();
            }
        }
Ejemplo n.º 3
0
        private void connectUsbCamera()
        {
            globalWebCamera = new WebCamera();

            if (globalWebCamera != null)
            {
                globalMediaConnector.Connect(globalWebCamera.VideoChannel, globalImageProvider);
                globalMediaConnector.Connect(globalWebCamera.VideoChannel, globalSnapshotHandler);
                videoViewer.SetImageProvider(globalImageProvider);
                globalWebCamera.Start();
                videoViewer.Start();
            }
        }
Ejemplo n.º 4
0
 private void BGW_CheckConnection_DoWork(object sender, DoWorkEventArgs e)
 {
     Invoke((MethodInvoker) delegate
     {
         lbl_WebCamConnectedState.Visible  = true;
         lbl_ArduinoConnectedState.Visible = true;
     });
     while (true)
     {
         try
         {
             if (!serialPort1.IsOpen)
             {
                 serialPort1.Open();
             }
             setLbl(lbl_ArduinoConnectedState, "Arduino Board is: connected.", Color.Green);
         }
         catch (Exception)
         {
             setLbl(lbl_ArduinoConnectedState, "Arduino Board is: Not connected.", Color.Red);
         }
         try
         {
             if (globalWebCamera.State != Ozeki.Camera.CameraState.Streaming)
             {
                 globalWebCamera.Stop();
                 videoViewer.Stop();
                 globalMediaConnector.Connect(globalWebCamera.VideoChannel, globalImageProvider);
                 globalMediaConnector.Connect(globalWebCamera.VideoChannel, globalSnapshotHandler);
                 videoViewer.SetImageProvider(globalImageProvider);
                 globalWebCamera.Start();
                 videoViewer.Start();
             }
             setLbl(lbl_WebCamConnectedState, "WebCam is: connected.", Color.Green);
         }
         catch (Exception)
         {
             setLbl(lbl_WebCamConnectedState, "WebCam is: Not connected.", Color.Red);
         }
     }
 }
Ejemplo n.º 5
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            _statusProvider.Start(stoppingToken);
            _webCamera.Start(stoppingToken);
            while (!stoppingToken.IsCancellationRequested)
            {
                try
                {
                    await Task.Delay(1000, stoppingToken);

                    if (_statusProvider.Status == null || _statusProvider.Status.IsIdle || _statusProvider.Status.IsBusy)
                    {
                        continue;
                    }

                    StartRecording(stoppingToken);
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, "Unhandled exception at worker");
                }
            }
            _webCamera.Dispose();
        }
Ejemplo n.º 6
0
        public video_chat_room(string myListening, string videop, string aup, string vclient_n, string vclient_ipadd, string client_videop, string client_aup, string camn, string audioinputn, string audiooutputn)
        {
            try
            {
                InitializeComponent();

                string[] splitmessage = myListening.Split(':');
                myListeningUrl         = splitmessage[0];
                videoport              = videop;
                auport                 = aup;
                vclient_name           = vclient_n;
                splitmessage           = vclient_ipadd.Split(':');
                vclient_ipaddress      = splitmessage[0];
                client_videoport       = client_videop;
                client_auport          = client_aup;
                camName                = camn;
                audioinputname         = audioinputn;
                audiooutputname        = audiooutputn;
                close_button.Enabled   = false;
                this.client_label.Text = vclient_name;

                //client
                vconnector      = new MediaConnector();
                mjpegConnection = new MJPEGConnection();
                vprovider       = new DrawingImageProvider();
                this.zoom       = new Zoom();

                videoViewer = new VideoViewerWF()
                {
                    Name      = "Video Preview",
                    Size      = new Size(300, 210),
                    Location  = new Point(20, 20),
                    BackColor = Color.Black
                };

                vvideoViewer = new VideoViewerWF()
                {
                    Name      = "Video Preview",
                    Size      = new Size(300, 210),
                    Location  = new Point(20, 20),
                    BackColor = Color.Black
                };



                connector = new MediaConnector();
                provider  = new DrawingImageProvider();
                videoViewer.SetImageProvider(provider);



                vvideoViewer.SetImageProvider(vprovider);

                groupBox1.Controls.Add(videoViewer);

                webCamera = null;

                foreach (var info in WebCameraFactory.GetDevices())
                {
                    if (info.Name == camName)
                    {
                        webCamera = WebCameraFactory.GetDevice(info);

                        break;
                    }
                }

                if (webCamera == null)
                {
                    MessageBox.Show("Couldn't connect to the camera");
                    return;
                }
                connector.Connect(webCamera.VideoChannel, provider);
                videoSender = webCamera.VideoChannel;

                webCamera.Start();
                videoViewer.Start();
                streamer = new MJPEGStreamer(myListeningUrl, int.Parse(videoport));


                if (!connector.Connect(videoSender, streamer.VideoChannel))
                {
                    MessageBox.Show("Failed to create connection..");
                }
                streamer.ClientConnected    += ClientConnected;
                streamer.ClientDisconnected += ClientDisconnected;

                streamer.Start();



                if (!this.vconnected)
                {
                    IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(this.myListeningUrl), int.Parse(this.auport));



                    this.selectedCodec = new AcmMuLawChatCodec();

                    this.ServerConnect(endPoint, int.Parse(audioinputn), selectedCodec);
                }
                else
                {
                    this.ServerDisconnect();
                }


                this.lblStatus.Text = "Server & camera started\n" + lblStatus.Text;
            }
            catch (Exception ex)
            {
                lblStatus.Text = ex.ToString() + "\n" + lblStatus.Text;
            }
        }