Beispiel #1
0
        private void SetupStreamers()
        {
            int screenId = 0;

            foreach (Screen screen in Screen.AllScreens)
            {
                ScreenVideoSource videoSource = new ScreenVideoSource(screen, screenId++);
                MJPEGStreamer     streamer    = new MJPEGStreamer(videoSource, qualityDefinition);
                streamer.StreamStarted += (sender, e) => {
                    if (_isRunning)
                    {
                        AddStreamClient(GetClientStreamDescription(e.Stream));
                    }
                };
                streamer.StreamStopped += (sender, e) => {
                    if (_isRunning)
                    {
                        RemoveStreamClient(GetClientStreamDescription(e.Stream));
                    }
                };

                string streamName = $"screen{screenId}";

                _streamers[streamName] = streamer;

                _previewImageList.Images.Add(streamName, _blankImage);
                _screensListView.Items.Add(streamName, $"Screen {screenId}", streamName);
            }
        }
 public MJpegServer(int port, VideoSource source, QualityDefinition qualityDefinition)
 {
     this._server = new ThreadedServer(port, System.Net.IPAddress.Parse("127.0.0.1"), 100);
     this._server.ClientDataReceived += new ThreadedServer.ClientDataReceivedEventHandler(this.OnClientDataReceived);
     this._server.SocketError        += new ThreadedServer.SocketErrorEventHandler(this.OnSocketError);
     this._streamer = new MJPEGStreamer(source, qualityDefinition);
 }
Beispiel #3
0
        private void Start_Streaming_Click(object sender, RoutedEventArgs e)
        {
            var ip   = ipAddressText.Text;
            var port = PortText.Text;

            _streamer = new MJPEGStreamer(ip, int.Parse(port));

            _connector.Connect(_videoSender, _streamer.VideoChannel);

            _streamer.ClientConnected    += streamer.ClientConnected;
            _streamer.ClientDisconnected += streamer.ClientDisconnected;

            _streamer.Start;
        }
Beispiel #4
0
        private void Start_Streaming_Click(object sender, RoutedEventArgs e)
        {
            var ip   = ipAddressText.Text;
            var port = PortText.Text;

            _streamer = new MJPEGStreamer(ip, int.Parse(port));

            _connector.Connect(_videoSender, _streamer.VideoChannel);

            _streamer.ClientConnected    += streamer_ClientConnected;
            _streamer.ClientDisconnected += streamer_ClientDisconnected;

            _streamer.Start();

            OpenInBrowserButton.IsEnabled = true;
            StartServerButton.IsEnabled   = false;
            StopServerButton.IsEnabled    = true;
        }
Beispiel #5
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;
            }
        }